# # # add_dir "guitone/res/icons" # # add_file "guitone/res/icons/tree.png" # content [ff19cc1b25b13815d85307dafe4cff116c793cfa] # # add_file "guitone/src/model/Changeset.cpp" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # add_file "guitone/src/model/Changeset.h" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # add_file "guitone/src/model/ChangesetModel.cpp" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # add_file "guitone/src/model/ChangesetModel.h" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # add_file "guitone/src/model/Toposort.cpp" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # add_file "guitone/src/model/Toposort.h" # content [da39a3ee5e6b4b0d3255bfef95601890afd80709] # # patch "guitone/guitone.pro" # from [3d2d29bd96e6f527b896970c453d06d0285564d8] # to [f9550b73c492528ffb9b17d14de2bd61f73cc512] # # patch "guitone/res/dialogs/databaseview.ui" # from [dca9ea47934658b3d60fbb154932f2b21fc0133f] # to [59d4f9cc9dcc44a936c7fe573013a83f71afd569] # # patch "guitone/res/guitone.qrc" # from [a32394bac9be41ea3df1691bd5638bf7849762d3] # to [aa792b0a9bacff4929d60c97e1d035f600b51d04] # # patch "guitone/res/i18n/guitone_de.ts" # from [5e73a7bc11b7d61fc74b67edca91faca0bcf68e7] # to [2b088ec657e5372dbb95ad281dfa80ac826fb559] # # patch "guitone/src/model/Branches.cpp" # from [28cdf3be5042f184093660b5072fd4e1ae7568ce] # to [b51ea32c7e7f816b9c081426eea077905531d237] # # patch "guitone/src/model/Branches.h" # from [77bb770356ae44702b9f47308c1f202588e09a40] # to [d366aeaf18e525b6f370f6cd3a5d93991c319201] # # patch "guitone/src/util/Settings.cpp" # from [659b9c2878fdf9d802dc6096ee1c31abdfb4ba42] # to [55f7c1a0f2ccb6a4a7433cf1043abf2e9326bc7f] # # patch "guitone/src/util/Settings.h" # from [3e2c304fa391e02e3e8a634384cd7ea27b639b38] # to [63ec72f169e90eac2a0ddeed6068c9ac179f3e53] # # patch "guitone/src/util/TreeBuilder.cpp" # from [081d27103c3d86fe87890fc1a29f9aee8e943af3] # to [9f2d8fe71f280dc17d3b983e99a21eb83bb80429] # # patch "guitone/src/view/dialogs/DatabaseView.cpp" # from [b90047b3c6b8787061a1805779bc30871cf2cf10] # to [f628458e2fdd4c387f0ed2d69604334d72c8ffce] # # patch "guitone/src/view/dialogs/DatabaseView.h" # from [77883e12c09eeee07a328582ea84712e02de5343] # to [1261cf82416de9fe1efc31c3350d35afcbb442a7] # # patch "guitone/src/view/dialogs/SwitchWorkspaceRevision.cpp" # from [5ca1a0e97176a1a68e5aaccd3b136a7fcaa794be] # to [11b0b16ca8593b24ab2b73d8fce05157edf43d04] # # set "guitone/res/icons/tree.png" # attr "mtn:manual_merge" # value "true" # ============================================================ # guitone/res/icons/tree.png is binary ============================================================ --- guitone/src/model/Changeset.cpp da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ guitone/src/model/Changeset.cpp da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- guitone/src/model/Changeset.h da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ guitone/src/model/Changeset.h da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- guitone/src/model/ChangesetModel.cpp da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ guitone/src/model/ChangesetModel.cpp da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- guitone/src/model/ChangesetModel.h da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ guitone/src/model/ChangesetModel.h da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- guitone/src/model/Toposort.cpp da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ guitone/src/model/Toposort.cpp da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- guitone/src/model/Toposort.h da39a3ee5e6b4b0d3255bfef95601890afd80709 +++ guitone/src/model/Toposort.h da39a3ee5e6b4b0d3255bfef95601890afd80709 ============================================================ --- guitone/guitone.pro 3d2d29bd96e6f527b896970c453d06d0285564d8 +++ guitone/guitone.pro f9550b73c492528ffb9b17d14de2bd61f73cc512 @@ -34,6 +34,9 @@ HEADERS += src/view/Guitone.h \ src/model/Tags.h \ src/model/Branches.h \ src/model/Keys.h \ + src/model/Changeset.h \ + src/model/ChangesetModel.h \ + src/model/Toposort.h \ src/util/IconProvider.h \ src/util/StanzaParser.h \ src/util/Settings.h \ @@ -70,6 +73,9 @@ SOURCES += src/view/Guitone.cpp \ src/model/Tags.cpp \ src/model/Branches.cpp \ src/model/Keys.cpp \ + src/model/Changeset.cpp \ + src/model/ChangesetModel.cpp \ + src/model/Toposort.cpp \ src/util/IconProvider.cpp \ src/util/StanzaParser.cpp \ src/util/Settings.cpp \ ============================================================ --- guitone/res/dialogs/databaseview.ui dca9ea47934658b3d60fbb154932f2b21fc0133f +++ guitone/res/dialogs/databaseview.ui 59d4f9cc9dcc44a936c7fe573013a83f71afd569 @@ -55,7 +55,7 @@ Qt::Vertical - + @@ -79,6 +79,16 @@ 6 + + + ... + + + :/icons/tree.png + + + + Update All Branches @@ -147,8 +157,8 @@ accept() - 579 - 523 + 630 + 539 319 ============================================================ --- guitone/res/guitone.qrc a32394bac9be41ea3df1691bd5638bf7849762d3 +++ guitone/res/guitone.qrc aa792b0a9bacff4929d60c97e1d035f600b51d04 @@ -1,7 +1,8 @@ guitone-icon.svg guitone-logo.svg + icons/tree.png i18n/guitone_de.qm overlays/added.png overlays/added_missing.png ============================================================ --- guitone/res/i18n/guitone_de.ts 5e73a7bc11b7d61fc74b67edca91faca0bcf68e7 +++ guitone/res/i18n/guitone_de.ts 2b088ec657e5372dbb95ad281dfa80ac826fb559 @@ -82,8 +82,13 @@ Branch Name - Zweig-Name + Zweig-Name + + + Branches + Zweige + Certs @@ -191,7 +196,7 @@ Branches - Zweige + Zweige ============================================================ --- guitone/src/model/Branches.cpp 28cdf3be5042f184093660b5072fd4e1ae7568ce +++ guitone/src/model/Branches.cpp b51ea32c7e7f816b9c081426eea077905531d237 @@ -21,21 +21,22 @@ #include "Branches.h" #include "../monotone/Monotone.h" -Branches::Branches(QObject *parent) +Branches::Branches(bool tree, QObject *parent) : AutomateCommand(parent) { - branches = new QStringList(); + builder = 0; + Branches::tree = tree; } Branches::~Branches() { - branches->clear(); - delete branches; + if(builder) + delete builder; } bool Branches::readBranches() { - branches->clear(); + branches.clear(); reset(); QStringList cmd; @@ -46,7 +47,29 @@ void Branches::parseOutput() void Branches::parseOutput() { - branches = new QStringList(AutomateCommand::data.split(QChar('\n'))); + branches.setHorizontalHeaderItem(0, new QStandardItem(tr("Branches"))); + if(tree) + { + QStandardItem *root = new QStandardItem("*"); + root->setData("*", Qt::ToolTipRole); + branches.appendRow(root); + + builder = new TreeBuilder(root, this); + builder->addList(AutomateCommand::data); + } + else + { + QStringList branchList = AutomateCommand::data.split("\n"); + + QStringListIterator iterator(branchList); + while(iterator.hasNext()) + { + QString it = iterator.next(); + QStandardItem *item = new QStandardItem(it); + item->setData(it, Qt::ToolTipRole); + branches.appendRow(item); + } + } reset(); emit branchesRead(); @@ -54,53 +77,73 @@ int Branches::columnCount(const QModelIn int Branches::columnCount(const QModelIndex &parent) const { - return 1; + QStandardItem * item = branchFromIndex(parent); + if(item) + return item->columnCount(); + else + return branches.columnCount(); } QVariant Branches::data(const QModelIndex &index, int role) const { - if (!index.isValid()) - { + QStandardItem * item = branchFromIndex(index); + if(item) + return item->data(role); + else 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; -} +//FIXME: Do we need this? +/*Qt::ItemFlags Branches::flags(const QModelIndex &index) const +{ + return branchFromIndex(index)->flags(); +}*/ + 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(); + return branches.headerData(section, orientation, role); } int Branches::rowCount(const QModelIndex& parent) const { - return branches->size(); + QStandardItem * item = branchFromIndex(parent); + if(item) + return item->rowCount(); + else + return branches.rowCount(); } QModelIndex Branches::index(int row, int column, const QModelIndex& parent) const { - return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex(); + return createIndex(row, column, getBranchItem(row, column, parent)); } QModelIndex Branches::parent(const QModelIndex& index) const +{ + QStandardItem * item = branchFromIndex(index); + if(item) + { + QStandardItem * parent = item->parent(); + if(parent) + return createIndex(parent->row(), parent->column(), parent); + } + + return QModelIndex(); +} + +void * Branches::getBranchItem(int row, int column, const QModelIndex& index) const { - return QModelIndex(); + if(index.isValid()) + return ((QStandardItem *) index.internalPointer())->child(row, column); + else + return branches.item(row, column); } +QStandardItem * Branches::branchFromIndex(const QModelIndex& index) const +{ + if(index.isValid()) + return (QStandardItem *) index.internalPointer(); + else + return 0; +} ============================================================ --- guitone/src/model/Branches.h 77bb770356ae44702b9f47308c1f202588e09a40 +++ guitone/src/model/Branches.h d366aeaf18e525b6f370f6cd3a5d93991c319201 @@ -23,17 +23,18 @@ #include "AutomateCommand.h" #include +#include "../../util/TreeBuilder.h" class Branches : public AutomateCommand { Q_OBJECT public: - Branches(QObject*); + Branches(bool tree, QObject*); virtual ~Branches(); // needed Qt Model methods QVariant data(const QModelIndex&, int) const; - Qt::ItemFlags flags(const QModelIndex&) 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; @@ -44,11 +45,15 @@ signals: bool readBranches(); signals: - void branchesRead(); + void branchesRead(void); private: + bool tree; + TreeBuilder *builder; void parseOutput(); - QStringList * branches; + QStandardItemModel branches; + void * getBranchItem(int row, int column, const QModelIndex& index) const; + QStandardItem * branchFromIndex(const QModelIndex& index) const; }; #endif ============================================================ --- guitone/src/util/Settings.cpp 659b9c2878fdf9d802dc6096ee1c31abdfb4ba42 +++ guitone/src/util/Settings.cpp 55f7c1a0f2ccb6a4a7433cf1043abf2e9326bc7f @@ -37,6 +37,17 @@ Settings::~Settings() {} Settings::~Settings() {} +void Settings::setBool(const QString &name, bool value) +{ + Settings *settings = singleton(); + settings->setValue(name, value); +} + +bool Settings::getBool(const QString &name, bool defaultVal) +{ + return singleton()->value(name, defaultVal).toBool(); +} + QSize Settings::getStartupSize(const QString &name) { return singleton()->value(name, QSize(640, 480)).toSize(); ============================================================ --- guitone/src/util/Settings.h 3e2c304fa391e02e3e8a634384cd7ea27b639b38 +++ guitone/src/util/Settings.h 63ec72f169e90eac2a0ddeed6068c9ac179f3e53 @@ -29,6 +29,8 @@ public: { public: + static void setBool(const QString &name, bool value); + static bool getBool(const QString &name, bool defaultVal); static QSize getStartupSize(const QString &name); static void setStartupSize(const QString &name, QSize size); static Qt::WindowStates getWindowState(const QString &name); ============================================================ --- guitone/src/util/TreeBuilder.cpp 081d27103c3d86fe87890fc1a29f9aee8e943af3 +++ guitone/src/util/TreeBuilder.cpp 9f2d8fe71f280dc17d3b983e99a21eb83bb80429 @@ -53,6 +53,8 @@ void TreeBuilder::addData(QStandardItem child->setData(branch, Qt::ToolTipRole); } +// FIXME: Bug with one character level + QStandardItem* TreeBuilder::add(const QString &branch, QStandardItem *parent) { if(branch == "") return NULL; ============================================================ --- guitone/src/view/dialogs/DatabaseView.cpp b90047b3c6b8787061a1805779bc30871cf2cf10 +++ guitone/src/view/dialogs/DatabaseView.cpp f628458e2fdd4c387f0ed2d69604334d72c8ffce @@ -28,42 +28,52 @@ DatabaseView::DatabaseView(QWidget *pare this->setWindowFlags(this->windowFlags() | Qt::WindowMaximizeButtonHint); this->setWindowFlags(this->windowFlags() | Qt::WindowMinimizeButtonHint); + tree = Settings::getBool("DatabaseViewTree", false); + initTreeWidget(); - readBranches(); resize(Settings::getStartupSize("DatabaseViewStartupSize")); setWindowState(Settings::getWindowState("DatabaseViewWindowState")); + + connect(branches, SIGNAL(clicked(QModelIndex)), + this, SLOT(branchesClicked(QModelIndex))); + connect(toolTree, SIGNAL(clicked()), + this, SLOT(toggleTree())); } DatabaseView::~DatabaseView() { - delete branchModel; - delete builder; + Settings::setBool("DatabaseViewTree", tree); } +void DatabaseView::toggleTree() +{ + tree = !tree; + initTreeWidget(); +} + void DatabaseView::branchesClicked(QModelIndex idx) { - QString branch = branchModel->itemFromIndex(idx)->data(Qt::ToolTipRole).toString(); + QString branch = branchModel->data(idx, Qt::ToolTipRole).toString(); readChangesets(branch); } void DatabaseView::initTreeWidget() { - QStandardItem *root = new QStandardItem("*"); - root->setData("*", Qt::ToolTipRole); - - branchModel = new QStandardItemModel(this); - branchModel->appendRow(root); - branchModel->setHorizontalHeaderItem(0, new QStandardItem(tr("Branches"))); - - builder = new TreeBuilder(root, this); + branchModel = new Branches(tree, this); + branchModel->readBranches(); branches->setRootIsDecorated(false); branches->setModel(branchModel); - branches->setExpanded(root->index(), true); - connect(branches, SIGNAL(clicked(QModelIndex)), - this, SLOT(branchesClicked(QModelIndex))); + connect(branchModel, SIGNAL(branchesRead(void)), + this, SLOT(branchesRead(void))); + } +void DatabaseView::branchesRead() +{ + branches->setExpanded(branchModel->index(0, 0, QModelIndex()), true); +} + void DatabaseView::closeEvent(QCloseEvent *event) { // Do some cleanup before closing down the application @@ -85,36 +95,3 @@ void DatabaseView::readChangesets(const { qDebug() << branch; } - - -void DatabaseView::readBranches() -{ - mtn = Monotone::singleton(this); - - connect( - mtn, SIGNAL(commandFinished(int)), - this, SLOT(addBranches(int)) - ); - mtn->triggerCommand(QStringList() << "branches"); -} - -void DatabaseView::addBranches(int ret) -{ - QString data(mtn->getDataAndReset()); - - if (ret == 0) - { - builder->addList(data); - } - else - { - // FIXME: should be generalized / pushed to the user somehow - qDebug("DatabaseView::addBranches: error while executing 'branches': %s", qPrintable(data)); - } - - disconnect( - mtn, SIGNAL(commandFinished(int)), - this, SLOT(addBranches(int)) - ); -} - ============================================================ --- guitone/src/view/dialogs/DatabaseView.h 77883e12c09eeee07a328582ea84712e02de5343 +++ guitone/src/view/dialogs/DatabaseView.h 1261cf82416de9fe1efc31c3350d35afcbb442a7 @@ -24,29 +24,28 @@ #include "ui_databaseview.h" #include #include "../../monotone/Monotone.h" -#include "../../util/TreeBuilder.h" +#include "../../model/Branches.h" class DatabaseView : public QDialog, private Ui::DatabaseView { Q_OBJECT public: - QStandardItemModel *branchModel; + Branches *branchModel; DatabaseView(QWidget *parent = 0); ~DatabaseView(); private slots: void branchesClicked(QModelIndex idx); - void addBranches(int ret); + void branchesRead(); + void toggleTree(); private: - void readBranches(); + bool tree; void initTreeWidget(); void readChangesets(const QString &branch); void resizeEvent ( QResizeEvent * event ); void closeEvent(QCloseEvent *); - Monotone *mtn; - TreeBuilder *builder; QSize curSize; }; ============================================================ --- guitone/src/view/dialogs/SwitchWorkspaceRevision.cpp 5ca1a0e97176a1a68e5aaccd3b136a7fcaa794be +++ guitone/src/view/dialogs/SwitchWorkspaceRevision.cpp 11b0b16ca8593b24ab2b73d8fce05157edf43d04 @@ -41,7 +41,7 @@ SwitchWorkspaceRevision::SwitchWorkspace // create the models selectorModel = new Select(this); certsModel = new Certs(this); - branchesModel = new Branches(this); + branchesModel = new Branches(false, this); tagsModel = new Tags(this); keysModel = new Keys(this);