Environment: Windows 10--- Inplemented with Qt Creator
"Metro Insider"* handles files with SQLite in-memory database with high efficiency, the following modules are implemented:
-> Loading Files with a Selector and Filter
-> SQLite Runner
-> Plotting & Analyzing
-> Route Planning
"choose a folder" button is expected to be pushed to start the whole process. It will open a dialogue to let users to select the "dataset" folder. It is implemented with QFileDialog::getExistingDirectory()
.
Then a tree widget is created to let users choose files and filters implemented with QTreeWidegetsItem
.
The files tree can synchronize the child node with the parent node all the time, with Qt::Checked; Qt::PartlyChecked; Qt:Unchecked;
which means that
- parent
Partlychecked
$\Leftrightarrow$ some childrenChecked
- parent
Checked
$\Leftrightarrow$ all childrenChecked
- parent
Unchecked
$\Leftrightarrow$ all childrenUnchecked
- It's implemented recursively.
And names of all the chosen files is maintained in QStringList chosen_files_names
timely before
the "load chosen files" bottom being pushed. (So the program won't have any problems when users change the checked items during the loading process.)
It is designed for choosing the fields to be loaded into the SQLite database. But "time" & "stationID" & "status" can not be unchecked since our mandatory task requires a plot on "Inflow & Outflow of a station".
Only selected fields of selected files will be loaded into the datatbase. The database would create a table whose columns are those fields. And this module has the following characteristics:
Loading the dataset of one day takes averagely 50s in my surface-Laptop (2017, 13.5'), it's relatively fast due to the insertion of data to SQLite can't be done by multicore.
With <QtConcurrent>
, the loading process is being done in another thread so the ui-thread will never be frozen.
The status bar is well designed to respond quickly to any situation
If users change filters or files selections after a loading, the status bar will suggest a renew.
- Loading process is based on a file list maintained before "pressing the load button", so even if users change the file selection box or filters during the load, they won't have a problem.
- Reloading is well supported since the database will drop and create a new table newly designed for the chosen column and ensure there will not be a leak of memory.
- Before the loading process have been done, all the buttons and combo boxes relied to chosen files and filters will be disabled to avoid possible errors.
SQLite Runner is designed for any explore of raw data by users. It is implemented by QTextEdit
QSqlQueryModel
QTableView
, it has following characteristics:
- The database is in-memory and has a carefully designed composite index. So almost all the
SELECT
operation can be done in 0.x seconds. QTableView
withQSqlQuerymodel
makes it possible for dynamic loading, which means that the ui will not show all the results from e.g.SELECT * FROM TABLE
at once so the ui will not freeze at any time. When users scrolls the table view, new query results will constantly be loaded
This function is implemented by
ui->statusbar->showMessage(model->lastError().databaseText(), 100000);
It will show any error message in the status bar.