PageRenderTime 46ms CodeModel.GetById 23ms 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. #ifndef GETATTRIBUTES_H
  19. #define GETATTRIBUTES_H
  20. #include "AutomateCommand.h"
  21. #include <QAbstractItemModel>
  22. class GetAttributes : public QAbstractItemModel, public AutomateCommand
  23. {
  24. Q_OBJECT
  25. public:
  26. struct Attribute {
  27. enum AttributeState { Added, Dropped, Changed, Unchanged } state;
  28. QString key;
  29. QString value;
  30. };
  31. GetAttributes(QObject *);
  32. virtual ~GetAttributes();
  33. // needed Qt Model methods
  34. QVariant data(const QModelIndex &, int) const;
  35. Qt::ItemFlags flags(const QModelIndex &) const;
  36. QVariant headerData(int, Qt::Orientation, int) const;
  37. QModelIndex index(int, int, const QModelIndex &) const;
  38. QModelIndex parent(const QModelIndex &) const;
  39. int rowCount(const QModelIndex &) const;
  40. int columnCount(const QModelIndex &) const;
  41. bool setAttribute(const QString &, const QString &);
  42. bool dropAttribute(const QString &);
  43. bool dropAllAttributes();
  44. bool hasDroppableAttributes() const;
  45. inline bool attributesLoaded() const { return !itemPath.isEmpty(); }
  46. public slots:
  47. void setMonotoneHandle(const MonotoneHandlePtr &);
  48. void readAttributes(const QString & itemPath = QString());
  49. void revert();
  50. signals:
  51. void attributesRead();
  52. private:
  53. void processTaskResult(const MonotoneTaskPtr &);
  54. QList<Attribute> attributes;
  55. MonotoneHandlePtr monotoneHandle;
  56. QString itemPath;
  57. };
  58. #endif