# # # patch "src/model/AutomateCommand.h" # from [0d7eaf1a4c9d8b9fdda0518c11d43bb0f7f84be7] # to [93261beb5e677059132b532464042b8a982e57f6] # # patch "src/model/ContentDiff.cpp" # from [330cf8f074e03c6fc73d6581933660f2e5ac411c] # to [95360ae033fee8d395fdd6d6dd0cd9c07ecaedd8] # # patch "src/model/ContentDiff.h" # from [9f0b45bde2c813734bf6f4a9a5c8cb88e629a41d] # to [7addcfc135b3ad5e6e2835fcb45b42c385f9bc5e] # ============================================================ --- src/model/AutomateCommand.h 0d7eaf1a4c9d8b9fdda0518c11d43bb0f7f84be7 +++ src/model/AutomateCommand.h 93261beb5e677059132b532464042b8a982e57f6 @@ -35,7 +35,7 @@ public: public: AutomateCommand(const QString &, AutomateCommandHelper * helper = 0); virtual ~AutomateCommand(); - + inline QString getDbPath() const { return dbPath; } friend class AutomateCommandHelper; protected: ============================================================ --- src/model/ContentDiff.cpp 330cf8f074e03c6fc73d6581933660f2e5ac411c +++ src/model/ContentDiff.cpp 95360ae033fee8d395fdd6d6dd0cd9c07ecaedd8 @@ -20,15 +20,15 @@ #include "ContentDiff.h" #include "Guitone.h" +#include "MonotoneUtil.h" #include #include -ContentDiff::ContentDiff(QObject *parent) - : QAbstractItemModel(parent) +ContentDiff::ContentDiff(QObject * parent, const QString & db) + : QAbstractItemModel(parent), AutomateCommand(db) { diffParser = 0; - mtnDelegate = new MonotoneDelegate(this); } ContentDiff::~ContentDiff() @@ -36,10 +36,9 @@ ContentDiff::~ContentDiff() if (diffParser) delete diffParser; qDeleteAll(lines); lines.clear(); - delete mtnDelegate; } -bool ContentDiff::readDiff( +void ContentDiff::readDiff( const QString & fileName, const QString & base, const QString & target ) { @@ -53,7 +52,7 @@ bool ContentDiff::readDiff( if (base.isEmpty()) { - opts << "r" << MonotoneDelegate::getBaseWorkspaceRevision(this); + opts << "r" << MonotoneUtil::getBaseWorkspaceRevision(getDbPath()); } else { @@ -65,13 +64,21 @@ bool ContentDiff::readDiff( opts << "r" << target; } - return mtnDelegate->triggerCommand(cmd, opts); + MonotoneTask task(cmd, opts); + AutomateCommand::enqueueTask(task); } -void ContentDiff::parseOutput() +void ContentDiff::processTaskResult(const MonotoneTask & task) { - diffParser = new DiffParser(AutomateCommand::data); + if (task.getReturnCode() != 0) + { + C(QString("Command returned with a non-zero return code (%1)") + .arg(task.getOutputUtf8())); + return; + } + diffParser = new DiffParser(task.getOutputUtf8()); + // flatten the data for the current view FileDiffs fileDiffs = diffParser->getAllDiffs(); @@ -130,17 +137,18 @@ void ContentDiff::parseOutput() emit diffRead(); } -int ContentDiff::columnCount(const QModelIndex &parent) const +int ContentDiff::columnCount(const QModelIndex & parent) const { + Q_UNUSED(parent); return 2; } -QVariant ContentDiff::data(const QModelIndex &index, int role) const +QVariant ContentDiff::data(const QModelIndex & index, int role) const { if (!index.isValid()) return QVariant(); int col = index.column(); - ListLine * line = static_cast(index.internalPointer()); + ListLine * line = static_cast(index.internalPointer()); if (role == Qt::DisplayRole) { @@ -197,8 +205,9 @@ QVariant ContentDiff::data(const QModelI return QVariant(); } -Qt::ItemFlags ContentDiff::flags(const QModelIndex &index) const -{ +Qt::ItemFlags ContentDiff::flags(const QModelIndex & index) const +{ + Q_UNUSED(index); return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } @@ -210,14 +219,14 @@ QVariant ContentDiff::headerData(int sec return QVariant(tr("File/Content")); } -int ContentDiff::rowCount(const QModelIndex& parent) const +int ContentDiff::rowCount(const QModelIndex & parent) const { if (!parent.isValid()) return lines.size(); - ListLine * line = static_cast(parent.internalPointer()); + ListLine * line = static_cast(parent.internalPointer()); return line->lines.size(); } -QModelIndex ContentDiff::index(int row, int column, const QModelIndex& parent) const +QModelIndex ContentDiff::index(int row, int column, const QModelIndex & parent) const { if (!parent.isValid()) { @@ -232,7 +241,7 @@ QModelIndex ContentDiff::index(int row, return createIndex(row, column, line); } -QModelIndex ContentDiff::parent(const QModelIndex& index) const +QModelIndex ContentDiff::parent(const QModelIndex & index) const { if (!index.isValid()) return QModelIndex(); ListLine * line = static_cast(index.internalPointer()); ============================================================ --- src/model/ContentDiff.h 9f0b45bde2c813734bf6f4a9a5c8cb88e629a41d +++ src/model/ContentDiff.h 7addcfc135b3ad5e6e2835fcb45b42c385f9bc5e @@ -17,15 +17,12 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - -// TODO: enable editing of items as well as dropping/adding them #ifndef CONTENT_DIFF_H #define CONTENT_DIFF_H #include "AutomateCommand.h" #include "DiffParser.h" -#include "MonotoneDelegate.h" #include #include @@ -60,32 +57,31 @@ public: { Q_OBJECT public: - ContentDiff(QObject*); + ContentDiff(QObject *, const QString &); virtual ~ContentDiff(); // needed Qt Model methods - QVariant data(const QModelIndex&, int) const; - Qt::ItemFlags flags(const QModelIndex&) const; + 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; + QModelIndex index(int, int, const QModelIndex &) const; + QModelIndex parent(const QModelIndex &) const; + int rowCount(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: - bool readDiff(const QString &, const QString & baseRev = QString(), const QString & targetRev = QString()); + void readDiff(const QString &, const QString & baseRev = QString(), const QString & targetRev = QString()); signals: void diffRead(); private: - void parseOutput(); + void processTaskResult(const MonotoneTask &); DiffParser * diffParser; ListLines lines; - MonotoneDelegate * mtnDelegate; }; #endif