# # # patch "src/model/Manifest.cpp" # from [e4700d858ea55077620324ec7c97cdb8286a876a] # to [be6be5adfedca9f6a9e763a6bcf0a7f0c253abf8] # # patch "src/model/Manifest.h" # from [43b4ed475bed5425df2dc7279b3dedf68adfec60] # to [cdad4943990688b7adfc1716e2a2b3e7f7bea0ac] # ============================================================ --- src/model/Manifest.cpp e4700d858ea55077620324ec7c97cdb8286a876a +++ src/model/Manifest.cpp be6be5adfedca9f6a9e763a6bcf0a7f0c253abf8 @@ -22,36 +22,40 @@ #include "BasicIOParser.h" #include "IconProvider.h" -Manifest::Manifest(QObject *parent) : QAbstractItemModel(parent) +Manifest::Manifest(QObject * parent, const QString & db) + : QAbstractItemModel(parent), AutomateCommand(db) { - mtnDelegate = new MonotoneDelegate(this); root = NULL; } Manifest::~Manifest() { delete root; - delete mtnDelegate; } -bool Manifest::readManifest(const QString & rev) +void Manifest::readManifest(const QString & rev) { // reset the view reset(); - QStringList cmd; - cmd << "get_manifest_of" << rev; - - return mtnDelegate->triggerCommand(cmd); + MonotoneTask task(QStringList() << "get_manifest_of" << rev); + AutomateCommand::enqueueTask(task); } -void Manifest::parseOutput() +void Manifest::processTaskResult(const MonotoneTask & task) { - BasicIOParser parser(AutomateCommand::data); + if (task.getReturnCode() != 0) + { + C(QString("Command returned with a non-zero return code (%1)") + .arg(task.getOutputUtf8())); + return; + } + + BasicIOParser parser(task.getOutputUtf8()); I(parser.parse()); StanzaList list = parser.getStanzas(); - QMap directoryMap; + QMap directoryMap; for (int i=0, size = list.size(); i < size; ++i) { @@ -137,19 +141,20 @@ void Manifest::parseOutput() emit manifestRead(); } -int Manifest::columnCount(const QModelIndex &parent) const +int Manifest::columnCount(const QModelIndex & parent) const { + Q_UNUSED(parent); return 2; } -QVariant Manifest::data(const QModelIndex &index, int role) const +QVariant Manifest::data(const QModelIndex & index, int role) const { if (!index.isValid()) { return QVariant(); } - ManifestEntry * entry = static_cast(index.internalPointer()); + ManifestEntry * entry = static_cast(index.internalPointer()); if (role == Qt::DisplayRole) { @@ -170,8 +175,9 @@ QVariant Manifest::data(const QModelInde return QVariant(); } -Qt::ItemFlags Manifest::flags(const QModelIndex &index) const +Qt::ItemFlags Manifest::flags(const QModelIndex & index) const { + Q_UNUSED(index); return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } @@ -188,13 +194,13 @@ QVariant Manifest::headerData(int sectio return QVariant(); } -int Manifest::rowCount(const QModelIndex& parent) const +int Manifest::rowCount(const QModelIndex & parent) const { ManifestEntry * parentEntry = root; if (parent.isValid()) { - parentEntry = static_cast(parent.internalPointer()); + parentEntry = static_cast(parent.internalPointer()); } if (!parentEntry) return 0; @@ -202,7 +208,7 @@ int Manifest::rowCount(const QModelIndex return parentEntry->children.size(); } -QModelIndex Manifest::index(int row, int column, const QModelIndex& parent) const +QModelIndex Manifest::index(int row, int column, const QModelIndex & parent) const { ManifestEntry * parentEntry; @@ -212,7 +218,7 @@ QModelIndex Manifest::index(int row, int } else { - parentEntry = static_cast(parent.internalPointer()); + parentEntry = static_cast(parent.internalPointer()); } if (!parentEntry) return QModelIndex(); @@ -227,14 +233,14 @@ QModelIndex Manifest::index(int row, int return QModelIndex(); } -QModelIndex Manifest::parent(const QModelIndex& index) const +QModelIndex Manifest::parent(const QModelIndex & index) const { if (!index.isValid()) { return QModelIndex(); } - ManifestEntry * child = static_cast(index.internalPointer()); + ManifestEntry * child = static_cast(index.internalPointer()); ManifestEntry * parent = child->parent; if (parent == root) ============================================================ --- src/model/Manifest.h 43b4ed475bed5425df2dc7279b3dedf68adfec60 +++ src/model/Manifest.h cdad4943990688b7adfc1716e2a2b3e7f7bea0ac @@ -22,7 +22,6 @@ #define MANIFEST_H #include "AutomateCommand.h" -#include "MonotoneDelegate.h" #include #include @@ -53,10 +52,10 @@ struct ManifestEntry inline int row() { if (parent) - return parent->children.indexOf(const_cast(this)); + return parent->children.indexOf(const_cast(this)); return 0; } - inline ManifestEntry* child(int row) + inline ManifestEntry * child(int row) { return children.value(row); } @@ -70,28 +69,28 @@ public: { Q_OBJECT public: - Manifest(QObject*); + Manifest(QObject *, const QString &); virtual ~Manifest(); // 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; public slots: - bool readManifest(const QString &); + void readManifest(const QString &); signals: void manifestRead(); private: - void parseOutput(); + void processTaskResult(const MonotoneTask &); ManifestEntry * root; - MonotoneDelegate * mtnDelegate; }; #endif +