PageRenderTime 28ms CodeModel.GetById 21ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/guitone-1.0rc5/src/model/GetAttributes.h

#
C Header | 70 lines | 40 code | 12 blank | 18 comment | 0 complexity | bc9a8b48c2144982f88b6df11bd52c22 MD5 | raw file
Possible License(s): GPL-3.0
 1/***************************************************************************
 2 *   Copyright (C) 2006 by Thomas Keller                                   *
 3 *   me@thomaskeller.biz                                                   *
 4 *                                                                         *
 5 *   This program is free software; you can redistribute it and/or modify  *
 6 *   it under the terms of the GNU General Public License as published by  *
 7 *   the Free Software Foundation, either version 3 of the License, or     *
 8 *   (at your option) any later version.                                   *
 9 *                                                                         *
10 *   This program is distributed in the hope that it will be useful,       *
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13 *   GNU General Public License for more details.                          *
14 *                                                                         *
15 *   You should have received a copy of the GNU General Public License     *
16 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
17 ***************************************************************************/
18
19#ifndef GETATTRIBUTES_H
20#define GETATTRIBUTES_H
21
22#include "AutomateCommand.h"
23
24#include <QAbstractItemModel>
25
26class GetAttributes : public QAbstractItemModel, public AutomateCommand
27{
28    Q_OBJECT
29public:
30    struct Attribute {
31        enum AttributeState { Added, Dropped, Changed, Unchanged } state;
32        QString key;
33        QString value;
34    };
35
36    GetAttributes(QObject *);
37    virtual ~GetAttributes();
38
39    // needed Qt Model methods
40    QVariant data(const QModelIndex &, int) const;
41    Qt::ItemFlags flags(const QModelIndex &) const;
42    QVariant headerData(int, Qt::Orientation, int) const;
43    QModelIndex index(int, int, const QModelIndex &) const;
44    QModelIndex parent(const QModelIndex &) const;
45    int rowCount(const QModelIndex &) const;
46    int columnCount(const QModelIndex &) const;
47
48    bool setAttribute(const QString &, const QString &);
49    bool dropAttribute(const QString &);
50    bool dropAllAttributes();
51    bool hasDroppableAttributes() const;
52
53    inline bool attributesLoaded() const { return !itemPath.isEmpty(); }
54
55public slots:
56    void setMonotoneHandle(const MonotoneHandlePtr &);
57    void readAttributes(const QString & itemPath = QString());
58    void revert();
59
60signals:
61    void attributesRead();
62
63private:
64    void processTaskResult(const MonotoneTaskPtr &);
65    QList<Attribute> attributes;
66    MonotoneHandlePtr monotoneHandle;
67    QString itemPath;
68};
69
70#endif