# # # add_dir "res/images" # # add_file "res/images/no_matches.png" # content [337b101d0aae1bd6427c33024259ff5b74998bf2] # # patch "res/guitone.qrc" # from [70016cdd429b5eb72a41b219045ec750d4b305df] # to [d54b2128c34474ef87ceb188a70323ef42d890f6] # # patch "src/model/InventoryProxyModel.cpp" # from [093b0acf5b5f07a14e3c6dad5dd559641ba5b132] # to [389f45374d65a9cdfb920f89dd3277d1184d17a4] # # patch "src/view/InventoryView.cpp" # from [e198631d80885cb76929c51545711969e9240513] # to [7c9731090329ba1e93c45a9436e7327951733419] # # patch "src/view/InventoryView.h" # from [2c0326d792dfe74d5bc029db8218b301459b3757] # to [0434946fdcb50d819048da08fac8a5c626c47e27] # # set "res/images/no_matches.png" # attr "mtn:manual_merge" # value "true" # ============================================================ # res/images/no_matches.png is binary ============================================================ --- res/guitone.qrc 70016cdd429b5eb72a41b219045ec750d4b305df +++ res/guitone.qrc d54b2128c34474ef87ceb188a70323ef42d890f6 @@ -18,5 +18,6 @@ overlays/content_changed.png overlays/attributes_changed.png overlays/invalid.png + images/no_matches.png ============================================================ --- src/model/InventoryProxyModel.cpp 093b0acf5b5f07a14e3c6dad5dd559641ba5b132 +++ src/model/InventoryProxyModel.cpp 389f45374d65a9cdfb920f89dd3277d1184d17a4 @@ -148,7 +148,7 @@ void InventoryProxyModel::setHideIgnored { if (hide == hideIgnored) return; hideIgnored = hide; - clear(); + filterChanged(); } void InventoryProxyModel::setViewOption(int opt) @@ -156,6 +156,6 @@ void InventoryProxyModel::setViewOption( ViewOption newOpt = static_cast(opt); if (viewOption == newOpt) return; viewOption = newOpt; - clear(); + filterChanged(); } ============================================================ --- src/view/InventoryView.cpp e198631d80885cb76929c51545711969e9240513 +++ src/view/InventoryView.cpp 7c9731090329ba1e93c45a9436e7327951733419 @@ -192,9 +192,24 @@ void InventoryView::setModel(QSortFilter if (oldModel) { disconnect( - newModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + oldModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(newNodeLoaded(const QModelIndex &, const QModelIndex &)) ); + + disconnect( + oldModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(setBackgroundImage()) + ); + + disconnect( + oldModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(setBackgroundImage()) + ); + + disconnect( + oldModel, SIGNAL(modelReset()), + this, SLOT(setBackgroundImage()) + ); } TreeView::setModel(newModel); @@ -203,6 +218,21 @@ void InventoryView::setModel(QSortFilter newModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(newNodeLoaded(const QModelIndex &, const QModelIndex &)) ); + + connect( + newModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(setBackgroundImage()) + ); + + connect( + newModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(setBackgroundImage()) + ); + + connect( + newModel, SIGNAL(modelReset()), + this, SLOT(setBackgroundImage()) + ); } void InventoryView::newNodeLoaded(const QModelIndex & index, const QModelIndex & dummy) @@ -652,3 +682,24 @@ void InventoryView::itemClicked(const QM return; } +/*! + If the model contains no data, display a "no matches" background image + This usually happens when the proxy model has filtered out everything + and maybe in some weird error case which should not happen at all... +*/ +void InventoryView::setBackgroundImage() +{ + if (model()->hasChildren()) + { + setStyleSheet(QString()); + } + else + { + setStyleSheet("InventoryView { " + "background-color: white;" + "background-image: url(:/images/no_matches.png);" + "background-attachment: fixed;" + "background-position: center;" + "background-repeat: no-repeat;}"); + } +} ============================================================ --- src/view/InventoryView.h 2c0326d792dfe74d5bc029db8218b301459b3757 +++ src/view/InventoryView.h 0434946fdcb50d819048da08fac8a5c626c47e27 @@ -83,6 +83,7 @@ private slots: void newNodeLoaded(const QModelIndex &, const QModelIndex &); void changeDirectory(const QModelIndex &); void itemClicked(const QModelIndex & index); + void setBackgroundImage(); void slotContextMenuRequested(const QModelIndexList &, const QPoint &); void slotChdir();