QCMakeCacheView.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 <QCheckBox>
  19. #include <QLineEdit>
  20. #include <QItemDelegate>
  21. #include <QSortFilterProxyModel>
  22. class QCMakeCacheModel;
  23. class QToolButton;
  24. /// Qt view class for cache properties
  25. class QCMakeCacheView : public QTableView
  26. {
  27. Q_OBJECT
  28. public:
  29. QCMakeCacheView(QWidget* p);
  30. QCMakeCacheModel* cacheModel() const;
  31. bool showAdvanced() const;
  32. public slots:
  33. void setShowAdvanced(bool);
  34. void setSearchFilter(const QString&);
  35. protected:
  36. QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
  37. void showEvent(QShowEvent* e);
  38. bool Init;
  39. QCMakeCacheModel* CacheModel;
  40. QSortFilterProxyModel* AdvancedFilter;
  41. QSortFilterProxyModel* SearchFilter;
  42. };
  43. /// Qt model class for cache properties
  44. class QCMakeCacheModel : public QAbstractTableModel
  45. {
  46. Q_OBJECT
  47. public:
  48. QCMakeCacheModel(QObject* parent);
  49. ~QCMakeCacheModel();
  50. enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
  51. public slots:
  52. void setProperties(const QCMakeCachePropertyList& props);
  53. void clear();
  54. void setEditEnabled(bool);
  55. bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
  56. bool insertRows(int row, int num, const QModelIndex&);
  57. public:
  58. // satisfy [pure] virtuals
  59. int columnCount (const QModelIndex& parent) const;
  60. QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
  61. QModelIndex parent (const QModelIndex& index) const;
  62. int rowCount (const QModelIndex& parent = QModelIndex()) const;
  63. QVariant headerData (int section, Qt::Orientation orient, int role) const;
  64. Qt::ItemFlags flags (const QModelIndex& index) const;
  65. bool setData (const QModelIndex& index, const QVariant& value, int role);
  66. QModelIndex buddy (const QModelIndex& index) const;
  67. // get the properties
  68. QCMakeCachePropertyList properties() const;
  69. // editing enabled
  70. bool editEnabled() const;
  71. int newCount() const;
  72. protected:
  73. QCMakeCachePropertyList Properties;
  74. int NewCount;
  75. bool EditEnabled;
  76. };
  77. /// Qt delegate class for interaction (or other customization)
  78. /// with cache properties
  79. class QCMakeCacheModelDelegate : public QItemDelegate
  80. {
  81. Q_OBJECT
  82. public:
  83. QCMakeCacheModelDelegate(QObject* p);
  84. /// create our own editors for cache properties
  85. QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
  86. const QModelIndex& index ) const;
  87. };
  88. /// Editor widget for editing paths or file paths
  89. class QCMakeCacheFileEditor : public QLineEdit
  90. {
  91. Q_OBJECT
  92. public:
  93. QCMakeCacheFileEditor(QWidget* p);
  94. protected slots:
  95. virtual void chooseFile() = 0;
  96. protected:
  97. void resizeEvent(QResizeEvent* e);
  98. QToolButton* ToolButton;
  99. };
  100. class QCMakeCachePathEditor : public QCMakeCacheFileEditor
  101. {
  102. Q_OBJECT
  103. public:
  104. QCMakeCachePathEditor(QWidget* p = NULL);
  105. void chooseFile();
  106. };
  107. class QCMakeCacheFilePathEditor : public QCMakeCacheFileEditor
  108. {
  109. Q_OBJECT
  110. public:
  111. QCMakeCacheFilePathEditor(QWidget* p = NULL);
  112. void chooseFile();
  113. };
  114. #endif