# # # add_file "guitone/src/model/Branches.cpp" # content [6bcb36870b9b9d22b9686e840f7307ee3e5e39be] # # add_file "guitone/src/model/Branches.h" # content [5a1c01a92003383ab83eeb385727cb6863872640] # # add_file "guitone/src/model/Tags.cpp" # content [4d3192e301ea504e6070e49c76212e1bf8acb194] # # add_file "guitone/src/model/Tags.h" # content [9ce672b41d2b578bcc499fb4ecfe26ce7b09fceb] # # patch "guitone/guitone.pro" # from [83d543d1ffc79f75e37533000e233f47953227d4] # to [c82b4a4df92e8799477921d981d51b28bfd768cb] # # patch "guitone/src/model/Keys.cpp" # from [2868d3db8852fafe2471388840bfafb1dafcabd2] # to [6ac683b3c0c133e255d5f0328b9eb1bda43ef1ed] # # patch "guitone/src/model/Keys.h" # from [fa48cbbf52ba7b888166849c0db3d1094a6cfa71] # to [ea3bff0fa4f455b6d2bf2059e5d92a727bf5db49] # # patch "guitone/src/util/Settings.cpp" # from [6d6651c1adb2d0df84c8ce4dce23fa25518f37b8] # to [f09f5c4e4725d265908c62c75790ac842df850a8] # # patch "guitone/src/util/Settings.h" # from [cd9740763378997917037234ba0f3ce02f0e1d8a] # to [81d4810800baf63a95af60eb5804783e36e9985e] # # patch "guitone/src/view/Guitone.cpp" # from [c007d15ec51b0c5d16ffa9ee5d4b308ee3bf5c84] # to [a3975cbce83cba1d70fb34d5c93f81436d7adbe7] # # patch "guitone/src/view/dialogs/SwitchWorkspaceRevision.cpp" # from [bd0ad69fbb460fbd87dcb1af104d4b0e82818402] # to [6211ee0e88fd910624de1bbb5420cbefca1797c2] # # patch "guitone/src/view/dialogs/SwitchWorkspaceRevision.h" # from [3ead290c3657c84b319bbffe4439e142a97ccf6c] # to [0c450243950807dc31146792a14ad442bf38fa30] # ============================================================ --- guitone/src/model/Branches.cpp 6bcb36870b9b9d22b9686e840f7307ee3e5e39be +++ guitone/src/model/Branches.cpp 6bcb36870b9b9d22b9686e840f7307ee3e5e39be @@ -0,0 +1,110 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "Branches.h" +#include "../monotone/Monotone.h" + +Branches::Branches(QObject *parent) + : AutomateCommand(parent) +{ + branches = new QStringList(); +} + +Branches::~Branches() +{ + branches->clear(); + delete branches; +} + +bool Branches::readBranches() +{ + branches->clear(); + reset(); + + QStringList cmd; + cmd << "branches"; + + Monotone *mtn = Monotone::singleton(); + + return mtn->triggerCommand(this, cmd); +} + +void Branches::parseOutput(AutomateCommand *caller) +{ + // if not we are the caller, omit the parsing + if (caller != this) return; + + branches = new QStringList(AutomateCommand::data.split(QChar('\n'))); + reset(); + + emit branchesRead(); +} + +int Branches::columnCount(const QModelIndex &parent) const +{ + return 1; +} + +QVariant Branches::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + { + return QVariant(); + } + + if (role != Qt::DisplayRole) + { + return QVariant(); + } + + int row = index.row(); + if (row >= branches->size()) return QVariant(); + + return QVariant(branches->at(row)); +} + +Qt::ItemFlags Branches::flags(const QModelIndex &index) const +{ + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +QVariant Branches::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + return QVariant(tr("Branch Name")); + } + return QVariant(); +} + +int Branches::rowCount(const QModelIndex& parent) const +{ + return branches->size(); +} + +QModelIndex Branches::index(int row, int column, const QModelIndex& parent) const +{ + return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex(); +} + +QModelIndex Branches::parent(const QModelIndex& index) const +{ + return QModelIndex(); +} ============================================================ --- guitone/src/model/Branches.h 5a1c01a92003383ab83eeb385727cb6863872640 +++ guitone/src/model/Branches.h 5a1c01a92003383ab83eeb385727cb6863872640 @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef BRANCHES_H +#define BRANCHES_H + +#include "AutomateCommand.h" +#include + +class Branches : public AutomateCommand +{ + Q_OBJECT +public: + Branches(QObject*); + virtual ~Branches(); + + // needed Qt Model methods + QVariant data(const QModelIndex&, int) const; + Qt::ItemFlags flags(const QModelIndex&) const; + QVariant headerData(int, Qt::Orientation, int) const; + QModelIndex index(int, int, const QModelIndex&) const; + QModelIndex parent(const QModelIndex&) const; + int rowCount(const QModelIndex&) const; + int columnCount(const QModelIndex&) const; + +public slots: + bool readBranches(); + +signals: + void branchesRead(); + +private: + void parseOutput(AutomateCommand*); + QStringList * branches; +}; + +#endif ============================================================ --- guitone/src/model/Tags.cpp 4d3192e301ea504e6070e49c76212e1bf8acb194 +++ guitone/src/model/Tags.cpp 4d3192e301ea504e6070e49c76212e1bf8acb194 @@ -0,0 +1,183 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "Tags.h" +#include "../monotone/Monotone.h" +#include "../util/StanzaParser.h" + +Tags::Tags(QObject *parent) + : AutomateCommand(parent) +{ + tags = new TagList(); +} + +Tags::~Tags() +{ + tags->clear(); + delete tags; +} + +bool Tags::readTags(const QString & branch) +{ + tags->clear(); + reset(); + + QStringList cmd; + cmd << "tags"; + if (branch.length() > 0) + { + cmd << branch; + } + + Monotone *mtn = Monotone::singleton(); + return mtn->triggerCommand(this, cmd); +} + +void Tags::parseOutput(AutomateCommand *caller) +{ + // if not we are the caller, omit the parsing + if (caller != this) return; + + StanzaParser* parser = new StanzaParser(AutomateCommand::data); + StanzaList list = parser->getStanzas(); + + for (int i=0, size = list.size(); i < size; ++i) + { + Stanza stanza = list.at(i); + + Tag tag; + + bool isItem = false; + + for (int j=0, size2 = stanza.size(); j < size2; j++) + { + StanzaEntry entry = stanza.at(j); + + // we're now only interested in stanzas starting with a "tag" entry + if (j == 0 && entry.sym != "tag") break; + + isItem = true; + + if (entry.sym == "tag") + { + Q_ASSERT(entry.vals.size() == 1); + tag.name = entry.vals.at(0); + continue; + } + + if (entry.sym == "revision") + { + Q_ASSERT(entry.vals.size() == 1); + tag.revision = entry.vals.at(0); + continue; + } + + if (entry.sym == "signer") + { + Q_ASSERT(entry.vals.size() == 1); + tag.signer = entry.vals.at(0); + continue; + } + + if (entry.sym == "branches") + { + tag.branches = entry.vals; + continue; + } + + qWarning("Tags::parseOutput(): Unknown symbol %s.", qPrintable(entry.sym)); + } + + // check if we really processed an item entry + if (!isItem) continue; + tags->append(tag); + } + + reset(); + emit tagsRead(); +} + +int Tags::columnCount(const QModelIndex &parent) const +{ + return 4; +} + +QVariant Tags::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + { + return QVariant(); + } + + if (role != Qt::DisplayRole) + { + return QVariant(); + } + + int row = index.row(); + if (row >= tags->size()) return QVariant(); + + Tag tag = tags->at(row); + + switch (index.column()) + { + case 0: return QVariant(tag.name); + case 1: return QVariant(tag.revision); + case 2: return QVariant(tag.signer); + case 3: return QVariant(tag.branches.join("\n")); + } + + return QVariant(); +} + +Qt::ItemFlags Tags::flags(const QModelIndex &index) const +{ + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; +} + +QVariant Tags::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { + switch (section) + { + case 0: return QVariant(tr("Name")); + case 1: return QVariant(tr("Revision")); + case 2: return QVariant(tr("Signer")); + case 3: return QVariant(tr("Branches")); + } + } + return QVariant(); +} + +int Tags::rowCount(const QModelIndex& parent) const +{ + return tags->size(); +} + +QModelIndex Tags::index(int row, int column, const QModelIndex& parent) const +{ + return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex(); +} + +QModelIndex Tags::parent(const QModelIndex& index) const +{ + return QModelIndex(); +} ============================================================ --- guitone/src/model/Tags.h 9ce672b41d2b578bcc499fb4ecfe26ce7b09fceb +++ guitone/src/model/Tags.h 9ce672b41d2b578bcc499fb4ecfe26ce7b09fceb @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (C) 2006 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef TAGS_H +#define TAGS_H + +#include "AutomateCommand.h" +#include + +typedef struct { + QString name; + QString revision; + QString signer; + QStringList branches; +} Tag; +typedef QList TagList; + +class Tags : public AutomateCommand +{ + Q_OBJECT +public: + Tags(QObject*); + virtual ~Tags(); + + // needed Qt Model methods + QVariant data(const QModelIndex&, int) const; + Qt::ItemFlags flags(const QModelIndex&) const; + QVariant headerData(int, Qt::Orientation, int) const; + QModelIndex index(int, int, const QModelIndex&) const; + QModelIndex parent(const QModelIndex&) const; + int rowCount(const QModelIndex&) const; + int columnCount(const QModelIndex&) const; + +public slots: + bool readTags(const QString &); + +signals: + void tagsRead(); + +private: + void parseOutput(AutomateCommand*); + TagList * tags; +}; + +#endif ============================================================ --- guitone/guitone.pro 83d543d1ffc79f75e37533000e233f47953227d4 +++ guitone/guitone.pro c82b4a4df92e8799477921d981d51b28bfd768cb @@ -29,6 +29,8 @@ HEADERS += src/view/Guitone.h \ src/model/ContentDiff.h \ src/model/GetFile.h \ src/model/GetFileProxyModel.h \ + src/model/Tags.h \ + src/model/Branches.h \ src/model/Keys.h \ src/util/IconProvider.h \ src/util/StanzaParser.h \ @@ -59,6 +61,8 @@ SOURCES += src/view/Guitone.cpp \ src/model/ContentDiff.cpp \ src/model/GetFile.cpp \ src/model/GetFileProxyModel.cpp \ + src/model/Tags.cpp \ + src/model/Branches.cpp \ src/model/Keys.cpp \ src/util/IconProvider.cpp \ src/util/StanzaParser.cpp \ ============================================================ --- guitone/src/model/Keys.cpp 2868d3db8852fafe2471388840bfafb1dafcabd2 +++ guitone/src/model/Keys.cpp 6ac683b3c0c133e255d5f0328b9eb1bda43ef1ed @@ -22,6 +22,9 @@ #include "../monotone/Monotone.h" #include "../util/StanzaParser.h" +const int Key::Database = 1; +const int Key::Keystore = 2; + Keys::Keys(QObject *parent) : AutomateCommand(parent) { @@ -186,12 +189,12 @@ QVariant Keys::data(const QModelIndex &i return QVariant(); } -QString Keys::getLocationString(int loc) +QString Keys::getLocationString(int loc) const { QStringList str; - if (loc & Key::Database == Key::Database) + if ((loc & Key::Database) == Key::Database) str << tr("Database"); - if (loc & Key::Keystore == Key::Keystore) + if ((loc & Key::Keystore) == Key::Keystore) str << tr("Keystore"); return str.join(", "); } ============================================================ --- guitone/src/model/Keys.h fa48cbbf52ba7b888166849c0db3d1094a6cfa71 +++ guitone/src/model/Keys.h ea3bff0fa4f455b6d2bf2059e5d92a727bf5db49 @@ -23,15 +23,16 @@ #include "AutomateCommand.h" -typedef struct { - static const int Database = 1; - static const int Keystore = 2; +struct Key { + static const int Database; + static const int Keystore; QString name; QString public_hash; QString private_hash; int public_locations; int private_locations; -} Key; + Key() : public_locations(0), private_locations(0) {}; +}; typedef QList KeyList; class Keys : public AutomateCommand @@ -58,7 +59,7 @@ private: private: void parseOutput(AutomateCommand*); - QString getLocationString(int); + QString getLocationString(int) const; KeyList * keys; }; ============================================================ --- guitone/src/util/Settings.cpp 6d6651c1adb2d0df84c8ce4dce23fa25518f37b8 +++ guitone/src/util/Settings.cpp f09f5c4e4725d265908c62c75790ac842df850a8 @@ -48,48 +48,6 @@ void Settings::setStartupSize(QSize size settings->setValue("StartupSize", size); } -QStringList Settings::getPreviousWorkspaces() -{ - return singleton()->value("RecentWorkspaceList").toStringList(); -} - -void Settings::setPreviousWorkspaces(QStringList list) -{ - Settings *settings = singleton(); - settings->setValue("RecentWorkspaceList", list); -} - -void Settings::addPreviousWorkspace(QString workspace) -{ - QStringList list = getPreviousWorkspaces(); - - // move an already recorded workspace to the front - // so it will always be loaded initially when the program starts - int pos = list.indexOf(workspace); - if (pos > -1) - { - list.move(pos, 0); - } - else - { - if (list.size() > MaxPreviousWorkspaces) - { - list.removeLast(); - } - list.prepend(workspace); - } - setPreviousWorkspaces(list); -} - -void Settings::removePreviousWorkspace(QString workspace) -{ - QStringList list = getPreviousWorkspaces(); - int pos = list.indexOf(workspace); - if (pos == -1) return; - list.removeAt(pos); - setPreviousWorkspaces(list); -} - QString Settings::getMtnExePath() { return singleton()->value("MtnExePath", "mtn").toString(); @@ -148,3 +106,45 @@ void Settings::setSplitterState(const QB Settings *settings = singleton(); settings->setValue(name, byteArray); } + +void Settings::setItemList(const QString & name, const QStringList & items) +{ + Settings *settings = singleton(); + settings->setValue(name, items); +} + +QStringList Settings::getItemList(const QString & name) +{ + return singleton()->value(name).toStringList(); +} + +void Settings::addItemToList(const QString & name, const QString & item, int maxItems) +{ + QStringList list = getItemList(name); + + // move an already recorded item to the front + int pos = list.indexOf(item); + if (pos > -1) + { + list.move(pos, 0); + } + else + { + if (list.size() > maxItems) + { + list.removeLast(); + } + list.prepend(item); + } + setItemList(name, list); +} + +void Settings::removeItemFromList(const QString & name, const QString & item) +{ + QStringList list = getItemList(name); + int pos = list.indexOf(item); + if (pos == -1) return; + list.removeAt(pos); + setItemList(name, list); +} + ============================================================ --- guitone/src/util/Settings.h cd9740763378997917037234ba0f3ce02f0e1d8a +++ guitone/src/util/Settings.h 81d4810800baf63a95af60eb5804783e36e9985e @@ -31,10 +31,10 @@ public: public: static QSize getStartupSize(void); static void setStartupSize(QSize); - static QStringList getPreviousWorkspaces(); - static void setPreviousWorkspaces(QStringList); - static void addPreviousWorkspace(QString); - static void removePreviousWorkspace(QString); + static QStringList getItemList(const QString &); + static void setItemList(const QString &, const QStringList &); + static void addItemToList(const QString&, const QString &, int); + static void removeItemFromList(const QString &, const QString &); static QString getMtnExePath(); static void setMtnExePath(QString); static void saveHeaderViewState(QHeaderView*, QString); @@ -42,8 +42,6 @@ public: static QByteArray getSplitterState(QString); static void setSplitterState(const QByteArray&, QString); - // FIXME: we may want to make this configurable later on - enum { MaxPreviousWorkspaces = 8 }; private: Settings(); ~Settings(void); ============================================================ --- guitone/src/view/Guitone.cpp c007d15ec51b0c5d16ffa9ee5d4b308ee3bf5c84 +++ guitone/src/view/Guitone.cpp a3975cbce83cba1d70fb34d5c93f81436d7adbe7 @@ -198,7 +198,7 @@ Guitone::Guitone() resize(Settings::getStartupSize()); // load the most recent previous workspace, if there is any - QStringList list = Settings::getPreviousWorkspaces(); + QStringList list = Settings::getItemList("RecentWorkspaceList"); if (list.size() > 0) { loadWorkspace(list[0]); @@ -295,7 +295,7 @@ void Guitone::loadWorkspace(QString fn) QMessageBox::Ok ); // remove the workspace if it was recorded as recent workspace - Settings::removePreviousWorkspace(fn); + Settings::removeItemFromList("RecentWorkspaceList", fn); updatePreviousWorkspacesMenu(); return; } @@ -312,7 +312,8 @@ void Guitone::loadWorkspace(QString fn) } // add the workspace to the recent workspace list - Settings::addPreviousWorkspace(invModel->getNormalizedWorkspaceDir()); + // FIXME: the amount of recent workspaces should be made configurable + Settings::addItemToList("RecentWorkspaceList", invModel->getNormalizedWorkspaceDir(), 5); updatePreviousWorkspacesMenu(); statusBar()->showMessage(tr("Loading workspace..."), 2000 ); @@ -350,7 +351,7 @@ void Guitone::updatePreviousWorkspacesMe // clear previous actions wsSubMenu->clear(); - QStringList previousWs = Settings::getPreviousWorkspaces(); + QStringList previousWs = Settings::getItemList("RecentWorkspaceList"); int elemCount = previousWs.size(); if (elemCount == 0) { ============================================================ --- guitone/src/view/dialogs/SwitchWorkspaceRevision.cpp bd0ad69fbb460fbd87dcb1af104d4b0e82818402 +++ guitone/src/view/dialogs/SwitchWorkspaceRevision.cpp 6211ee0e88fd910624de1bbb5420cbefca1797c2 @@ -19,11 +19,10 @@ ***************************************************************************/ #include "SwitchWorkspaceRevision.h" -#include "../../model/Select.h" -#include "../../model/Certs.h" #include #include +#include "../../util/Settings.h" SwitchWorkspaceRevision::SwitchWorkspaceRevision(QWidget* parent) : QDialog(parent) @@ -37,11 +36,18 @@ SwitchWorkspaceRevision::SwitchWorkspace selectorBox->addItem(tr("Author"), "a"); selectorBox->addItem(tr("Date"), "d"); selectorBox->addItem(tr("Custom"), "c"); + selectorBox->addItem(tr("Combined"), ""); // create the models - selectorModel = new Select(this); - certsModel = new Certs(this); + selectorModel = new Select(this); + certsModel = new Certs(this); + branchesModel = new Branches(this); + tagsModel = new Tags(this); + keysModel = new Keys(this); + // set initial completer + setCompleter(0); + // assign the models to the views revisionList->setModel(selectorModel); certList->setModel(certsModel); @@ -73,6 +79,12 @@ SwitchWorkspaceRevision::SwitchWorkspace this, SLOT(handleInvalidSelection(QString)) ); + // connect to the completer for valid types + connect( + selectorBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(setCompleter(int)) + ); + // disable the OK button unless we have a valid selected revision okButton->setEnabled(false); @@ -85,9 +97,35 @@ void SwitchWorkspaceRevision::triggerRev void SwitchWorkspaceRevision::triggerRevisionSearch() { QString selector = selectorBox->itemData(selectorBox->currentIndex()).toString(); - selector.append(":"); - selector.append(selectorValue->text().replace('/', "\\/")); + if (selector == "i") + { + Settings::addItemToList("RecentRevisionSelector", selectorValue->text(), 10); + } + + if (selector == "d") + { + Settings::addItemToList("RecentDateSelector", selectorValue->text(), 10); + } + + if (selector == "c") + { + Settings::addItemToList("RecentCustomSelector", selectorValue->text(), 10); + } + + if (selector == "") + { + Settings::addItemToList("RecentCombinedSelector", selectorValue->text(), 10); + } + + // combined selectors have no common prefix + if (selector != "") + { + selector.append(":"); + } + + selector.append(selectorValue->text()); //.replace('/', "\\/")); + if (!selectorModel->readSelection(selector)) { QMessageBox::warning( @@ -131,6 +169,84 @@ void SwitchWorkspaceRevision::enableDisa okButton->setEnabled(true); } +void SwitchWorkspaceRevision::setCompleter(int index) +{ + QString selector = selectorBox->itemData(index).toString(); + + if (selector == "t") + { + tagsModel->readTags(QString()); + selectorCompleter = new QCompleter(this); + selectorCompleter->setCaseSensitivity(Qt::CaseInsensitive); + selectorCompleter->setModel(tagsModel); + selectorCompleter->setCompletionRole(Qt::DisplayRole); + selectorValue->setCompleter(selectorCompleter); + return; + } + + if (selector == "a") + { + keysModel->readKeys(); + selectorCompleter = new QCompleter(this); + selectorCompleter->setCaseSensitivity(Qt::CaseInsensitive); + selectorCompleter->setModel(keysModel); + selectorCompleter->setCompletionRole(Qt::DisplayRole); + selectorValue->setCompleter(selectorCompleter); + return; + } + + if (selector == "b") + { + branchesModel->readBranches(); + selectorCompleter = new QCompleter(this); + selectorCompleter->setCaseSensitivity(Qt::CaseInsensitive); + selectorCompleter->setModel(branchesModel); + selectorCompleter->setCompletionRole(Qt::DisplayRole); + selectorValue->setCompleter(selectorCompleter); + return; + } + + if (selector == "i") + { + selectorCompleter = new QCompleter( + Settings::getItemList("RecentRevisionSelector"), + this + ); + selectorCompleter->setCaseSensitivity(Qt::CaseInsensitive); + selectorValue->setCompleter(selectorCompleter); + return; + } + + if (selector == "d") + { + selectorCompleter = new QCompleter( + Settings::getItemList("RecentDateSelector"), + this + ); + selectorCompleter->setCaseSensitivity(Qt::CaseInsensitive); + selectorValue->setCompleter(selectorCompleter); + return; + } + + if (selector == "c") + { + selectorCompleter = new QCompleter( + Settings::getItemList("RecentCustomSelector"), + this + ); + selectorCompleter->setCaseSensitivity(Qt::CaseInsensitive); + selectorValue->setCompleter(selectorCompleter); + return; + } + + selectorCompleter = new QCompleter( + Settings::getItemList("RecentCombinedSelector"), + this + ); + selectorCompleter->setCaseSensitivity(Qt::CaseInsensitive); + selectorValue->setCompleter(selectorCompleter); +} + void SwitchWorkspaceRevision::accept() { saveState(); @@ -150,3 +266,4 @@ void SwitchWorkspaceRevision::saveState( // save the states of the UI elements splitter->saveState(); } + ============================================================ --- guitone/src/view/dialogs/SwitchWorkspaceRevision.h 3ead290c3657c84b319bbffe4439e142a97ccf6c +++ guitone/src/view/dialogs/SwitchWorkspaceRevision.h 0c450243950807dc31146792a14ad442bf38fa30 @@ -22,9 +22,13 @@ #define SWITCH_WORKSPACE_REVISION_H #include "ui_switch_workspace.h" +#include "../../model/Select.h" +#include "../../model/Certs.h" +#include "../../model/Branches.h" +#include "../../model/Tags.h" +#include "../../model/Keys.h" -class Select; -class Certs; +#include class SwitchWorkspaceRevision : public QDialog, private Ui::SwitchWorkspaceRevision { @@ -35,17 +39,22 @@ private: ~SwitchWorkspaceRevision(); private: - Select *selectorModel; - Certs *certsModel; - + Select * selectorModel; + Certs * certsModel; + Branches * branchesModel; + Tags * tagsModel; + Keys * keysModel; + QCompleter * selectorCompleter; + void saveState(); private slots: void triggerRevisionSearch(); void handleInvalidSelection(QString); void enableDisableOkButton(const QModelIndex&); + void setCompleter(int); void accept(); void reject(); }; - + #endif