diff options
-rw-r--r-- | mainwindow.cpp | 7 | ||||
-rw-r--r-- | storemodel.cpp | 8 | ||||
-rw-r--r-- | storemodel.h | 5 |
3 files changed, 15 insertions, 5 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp index b143f441..b92f8f22 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -90,8 +90,9 @@ void MainWindow::checkConfig() { model.setNameFilterDisables(false); proxyModel.setSourceModel(&model); + proxyModel.setFSModel(&model); model.fetchMore(model.setRootPath(passStore)); - model.sort(0,Qt::AscendingOrder); + model.sort(0, Qt::AscendingOrder); ui->treeView->setModel(&proxyModel); ui->treeView->setRootIndex(proxyModel.mapFromSource(model.setRootPath(passStore))); @@ -336,9 +337,9 @@ void MainWindow::on_configButton_clicked() */ void MainWindow::on_lineEdit_textChanged(const QString &arg1) { + ui->treeView->expandAll(); ui->statusBar->showMessage(tr("Looking for: ") + arg1, 1000); - Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive; - QRegExp regExp(arg1, caseSensitivity); + QRegExp regExp(arg1, Qt::CaseInsensitive); proxyModel.setFilterRegExp(regExp); ui->treeView->setRootIndex(proxyModel.mapFromSource(model.setRootPath(passStore))); } diff --git a/storemodel.cpp b/storemodel.cpp index 7148f83f..f7c7b8c2 100644 --- a/storemodel.cpp +++ b/storemodel.cpp @@ -47,8 +47,8 @@ bool StoreModel::ShowThis(const QModelIndex index) const else { QModelIndex useIndex = sourceModel()->index(index.row(), 0, index.parent()); - QString type = sourceModel()->data(useIndex, Qt::DisplayRole).toString(); - if ( ! type.contains(filterRegExp())) + QString path = fs->filePath(useIndex); + if ( ! path.contains(filterRegExp())) { retVal = false; } @@ -59,3 +59,7 @@ bool StoreModel::ShowThis(const QModelIndex index) const } return retVal; } + +void StoreModel::setFSModel(QFileSystemModel *sourceModel) { + fs = sourceModel; +} diff --git a/storemodel.h b/storemodel.h index a02b033f..e503a1ce 100644 --- a/storemodel.h +++ b/storemodel.h @@ -2,15 +2,20 @@ #define STOREMODEL_H #include <QSortFilterProxyModel> +#include <QFileSystemModel> class StoreModel : public QSortFilterProxyModel { Q_OBJECT +private: + QFileSystemModel* fs; + public: StoreModel(); bool filterAcceptsRow(int, const QModelIndex &) const; bool ShowThis(const QModelIndex) const; + void setFSModel(QFileSystemModel *sourceModel); }; #endif // STOREMODEL_H |