QCMakeCacheView.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. void contextMenuEvent(QContextMenuEvent* e);
  37. QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
  38. void showEvent(QShowEvent* e);
  39. bool Init;
  40. QCMakeCacheModel* CacheModel;
  41. QSortFilterProxyModel* AdvancedFilter;
  42. QSortFilterProxyModel* SearchFilter;
  43. };
  44. /// Qt model class for cache properties
  45. class QCMakeCacheModel : public QAbstractTableModel
  46. {
  47. Q_OBJECT
  48. public:
  49. QCMakeCacheModel(QObject* parent);
  50. ~QCMakeCacheModel();
  51. enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
  52. public slots:
  53. void setProperties(const QCMakeCachePropertyList& props);
  54. void clear();
  55. void setEditEnabled(bool);
  56. bool removeRows(int row, int count, const QModelIndex& idx = 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 ) 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. // flag if a cache property has been modified
  68. bool modifiedValues() const;
  69. // get the properties
  70. QCMakeCachePropertyList properties() const;
  71. // editing enabled
  72. bool editEnabled() const;
  73. protected:
  74. QCMakeCachePropertyList Properties;
  75. int NewCount;
  76. bool ModifiedValues;
  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. };
  90. /// Editor widget for editing paths or file paths
  91. class QCMakeCachePathEditor : public QLineEdit
  92. {
  93. Q_OBJECT
  94. public:
  95. QCMakeCachePathEditor(bool isFilePath, QWidget* p);
  96. protected slots:
  97. void chooseFile();
  98. protected:
  99. void resizeEvent(QResizeEvent* e);
  100. bool IsFilePath;
  101. QToolButton* ToolButton;
  102. };
  103. #endif