QCMakeCacheView.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. public:
  57. // satisfy [pure] virtuals
  58. int columnCount ( const QModelIndex & parent ) const;
  59. QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole) const;
  60. QModelIndex parent ( const QModelIndex & index ) const;
  61. int rowCount ( const QModelIndex & parent ) const;
  62. QVariant headerData ( int section, Qt::Orientation orient, int role ) const;
  63. Qt::ItemFlags flags ( const QModelIndex& index ) const;
  64. bool setData ( const QModelIndex& index, const QVariant& value, int role );
  65. QModelIndex buddy ( const QModelIndex& index ) const;
  66. // get the properties
  67. QCMakeCachePropertyList properties() const;
  68. // editing enabled
  69. bool editEnabled() const;
  70. int newCount() const;
  71. protected:
  72. QCMakeCachePropertyList Properties;
  73. int NewCount;
  74. bool EditEnabled;
  75. };
  76. /// Qt delegate class for interaction (or other customization)
  77. /// with cache properties
  78. class QCMakeCacheModelDelegate : public QItemDelegate
  79. {
  80. Q_OBJECT
  81. public:
  82. QCMakeCacheModelDelegate(QObject* p);
  83. /// create our own editors for cache properties
  84. QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
  85. const QModelIndex& index ) const;
  86. };
  87. /// Editor widget for editing paths or file paths
  88. class QCMakeCachePathEditor : public QLineEdit
  89. {
  90. Q_OBJECT
  91. public:
  92. QCMakeCachePathEditor(bool isFilePath, QWidget* p);
  93. protected slots:
  94. void chooseFile();
  95. protected:
  96. void resizeEvent(QResizeEvent* e);
  97. bool IsFilePath;
  98. QToolButton* ToolButton;
  99. };
  100. #endif