#
#
# patch "i18n/guitone_de.ts"
# from [314d8e73eb4391e445bdfec5a0c301557a7b8c1a]
# to [79bc887d4ffadd3faba7d75ed3cc3ccec81e6c9e]
#
# patch "src/view/WorkspaceView.cpp"
# from [c845598a3be8c3b345dcc12837e49f6b8d6d9f0a]
# to [966b0b069cb1beee7e000e51c2fcaab08a1eca82]
#
# patch "src/view/WorkspaceView.h"
# from [55fc84d9850cdd49543628db976f1a2761fb08e7]
# to [94ebf2667010edcdb4719adef3b787274f39a630]
#
============================================================
--- i18n/guitone_de.ts 314d8e73eb4391e445bdfec5a0c301557a7b8c1a
+++ i18n/guitone_de.ts 79bc887d4ffadd3faba7d75ed3cc3ccec81e6c9e
@@ -11,7 +11,7 @@
- Arbeitsbereich &importieren
+ Arbeitsbereich &importieren
@@ -63,6 +63,10 @@
Das gewählte Verzeichnis ist kein monotone-Arbeitsverzeichnis!
+
+
+ &Importiere Arbeitsbereich
+
Monotone
@@ -273,6 +277,104 @@
+ WorkspaceView
+
+
+ &Hinzufügen
+
+
+
+
+
+
+
+ En&tfernen
+
+
+
+ &Einpflegen
+
+
+
+ Datei nicht ign&orieren
+
+
+
+ &Zurücksetzen
+
+
+
+ Um&benennen
+
+
+
+ Add
+
+
+
+
+ Zum Arbeitsbereich hinzufügen
+
+
+
+ Remove
+
+
+
+
+ Vom Arbeitsbereich entfernen
+
+
+
+ Commit
+
+
+
+
+ Einpflegen
+
+
+
+ Datei &ignorieren
+
+
+
+ Ignore
+
+
+
+
+ Datei ignorieren
+
+
+
+ Unignore
+
+
+
+
+ Datei nicht mehr ignorieren
+
+
+
+ Nicht eingepflegte Ãnderungen verwerfen
+
+
+
+ Rename
+
+
+
+
+ Datei umbenennen
+
+
+
+ Revert
+
+
+
+
main
============================================================
--- src/view/WorkspaceView.cpp c845598a3be8c3b345dcc12837e49f6b8d6d9f0a
+++ src/view/WorkspaceView.cpp 966b0b069cb1beee7e000e51c2fcaab08a1eca82
@@ -46,39 +46,131 @@
WorkspaceView::~WorkspaceView() {}
-void WorkspaceView::contextMenuEvent(QContextMenuEvent * ev)
+void WorkspaceView::contextMenuEvent(QContextMenuEvent* ev)
{
- QMenu menu(this);
- menu.addAction(actAdd);
- menu.addAction(actRemove);
- menu.addAction(actCommit);
- menu.addAction(actIgnore);
- menu.exec(mapToGlobal(ev->pos()));
+ //
+ // make sure the element under the cursor is selected as well
+ // TODO: it seems as sometimes the selection is screwed up for
+ // no particular reason... why?
+ //
+ QItemSelectionModel* selection = selectionModel();
+ QModelIndex index = indexAt(ev->pos());
+ selection->select(index,
+ QItemSelectionModel::Select |
+ QItemSelectionModel::Current
+ );
+ setSelectionModel(selection);
+
+ //
+ // add elements to the popup menu based on the selected items
+ // since not all actions may apply on all items
+ //
+ QList indexList = selection->selectedIndexes();
+
+ qDebug("Selected indexes: %d", indexList.size());
+
+ if (indexList.size() == 1)
+ {
+ QMenu menu(this);
+ WorkspaceItem* item = (WorkspaceItem*)indexList[0].internalPointer();
+
+ if (item->hasStatus(WorkspaceItem::Unknown))
+ {
+ menu.addAction(actAdd);
+ menu.addAction(actIgnore);
+ }
+
+ if (item->hasStatus(WorkspaceItem::Ignored))
+ {
+ menu.addAction(actUnignore);
+ }
+
+ if (item->hasNotStatus(WorkspaceItem::Ignored) &&
+ item->hasNotStatus(WorkspaceItem::Unknown))
+ {
+ menu.addAction(actCommit);
+ menu.addAction(actRemove);
+ menu.addAction(actRename);
+ }
+
+ // adds, drops, renames and changed files can be reverted
+ if (item->hasNotStatus(WorkspaceItem::Ignored) &&
+ item->hasNotStatus(WorkspaceItem::Unchanged) &&
+ item->hasNotStatus(WorkspaceItem::Unknown))
+ {
+ menu.addAction(actRevert);
+ }
+
+ menu.exec(mapToGlobal(ev->pos()));
+ }
+ else
+ {
+ //
+ // TODO: a smart multi-column menu could work like this:
+ //
+ // a) loop through all index items detecting the type of actions
+ // which could be executed on them
+ // b) create a menu which contains each action which can be at least
+ // executed on one item:
+ //
+ // |------------------|
+ // | Add (3 items) |
+ // | Ignore (2 items) |
+ // | ... |
+ // |------------------|
+ //
+ // Since we need to do that again later on when the actual action should
+ // take place, we might think about creating some kind of "temporary"
+ // selection which isn't visible (or some other "hack") but serves as
+ // input for the slot.
+ //
+ qDebug("No popup menu on multi-item selections yet.");
+ return;
+ }
}
void WorkspaceView::createAndConnectContextActions(void)
{
actAdd = new QAction(tr("&Add"), this);
- actAdd->setShortcut(tr("Ctrl+A"));
- actAdd->setStatusTip(tr("")); connect(actAdd, SIGNAL(triggered()), this, SLOT(slotAdd()));
+ actAdd->setShortcut(tr("Ctrl+A", "Add"));
+ actAdd->setStatusTip(tr("Add to workspace"));
+ connect(actAdd, SIGNAL(triggered()), this, SLOT(slotAdd()));
actRemove = new QAction(tr("&Remove"), this);
- actRemove->setShortcut(tr("Ctrl+R"));
- actRemove->setStatusTip(tr("")); connect(actRemove, SIGNAL(triggered()), this, SLOT(slotRemove()));
+ actRemove->setShortcut(tr("Ctrl+R", "Remove"));
+ actRemove->setStatusTip(tr("Remove from workspace"));
+ connect(actRemove, SIGNAL(triggered()), this, SLOT(slotRemove()));
actCommit = new QAction(tr("&Commit"), this);
- actCommit->setShortcut(tr("Ctrl+C"));
- actCommit->setStatusTip(tr("")); connect(actCommit, SIGNAL(triggered()), this, SLOT(slotCommit()));
+ actCommit->setShortcut(tr("Ctrl+C", "Commit"));
+ actCommit->setStatusTip(tr("Commit"));
+ connect(actCommit, SIGNAL(triggered()), this, SLOT(slotCommit()));
- actIgnore = new QAction(tr("&Ignore"), this);
- actIgnore->setShortcut(tr("Ctrl+I"));
- actIgnore->setStatusTip(tr("")); connect(actIgnore, SIGNAL(triggered()), this, SLOT(slotIgnore()));
+ actIgnore = new QAction(tr("I&gnore"), this);
+ actIgnore->setShortcut(tr("Ctrl+G", "Ignore"));
+ actIgnore->setStatusTip(tr("Ignore file"));
+ connect(actIgnore, SIGNAL(triggered()), this, SLOT(slotIgnore()));
+
+ actUnignore = new QAction(tr("&Unignore"), this);
+ actUnignore->setShortcut(tr("Ctrl+U","Unignore"));
+ actUnignore->setStatusTip(tr("Unignore file"));
+ connect(actUnignore, SIGNAL(triggered()), this, SLOT(slotUnignore()));
+
+ actRevert = new QAction(tr("R&evert"), this);
+ actRevert->setShortcut(tr("Ctrl+E", "Revert"));
+ actRevert->setStatusTip(tr("Revert uncommitted changes"));
+ connect(actRevert, SIGNAL(triggered()), this, SLOT(slotRevert()));
+
+ actRename = new QAction(tr("Rena&me"), this);
+ actRename->setShortcut(tr("Ctrl+M", "Rename"));
+ actRename->setStatusTip(tr("Rename file"));
+ connect(actRename, SIGNAL(triggered()), this, SLOT(slotRename()));
}
void WorkspaceView::slotAdd(void)
{
QItemSelectionModel *selectionModel = this->selectionModel();
- QModelIndexList modelIndexList(selectionModel->selectedIndexes());
+ QList modelIndexList(selectionModel->selectedIndexes());
if(modelIndexList.size() == 0)
{
@@ -110,11 +202,34 @@
qDebug("WorkspaceView::slotCommit!!!");
}
+void WorkspaceView::slotRevert(void)
+{
+ qDebug("WorkspaceView::slotRevert!!!");
+}
+
+void WorkspaceView::slotRename(void)
+{
+ qDebug("WorkspaceView::slotRename!!!");
+}
+
+//
+// TODO: there is no mtn API for the next two commands available
+// right now so we need to manually edit the WD/.mtn-ignore file
+// Q: If this file is under version control, should a change
+// be committed in the background?
+//
void WorkspaceView::slotIgnore(void)
{
qDebug("WorkspaceView::slotIgnore!!!");
}
+void WorkspaceView::slotUnignore(void)
+{
+ qDebug("WorkspaceView::slotUnignore!!!");
+}
+
+
+
/*
void WorkspaceView::display(std::list* items)
{
============================================================
--- src/view/WorkspaceView.h 55fc84d9850cdd49543628db976f1a2761fb08e7
+++ src/view/WorkspaceView.h 94ebf2667010edcdb4719adef3b787274f39a630
@@ -65,13 +65,18 @@
QAction *actRemove;
QAction *actCommit;
QAction *actIgnore;
+ QAction *actUnignore;
+ QAction *actRevert;
+ QAction *actRename;
private slots:
void slotAdd(void);
void slotRemove(void);
void slotCommit(void);
void slotIgnore(void);
-
+ void slotUnignore(void);
+ void slotRevert(void);
+ void slotRename(void);
};
#endif