QCMakeCacheView.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef QCMakeCacheView_h
  14. #define QCMakeCacheView_h
  15. #include "QCMake.h"
  16. #include <QTableView>
  17. #include <QAbstractTableModel>
  18. #include <QItemDelegate>
  19. class QSortFilterProxyModel;
  20. class QCMakeCacheModel;
  21. /// Qt view class for cache properties
  22. class QCMakeCacheView : public QTableView
  23. {
  24. Q_OBJECT
  25. public:
  26. QCMakeCacheView(QWidget* p);
  27. QCMakeCacheModel* cacheModel() const;
  28. bool showAdvanced() const;
  29. public slots:
  30. void setShowAdvanced(bool);
  31. void setSearchFilter(const QString&);
  32. protected:
  33. QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
  34. void showEvent(QShowEvent* e);
  35. bool Init;
  36. QCMakeCacheModel* CacheModel;
  37. QSortFilterProxyModel* AdvancedFilter;
  38. QSortFilterProxyModel* SearchFilter;
  39. };
  40. /// Qt model class for cache properties
  41. class QCMakeCacheModel : public QAbstractTableModel
  42. {
  43. Q_OBJECT
  44. public:
  45. QCMakeCacheModel(QObject* parent);
  46. ~QCMakeCacheModel();
  47. enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
  48. public slots:
  49. void setProperties(const QCMakePropertyList& props);
  50. void clear();
  51. void setEditEnabled(bool);
  52. bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
  53. bool insertRows(int row, int num, const QModelIndex&);
  54. // insert a property at a row specifying all the information about the
  55. // property
  56. bool insertProperty(int row, QCMakeProperty::PropertyType t,
  57. const QString& name, const QString& description,
  58. const QVariant& value, bool advanced);
  59. public:
  60. // satisfy [pure] virtuals
  61. int columnCount (const QModelIndex& parent) const;
  62. QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
  63. QModelIndex parent (const QModelIndex& index) const;
  64. int rowCount (const QModelIndex& parent = QModelIndex()) const;
  65. QVariant headerData (int section, Qt::Orientation orient, int role) const;
  66. Qt::ItemFlags flags (const QModelIndex& index) const;
  67. bool setData (const QModelIndex& index, const QVariant& value, int role);
  68. QModelIndex buddy (const QModelIndex& index) const;
  69. // get the properties
  70. QCMakePropertyList properties() const;
  71. // editing enabled
  72. bool editEnabled() const;
  73. int newCount() const;
  74. protected:
  75. QCMakePropertyList Properties;
  76. int NewCount;
  77. bool EditEnabled;
  78. };
  79. /// Qt delegate class for interaction (or other customization)
  80. /// with cache properties
  81. class QCMakeCacheModelDelegate : public QItemDelegate
  82. {
  83. Q_OBJECT
  84. public:
  85. QCMakeCacheModelDelegate(QObject* p);
  86. /// create our own editors for cache properties
  87. QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
  88. const QModelIndex& index ) const;
  89. bool editorEvent (QEvent* event, QAbstractItemModel* model,
  90. const QStyleOptionViewItem& option, const QModelIndex& index);
  91. bool eventFilter(QObject* object, QEvent* event);
  92. protected slots:
  93. void setFileDialogFlag(bool);
  94. protected:
  95. bool FileDialogFlag;
  96. };
  97. #endif