# # # patch "src/model/GetAttributes.cpp" # from [c1f8ccabf73da0b5f91634619197f0adbfeb31de] # to [c52394f265f3b54ffd7f9bdead8abf5a08f67cad] # # patch "src/model/GetAttributes.h" # from [f9f06f87a1177277bce55b69800a14df55fffbd3] # to [691ce26cea013eebf8c329a2cf31a3f95da68ad6] # ============================================================ --- src/model/GetAttributes.cpp c1f8ccabf73da0b5f91634619197f0adbfeb31de +++ src/model/GetAttributes.cpp c52394f265f3b54ffd7f9bdead8abf5a08f67cad @@ -25,18 +25,16 @@ #include #include -GetAttributes::GetAttributes(QObject *parent) - : QAbstractItemModel(parent) +GetAttributes::GetAttributes(QObject * parent, const QString & db) + : QAbstractItemModel(parent), AutomateCommand(db) { attributes = new AttributeList(); - mtnDelegate = new MonotoneDelegate(this); } GetAttributes::~GetAttributes() { attributes->clear(); delete attributes; - delete mtnDelegate; } void GetAttributes::revert() @@ -46,25 +44,29 @@ void GetAttributes::revert() reset(); } -bool GetAttributes::readAttributes(const QString & p) +void GetAttributes::readAttributes(const QString & p) { // clear current attributes list attributes->clear(); // reset the view reset(); - - QStringList cmd; - cmd.append("get_attributes"); - cmd.append(p); - + path = p; - - return mtnDelegate->triggerCommand(cmd); + + MonotoneTask task(QStringList() << "get_attributes" << p); + AutomateCommand::enqueueTask(task); } -void GetAttributes::parseOutput() +void GetAttributes::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(); @@ -135,12 +137,13 @@ void GetAttributes::parseOutput() emit attributesRead(); } -int GetAttributes::columnCount(const QModelIndex &parent) const +int GetAttributes::columnCount(const QModelIndex & parent) const { + Q_UNUSED(parent); return 3; } -QVariant GetAttributes::data(const QModelIndex &index, int role) const +QVariant GetAttributes::data(const QModelIndex & index, int role) const { if (!index.isValid()) { @@ -213,8 +216,9 @@ QVariant GetAttributes::data(const QMode return QVariant(); } -Qt::ItemFlags GetAttributes::flags(const QModelIndex &index) const -{ +Qt::ItemFlags GetAttributes::flags(const QModelIndex & index) const +{ + Q_UNUSED(index); return Qt::ItemIsEnabled | Qt::ItemIsSelectable; } @@ -240,18 +244,20 @@ QVariant GetAttributes::headerData(int s return QVariant(); } -int GetAttributes::rowCount(const QModelIndex& parent) const +int GetAttributes::rowCount(const QModelIndex & parent) const { + Q_UNUSED(parent); return attributes->size(); } -QModelIndex GetAttributes::index(int row, int column, const QModelIndex& parent) const +QModelIndex GetAttributes::index(int row, int column, const QModelIndex & parent) const { return hasIndex(row, column, parent) ? createIndex(row, column, 0) : QModelIndex(); } -QModelIndex GetAttributes::parent(const QModelIndex& index) const +QModelIndex GetAttributes::parent(const QModelIndex & index) const { + Q_UNUSED(index); return QModelIndex(); } ============================================================ --- src/model/GetAttributes.h f9f06f87a1177277bce55b69800a14df55fffbd3 +++ src/model/GetAttributes.h 691ce26cea013eebf8c329a2cf31a3f95da68ad6 @@ -22,7 +22,6 @@ #define GETATTRIBUTES_H #include "AutomateCommand.h" -#include "MonotoneDelegate.h" #include @@ -37,31 +36,30 @@ public: { Q_OBJECT public: - GetAttributes(QObject*); + GetAttributes(QObject *, const QString &); virtual ~GetAttributes(); inline QString currentPath() const { return path; } // 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 readAttributes(const QString &); + void readAttributes(const QString &); void revert(); signals: void attributesRead(); private: - void parseOutput(); + void processTaskResult(const MonotoneTask &); AttributeList * attributes; - MonotoneDelegate * mtnDelegate; QString path; };