# # # patch "src/view/InventoryView.cpp" # from [4dc2768b6d4dacd9c81420ded69f83fe689ee464] # to [459a7ffa747b6a863200677a97ae897fbc808ede] # # patch "src/view/InventoryView.h" # from [4600fd50ceb332bde69a80bf6284e727732035f9] # to [f05ba7b23f419f5540c42036dbdeb26cafeb799a] # ============================================================ --- src/view/InventoryView.cpp 4dc2768b6d4dacd9c81420ded69f83fe689ee464 +++ src/view/InventoryView.cpp 459a7ffa747b6a863200677a97ae897fbc808ede @@ -577,12 +577,97 @@ void InventoryView::slotAdd() void InventoryView::slotAdd() { - C("Not implemented."); + QSet items = getSelectedItems(); + if (items.size() == 0) return; + + QStringList paths; + foreach (const ModelItem * item, items) + { + const InventoryItem * invitem = dynamic_cast(item); + + if (!invitem || invitem->isTracked()) + { + continue; + } + + // rename the "root" directory to ".", since empty restrictions + // a la "" will make mtn bail out + QString path = invitem->getPath(); + if (path.isEmpty()) + { + path = "."; + } + paths.push_back(path); + } + + if (paths.size() == 0) + { + QMessageBox::information( + this, + tr("Items can't be added"), + tr("None of the selected items can be added."), + QMessageBox::Ok + ); + return; + } + + emit addPaths(paths); } void InventoryView::slotRemove() { - C("Not implemented."); + QSet items = getSelectedItems(); + if (items.size() == 0) return; + + QStringList paths; + foreach (const ModelItem * item, items) + { + const InventoryItem * invitem = dynamic_cast(item); + + if (!invitem) + continue; + + QString path = invitem->getPath(); + if (path.isEmpty()) + { + QMessageBox::information( + this, + tr("Item can't be dropped"), + tr("The workspace root cannot be dropped."), + QMessageBox::Ok + ); + return; + } + + int status = invitem->getStatusRecursive(); + + if ((status & InventoryItem::Unknown) == InventoryItem::Unknown || + (status & InventoryItem::Ignored) == InventoryItem::Ignored) + { + QMessageBox::information( + this, + tr("Item can't be dropped"), + tr("The item '%1' contains unversioned files and " + "therefor cannot be dropped.").arg(path), + QMessageBox::Ok + ); + return; + } + paths.push_back(path); + } + + if (paths.size() == 0) + { + QMessageBox::information( + this, + tr("Items can't be dropped"), + tr("None of the selected items can be dropped."), + QMessageBox::Ok + ); + return; + } + + emit dropPaths(paths); } void InventoryView::slotCommit() @@ -616,7 +701,7 @@ void InventoryView::slotCommit() QMessageBox::information( this, tr("Items can't be committed"), - tr("None of the selected items can be committed."), + tr("None of the selected items have changes or can be committed."), QMessageBox::Ok ); return; ============================================================ --- src/view/InventoryView.h 4600fd50ceb332bde69a80bf6284e727732035f9 +++ src/view/InventoryView.h f05ba7b23f419f5540c42036dbdeb26cafeb799a @@ -49,6 +49,8 @@ signals: void fileHistory(const QString &); void commitRevision(const QStringList &); void refreshPath(const QString &); + void addPaths(const QStringList &); + void dropPaths(const QStringList &); private: enum DefaultAction { None, Chdir, Open, FileDiff, Commit };