# # # patch "src/model/Tags.cpp" # from [f0fab0f388865ab22baea3acf6e5d98c13835b99] # to [cac18773608543dbf2f2a35e8b4d03e50e1b197b] # # patch "src/model/Tags.h" # from [b8fc6606f1949cb5fa1a13f81d09b5f5e02b1616] # to [8f6b0ae7e02a74311d3351e19e7387fb307b9e2b] # ============================================================ --- src/model/Tags.cpp f0fab0f388865ab22baea3acf6e5d98c13835b99 +++ src/model/Tags.cpp cac18773608543dbf2f2a35e8b4d03e50e1b197b @@ -19,23 +19,21 @@ ***************************************************************************/ #include "Tags.h" -#include "Monotone.h" #include "BasicIOParser.h" -Tags::Tags(QObject *parent) : QAbstractItemModel(parent) +Tags::Tags(QObject * parent, const QString & db) + : QAbstractItemModel(parent), AutomateCommand(db) { tags = new TagList(); - mtnDelegate = new MonotoneDelegate(this); } Tags::~Tags() { tags->clear(); delete tags; - delete mtnDelegate; } -bool Tags::readTags(const QString & branch) +void Tags::readTags(const QString & branch) { QStringList cmd; cmd << "tags"; @@ -44,14 +42,22 @@ bool Tags::readTags(const QString & bran cmd << branch; } - return mtnDelegate->triggerCommand(cmd); + MonotoneTask task(cmd); + AutomateCommand::enqueueTask(task); } -void Tags::parseOutput() +void Tags::processTaskResult(const MonotoneTask & task) { + if (task.getReturnCode() != 0) + { + C(QString("Command returned with a non-zero return code (%1)") + .arg(task.getOutputUtf8())); + return; + } + tags->clear(); - BasicIOParser parser(AutomateCommand::data); + BasicIOParser parser(task.getOutputUtf8()); I(parser.parse()); StanzaList list = parser.getStanzas(); @@ -110,12 +116,13 @@ void Tags::parseOutput() emit tagsRead(); } -int Tags::columnCount(const QModelIndex &parent) const +int Tags::columnCount(const QModelIndex & parent) const { + Q_UNUSED(parent); return 4; } -QVariant Tags::data(const QModelIndex &index, int role) const +QVariant Tags::data(const QModelIndex & index, int role) const { if (!index.isValid()) { @@ -143,8 +150,9 @@ QVariant Tags::data(const QModelIndex &i return QVariant(); } -Qt::ItemFlags Tags::flags(const QModelIndex &index) const -{ +Qt::ItemFlags Tags::flags(const QModelIndex & index) const +{ + Q_UNUSED(index); return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } @@ -163,18 +171,20 @@ QVariant Tags::headerData(int section, Q return QVariant(); } -int Tags::rowCount(const QModelIndex& parent) const +int Tags::rowCount(const QModelIndex & parent) const { + Q_UNUSED(parent); return tags->size(); } -QModelIndex Tags::index(int row, int column, const QModelIndex& parent) const +QModelIndex Tags::index(int row, int column, const QModelIndex & parent) const { return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex(); } -QModelIndex Tags::parent(const QModelIndex& index) const +QModelIndex Tags::parent(const QModelIndex & index) const { + Q_UNUSED(index); return QModelIndex(); } ============================================================ --- src/model/Tags.h b8fc6606f1949cb5fa1a13f81d09b5f5e02b1616 +++ src/model/Tags.h 8f6b0ae7e02a74311d3351e19e7387fb307b9e2b @@ -22,7 +22,6 @@ #define TAGS_H #include "AutomateCommand.h" -#include "MonotoneDelegate.h" #include #include @@ -39,28 +38,27 @@ public: { Q_OBJECT public: - Tags(QObject*); + Tags(QObject *, const QString &); virtual ~Tags(); // 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 readTags(const QString &); + void readTags(const QString &); signals: void tagsRead(); private: - void parseOutput(); + void processTaskResult(const MonotoneTask &); TagList * tags; - MonotoneDelegate * mtnDelegate; }; #endif