# # # patch "src/model/Ancestors.cpp" # from [7d07e9a3bcb9e2dba0933333cbb51f4037ee0e9f] # to [29675a51f35055b31a8692143e8e821bb8e47420] # # patch "src/model/Ancestors.h" # from [8588c2bcb2731b1202362baa3a8038198becbde9] # to [a6b0213eed2a40a255465157f84d91c1d61224a4] # # patch "src/model/Branches.cpp" # from [ae0c27ed7f2086e4990ffaa2ad0d22462586e890] # to [9270c6f1e10826443f3421a872cfe5061be6a4ff] # # patch "src/model/Branches.h" # from [731c2a00b2e67f3f5045f6c4a641a5be87358276] # to [fccb87b89b30e4fc485b56b24b17d45865750846] # # patch "src/model/Certs.cpp" # from [ca1ec86b2b21a2547e9028a90c3e25094f655878] # to [147bef5808860b7085a17ee44b949ed87e72b6bc] # # patch "src/model/Certs.h" # from [7fb966cf102320f265cffb07ecc235c7432d74ab] # to [c7be6e51d96a5b160aa89fe5984a753aab7e3d3d] # # patch "src/model/ChangesetModel.cpp" # from [94ab98b2cfb7f6316fc569b9e08c599011e9c237] # to [204808846cac0f1f953ca56688b2e7e3c38bdd76] # # patch "src/model/ChangesetModel.h" # from [c5efef03b82eb660d382f3e3a3a79bf404991f3a] # to [c573ec229b84ef887235ee087319736467925342] # # patch "src/model/ContentDiff.cpp" # from [95360ae033fee8d395fdd6d6dd0cd9c07ecaedd8] # to [8ef33c0ee0df05fa76dcbe497d29dedac2059784] # # patch "src/model/ContentDiff.h" # from [7addcfc135b3ad5e6e2835fcb45b42c385f9bc5e] # to [af86806f65f4dd445d9b86321b9ca751816e0508] # # patch "src/model/GetAttributes.cpp" # from [d8a85b2fc3848f2eb913c49ddaf3423c63273284] # to [788b143a775e678233581e431466c91890124dfd] # # patch "src/model/GetAttributes.h" # from [de87690563da758329186f4aa44b6dac47d46a45] # to [32cd96a45c84b05f2817ec8dad06d068583cf6eb] # # patch "src/model/GetBranchLog.cpp" # from [f166e4acdc755a7364eba01eb120ecc865f775e6] # to [efea9b6fa86857e3563d2ebc15a6dda069ddae6a] # # patch "src/model/GetBranchLog.h" # from [e35442cb15dcf7ea81b68e25172c8e6283081420] # to [b5bba049dabe1b6de146eaf5ba81ae26928240a0] # # patch "src/model/GetContentChanged.cpp" # from [3dc7307b83aa8f92a1a5643d7cd76f447a3beec8] # to [d0db3a1357e29cb5dfd5a5320ba464331d2541bb] # # patch "src/model/GetContentChanged.h" # from [174eb4b1c48da00efa1af2b3169c42f8fa620f7a] # to [6aef1cefacc2ae69f66325a7a65eb3eb29c1fa58] # # patch "src/model/GetFile.cpp" # from [48e5c3805ba8a423eb292346a7064eb3e0f86422] # to [1bf34182253597a267fbdbb3df6d8310307f2ca0] # # patch "src/model/GetFile.h" # from [10f469a2c421e93d9ba10d3235b76321dcc08910] # to [017efe23e86731dbbfc7dabb40fccefe3d3632c9] # # patch "src/model/GetFileProxyModel.cpp" # from [0756529c21b7ccf99a17ac2a7fee473cf6a97aa3] # to [8b19a1596259f8400fb4d857bd6599ecf0163a61] # # patch "src/model/GetFileProxyModel.h" # from [160c9b398234711a4819583a49ea950f4ee62b8a] # to [adc53b614cef541e150d407316cb8d3b1bd58afc] # # patch "src/model/GetRevision.cpp" # from [77ca78c81dd8faca37a87aada5170b436758b8c6] # to [9258ab3149451dcf177958b1be1dc408547bfae6] # # patch "src/model/GetRevision.h" # from [b56605574c48d9c4d51b2b5e3a84340b8813f793] # to [0d219aecb29f31a4ff5b9ee8b87fcb46b8c97d7c] # # patch "src/model/Inventory.cpp" # from [9f7bc8a94c7149580c0c3cd900e8b5a6e31186c7] # to [08328754d22ea941a54f2c62924921841477e664] # # patch "src/model/Inventory.h" # from [61bd1cbd1c9cb2c142f95205f66df308dcc836c8] # to [c12c8bd63a9faeacd062544fc292cc0559cc3aa5] # # patch "src/model/InventoryItem.h" # from [ccf79af033dde978761b38c6331274349121acad] # to [0498e1d8a79804da34e4e789ad05e544026aa2b0] # # patch "src/model/Keys.cpp" # from [30bab80f7bc8a8c877a788bd799d758f6cb199bd] # to [7709a27606528064c62b84361292ece16aeba9cf] # # patch "src/model/Keys.h" # from [a9e62309d1c81bfbe903b13ec2b02d36ba2cf47e] # to [f5bcda560a03b830c14c8f8c369b4a96f695704d] # # patch "src/model/Manifest.cpp" # from [be6be5adfedca9f6a9e763a6bcf0a7f0c253abf8] # to [dccb314934d5ea95631976a992ebe532c57c39f1] # # patch "src/model/Manifest.h" # from [cdad4943990688b7adfc1716e2a2b3e7f7bea0ac] # to [e482dcbaf3c30bd2a61773af588c7e6ff681df96] # # patch "src/model/Select.cpp" # from [7d4f1170fdd0328c6740a523244e76a31e82d4f6] # to [d1b4aa62ba14950f1c8dbc53caa5ad6041d0cdfc] # # patch "src/model/Select.h" # from [b0894a2dde22e024f8db52fea72fcc918234b6e1] # to [8f50baba9f3d2d49b1ddc621182ea60b42139d62] # # patch "src/model/Tags.cpp" # from [cac18773608543dbf2f2a35e8b4d03e50e1b197b] # to [fb04a57ba98d4989e6cb18cdd30b1c1f72e079d5] # # patch "src/model/Tags.h" # from [8f6b0ae7e02a74311d3351e19e7387fb307b9e2b] # to [f2e018cc8573864ec37d59bccae044789ba8f7cc] # # patch "src/model/Toposort.cpp" # from [14e33beed3bd500077de471f195db59d9c0d2f72] # to [9fec281ab3ffd60c7a7eb2f01cd07cdb1734a88e] # # patch "src/model/Toposort.h" # from [b28121c09bb13270e08912d254a8915871fac293] # to [30f5a31bfba3f1af1d5eade39b7f04790ff54335] # ============================================================ --- src/model/Ancestors.cpp 7d07e9a3bcb9e2dba0933333cbb51f4037ee0e9f +++ src/model/Ancestors.cpp 29675a51f35055b31a8692143e8e821bb8e47420 @@ -22,8 +22,8 @@ #include -Ancestors::Ancestors(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +Ancestors::Ancestors(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) { selRevisions = new RevisionList(); } @@ -45,7 +45,7 @@ void Ancestors::readAncestors(const QStr reset(); MonotoneTask task(QStringList() << "ancestors" << parents); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Ancestors::processTaskResult(const MonotoneTask & task) ============================================================ --- src/model/Ancestors.h 8588c2bcb2731b1202362baa3a8038198becbde9 +++ src/model/Ancestors.h a6b0213eed2a40a255465157f84d91c1d61224a4 @@ -31,9 +31,9 @@ public: { Q_OBJECT public: - Ancestors(QObject *, const QString &); + Ancestors(QObject *, const DatabaseFile &); virtual ~Ancestors(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -41,7 +41,7 @@ public: QModelIndex index(int, int, const QModelIndex &) const; QModelIndex parent(const QModelIndex &) const; int rowCount(const QModelIndex &) const; - int columnCount(const QModelIndex &) const; + int columnCount(const QModelIndex &) const; public slots: void readAncestors(const QStringList &); @@ -49,11 +49,12 @@ signals: signals: void ancestorsRead(); void invalidAncestor(QString); - + private: void processTaskResult(const MonotoneTask &); RevisionList * selRevisions; bool sorted; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/Branches.cpp ae0c27ed7f2086e4990ffaa2ad0d22462586e890 +++ src/model/Branches.cpp 9270c6f1e10826443f3421a872cfe5061be6a4ff @@ -17,28 +17,29 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "Branches.h" -Branches::Branches(QObject * parent, const QString & db, bool display_tree) - : QAbstractItemModel(parent), AutomateCommand(db), tree(display_tree) +Branches::Branches(QObject * parent, const DatabaseFile & db, bool display_tree) + : QAbstractItemModel(parent), AutomateCommand(0), + tree(display_tree), databaseFile(db) { - builder = 0; + builder = 0; } Branches::~Branches() { - if(builder) - delete builder; + if (builder) + delete builder; } void Branches::readBranches() { branches.clear(); reset(); - + MonotoneTask task(QStringList() << "branches"); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Branches::processTaskResult(const MonotoneTask & task) @@ -49,66 +50,66 @@ void Branches::processTaskResult(const M .arg(task.getOutputUtf8())); return; } - - 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(task.getOutputUtf8()); - } - else - { - QStringList branchList = task.getOutputUtf8().split("\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(task.getOutputUtf8()); + } + else + { + QStringList branchList = task.getOutputUtf8().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); - } - } + while(iterator.hasNext()) + { + QString it = iterator.next(); + QStandardItem * item = new QStandardItem(it); + item->setData(it, Qt::ToolTipRole); + branches.appendRow(item); + } + } reset(); - + emit branchesRead(); } int Branches::columnCount(const QModelIndex & parent) const { - QStandardItem * item = branchFromIndex(parent); - if (item) + QStandardItem * item = branchFromIndex(parent); + if (item) { - return item->columnCount(); - } + return item->columnCount(); + } return branches.columnCount(); } QVariant Branches::data(const QModelIndex & index, int role) const { - QStandardItem * item = branchFromIndex(index); - if (item) + QStandardItem * item = branchFromIndex(index); + if (item) { - return item->data(role); - } - return QVariant(); + return item->data(role); + } + return QVariant(); } QVariant Branches::headerData(int section, Qt::Orientation orientation, int role) const { - return branches.headerData(section, orientation, role); + return branches.headerData(section, orientation, role); } int Branches::rowCount(const QModelIndex & parent) const { - QStandardItem * item = branchFromIndex(parent); - if (item) + QStandardItem * item = branchFromIndex(parent); + if (item) { - return item->rowCount(); - } + return item->rowCount(); + } return branches.rowCount(); } @@ -118,34 +119,34 @@ QModelIndex Branches::parent(const QMode } QModelIndex Branches::parent(const QModelIndex & index) const -{ - QStandardItem * item = branchFromIndex(index); - if (item) - { - QStandardItem * parent = item->parent(); - if (parent) +{ + QStandardItem * item = branchFromIndex(index); + if (item) + { + QStandardItem * parent = item->parent(); + if (parent) { - return createIndex(parent->row(), parent->column(), parent); + return createIndex(parent->row(), parent->column(), parent); } } - return QModelIndex(); + return QModelIndex(); } QStandardItem * Branches::getBranchItem(int row, int column, const QModelIndex & index) const { - if (index.isValid()) + if (index.isValid()) { - return static_cast(index.internalPointer())->child(row, column); - } + return static_cast(index.internalPointer())->child(row, column); + } return 0; } QStandardItem * Branches::branchFromIndex(const QModelIndex & index) const { - if (index.isValid()) + if (index.isValid()) { - return static_cast(index.internalPointer()); - } + return static_cast(index.internalPointer()); + } return 0; } ============================================================ --- src/model/Branches.h 731c2a00b2e67f3f5045f6c4a641a5be87358276 +++ src/model/Branches.h fccb87b89b30e4fc485b56b24b17d45865750846 @@ -29,33 +29,34 @@ class Branches : public QAbstractItemMod class Branches : public QAbstractItemModel, public AutomateCommand { - Q_OBJECT + Q_OBJECT public: - Branches(QObject *, const QString &, bool); - virtual ~Branches(); - - // needed Qt Model methods - QVariant data(const QModelIndex &, int) 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; + Branches(QObject *, const DatabaseFile &, bool); + virtual ~Branches(); + // needed Qt Model methods + QVariant data(const QModelIndex &, int) 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: - void readBranches(); + void readBranches(); signals: - void branchesRead(void); + void branchesRead(void); private: - void processTaskResult(const MonotoneTask &); - QStandardItem * getBranchItem(int row, int column, const QModelIndex & index) const; - QStandardItem * branchFromIndex(const QModelIndex & index) const; + void processTaskResult(const MonotoneTask &); + QStandardItem * getBranchItem(int row, int column, const QModelIndex & index) const; + QStandardItem * branchFromIndex(const QModelIndex & index) const; bool tree; - TreeBuilder * builder; - QStandardItemModel branches; + TreeBuilder * builder; + QStandardItemModel branches; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/Certs.cpp ca1ec86b2b21a2547e9028a90c3e25094f655878 +++ src/model/Certs.cpp 147bef5808860b7085a17ee44b949ed87e72b6bc @@ -21,8 +21,8 @@ #include "Certs.h" #include "BasicIOParser.h" -Certs::Certs(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +Certs::Certs(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) { certs = new CertList(); } @@ -43,7 +43,7 @@ void Certs::readCerts(const QString & re if (rev.size() == 0) return; MonotoneTask task(QStringList() << "certs" << rev); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Certs::processTaskResult(const MonotoneTask & task) ============================================================ --- src/model/Certs.h 7fb966cf102320f265cffb07ecc235c7432d74ab +++ src/model/Certs.h c7be6e51d96a5b160aa89fe5984a753aab7e3d3d @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef CERTS_H #define CERTS_H @@ -30,10 +30,10 @@ public: { Q_OBJECT public: - Certs(QObject *, const QString &); + Certs(QObject *, const DatabaseFile &); virtual ~Certs(); void clearData(); - + // needed Qt Model methods QVariant data(const QModelIndex&, int) const; Qt::ItemFlags flags(const QModelIndex&) const; @@ -41,7 +41,7 @@ public: QModelIndex index(int, int, const QModelIndex&) const; QModelIndex parent(const QModelIndex&) const; int rowCount(const QModelIndex&) const; - int columnCount(const QModelIndex&) const; + int columnCount(const QModelIndex&) const; public slots: void readCerts(const QString &); @@ -54,6 +54,8 @@ private: private: void processTaskResult(const MonotoneTask &); + + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/ChangesetModel.cpp 94ab98b2cfb7f6316fc569b9e08c599011e9c237 +++ src/model/ChangesetModel.cpp 204808846cac0f1f953ca56688b2e7e3c38bdd76 @@ -22,8 +22,8 @@ #include -ChangesetModel::ChangesetModel(QObject * parent, const QString & db) - : QAbstractItemModel(parent), dbPath(db), currentBranch(""), branchLog(0) +ChangesetModel::ChangesetModel(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), databaseFile(db), currentBranch(""), branchLog(0) {} ChangesetModel::~ChangesetModel() {} @@ -33,14 +33,14 @@ void ChangesetModel::receiveRevisions(bo int i = branchMap[currentBranch].certsRead; int to = branchMap[currentBranch].revisions.count(); int c = 0; - + while (i < to && (c < revPerReceive || all)) { QString revision = branchMap[currentBranch].revisions[i]; - + if (!changesetMap.contains(revision)) { - ChangesetCerts * certs = new ChangesetCerts(this, dbPath); + ChangesetCerts * certs = new ChangesetCerts(this, databaseFile); connect( certs, SIGNAL(changesetReady(const Changeset &)), this, SLOT(changesetReady(const Changeset &)) @@ -52,14 +52,14 @@ void ChangesetModel::receiveRevisions(bo } } -void ChangesetModel::setBranch(QString branch) +void ChangesetModel::setBranch(const QString & branch) { currentBranch = branch; - + if (branchMap[currentBranch].revisions.count() == 0) { branchMap[currentBranch].certsRead = 0; - + if (branchLog) { disconnect( @@ -68,8 +68,8 @@ void ChangesetModel::setBranch(QString b ); delete branchLog; } - - branchLog = new GetBranchLog(this, dbPath, branch); + + branchLog = new GetBranchLog(this, databaseFile, branch); connect( branchLog, SIGNAL(commandDone(const QString &, const QStringList &)), this, SLOT(branchLogRead(const QString &, const QStringList &)) @@ -86,7 +86,7 @@ void ChangesetModel::branchLogRead(const void ChangesetModel::branchLogRead(const QString & branch, const QStringList & revisions) { branchMap[branch].revisions += revisions; - + if (branch == currentBranch) { receiveRevisions(false); @@ -97,9 +97,9 @@ void ChangesetModel::changesetReady(cons { changesetMap[change.revision] = change; branchMap[currentBranch].certsRead += 1; - + beginInsertRows( - QModelIndex(), + QModelIndex(), branchMap[currentBranch].certsRead, branchMap[currentBranch].certsRead ); @@ -118,7 +118,7 @@ QVariant ChangesetModel::data(const QMod { return QVariant(); } - + if (role == Qt::FontRole) { QFont font; @@ -126,19 +126,19 @@ QVariant ChangesetModel::data(const QMod font.setFamily("Courier"); return QVariant(font); } - + if (role == Qt::DisplayRole) { BranchInfo branchInfo = branchMap[currentBranch]; int row = index.row(); - + if (branchInfo.revisions.count() > row) { int col = index.column(); QString rev = branchInfo.revisions[row]; - + if (!changesetMap.contains(rev)) return QVariant(); - + switch(col) { case(0): @@ -156,7 +156,7 @@ QVariant ChangesetModel::data(const QMod } } } - + return QVariant(); } @@ -204,7 +204,7 @@ QModelIndex ChangesetModel::index(int ro { return QModelIndex(); } - + return createIndex(row, column, 0); } ============================================================ --- src/model/ChangesetModel.h c5efef03b82eb660d382f3e3a3a79bf404991f3a +++ src/model/ChangesetModel.h c573ec229b84ef887235ee087319736467925342 @@ -44,7 +44,7 @@ public: { Q_OBJECT public: - ChangesetCerts(QObject * parent, const QString & db) : Certs(parent, db) + ChangesetCerts(QObject * parent, const DatabaseFile & db) : Certs(parent, db) { connect( this, SIGNAL(certsRead()), @@ -102,11 +102,11 @@ public: public: ChangesetMap branchModel; - ChangesetModel(QObject * parent, const QString &); + ChangesetModel(QObject *, const DatabaseFile &); ~ChangesetModel(); - void setBranch(QString branch); - void receiveRevisions(bool all); + void setBranch(const QString & branch); + void receiveRevisions(bool); // needed Qt Model methods QVariant data(const QModelIndex &, int) const; @@ -120,7 +120,7 @@ private: private: static const int revPerReceive = 50; - QString dbPath; + DatabaseFile databaseFile; QString currentBranch; BranchMap branchMap; ChangesetMap changesetMap; ============================================================ --- src/model/ContentDiff.cpp 95360ae033fee8d395fdd6d6dd0cd9c07ecaedd8 +++ src/model/ContentDiff.cpp 8ef33c0ee0df05fa76dcbe497d29dedac2059784 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "ContentDiff.h" #include "Guitone.h" #include "MonotoneUtil.h" @@ -25,7 +25,7 @@ #include #include -ContentDiff::ContentDiff(QObject * parent, const QString & db) +ContentDiff::ContentDiff(QObject * parent, const QString & db) : QAbstractItemModel(parent), AutomateCommand(db) { diffParser = 0; @@ -34,7 +34,7 @@ ContentDiff::~ContentDiff() ContentDiff::~ContentDiff() { if (diffParser) delete diffParser; - qDeleteAll(lines); + qDeleteAll(lines); lines.clear(); } @@ -44,26 +44,13 @@ void ContentDiff::readDiff( { // reset the view reset(); - + QStringList cmd; cmd << "content_diff" << fileName; - + QStringList opts; - - if (base.isEmpty()) - { - opts << "r" << MonotoneUtil::getBaseWorkspaceRevision(getDbPath()); - } - else - { - opts << "r" << base; - } - - if (!target.isEmpty()) - { - opts << "r" << target; - } - + opts << "r" << base << "r" << target; + MonotoneTask task(cmd, opts); AutomateCommand::enqueueTask(task); } @@ -76,30 +63,30 @@ void ContentDiff::processTaskResult(cons .arg(task.getOutputUtf8())); return; } - + diffParser = new DiffParser(task.getOutputUtf8()); - + // flatten the data for the current view FileDiffs fileDiffs = diffParser->getAllDiffs(); - + QMapIterator i(fileDiffs); while (i.hasNext()) { i.next(); ListLine * fileLine = new ListLine(ListLine::FileLine); lines.append(fileLine); - + Diff * diff = (Diff*)i.value(); - + if (diff->is_binary) { fileLine->secondColumn = tr("%1 (binary)").arg(i.key()); continue; } - - fileLine->secondColumn = + + fileLine->secondColumn = tr("%1 (%2 hunks)").arg(i.key()).arg(diff->hunks.size()); - + for (int j=0, k=diff->hunks.size(); jhunks.at(j); @@ -108,7 +95,7 @@ void ContentDiff::processTaskResult(cons DiffLine * line = hunk->lines.at(m); ListLine * hunkLine = new ListLine(ListLine::HunkLine); fileLine->addChild(hunkLine); - + if (line->state == DiffLine::Unchanged) { hunkLine->firstColumn = QString::number(hunk->leftStart + m); @@ -123,7 +110,7 @@ void ContentDiff::processTaskResult(cons } hunkLine->secondColumn = line->content; } - + if (j < k-1) { ListLine * sep = new ListLine(ListLine::HunkSep); @@ -131,25 +118,25 @@ void ContentDiff::processTaskResult(cons } } } - + reset(); - + emit diffRead(); } int ContentDiff::columnCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return 2; + return 2; } QVariant ContentDiff::data(const QModelIndex & index, int role) const { if (!index.isValid()) return QVariant(); - + int col = index.column(); ListLine * line = static_cast(index.internalPointer()); - + if (role == Qt::DisplayRole) { switch (col) @@ -157,63 +144,63 @@ QVariant ContentDiff::data(const QModelI case 0: return QVariant(line->firstColumn); case 1: return QVariant(line->secondColumn); } - + I(false); } - + if (role == Qt::FontRole && col == 1) { QFont font; - + if (line->type == ListLine::FileLine) { font.setBold(true); } - + if (line->type == ListLine::HunkLine) { font.setStyleHint(QFont::Courier); font.setFamily("Courier"); } - + return QVariant(font); } - + if (role == Qt::TextAlignmentRole && col == 0) { return QVariant(Qt::AlignRight); } - + if (role == Qt::BackgroundRole) { if (line->type != ListLine::HunkLine) return QVariant(); - + if (line->firstColumn.compare("-") == 0) { return QVariant(QBrush(Qt::red)); } - + if (line->firstColumn.compare("+") == 0) { return QVariant(QBrush(Qt::green)); } - + // unchanged lines return QVariant(); } - + return QVariant(); } Qt::ItemFlags ContentDiff::flags(const QModelIndex & index) const { Q_UNUSED(index); - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant ContentDiff::headerData(int section, Qt::Orientation orientation, int role) const { - if (role != Qt::DisplayRole || orientation != Qt::Horizontal) + if (role != Qt::DisplayRole || orientation != Qt::Horizontal) return QVariant(); if (section == 0) return QVariant(tr("Line")); return QVariant(tr("File/Content")); ============================================================ --- src/model/ContentDiff.h 7addcfc135b3ad5e6e2835fcb45b42c385f9bc5e +++ src/model/ContentDiff.h af86806f65f4dd445d9b86321b9ca751816e0508 @@ -27,26 +27,26 @@ #include #include -struct ListLine +struct ListLine { enum Type { FileLine, HunkSep, HunkLine }; - + Type type; QString firstColumn; QString secondColumn; ListLine * parent; QList lines; - + ListLine() : type(HunkLine), parent(0) {} ListLine(Type t) : type(t), parent(0) { - if (type == HunkSep) firstColumn = "..."; + if (type == HunkSep) firstColumn = "..."; } - inline ~ListLine() - { - qDeleteAll(lines); + inline ~ListLine() + { + qDeleteAll(lines); lines.clear(); - } + } void addChild(ListLine * l) { lines.append(l); l->parent = this; } }; @@ -59,7 +59,7 @@ public: public: ContentDiff(QObject *, const QString &); virtual ~ContentDiff(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -67,13 +67,13 @@ public: QModelIndex index(int, int, const QModelIndex &) const; QModelIndex parent(const QModelIndex &) const; int rowCount(const QModelIndex &) const; - int columnCount(const QModelIndex &) const; + int columnCount(const QModelIndex &) const; inline Diff * getDiff(QString fileName) { return diffParser->getDiff(fileName); } inline FileDiffs getAllDiffs() { return diffParser->getAllDiffs(); } - + public slots: - void readDiff(const QString &, const QString & baseRev = QString(), const QString & targetRev = QString()); + void readDiff(const QString &, const QString &, const QString &); signals: void diffRead(); ============================================================ --- src/model/GetAttributes.cpp d8a85b2fc3848f2eb913c49ddaf3423c63273284 +++ src/model/GetAttributes.cpp 788b143a775e678233581e431466c91890124dfd @@ -25,8 +25,8 @@ #include #include -GetAttributes::GetAttributes(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +GetAttributes::GetAttributes(QObject * parent, const WorkspacePath & ws) + : QAbstractItemModel(parent), AutomateCommand(0), workspacePath(ws) { attributes = new AttributeList(); } @@ -54,7 +54,7 @@ void GetAttributes::readAttributes(const path = p; MonotoneTask task(QStringList() << "get_attributes" << p); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueWorkspaceTask(workspacePath, task); } void GetAttributes::processTaskResult(const MonotoneTask & task) @@ -263,15 +263,19 @@ bool GetAttributes::setAttribute(const Q bool GetAttributes::setAttribute(const QString & key, const QString & value) { - MonotoneTask in(QStringList() << "set_attribute" << path << key << value); - MonotoneTask out = MonotoneUtil::runSynchronousTask(getDbPath(), in); + MonotoneTask out = MonotoneUtil::runSynchronousWorkspaceTask( + workspacePath, + MonotoneTask(QStringList() << "set_attribute" << path << key << value) + ); return out.getReturnCode() == 0; } bool GetAttributes::dropAttribute(const QString & key) { - MonotoneTask in(QStringList() << "drop_attribute" << path << key); - MonotoneTask out = MonotoneUtil::runSynchronousTask(getDbPath(), in); + MonotoneTask out = MonotoneUtil::runSynchronousWorkspaceTask( + workspacePath, + MonotoneTask(QStringList() << "drop_attribute" << path << key) + ); return out.getReturnCode() == 0; } ============================================================ --- src/model/GetAttributes.h de87690563da758329186f4aa44b6dac47d46a45 +++ src/model/GetAttributes.h 32cd96a45c84b05f2817ec8dad06d068583cf6eb @@ -36,7 +36,7 @@ public: { Q_OBJECT public: - GetAttributes(QObject *, const QString &); + GetAttributes(QObject *, const WorkspacePath &); virtual ~GetAttributes(); // needed Qt Model methods @@ -63,6 +63,7 @@ private: void processTaskResult(const MonotoneTask &); AttributeList * attributes; QString path; + WorkspacePath workspacePath; }; #endif ============================================================ --- src/model/GetBranchLog.cpp f166e4acdc755a7364eba01eb120ecc865f775e6 +++ src/model/GetBranchLog.cpp efea9b6fa86857e3563d2ebc15a6dda069ddae6a @@ -20,24 +20,24 @@ #include "GetBranchLog.h" -GetBranchLog::GetBranchLog(QObject * parent, const QString & db, const QString & b) - : QObject(parent), branch(b) +GetBranchLog::GetBranchLog(QObject * parent, const DatabaseFile & db, const QString & b) + : QObject(parent), branch(b), databaseFile(db) { - selectModel = new Select(this, db); - revSortModel = new Toposort(this, db); - ancestorModel = new Ancestors(this, db); + selectModel = new Select(this, databaseFile); + revSortModel = new Toposort(this, databaseFile); + ancestorModel = new Ancestors(this, databaseFile); revSortModel->setSourceModel(ancestorModel); - + connect( selectModel, SIGNAL(selectionRead()), this, SLOT(selectionReady()) ); - + connect( revSortModel, SIGNAL(sortingFinished()), this, SLOT(revisionsReady()) ); - + selectModel->readSelection("h:" + branch); } @@ -52,7 +52,7 @@ void GetBranchLog::selectionReady() { QStringList heads; int count = selectModel->rowCount(QModelIndex()); - + for (int i = 0; i < count; i++) { heads.append( ============================================================ --- src/model/GetBranchLog.h e35442cb15dcf7ea81b68e25172c8e6283081420 +++ src/model/GetBranchLog.h b5bba049dabe1b6de146eaf5ba81ae26928240a0 @@ -29,7 +29,7 @@ public: { Q_OBJECT public: - GetBranchLog(QObject *, const QString &, const QString &); + GetBranchLog(QObject *, const DatabaseFile &, const QString &); ~GetBranchLog(); signals: @@ -37,6 +37,7 @@ private: private: QString branch; + DatabaseFile databaseFile; QStringList revisions; Select * selectModel; Toposort * revSortModel; ============================================================ --- src/model/GetContentChanged.cpp 3dc7307b83aa8f92a1a5643d7cd76f447a3beec8 +++ src/model/GetContentChanged.cpp d0db3a1357e29cb5dfd5a5320ba464331d2541bb @@ -17,15 +17,15 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "GetContentChanged.h" #include "BasicIOParser.h" #include "MonotoneUtil.h" #include -GetContentChanged::GetContentChanged(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +GetContentChanged::GetContentChanged(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) {} GetContentChanged::~GetContentChanged() @@ -34,7 +34,7 @@ GetContentChanged::~GetContentChanged() { W("Unfinished commands."); } - + revisions.clear(); pathInRevision.clear(); } @@ -62,48 +62,45 @@ GetContentChanged::~GetContentChanged() // | V // |--- < --- [ get corresponding path for each parent ] -> stop if no path // -void GetContentChanged::readChanges(const QString & path) +void GetContentChanged::readChanges(const QString & path, const QString & rev) { - revisions.clear(); + revisions.clear(); pathInRevision.clear(); - + // reset the view reset(); - - // find a starting point + // FIXME: we assume that the given path is part of this revision! - startRev = MonotoneUtil::getBaseWorkspaceRevision(getDbPath()); - I(!startRev.isNull()); + startRev = rev; startPath = path; - + queryContentChanged(startRev, startPath); } void GetContentChanged::queryContentChanged(const QString & rev, const QString & path) { commandStack.enqueue(ContentChanged); - + MonotoneTask task(QStringList() << "get_content_changed" << rev << path); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void GetContentChanged::queryParents(const QString & rev) { commandStack.enqueue(Parents); - + MonotoneTask task(QStringList() << "parents" << rev); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void GetContentChanged::queryCorrespondingPath(const QString & rev, const QString & path, const QString & par) { commandStack.enqueue(CorrespondingPath); - + MonotoneTask task(QStringList() << "get_corresponding_path" << rev << path << par); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } - void GetContentChanged::processTaskResult(const MonotoneTask & task) { if (task.getReturnCode() == 2) @@ -120,35 +117,35 @@ void GetContentChanged::processTaskResul return; } } - + if (task.getReturnCode() != 0) { C(QString("Command returned with a non-zero return code (%1)") .arg(task.getOutputUtf8())); return; } - + // this method is called when we either called get_content_changed, // parents or get_corresponding_path // to decide what to do next, we need to know what was triggered // lately in the queue Command current = commandStack.dequeue(); QString output = task.getOutputUtf8(); - + if (current == Parents) { - + if (output.isEmpty()) { reset(); emit rootReached(); return; } - + QStringList parents = output.split( '\n', QString::SkipEmptyParts ); - + foreach (QString par, parents) { // if we checked this revision already, skip it @@ -156,13 +153,13 @@ void GetContentChanged::processTaskResul { continue; } - + revsForPathStack.enqueue(par); queryCorrespondingPath(startRev, startPath, par); } return; } - + if (current == ContentChanged) { // since we're looking for a file in a certain revision @@ -176,37 +173,37 @@ void GetContentChanged::processTaskResul I(st.size() == 1); QString rev = st.at(0).hash; I(!rev.isNull()); - + // if we have this particular revision already recorded, // skip it if (revisions.contains(rev)) continue; - + // append the revision to the ordered list revisions.append(rev); - + // check if we already know the path in that revision if (!pathInRevision.contains(rev)) { // add the revision to the stack of revs which need // to get a valid path queried revsForPathStack.enqueue(rev); - + // query for the corresponding path queryCorrespondingPath(startRev, startPath, rev); } - + // query for the parents of this revision for the // next round queryParents(rev); } return; } - + if (current == CorrespondingPath) { I(revsForPathStack.size() > 0); QString rev = revsForPathStack.dequeue(); - + BasicIOParser parser(output); I(parser.parse()); StanzaList stanzas = parser.getStanzas(); @@ -216,35 +213,35 @@ void GetContentChanged::processTaskResul StanzaEntry en = st.at(0); I(en.sym == "file" && en.vals.size() == 1); QString path = en.vals.at(0); - + // we're also inserting a lot of uninteresting (revision, path) // tuples here, i.e. for every parent revision of a marked node, // however the only list that counts is revisions pathInRevision.insert(rev, path); - + // try to get the next marked node queryContentChanged(rev, path); return; } - + I(false); } int GetContentChanged::columnCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return 2; + return 2; } QVariant GetContentChanged::data(const QModelIndex & index, int role) const { - if (!index.isValid()) - { - return QVariant(); - } - + if (!index.isValid()) + { + return QVariant(); + } + int col = index.column(); - + if (role == Qt::FontRole && col == 0) { QFont font; @@ -252,14 +249,14 @@ QVariant GetContentChanged::data(const Q font.setFamily("Courier"); return QVariant(font); } - + if (role == Qt::DisplayRole) - { + { int row = index.row(); if (row >= revisions.size()) return QVariant(); QString rev = revisions.at(row); I(pathInRevision.contains(rev)); - + switch (col) { case 0: return QVariant(rev); @@ -267,8 +264,8 @@ QVariant GetContentChanged::data(const Q } return QVariant(); } - - return QVariant(); + + return QVariant(); } Qt::ItemFlags GetContentChanged::flags(const QModelIndex & index) const @@ -282,8 +279,8 @@ QVariant GetContentChanged::headerData(i QVariant GetContentChanged::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - { + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { switch (section) { case 0: return QVariant(tr("Revision ID")); @@ -296,7 +293,7 @@ int GetContentChanged::rowCount(const QM int GetContentChanged::rowCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return revisions.size(); + return revisions.size(); } QModelIndex GetContentChanged::index(int row, int column, const QModelIndex & parent) const @@ -305,7 +302,7 @@ QModelIndex GetContentChanged::index(int { return QModelIndex(); } - + return createIndex(row, column, 0); } ============================================================ --- src/model/GetContentChanged.h 174eb4b1c48da00efa1af2b3169c42f8fa620f7a +++ src/model/GetContentChanged.h 6aef1cefacc2ae69f66325a7a65eb3eb29c1fa58 @@ -33,9 +33,9 @@ public: { Q_OBJECT public: - GetContentChanged(QObject *, const QString &); + GetContentChanged(QObject *, const DatabaseFile &); virtual ~GetContentChanged(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -46,7 +46,7 @@ public slots: int columnCount(const QModelIndex &) const; public slots: - void readChanges(const QString &); + void readChanges(const QString &, const QString &); signals: // is emitted each time the algorithm reaches the end of a @@ -55,25 +55,27 @@ signals: // is emitted if the root revision has been reached, // which has per se no parent revisions void rootReached(); - + private: void queryContentChanged(const QString &, const QString &); void queryParents(const QString &); void queryCorrespondingPath(const QString &, const QString &, const QString &); - + void processTaskResult(const MonotoneTask &); - + RevisionList revisions; - + enum Command { ContentChanged, CorrespondingPath, Parents }; - + QQueue commandStack; QQueue revsForPathStack; - + QMap pathInRevision; - + QString startRev; QString startPath; + + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/GetFile.cpp 48e5c3805ba8a423eb292346a7064eb3e0f86422 +++ src/model/GetFile.cpp 1bf34182253597a267fbdbb3df6d8310307f2ca0 @@ -17,15 +17,15 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "GetFile.h" #include "MonotoneUtil.h" #include #include -GetFile::GetFile(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +GetFile::GetFile(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) {} GetFile::~GetFile() {} @@ -34,17 +34,10 @@ void GetFile::readFileByName(const QStri { QStringList cmd; cmd << "get_file_of" << fileName; - + QStringList opts; - if (rev.isEmpty()) - { - opts << "r" << MonotoneUtil::getBaseWorkspaceRevision(getDbPath()); - } - else - { - opts << "r" << rev; - } - + opts << "r" << rev; + readFile(cmd, opts); } @@ -52,7 +45,7 @@ void GetFile::readFileById(const QString { QStringList cmd; cmd << "get_file" << fileID; - + readFile(cmd, QStringList()); } @@ -61,7 +54,7 @@ void GetFile::readFile(QStringList cmd, // reset attached views reset(); MonotoneTask task(cmd, opts); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void GetFile::processTaskResult(const MonotoneTask & task) @@ -72,12 +65,12 @@ void GetFile::processTaskResult(const Mo .arg(task.getOutputUtf8())); return; } - + // FIXME: if the file contents is misinterpreted as utf-8, we have a // problem here. The only thing we could do here is to let the user // select the charset of the file and re-read it afterwards QString output = task.getOutputUtf8(); - + QRegExp rx("\\0x00"); if (rx.indexIn(output) != -1) { @@ -94,41 +87,41 @@ void GetFile::processTaskResult(const Mo new ContentLine(lines.at(i),ContentLine::Unchanged) ); } - + reset(); - + emit fileRead(); } void GetFile::applyDiff(Diff * diff) { int lineOffset = 0; - + for (int i=0, s=diff->hunks.size(); ihunks.at(i); int lineStart = hunk->leftStart + lineOffset; - + for (int j=0, t=hunk->lines.size(); jlines.at(j); - + // skip unchanged lines if (line->state == DiffLine::Unchanged) { lineStart++; continue; } - + if (line->state == DiffLine::Removed) { fileContents.value(lineStart-1)->marker = ContentLine::Removed; lineStart++; continue; } - + I(line->state == DiffLine::Added); - + fileContents.insert( lineStart - 1, new ContentLine(line->content, ContentLine::Added) @@ -150,7 +143,7 @@ QModelIndex GetFile::getNextGroup(const startRow = base.row(); lastMarker = fileContents.at(startRow)->marker; } - + for (int i=startRow, j=fileContents.size(); imarker; } - + // if we already recursed, stop here if (recurse) return QModelIndex(); // try to get the first group @@ -176,12 +169,12 @@ QModelIndex GetFile::getPrevGroup(const startRow = base.row(); lastMarker = fileContents.at(startRow)->marker; } - + bool foundLast = false; for (int i=startRow; i>=0; i--) { ContentLine * line = fileContents.at(i); - + // did we already found the last line of a group of similar lines? if (!foundLast) { @@ -192,7 +185,7 @@ QModelIndex GetFile::getPrevGroup(const lastMarker = line->marker; continue; } - + if (foundLast) { // if the marker just changed, the previous line was our @@ -203,33 +196,33 @@ QModelIndex GetFile::getPrevGroup(const } } } - + // if we've already recursed, stop here if (recurse) return QModelIndex(); // try to get the last group return getPrevGroup(QModelIndex(), true); } - + int GetFile::columnCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return 2; + return 2; } QVariant GetFile::data(const QModelIndex & index, int role) const { - if (!index.isValid()) - { - return QVariant(); - } - + if (!index.isValid()) + { + return QVariant(); + } + int row = index.row(); if (row >= fileContents.size()) return QVariant(); ContentLine * line = fileContents.at(row); - + if (role == Qt::DisplayRole) - { + { switch (index.column()) { case 0: return QVariant(row + 1); @@ -266,14 +259,14 @@ Qt::ItemFlags GetFile::flags(const QMode Qt::ItemFlags GetFile::flags(const QModelIndex & index) const { Q_UNUSED(index); - return Qt::ItemIsEnabled; + return Qt::ItemIsEnabled; } QVariant GetFile::headerData(int section, Qt::Orientation orientation, int role) const { Q_UNUSED(orientation); - if (role == Qt::DisplayRole) + if (role == Qt::DisplayRole) { switch (section) { @@ -288,7 +281,7 @@ int GetFile::rowCount(const QModelIndex int GetFile::rowCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return fileContents.size(); + return fileContents.size(); } QModelIndex GetFile::index(int row, int column, const QModelIndex& parent) const @@ -297,7 +290,7 @@ QModelIndex GetFile::index(int row, int { return QModelIndex(); } - + ContentLine * line = fileContents.at(row); return createIndex(row, column, line); } ============================================================ --- src/model/GetFile.h 10f469a2c421e93d9ba10d3235b76321dcc08910 +++ src/model/GetFile.h 017efe23e86731dbbfc7dabb40fccefe3d3632c9 @@ -39,9 +39,9 @@ public: { Q_OBJECT public: - GetFile(QObject *, const QString &); + GetFile(QObject *, const DatabaseFile &); virtual ~GetFile(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -49,13 +49,13 @@ public: QModelIndex index(int, int, const QModelIndex &) const; QModelIndex parent(const QModelIndex &) const; int rowCount(const QModelIndex &) const; - int columnCount(const QModelIndex &) const; + int columnCount(const QModelIndex &) const; QModelIndex getNextGroup(const QModelIndex &, bool recurse = false); QModelIndex getPrevGroup(const QModelIndex &, bool recurse = false); public slots: void readFileById(const QString &); - void readFileByName(const QString &, const QString & rev = QString()); + void readFileByName(const QString &, const QString &); void applyDiff(Diff * diff); signals: @@ -64,7 +64,9 @@ private: private: void readFile(QStringList, QStringList); void processTaskResult(const MonotoneTask &); + Content fileContents; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/GetFileProxyModel.cpp 0756529c21b7ccf99a17ac2a7fee473cf6a97aa3 +++ src/model/GetFileProxyModel.cpp 8b19a1596259f8400fb4d857bd6599ecf0163a61 @@ -23,8 +23,7 @@ GetFileProxyModel::GetFileProxyModel(QOb GetFileProxyModel::GetFileProxyModel(QObject * parent) : QSortFilterProxyModel(parent), version(Both) -{ -} +{} GetFileProxyModel::~GetFileProxyModel() {} ============================================================ --- src/model/GetFileProxyModel.h 160c9b398234711a4819583a49ea950f4ee62b8a +++ src/model/GetFileProxyModel.h adc53b614cef541e150d407316cb8d3b1bd58afc @@ -27,13 +27,13 @@ public: { public: - explicit GetFileProxyModel(QObject * parent); - ~GetFileProxyModel(void); - bool filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const; + explicit GetFileProxyModel(QObject *); + ~GetFileProxyModel(); + bool filterAcceptsRow(int, const QModelIndex &) const; enum FileVersion { Left, Right, Both }; - void setFileVersion(FileVersion version); + void setFileVersion(FileVersion); FileVersion fileVersion() const; private: ============================================================ --- src/model/GetRevision.cpp 77ca78c81dd8faca37a87aada5170b436758b8c6 +++ src/model/GetRevision.cpp 9258ab3149451dcf177958b1be1dc408547bfae6 @@ -26,8 +26,8 @@ #include #include -GetRevision::GetRevision(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +GetRevision::GetRevision(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) {} GetRevision::~GetRevision() {} @@ -36,15 +36,8 @@ void GetRevision::readRevision(const QSt { revision.clear(); - QStringList cmd; - cmd << "get_revision"; - if (rev.size() > 0) - { - cmd << rev; - } - - MonotoneTask task(cmd); - AutomateCommand::enqueueTask(task); + MonotoneTask task(QStringList() << "get_revision" << rev); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void GetRevision::processTaskResult(const MonotoneTask & task) ============================================================ --- src/model/GetRevision.h b56605574c48d9c4d51b2b5e3a84340b8813f793 +++ src/model/GetRevision.h 0d219aecb29f31a4ff5b9ee8b87fcb46b8c97d7c @@ -105,7 +105,7 @@ public: { Q_OBJECT public: - GetRevision(QObject *, const QString &); + GetRevision(QObject *, const DatabaseFile &); virtual ~GetRevision(); QStringList getParentRevisions() const; @@ -130,6 +130,7 @@ private: Revision revision; QString changesAgainstParent; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/Inventory.cpp 9f7bc8a94c7149580c0c3cd900e8b5a6e31186c7 +++ src/model/Inventory.cpp 08328754d22ea941a54f2c62924921841477e664 @@ -26,8 +26,8 @@ #include -Inventory::Inventory(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +Inventory::Inventory(QObject * parent, const WorkspacePath & ws) + : QAbstractItemModel(parent), AutomateCommand(0), workspacePath(ws) { // create a dummy item since the view needs at least one item // in the model, otherwise the app crashes @@ -50,7 +50,7 @@ void Inventory::readInventory() void Inventory::readInventory() { MonotoneTask task(QStringList() << "inventory"); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueWorkspaceTask(workspacePath, task); } void Inventory::processTaskResult(const MonotoneTask & task) @@ -150,7 +150,7 @@ void Inventory::loadBranchName() #else QList children = rootItem->getChildren(); I(children.size() > 0); - children[0]->setLabel(MonotoneUtil::getBranchName(getDbPath())); + children[0]->setLabel(MonotoneUtil::getBranchName(workspacePath)); emit layoutChanged(); #endif } @@ -456,9 +456,11 @@ QMap Inventory // TODO: progess bar here! - QString parentRev = MonotoneUtil::getBaseWorkspaceRevision(getDbPath()); - FileEntryList parentList = - MonotoneUtil::getRevisionManifest(getDbPath(), parentRev); + QString parentRev = MonotoneUtil::getBaseWorkspaceRevision(workspacePath); + FileEntryList parentList = MonotoneUtil::getRevisionManifest( + MonotoneUtil::getDatabaseFile(workspacePath), + parentRev + ); QMap unaccountedRenames; QMap fileIds; @@ -497,7 +499,10 @@ QMap Inventory if (!unknownItem->isDirectory() && !fileIds.contains(unknownPath)) { - QString fileid = MonotoneUtil::getFileId(getDbPath(), unknownPath); + QString fileid = MonotoneUtil::getFileId( + MonotoneUtil::getDatabaseFile(workspacePath), + unknownPath + ); // file was not readable, etc. if (fileid.isEmpty()) continue; fileIds.insert(unknownPath, fileid); ============================================================ --- src/model/Inventory.h 61bd1cbd1c9cb2c142f95205f66df308dcc836c8 +++ src/model/Inventory.h c12c8bd63a9faeacd062544fc292cc0559cc3aa5 @@ -32,8 +32,9 @@ public: { Q_OBJECT public: - Inventory(QObject *, const QString &); + Inventory(QObject *, const WorkspacePath &); ~Inventory(); + void readInventory(); QMap findUnaccountedRenames(); @@ -57,6 +58,7 @@ private: QRegExp * regex; QString branchName; QList flatItemList; + WorkspacePath workspacePath; private slots: void loadBranchName(); ============================================================ --- src/model/InventoryItem.h ccf79af033dde978761b38c6331274349121acad +++ src/model/InventoryItem.h 0498e1d8a79804da34e4e789ad05e544026aa2b0 @@ -26,24 +26,23 @@ class InventoryItem : public QObject class InventoryItem : public QObject { Q_OBJECT - public: InventoryItem(bool isDir = false, bool isRoot = false); InventoryItem(const InventoryItem *); ~InventoryItem(void); - + inline void setRenamedFrom(InventoryItem * from) { renamed_from = from; } inline void setRenamedTo(InventoryItem * to) { renamed_to = to; } inline InventoryItem * getRenamedFrom(void) const { return renamed_from; } inline InventoryItem * getRenamedTo(void) const { return renamed_to; } - + inline void setParent(InventoryItem * p) { parentItem = p; } inline InventoryItem * parent() const { return parentItem; } inline QList getChildren(void) const { return children; } - + inline QString getPath(void) const { return path; } - inline void setPath(const QString & p) { path = p; } - + inline void setPath(const QString & p) { path = p; } + inline bool isCdUp() const { return getFilename() == ".."; } inline bool isTracked() const { return hasNotStatus(Ignored | Unknown); } inline bool isDirectory(void) const { return dirFlag; } @@ -52,28 +51,28 @@ public: inline void setStatus(int st) { status = st; } inline void setLabel(const QString & l) { label = l; } inline QString getLabel() const { return label; } - + inline InventoryItem * child(int row) const { return children.value(row); } inline int childCount(void) const { return children.count(); }; inline int columnCount(void) const { return 3; } - + void setChildren(QList); void deleteAllChildren(void); - + QString getRelativePath(const QString&) const; QString getFilename(void) const; QString getBaseDirectory(void) const; - + bool hasStatus(int) const; bool hasNotStatus(int) const; int getStatusRecursive() const; bool hasChangedRecursive() const; - + /* needed for Qt model class */ int row(void) const; void appendChild(InventoryItem*); QVariant data(int, int) const; - + static const int RenamedFrom; static const int RenamedTo; static const int Added; @@ -83,14 +82,14 @@ public: static const int Unchanged; static const int Unknown; static const int Ignored; - + static const QList ValidStates; private: QString getItemName(void) const; QString getStatusString(void) const; QString getRenameInfo(void) const; - + InventoryItem * renamed_from; InventoryItem * renamed_to; InventoryItem * parentItem; ============================================================ --- src/model/Keys.cpp 30bab80f7bc8a8c877a788bd799d758f6cb199bd +++ src/model/Keys.cpp 7709a27606528064c62b84361292ece16aeba9cf @@ -17,15 +17,15 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "Keys.h" #include "BasicIOParser.h" const int Key::Database = 1; const int Key::Keystore = 2; -Keys::Keys(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +Keys::Keys(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) {} Keys::~Keys() {} @@ -34,9 +34,9 @@ void Keys::readKeys() { keys.clear(); reset(); - + MonotoneTask task(QStringList() << "keys"); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Keys::processTaskResult(const MonotoneTask & task) @@ -51,44 +51,44 @@ void Keys::processTaskResult(const Monot BasicIOParser parser(task.getOutputUtf8()); I(parser.parse()); StanzaList list = parser.getStanzas(); - + for (int i=0, size = list.size(); i < size; ++i) { Stanza stanza = list.at(i); - + Key key; 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 "name" entry if (j == 0 && entry.sym != "name") break; - + isItem = true; - + if (entry.sym == "name") { I(entry.vals.size() == 1); key.name = entry.vals.at(0); continue; } - + if (entry.sym == "public_hash") { I(!entry.hash.isNull()); key.public_hash = entry.hash; continue; } - + if (entry.sym == "private_hash") { I(!entry.hash.isNull()); key.private_hash = entry.hash; continue; } - + if (entry.sym == "public_location") { for (int k=0, size3 = entry.vals.size(); k < size3; k++) @@ -98,18 +98,18 @@ void Keys::processTaskResult(const Monot key.public_locations |= Key::Database; continue; } - + if (entry.vals.at(k) == "keystore") { key.public_locations |= Key::Keystore; continue; } - + W(QString("Unknown key location '%1'.").arg(entry.vals.at(k))); } continue; } - + if (entry.sym == "private_location") { for (int k=0, size3 = entry.vals.size(); k < size3; k++) @@ -119,26 +119,26 @@ void Keys::processTaskResult(const Monot key.private_locations |= Key::Database; continue; } - + if (entry.vals.at(k) == "keystore") { key.private_locations |= Key::Keystore; continue; } - + W(QString("Unknown key location '%1'.").arg(entry.vals.at(k))); } continue; } - + W(QString("Unknown symbol %1.").arg(entry.sym)); } - + // check if we really processed an item entry if (!isItem) continue; keys.append(key); - } - + } + reset(); emit keysRead(); } @@ -146,26 +146,26 @@ int Keys::columnCount(const QModelIndex int Keys::columnCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return 5; + return 5; } QVariant Keys::data(const QModelIndex & index, int role) const { - if (!index.isValid()) - { - return QVariant(); - } - + if (!index.isValid()) + { + return QVariant(); + } + if (role != Qt::DisplayRole) - { + { return QVariant(); } - + int row = index.row(); if (row >= keys.size()) return QVariant(); - + Key key(keys.at(row)); - + switch (index.column()) { case 0: return QVariant(key.name); @@ -174,7 +174,7 @@ QVariant Keys::data(const QModelIndex & case 3: return QVariant(getLocationString(key.public_locations)); case 4: return QVariant(getLocationString(key.private_locations)); } - + return QVariant(); } @@ -191,13 +191,13 @@ Qt::ItemFlags Keys::flags(const QModelIn Qt::ItemFlags Keys::flags(const QModelIndex & index) const { Q_UNUSED(index); - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant Keys::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - { + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { switch (section) { case 0: return QVariant(tr("Name")); @@ -213,7 +213,7 @@ int Keys::rowCount(const QModelIndex & p int Keys::rowCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return keys.size(); + return keys.size(); } QModelIndex Keys::index(int row, int column, const QModelIndex & parent) const @@ -222,7 +222,7 @@ QModelIndex Keys::index(int row, int col { return QModelIndex(); } - + if (row >= keys.size()) return QModelIndex(); Key key(keys.at(row)); return createIndex(row, column, &key); ============================================================ --- src/model/Keys.h a9e62309d1c81bfbe903b13ec2b02d36ba2cf47e +++ src/model/Keys.h f5bcda560a03b830c14c8f8c369b4a96f695704d @@ -41,9 +41,9 @@ public: { Q_OBJECT public: - Keys(QObject *, const QString &); + Keys(QObject *, const DatabaseFile &); virtual ~Keys(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -51,7 +51,7 @@ public: QModelIndex index(int, int, const QModelIndex &) const; QModelIndex parent(const QModelIndex &) const; int rowCount(const QModelIndex &) const; - int columnCount(const QModelIndex &) const; + int columnCount(const QModelIndex &) const; public slots: void readKeys(); @@ -63,6 +63,7 @@ private: void processTaskResult(const MonotoneTask &); QString getLocationString(int) const; KeyList keys; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/Manifest.cpp be6be5adfedca9f6a9e763a6bcf0a7f0c253abf8 +++ src/model/Manifest.cpp dccb314934d5ea95631976a992ebe532c57c39f1 @@ -17,29 +17,29 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "Manifest.h" #include "BasicIOParser.h" #include "IconProvider.h" -Manifest::Manifest(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +Manifest::Manifest(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) { root = NULL; } Manifest::~Manifest() { - delete root; + delete root; } void Manifest::readManifest(const QString & rev) { // reset the view reset(); - + MonotoneTask task(QStringList() << "get_manifest_of" << rev); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Manifest::processTaskResult(const MonotoneTask & task) @@ -56,48 +56,48 @@ void Manifest::processTaskResult(const M StanzaList list = parser.getStanzas(); QMap directoryMap; - + for (int i=0, size = list.size(); i < size; ++i) { Stanza stanza = list.at(i); ManifestEntry * mEntry = NULL; - + for (int j=0, size2 = stanza.size(); j < size2; j++) { StanzaEntry entry = stanza.at(j); - + // skip the format version if (j == 0) { if (entry.sym == "format_version") break; mEntry = new ManifestEntry(); } - + I(mEntry); - + if (entry.sym == "dir") { I(entry.vals.size() == 1); mEntry->path = entry.vals.at(0); mEntry->is_directory = true; - + // check if this is the root entry if (mEntry->path == "") { I(!root); root = mEntry; } - + directoryMap.insert(mEntry->path, mEntry); } - + if (entry.sym == "file") { I(entry.vals.size() == 1); mEntry->path = entry.vals.at(0); mEntry->is_directory = false; } - + if (entry.sym == "dir" || entry.sym == "file") { if (mEntry->path != "") @@ -115,27 +115,27 @@ void Manifest::processTaskResult(const M } continue; } - + if (entry.sym == "content") { I(!entry.hash.isNull()); mEntry->hash = entry.hash; continue; } - + if (entry.sym == "attr") { I(entry.vals.size() == 2); mEntry->attributes.insert(entry.vals.at(0), entry.vals.at(1)); continue; } - + W(QString("Unknown symbol %1.").arg(entry.sym)); } } - + I(root); - + // reset any connected view(s) reset(); emit manifestRead(); @@ -144,18 +144,18 @@ int Manifest::columnCount(const QModelIn int Manifest::columnCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return 2; + return 2; } QVariant Manifest::data(const QModelIndex & index, int role) const { - if (!index.isValid()) - { - return QVariant(); - } - + if (!index.isValid()) + { + return QVariant(); + } + ManifestEntry * entry = static_cast(index.internalPointer()); - + if (role == Qt::DisplayRole) { switch (index.column()) @@ -164,27 +164,27 @@ QVariant Manifest::data(const QModelInde case 1: return QVariant(entry->hash); } } - + if (role == Qt::DecorationRole && index.column() == 0) - { + { IconProvider * provider = IconProvider::singleton(); if (entry->is_directory) return provider->getPlainFolderIcon(); - return provider->getPlainFileIcon(); - } - + return provider->getPlainFileIcon(); + } + return QVariant(); } Qt::ItemFlags Manifest::flags(const QModelIndex & index) const { Q_UNUSED(index); - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant Manifest::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - { + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { switch (section) { case 0: return QVariant(tr("File")); @@ -198,13 +198,13 @@ int Manifest::rowCount(const QModelIndex { ManifestEntry * parentEntry = root; - if (parent.isValid()) - { - parentEntry = static_cast(parent.internalPointer()); - } - + if (parent.isValid()) + { + parentEntry = static_cast(parent.internalPointer()); + } + if (!parentEntry) return 0; - + return parentEntry->children.size(); } @@ -212,42 +212,42 @@ QModelIndex Manifest::index(int row, int { ManifestEntry * parentEntry; - if (!parent.isValid()) - { - parentEntry = root; - } - else - { - parentEntry = static_cast(parent.internalPointer()); - } + if (!parent.isValid()) + { + parentEntry = root; + } + else + { + parentEntry = static_cast(parent.internalPointer()); + } if (!parentEntry) return QModelIndex(); - - ManifestEntry * entry = parentEntry->child(row); - if (entry) - { - return createIndex(row, column, entry); - } + ManifestEntry * entry = parentEntry->child(row); - return QModelIndex(); + if (entry) + { + return createIndex(row, column, entry); + } + + return QModelIndex(); } QModelIndex Manifest::parent(const QModelIndex & index) const { if (!index.isValid()) - { - return QModelIndex(); - } + { + return QModelIndex(); + } - ManifestEntry * child = static_cast(index.internalPointer()); - ManifestEntry * parent = child->parent; - - if (parent == root) - { - return QModelIndex(); - } + ManifestEntry * child = static_cast(index.internalPointer()); + ManifestEntry * parent = child->parent; - return createIndex(parent->row(), 0, parent); + if (parent == root) + { + return QModelIndex(); + } + + return createIndex(parent->row(), 0, parent); } ============================================================ --- src/model/Manifest.h cdad4943990688b7adfc1716e2a2b3e7f7bea0ac +++ src/model/Manifest.h e482dcbaf3c30bd2a61773af588c7e6ff681df96 @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef MANIFEST_H #define MANIFEST_H @@ -35,14 +35,14 @@ struct ManifestEntry QString hash; bool is_directory; QMap attributes; - + inline ManifestEntry() : parent(NULL), path(""), hash(""), is_directory(true) {} - inline ~ManifestEntry() - { - foreach(ManifestEntry *it, children) - delete it; - } - + inline ~ManifestEntry() + { + foreach(ManifestEntry *it, children) + delete it; + } + inline QString filename() { int last = path.lastIndexOf("/"); @@ -69,9 +69,9 @@ public: { Q_OBJECT public: - Manifest(QObject *, const QString &); + Manifest(QObject *, const DatabaseFile &); virtual ~Manifest(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -90,6 +90,7 @@ private: private: void processTaskResult(const MonotoneTask &); ManifestEntry * root; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/Select.cpp 7d4f1170fdd0328c6740a523244e76a31e82d4f6 +++ src/model/Select.cpp d1b4aa62ba14950f1c8dbc53caa5ad6041d0cdfc @@ -17,13 +17,13 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "Select.h" #include -Select::Select(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +Select::Select(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) { selRevisions = new RevisionList(); } @@ -39,9 +39,9 @@ void Select::readSelection(const QString selRevisions->clear(); // reset the view reset(); - + MonotoneTask task(QStringList() << "select" << selector); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Select::processTaskResult(const MonotoneTask & task) @@ -53,14 +53,14 @@ void Select::processTaskResult(const Mon emit invalidSelection(task.getOutputUtf8()); return; } - + if (task.getReturnCode() != 0) { C(QString("Command returned with a non-zero return code (%1)") .arg(task.getOutputUtf8())); return; } - + delete selRevisions; selRevisions = new RevisionList( task.getOutputUtf8().split('\n', QString::SkipEmptyParts) @@ -83,7 +83,7 @@ QVariant Select::data(const QModelIndex { return QVariant(); } - + if (role == Qt::FontRole) { QFont font; @@ -91,14 +91,14 @@ QVariant Select::data(const QModelIndex font.setFamily("Courier"); return QVariant(font); } - + if (role == Qt::DisplayRole) { int row = index.row(); if (row >= selRevisions->size()) return QVariant(); return QVariant(selRevisions->at(row)); } - + return QVariant(); } @@ -133,7 +133,7 @@ QModelIndex Select::index(int row, int c { return QModelIndex(); } - + return createIndex(row, column, 0); } ============================================================ --- src/model/Select.h b0894a2dde22e024f8db52fea72fcc918234b6e1 +++ src/model/Select.h 8f50baba9f3d2d49b1ddc621182ea60b42139d62 @@ -31,9 +31,9 @@ public: { Q_OBJECT public: - Select(QObject *, const QString &); + Select(QObject *, const DatabaseFile &); virtual ~Select(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -41,7 +41,7 @@ public: QModelIndex index(int, int, const QModelIndex &) const; QModelIndex parent(const QModelIndex &) const; int rowCount(const QModelIndex &) const; - int columnCount(const QModelIndex &) const; + int columnCount(const QModelIndex &) const; public slots: void readSelection(const QString &); @@ -49,12 +49,13 @@ signals: signals: void selectionRead(); void invalidSelection(QString); - + private: void processTaskResult(const MonotoneTask &); RevisionList * selRevisions; bool sorted; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/Tags.cpp cac18773608543dbf2f2a35e8b4d03e50e1b197b +++ src/model/Tags.cpp fb04a57ba98d4989e6cb18cdd30b1c1f72e079d5 @@ -17,12 +17,12 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "Tags.h" #include "BasicIOParser.h" -Tags::Tags(QObject * parent, const QString & db) - : QAbstractItemModel(parent), AutomateCommand(db) +Tags::Tags(QObject * parent, const DatabaseFile & db) + : QAbstractItemModel(parent), AutomateCommand(0), databaseFile(db) { tags = new TagList(); } @@ -41,9 +41,9 @@ void Tags::readTags(const QString & bran { cmd << branch; } - + MonotoneTask task(cmd); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Tags::processTaskResult(const MonotoneTask & task) @@ -54,9 +54,9 @@ void Tags::processTaskResult(const Monot .arg(task.getOutputUtf8())); return; } - + tags->clear(); - + BasicIOParser parser(task.getOutputUtf8()); I(parser.parse()); StanzaList list = parser.getStanzas(); @@ -64,54 +64,54 @@ void Tags::processTaskResult(const Monot 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") { I(entry.vals.size() == 1); tag.name = entry.vals.at(0); continue; } - + if (entry.sym == "revision") { I(!entry.hash.isNull()); tag.revision = entry.hash; } - + if (entry.sym == "signer") { I(entry.vals.size() == 1); tag.signer = entry.vals.at(0); continue; } - + if (entry.sym == "branches") { tag.branches = entry.vals; continue; } - + W(QString("Unknown symbol %1.").arg(entry.sym)); } - + // check if we really processed an item entry if (!isItem) continue; tags->append(tag); - } - + } + reset(); emit tagsRead(); } @@ -119,26 +119,26 @@ int Tags::columnCount(const QModelIndex int Tags::columnCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return 4; + return 4; } QVariant Tags::data(const QModelIndex & index, int role) const { - if (!index.isValid()) - { - return QVariant(); - } - + 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); @@ -146,20 +146,20 @@ QVariant Tags::data(const QModelIndex & case 2: return QVariant(tag.signer); case 3: return QVariant(tag.branches.join("\n")); } - + return QVariant(); } Qt::ItemFlags Tags::flags(const QModelIndex & index) const { Q_UNUSED(index); - return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } QVariant Tags::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - { + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + { switch (section) { case 0: return QVariant(tr("Name")); @@ -174,7 +174,7 @@ int Tags::rowCount(const QModelIndex & p int Tags::rowCount(const QModelIndex & parent) const { Q_UNUSED(parent); - return tags->size(); + return tags->size(); } QModelIndex Tags::index(int row, int column, const QModelIndex & parent) const ============================================================ --- src/model/Tags.h 8f6b0ae7e02a74311d3351e19e7387fb307b9e2b +++ src/model/Tags.h f2e018cc8573864ec37d59bccae044789ba8f7cc @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef TAGS_H #define TAGS_H @@ -38,9 +38,9 @@ public: { Q_OBJECT public: - Tags(QObject *, const QString &); + Tags(QObject *, const DatabaseFile &); virtual ~Tags(); - + // needed Qt Model methods QVariant data(const QModelIndex &, int) const; Qt::ItemFlags flags(const QModelIndex &) const; @@ -48,7 +48,7 @@ public: QModelIndex index(int, int, const QModelIndex &) const; QModelIndex parent(const QModelIndex &) const; int rowCount(const QModelIndex &) const; - int columnCount(const QModelIndex &) const; + int columnCount(const QModelIndex &) const; public slots: void readTags(const QString &); @@ -59,6 +59,7 @@ private: private: void processTaskResult(const MonotoneTask &); TagList * tags; + DatabaseFile databaseFile; }; #endif ============================================================ --- src/model/Toposort.cpp 14e33beed3bd500077de471f195db59d9c0d2f72 +++ src/model/Toposort.cpp 9fec281ab3ffd60c7a7eb2f01cd07cdb1734a88e @@ -17,14 +17,14 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #include "Toposort.h" #include #include -Toposort::Toposort(QObject * parent, const QString & db) - : QSortFilterProxyModel(parent), AutomateCommand(db), +Toposort::Toposort(QObject * parent, const DatabaseFile & db) + : QSortFilterProxyModel(parent), AutomateCommand(0), databaseFile(db), sortColumn(0), sortOrder(Qt::AscendingOrder) { ordRevisions = new RevisionMap(); @@ -46,7 +46,7 @@ void Toposort::setSourceModel(QAbstractI sourceModel(), SIGNAL(modelReset()), this, SLOT(sortModel()) ); - + QSortFilterProxyModel::setSourceModel(source); connect( @@ -59,13 +59,13 @@ bool Toposort::lessThan(const QModelInde { QString leftRev = sourceModel()->data(left).toString(); QString rightRev = sourceModel()->data(right).toString(); - + if (!ordRevisions->contains(leftRev) || !ordRevisions->contains(leftRev)) { D("One or both revisions not found."); return false; } - + return ordRevisions->value(leftRev) < ordRevisions->value(rightRev); } @@ -87,7 +87,7 @@ void Toposort::sortModel() { showRows = false; ordRevisions->clear(); - + int row = 0; QModelIndex current = sourceModel()->index(row,0); if (!current.isValid()) @@ -95,7 +95,7 @@ void Toposort::sortModel() D("No items found in source model"); return; } - + QStringList revs; do { @@ -109,9 +109,9 @@ void Toposort::sortModel() if (!current.isValid()) break; } while (true); - + MonotoneTask task(QStringList() << "toposort" << revs); - AutomateCommand::enqueueTask(task); + AutomateCommand::enqueueDatabaseTask(databaseFile, task); } void Toposort::processTaskResult(const MonotoneTask & task) @@ -122,19 +122,19 @@ void Toposort::processTaskResult(const M .arg(task.getOutputUtf8())); return; } - + QStringList sortedRevs(task.getOutputUtf8().split("\n")); for (int i=0, j=sortedRevs.size(); iinsert(sortedRevs.at(i), i); } - + showRows = true; filterChanged(); clear(); - + D("Sorting finished"); - + // signal that we've finished (whoever listens to that) emit sortingFinished(); } ============================================================ --- src/model/Toposort.h b28121c09bb13270e08912d254a8915871fac293 +++ src/model/Toposort.h 30f5a31bfba3f1af1d5eade39b7f04790ff54335 @@ -32,24 +32,25 @@ public: { Q_OBJECT public: - Toposort(QObject *, const QString &); + Toposort(QObject *, const DatabaseFile &); virtual ~Toposort(); void setSourceModel(QAbstractItemModel *); void sort(int, Qt::SortOrder); signals: void sortingFinished(); - + private: void processTaskResult(const MonotoneTask &); bool lessThan(const QModelIndex &, const QModelIndex &) const; bool filterAcceptsRow(int, const QModelIndex &) const; RevisionMap * ordRevisions; + DatabaseFile databaseFile; bool showRows; int sortColumn; Qt::SortOrder sortOrder; - + private slots: void sortModel(); };