summaryrefslogtreecommitdiffstats
path: root/examples/widgets/itemviews/storageview/main.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2017-09-20 11:36:42 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-09-20 12:19:39 +0000
commit29b38bea45712c85a0c9f07bfa26524f3a35668f (patch)
tree0d8fc2d67444cc4dfe8cb1e12156059cf357b895 /examples/widgets/itemviews/storageview/main.cpp
parentbf41fbb233d65b6cc19837da038e2672bb34f562 (diff)
Polish the StorageView example
Introduce nullptr and override. Change the ready/valid columns to use check marks. Right-align the numerical columns. Add a shortcut to refresh. Sort by path, making sure the root volume is first. Task-number: QTBUG-60635 Change-Id: I74cda7647f544902aaf4d2a0ab76986f1523aa6f Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
Diffstat (limited to 'examples/widgets/itemviews/storageview/main.cpp')
-rw-r--r--examples/widgets/itemviews/storageview/main.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/widgets/itemviews/storageview/main.cpp b/examples/widgets/itemviews/storageview/main.cpp
index c8057186fc..f349e58fad 100644
--- a/examples/widgets/itemviews/storageview/main.cpp
+++ b/examples/widgets/itemviews/storageview/main.cpp
@@ -51,6 +51,7 @@
#include <QtWidgets/QApplication>
#include <QtWidgets/QHeaderView>
+#include <QtWidgets/QShortcut>
#include <QtWidgets/QTreeView>
#include "storagemodel.h"
@@ -60,9 +61,16 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
QTreeView view;
- view.setModel(new StorageModel(&view));
view.resize(640, 480);
+ view.setWindowTitle("Storage View");
view.setSelectionBehavior(QAbstractItemView::SelectRows);
+
+ StorageModel *model = new StorageModel(&view);
+ model->refresh();
+ QShortcut *refreshShortcut = new QShortcut(Qt::CTRL + Qt::Key_R, &view);
+ QObject::connect(refreshShortcut, &QShortcut::activated, model, &StorageModel::refresh);
+ view.setModel(model);
+
int columnCount = view.model()->columnCount();
for (int c = 0; c < columnCount; ++c)
view.resizeColumnToContents(c);