QCMakeCacheView.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. /// Qt view class for cache properties
  24. class QCMakeCacheView : public QTableView
  25. {
  26. Q_OBJECT
  27. public:
  28. QCMakeCacheView(QWidget* p);
  29. QCMakeCacheModel* cacheModel() const;
  30. bool showAdvanced() const;
  31. public slots:
  32. void setShowAdvanced(bool);
  33. void setSearchFilter(const QString&);
  34. protected:
  35. QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
  36. void showEvent(QShowEvent* e);
  37. bool Init;
  38. QCMakeCacheModel* CacheModel;
  39. QSortFilterProxyModel* AdvancedFilter;
  40. QSortFilterProxyModel* SearchFilter;
  41. };
  42. /// Qt model class for cache properties
  43. class QCMakeCacheModel : public QAbstractTableModel
  44. {
  45. Q_OBJECT
  46. public:
  47. QCMakeCacheModel(QObject* parent);
  48. ~QCMakeCacheModel();
  49. enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
  50. public slots:
  51. void setProperties(const QCMakeCachePropertyList& props);
  52. void clear();
  53. public:
  54. // satisfy [pure] virtuals
  55. int columnCount ( const QModelIndex & parent ) const;
  56. QVariant data ( const QModelIndex & index, int role ) const;
  57. QModelIndex parent ( const QModelIndex & index ) const;
  58. int rowCount ( const QModelIndex & parent ) const;
  59. QVariant headerData ( int section, Qt::Orientation orient, int role ) const;
  60. Qt::ItemFlags flags ( const QModelIndex& index ) const;
  61. bool setData ( const QModelIndex& index, const QVariant& value, int role );
  62. // flag if a cache property has been modified
  63. bool isDirty() const;
  64. // get the properties
  65. QCMakeCachePropertyList properties() const;
  66. protected:
  67. QCMakeCachePropertyList Properties;
  68. int NewCount;
  69. bool IsDirty;
  70. };
  71. /// Qt delegate class for interaction (or other customization)
  72. /// with cache properties
  73. class QCMakeCacheModelDelegate : public QItemDelegate
  74. {
  75. Q_OBJECT
  76. public:
  77. QCMakeCacheModelDelegate(QObject* p);
  78. /// create our own editors for cache properties
  79. QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
  80. const QModelIndex& index ) const;
  81. };
  82. /// Editor widget for editing paths or file paths
  83. class QCMakeCachePathEditor : public QWidget
  84. {
  85. Q_OBJECT
  86. Q_PROPERTY(QString value READ value USER true)
  87. public:
  88. QCMakeCachePathEditor(const QString& file, bool isFilePath, QWidget* p);
  89. QString value() const { return this->LineEdit.text(); }
  90. protected slots:
  91. void chooseFile();
  92. protected:
  93. QLineEdit LineEdit;
  94. bool IsFilePath;
  95. };
  96. #endif