diff options
author | Arno <arno@disconnect.de> | 2018-07-21 01:39:55 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2018-07-21 01:39:55 +0200 |
commit | 0c20652c4b352e0498583c9fdb98f7e289087433 (patch) | |
tree | 87a991857b2cce0ce2a5e39dae3b01849a5a0f95 | |
parent | 46107d3b705eb379a2f007a4cfc9876521298254 (diff) | |
download | SheMov-0c20652c4b352e0498583c9fdb98f7e289087433.tar.gz SheMov-0c20652c4b352e0498583c9fdb98f7e289087433.tar.bz2 SheMov-0c20652c4b352e0498583c9fdb98f7e289087433.zip |
Prepare FSWidget for show/hide headers
Don't clear the model when gathering data. Delete all rows instead to
keep the headers consistent. Also add a visible column for the full
path.
-rw-r--r-- | fswidget.cpp | 13 | ||||
-rw-r--r-- | fswidget.h | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/fswidget.cpp b/fswidget.cpp index 1ff94ed..72cae8c 100644 --- a/fswidget.cpp +++ b/fswidget.cpp @@ -158,8 +158,14 @@ void FSWidget::setupWidget(){ mFileView->setUniformRowHeights(true); mFileView->setSelectionBehavior(QAbstractItemView::SelectRows); mFileView->setSelectionMode(QAbstractItemView::ExtendedSelection); + mFileView->setRootIsDecorated(false); connect(mFileView, &QTreeView::doubleClicked, this, &FSWidget::doubleClicked); mModel = new QStandardItemModel; + QStringList headers = QStringList() << tr("Name") << tr("MIME") << tr("Size") << tr("Duration") << tr("MD5") << tr("Presence") << tr("Full path"); + for(int i = 0; i < headers.count(); ++i){ + mHeaderData.insert(headers.at(i), i); + } + mModel->setHorizontalHeaderLabels(headers); mProxy = new FSProxy; mProxy->setSourceModel(mModel); mFileView->setModel(mProxy); @@ -263,11 +269,9 @@ void FSWidget::gatherData(const QString &curDir){ timer.start(); emit message(tr("Gathering data...")); mFileView->setSortingEnabled(false); - mFileView->setRootIsDecorated(false); - mModel->clear(); QStandardItem *root = mModel->invisibleRootItem(); + mModel->removeRows(0, mModel->rowCount()); QMimeDatabase mimedb; - mModel->setHorizontalHeaderLabels(QStringList() << tr("Name") << tr("MIME") << tr("Size") << tr("Duration") << tr("MD5") << tr("Presence")); QIcon videoIcon = Helper::icon(QColor(255,85,255), Qt::white, 'M', true, true); QIcon imageIcon = Helper::icon(QColor(255,85,255), Qt::white, 'P', true, true); QIcon otherIcon = Helper::icon(QColor(255,85,255), Qt::white, 'O', true, true); @@ -357,7 +361,7 @@ void FSWidget::gatherData(const QString &curDir){ } ci: - for(int i = 0; i < 6; ++i){ + for(int i = 0; i < 7; ++i){ QStandardItem *item = new QStandardItem; item->setFont(f); item->setEditable(false); @@ -383,6 +387,7 @@ void FSWidget::gatherData(const QString &curDir){ items[3]->setText(durStr); items[4]->setText(md5); items[5]->setText(presenceStr); + items[6]->setText(fi.absoluteFilePath()); root->appendRow(items); for(int i = 0; i < 6; ++i){ mFileView->resizeColumnToContents(i); @@ -65,6 +65,7 @@ class FSWidget : public QWidget { Viewer *mViewer; int mQueryCount; QAction *mPlayWithA; + QHash<QString, int> mHeaderData; }; #endif // FSWIDGET_H |