Mercurial > retraceit
changeset 28:4e16fbd10945
(issue3-5) Make the default sort order configurable
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 05 May 2015 18:46:35 +0200 |
parents | 5bd14af5bce5 |
children | c2aec2f33928 |
files | src/constants.h src/filterwidget.cpp src/filterwidget.h src/l10n/main_de_DE.ts src/metadataview.cpp src/metadataview.h |
diffstat | 6 files changed, 72 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/src/constants.h Tue May 05 18:45:49 2015 +0200 +++ b/src/constants.h Tue May 05 18:46:35 2015 +0200 @@ -32,7 +32,7 @@ #define DESCRIPTION "A tool to replay recorded user sessions." /**@def Short copyright notice to show users. */ -#define COPYRIGHT "Copyright (C) 2015 Intevation GmbH \n\n" \ +#define COPYRIGHT "Copyright (C) 2015 ETH Zürich \n\n" \ "This file is Free Software under the GNU GPL (v>=2)\n" \ "and comes with ABSOLUTELY NO WARRANTY!\n" @@ -70,4 +70,16 @@ /**@def The seperator used in the patterns. */ #define PATTERN_SEPERATOR "_" +/**@def The default sort column */ +#define SORT_COLUMN_KEY "Sort" + +/**@def The default value for the sort column */ +#define SORT_COLUMN_DEFAULT "Date" + +/**@def The default sort order (boolean) */ +#define SORT_ORDER_KEY "SortAscending" + +/**@def The default sort order value. */ +#define SORT_ORDER_VALUE true + #endif // CONSTANTS_H
--- a/src/filterwidget.cpp Tue May 05 18:45:49 2015 +0200 +++ b/src/filterwidget.cpp Tue May 05 18:46:35 2015 +0200 @@ -54,6 +54,7 @@ QString filterText = mEditLine->text(); mModel->setFilterKeyColumn(mColFilterMap.value(mCombo->currentIndex())); mModel->setFilterWildcard(filterText); + emit filterHasChanged(); } void FilterWidget::setupGUI() {
--- a/src/filterwidget.h Tue May 05 18:45:49 2015 +0200 +++ b/src/filterwidget.h Tue May 05 18:46:35 2015 +0200 @@ -22,6 +22,9 @@ FilterWidget (QSortFilterProxyModel *model, QWidget * parent = 0, Qt::WindowFlags f = 0); +Q_SIGNALS: + void filterHasChanged(); + protected: void setupGUI();
--- a/src/l10n/main_de_DE.ts Tue May 05 18:45:49 2015 +0200 +++ b/src/l10n/main_de_DE.ts Tue May 05 18:46:35 2015 +0200 @@ -4,12 +4,12 @@ <context> <name>FilterWidget</name> <message> - <location filename="../filterwidget.cpp" line="55"/> + <location filename="../filterwidget.cpp" line="63"/> <source>Filter</source> <translation>Filter</translation> </message> <message> - <location filename="../filterwidget.cpp" line="65"/> + <location filename="../filterwidget.cpp" line="73"/> <source>Filter expression</source> <translation>Filter-Ausdruck</translation> </message> @@ -17,22 +17,22 @@ <context> <name>FolderSelectDialog</name> <message> - <location filename="../folderselectdialog.cpp" line="59"/> + <location filename="../folderselectdialog.cpp" line="60"/> <source>Select folder</source> <translation>Ordner auswählen</translation> </message> <message> - <location filename="../folderselectdialog.cpp" line="71"/> + <location filename="../folderselectdialog.cpp" line="72"/> <source>Go</source> <translation></translation> </message> <message> - <location filename="../folderselectdialog.cpp" line="99"/> + <location filename="../folderselectdialog.cpp" line="100"/> <source>Ok</source> <translation>Ok</translation> </message> <message> - <location filename="../folderselectdialog.cpp" line="187"/> + <location filename="../folderselectdialog.cpp" line="188"/> <source>Select %1</source> <translation type="unfinished"></translation> </message> @@ -40,52 +40,52 @@ <context> <name>MainWindow</name> <message> - <location filename="../mainwindow.cpp" line="55"/> + <location filename="../mainwindow.cpp" line="56"/> <source>Player</source> <translation>Player</translation> </message> <message> - <location filename="../mainwindow.cpp" line="56"/> + <location filename="../mainwindow.cpp" line="57"/> <source>Filter/Details</source> <translation>Filter/Details</translation> </message> <message> - <location filename="../mainwindow.cpp" line="72"/> + <location filename="../mainwindow.cpp" line="73"/> <source>Error!</source> <translation>Fehler!</translation> </message> <message> - <location filename="../mainwindow.cpp" line="135"/> + <location filename="../mainwindow.cpp" line="136"/> <source>Failed to access directory: '%1'</source> <translation>Auf das Verzeichnis '%1' konnte nicht zugegriffen werden.</translation> </message> <message> - <location filename="../mainwindow.cpp" line="140"/> + <location filename="../mainwindow.cpp" line="141"/> <source>Failed to access meta data file: '%1'</source> <translation>Auf die Metadaten-Datei: '%1' konnte nicht zugegriffen werden.</translation> </message> <message> - <location filename="../mainwindow.cpp" line="149"/> + <location filename="../mainwindow.cpp" line="150"/> <source>Parsed: '%1'</source> <translation>'%1' eingelesen</translation> </message> <message> - <location filename="../mainwindow.cpp" line="160"/> + <location filename="../mainwindow.cpp" line="161"/> <source>Showing: '%1'</source> <translation>Zeige: '%1'</translation> </message> <message> - <location filename="../mainwindow.cpp" line="178"/> + <location filename="../mainwindow.cpp" line="179"/> <source>Persons</source> <translation>Personen</translation> </message> <message> - <location filename="../mainwindow.cpp" line="194"/> + <location filename="../mainwindow.cpp" line="195"/> <source>Exams</source> <translation>Prüfungen</translation> </message> <message> - <location filename="../mainwindow.cpp" line="193"/> + <location filename="../mainwindow.cpp" line="194"/> <source>Root-Path</source> <translation>Wurzelverzeichnis</translation> </message> @@ -93,7 +93,7 @@ <context> <name>MetaDataView</name> <message> - <location filename="../metadataview.cpp" line="54"/> + <location filename="../metadataview.cpp" line="65"/> <source>Failed to parse file: '%1'</source> <translation>Die Datei '%1' konnte nicht eingelesen werden.</translation> </message> @@ -101,32 +101,32 @@ <context> <name>PNGPlayer</name> <message> - <location filename="../pngplayer.cpp" line="75"/> + <location filename="../pngplayer.cpp" line="76"/> <source>Speed:</source> <translation>Geschwindigkeit:</translation> </message> <message> - <location filename="../pngplayer.cpp" line="125"/> + <location filename="../pngplayer.cpp" line="126"/> <source>Screenshot Nr.:</source> <translation>Screenshot Nr.:</translation> </message> <message> - <location filename="../pngplayer.cpp" line="127"/> + <location filename="../pngplayer.cpp" line="128"/> <source>Timestamp:</source> <translation>Zeitstempel:</translation> </message> <message> - <location filename="../pngplayer.cpp" line="128"/> + <location filename="../pngplayer.cpp" line="129"/> <source>Unknown</source> <translation>Unbekannt</translation> </message> <message> - <location filename="../pngplayer.cpp" line="137"/> + <location filename="../pngplayer.cpp" line="138"/> <source>%1 second per Picture</source> <translation>%1 Sekunde pro Bild</translation> </message> <message> - <location filename="../pngplayer.cpp" line="140"/> + <location filename="../pngplayer.cpp" line="141"/> <source>%1 seconds per Picture</source> <translation>%1 Sekunden pro Bild</translation> </message> @@ -134,12 +134,12 @@ <context> <name>main</name> <message> - <location filename="../main.cpp" line="145"/> + <location filename="../main.cpp" line="146"/> <source>The folder containing the data to replay.</source> <translation>Der Ordner mit den Replaydaten</translation> </message> <message> - <location filename="../main.cpp" line="147"/> + <location filename="../main.cpp" line="148"/> <source>Print debug output.</source> <translation>Debugausgaben anzeigen</translation> </message>
--- a/src/metadataview.cpp Tue May 05 18:45:49 2015 +0200 +++ b/src/metadataview.cpp Tue May 05 18:46:35 2015 +0200 @@ -8,6 +8,7 @@ #include "metadataview.h" #include "qxtcsvmodel.h" #include "filterwidget.h" +#include "constants.h" #include <QTextCodec> #include <QTableView> @@ -18,6 +19,7 @@ #include <QModelIndex> #include <QHeaderView> #include <QItemSelectionModel> +#include <QSettings> MetaDataView::MetaDataView(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { @@ -37,6 +39,8 @@ QVBoxLayout *baseLayout = new QVBoxLayout; FilterWidget *filterWidget = new FilterWidget(mSortModel); + connect(filterWidget, &FilterWidget::filterHasChanged, + this, &MetaDataView::applyDefaultSort); baseLayout->addWidget(filterWidget); mView = new QTableView; @@ -63,6 +67,7 @@ mSortModel->setSourceModel(mCSVModel); qDebug() << "Parsed: " << mCSVModel->rowCount() << " rows."; + applyDefaultSort(); return QString(); } @@ -159,3 +164,25 @@ QModelIndex newIdx = mSortModel->index(row, col); selection->select(newIdx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); } + +void MetaDataView::applyDefaultSort() { + QSettings settings; + QString sortField = settings.value(SORT_COLUMN_KEY, SORT_COLUMN_DEFAULT).toString(); + bool sortAsc = settings.value(SORT_ORDER_KEY, SORT_ORDER_VALUE).toBool(); + + int idx = -1; + for (int i=0; i < mSortModel->columnCount(); i++) { + QString entry = mSortModel->headerData(i, Qt::Horizontal).toString(); + if (entry.toLower() == sortField.toLower()) { + idx = 1; + break; + } + } + if (idx == -1) { + qDebug() << "Failed to find configured sort column: " << sortField; + return; + } + qDebug() << "Applying default sort order on column " << idx; + mView->sortByColumn(idx, sortAsc ? Qt::AscendingOrder : Qt::DescendingOrder); +} +
--- a/src/metadataview.h Tue May 05 18:45:49 2015 +0200 +++ b/src/metadataview.h Tue May 05 18:46:35 2015 +0200 @@ -56,6 +56,9 @@ /**@brief select a specific row. */ void selectRow(int row); + /**@brief applies the default sort order from configuration */ + void applyDefaultSort(); + protected: QxtCsvModel *mCSVModel; QSortFilterProxyModel *mSortModel;