# # # patch "src/view/InventoryView.cpp" # from [2edeb0faf0b6174296532182fc7fd141822c704d] # to [6e95efeb83a5a69389b7585243530be2ad7f3cfe] # # patch "src/view/InventoryView.h" # from [0593223a91095a8c0a4a149a8b85b050d1b55361] # to [14524e468a4fcf51254e3c066d3c571acf5acd1c] # # patch "src/view/WorkspaceWindow.cpp" # from [b95bcec3c4bb829f858da986a0d5611b749a33b0] # to [313818ac62c61486a5a96ea6963a3734619c9307] # ============================================================ --- src/view/InventoryView.cpp 2edeb0faf0b6174296532182fc7fd141822c704d +++ src/view/InventoryView.cpp 6e95efeb83a5a69389b7585243530be2ad7f3cfe @@ -135,6 +135,10 @@ void InventoryView::createAndConnectCont actRename->setStatusTip(tr("Rename file")); connect(actRename, SIGNAL(triggered()), this, SLOT(slotRename())); + actRefresh = new QAction(tr("Refresh"), this); + actRefresh->setStatusTip(tr("Re-reads the item and refeshes the view")); + connect(actRefresh, SIGNAL(triggered()), this, SLOT(slotRefresh())); + actAddMultiple = new QAction(tr("Add %1 items"), this); actAddMultiple->setStatusTip(tr("Add multiple items")); connect(actAddMultiple, SIGNAL(triggered()), this, SLOT(slotAdd())); @@ -174,6 +178,7 @@ InventoryView::~InventoryView() delete actFileHistory; delete actRevisionDiff; delete actRename; + delete actRefresh; delete actAddMultiple; delete actRemoveMultiple; delete actCommitMultiple; @@ -265,7 +270,19 @@ void InventoryView::slotContextMenuReque // since not all actions may apply on all items void InventoryView::slotContextMenuRequested(const QModelIndexList & indexList, const QPoint & pos) { - if (indexList.size() == 0) return; + // + // no selected items - just show the refresh entry + // + if (indexList.size() == 0) + { + QMenu menu(this); + menu.addAction(actRefresh); + QFont activeFont; + activeFont.setBold(true); + actRefresh->setFont(activeFont); + menu.exec(pos); + return; + } // // single item selected @@ -377,6 +394,12 @@ void InventoryView::slotContextMenuReque break; } + // + // add the refresh action + // + menu.addSeparator(); + menu.addAction(actRefresh); + menu.exec(pos); return; } @@ -583,6 +606,48 @@ void InventoryView::slotCommit() emit commitRevision(paths); } +void InventoryView::slotRefresh() +{ + QSet items = getSelectedItems(); + + // for now we can only handle one refresh at a time + if (items.size() > 1) return; + + ModelItem * item; + + // special hack: if there are no selected items, refresh the + // current root item + if (items.size() == 0) + { + QModelIndex proxyRoot = rootIndex(); + QModelIndex realRoot = + dynamic_cast(model())->mapFromSource(proxyRoot); + + // even more special case - select the first child of this (pseudo) root + if (!realRoot.isValid()) + { + realRoot = realRoot.child(0, 0); + } + + // still not valid, i.e. filtered out? + if (!realRoot.isValid()) return; + + item = static_cast(realRoot.internalPointer()); + } + else + { + item = *(items.begin()); + } + + if (!item) return; + + InventoryItem * invItem = dynamic_cast(item); + if (!invItem) return; + + emit refreshPath(invItem->getPath()); + return; +} + void InventoryView::slotRevert() { C("Not implemented."); ============================================================ --- src/view/InventoryView.h 0593223a91095a8c0a4a149a8b85b050d1b55361 +++ src/view/InventoryView.h 14524e468a4fcf51254e3c066d3c571acf5acd1c @@ -50,6 +50,7 @@ signals: void commitRevision(const QStringList &); void addedToViewport(const QModelIndexList &); void removedFromViewport(const QModelIndexList &); + void refreshPath(const QString &); private: enum DefaultAction { None, Chdir, Open, FileDiff, Commit }; @@ -74,6 +75,7 @@ private: QAction * actFileDiff; QAction * actFileHistory; QAction * actRevisionDiff; + QAction * actRefresh; QAction * actAddMultiple; QAction * actRemoveMultiple; @@ -109,6 +111,7 @@ private slots: void slotFileDiff(); void slotFileHistory(); void slotRevisionDiff(); + void slotRefresh(); }; #endif ============================================================ --- src/view/WorkspaceWindow.cpp b95bcec3c4bb829f858da986a0d5611b749a33b0 +++ src/view/WorkspaceWindow.cpp 313818ac62c61486a5a96ea6963a3734619c9307 @@ -247,6 +247,16 @@ void WorkspaceWindow::setup() listView->setType(InventoryView::FileList); connect( + treeView, SIGNAL(refreshPath(const QString &)), + invModel, SLOT(refresh(const QString &)) + ); + + connect( + listView, SIGNAL(refreshPath(const QString &)), + invModel, SLOT(refresh(const QString &)) + ); + + connect( treeView, SIGNAL(addedToViewport(const QModelIndexList &)), invWatcher, SLOT(watchItems(const QModelIndexList &)) );