diff --git a/filesystemwidget.cpp b/filesystemwidget.cpp index 61b7e96..9a1ae3f 100644 --- a/filesystemwidget.cpp +++ b/filesystemwidget.cpp @@ -20,6 +20,18 @@ FilesystemWidget::FilesystemWidget(QAbstractItemModel *model, QWidget *parent) : connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FilesystemWidget::fileClicked); } +void FilesystemWidget::contextMenuEvent(QContextMenuEvent *event) +{ + QMenu menu; + menu.addAction(tr("Sort by filename"), [this](){ emit sortChanged(QDir::Name); }); + menu.addAction(tr("Sort by time"), [this](){ emit sortChanged(QDir::Time); }); + menu.addAction(tr("Sort by size"), [this](){ emit sortChanged(QDir::Size); }); + menu.addAction(tr("Sort by type"), [this](){ emit sortChanged(QDir::Type); }); + menu.addAction(tr("Reverse"), [this](){ emit reverseSort(); }); + + menu.exec(event->globalPos()); +} + void FilesystemWidget::selectFile(int row) { QModelIndex index = m_model->index(row, 0); diff --git a/filesystemwidget.h b/filesystemwidget.h index e0dd493..936b4cf 100644 --- a/filesystemwidget.h +++ b/filesystemwidget.h @@ -13,11 +13,14 @@ class FilesystemWidget : public QWidget QAbstractItemModel *m_model; public: explicit FilesystemWidget(QAbstractItemModel *model, QWidget *parent = nullptr); + void contextMenuEvent(QContextMenuEvent *event) override; private slots: void selectFile(int row); void fileClicked(const QModelIndex &index, const QModelIndex &); signals: void fileSelected(int row); + void sortChanged(QDir::SortFlag sort); + void reverseSort(); }; class Filetree : public QTreeView diff --git a/imageringlist.cpp b/imageringlist.cpp index 6423e84..a578f35 100644 --- a/imageringlist.cpp +++ b/imageringlist.cpp @@ -129,7 +129,9 @@ bool ImageRingList::setDir(const QString path, const QString ¤tFile) if(dir.exists()) { - QStringList list = dir.entryList(m_nameFilter, QDir::Files | QDir::Readable, m_liveMode ? QDir::Time : QDir::Name | QDir::IgnoreCase); + QDir::SortFlags sortFlags = m_liveMode ? QDir::Time : m_sort | QDir::IgnoreCase; + if(m_reversed)sortFlags |= QDir::Reversed; + QStringList list = dir.entryList(m_nameFilter, QDir::Files | QDir::Readable, sortFlags); QStringList absolutePaths; foreach(const QString &file, list) { @@ -377,6 +379,29 @@ void ImageRingList::setPreload(int width) m_width = newWidth; } +void ImageRingList::setSort(QDir::SortFlag sort) +{ + if(m_sort != sort) + { + m_sort = sort; + if(m_images.size()) + { + QString path = (*m_currImage)->name(); + setFile(path); + } + } +} + +void ImageRingList::reverseSort() +{ + m_reversed = !m_reversed; + if(m_images.size()) + { + QString path = (*m_currImage)->name(); + setFile(path); + } +} + void ImageRingList::setFiles(const QStringList files, const QString ¤tFile) { QThreadPool::globalInstance()->clear(); diff --git a/imageringlist.h b/imageringlist.h index 23b209a..0a8ccc5 100644 --- a/imageringlist.h +++ b/imageringlist.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "imageinfo.h" #include "rawimage.h" @@ -58,6 +59,8 @@ class ImageRingList : public QAbstractItemModel QList::iterator m_lastImage; QFileSystemWatcher m_fileSystemWatcher; bool m_liveMode; + QDir::SortFlag m_sort = QDir::Name; + bool m_reversed = false; AnalyzeLevel m_analyzeLevel; QThreadPool *m_thumbPool; Database *m_database; @@ -91,6 +94,8 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; public slots: void setPreload(int width); + void setSort(QDir::SortFlag sort); + void reverseSort(); protected: void setFiles(const QStringList files, const QString ¤tFile = QString()); QList::iterator increment(QList::iterator iter); diff --git a/libXISF b/libXISF index e1fe893..43533aa 160000 --- a/libXISF +++ b/libXISF @@ -1 +1 @@ -Subproject commit e1fe893e2ab9f8803e849b4e30ea1358cd9aad86 +Subproject commit 43533aa36310cce0a08a8e557d35267fc58fd1ff diff --git a/mainwindow.cpp b/mainwindow.cpp index 4a7a2ef..203553c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -88,6 +88,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) m_ringList = new ImageRingList(m_database, nameFilter, this); m_filesystem = new FilesystemWidget(m_ringList, this); connect(m_filesystem, SIGNAL(fileSelected(int)), this, SLOT(loadFile(int))); + connect(m_filesystem, &FilesystemWidget::sortChanged, m_ringList, &ImageRingList::setSort); + connect(m_filesystem, &FilesystemWidget::reverseSort, m_ringList, &ImageRingList::reverseSort); m_filetree = new Filetree(this); connect(m_filetree, &Filetree::fileSelected, this, static_cast(&MainWindow::loadFile)); diff --git a/translations/tenmon_en.qm b/translations/tenmon_en.qm index 5479138..3834980 100644 Binary files a/translations/tenmon_en.qm and b/translations/tenmon_en.qm differ diff --git a/translations/tenmon_en.ts b/translations/tenmon_en.ts index a3330c8..2fb0a6a 100644 --- a/translations/tenmon_en.ts +++ b/translations/tenmon_en.ts @@ -41,6 +41,29 @@ File name + + FilesystemWidget + + Sort by filename + Sort by file name + + + Sort by time + Sort by time + + + Sort by size + Sort by size + + + Sort by type + Sort by type + + + Reverse + Reverse order + + Filetree @@ -515,7 +538,7 @@ Changes in settings will take effect after program restart. - Changes in settings will take effect after program restart. + Changes in settings will take effect after program restart. Don't use native file dialog diff --git a/translations/tenmon_fr.qm b/translations/tenmon_fr.qm index e757d16..e8a1639 100644 Binary files a/translations/tenmon_fr.qm and b/translations/tenmon_fr.qm differ diff --git a/translations/tenmon_fr.ts b/translations/tenmon_fr.ts index 8276f76..412bceb 100644 --- a/translations/tenmon_fr.ts +++ b/translations/tenmon_fr.ts @@ -41,6 +41,29 @@ Nom de fichier + + FilesystemWidget + + Sort by filename + Trier par nom de fichier + + + Sort by time + Trier par heure + + + Sort by size + Trier par taille + + + Sort by type + Trier par type + + + Reverse + Ordre inverse + + Filetree @@ -515,7 +538,7 @@ Changes in settings will take effect after program restart. - Les changements de paramètres prendront effet après le redémarrage du programme. + Les changements de paramètres prendront effet après le redémarrage du programme. Don't use native file dialog diff --git a/translations/tenmon_sk.qm b/translations/tenmon_sk.qm index 0596d70..bf6e8dc 100644 Binary files a/translations/tenmon_sk.qm and b/translations/tenmon_sk.qm differ diff --git a/translations/tenmon_sk.ts b/translations/tenmon_sk.ts index f2576cd..00fefea 100644 --- a/translations/tenmon_sk.ts +++ b/translations/tenmon_sk.ts @@ -42,6 +42,29 @@ Meno súboru + + FilesystemWidget + + Sort by filename + Zoradiť podľa názvu súboru + + + Sort by time + Zoradiť podľa času + + + Sort by size + Zoradiť podľa veľkosti + + + Sort by type + Zoradiť podľa typu + + + Reverse + Otočit poradie + + Filetree @@ -516,7 +539,7 @@ Changes in settings will take effect after program restart. - Zmeny v nastaveniach sa prejavia po reštarte programu. + Zmeny v nastaveniach sa prejavia po reštarte programu. Don't use native file dialog