summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMakeCacheView.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2009-07-17 18:38:36 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2009-07-17 18:38:36 (GMT)
commit17acf0a310a8f10543c2be9fe902095a5a3c3c1d (patch)
tree4052fa5cd94ae8131c53db5c4e5ac358c581237d /Source/QtDialog/QCMakeCacheView.cxx
parent3250cb3d3b5b4ed60e620ff78cad7fa8fb24113f (diff)
downloadCMake-17acf0a310a8f10543c2be9fe902095a5a3c3c1d.zip
CMake-17acf0a310a8f10543c2be9fe902095a5a3c3c1d.tar.gz
CMake-17acf0a310a8f10543c2be9fe902095a5a3c3c1d.tar.bz2
ENH: Add a "Show my changes" to the Tools menu.
Changes by the user are recorded and when requested, it shows -D arguments for commandline or contents for a cache file.
Diffstat (limited to 'Source/QtDialog/QCMakeCacheView.cxx')
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx54
1 files changed, 53 insertions, 1 deletions
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index 7996559..b98ffd3 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -23,6 +23,7 @@
#include <QStyle>
#include <QKeyEvent>
#include <QSortFilterProxyModel>
+#include <QMetaProperty>
#include "QCMakeWidgets.h"
@@ -633,14 +634,22 @@ bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model,
Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
- return model->setData(index, state, Qt::CheckStateRole);
+ bool success = model->setData(index, state, Qt::CheckStateRole);
+ if(success)
+ {
+ this->recordChange(model, index);
+ }
+ return success;
}
+// Issue 205903 fixed in Qt 4.5.0.
+// Can remove this function and FileDialogFlag when minimum Qt version is 4.5
bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* event)
{
// workaround for what looks like a bug in Qt on Mac OS X
// where it doesn't create a QWidget wrapper for the native file dialog
// so the Qt library ends up assuming the focus was lost to something else
+
if(event->type() == QEvent::FocusOut && this->FileDialogFlag)
{
return false;
@@ -648,4 +657,47 @@ bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* event)
return QItemDelegate::eventFilter(object, event);
}
+void QCMakeCacheModelDelegate::setModelData(QWidget* editor,
+ QAbstractItemModel* model, const QModelIndex& index ) const
+{
+ QItemDelegate::setModelData(editor, model, index);
+ const_cast<QCMakeCacheModelDelegate*>(this)->recordChange(model, index);
+}
+QSet<QCMakeProperty> QCMakeCacheModelDelegate::changes() const
+{
+ return mChanges;
+}
+
+void QCMakeCacheModelDelegate::clearChanges()
+{
+ mChanges.clear();
+}
+
+void QCMakeCacheModelDelegate::recordChange(QAbstractItemModel* model, const QModelIndex& index)
+{
+ QModelIndex idx = index;
+ QAbstractItemModel* mymodel = model;
+ while(qobject_cast<QAbstractProxyModel*>(mymodel))
+ {
+ idx = static_cast<QAbstractProxyModel*>(mymodel)->mapToSource(idx);
+ mymodel = static_cast<QAbstractProxyModel*>(mymodel)->sourceModel();
+ }
+ QCMakeCacheModel* cache_model = qobject_cast<QCMakeCacheModel*>(mymodel);
+ if(cache_model && idx.isValid())
+ {
+ QCMakeProperty property;
+ idx = idx.sibling(idx.row(), 0);
+ cache_model->getPropertyData(idx, property);
+
+ // clean out an old one
+ QSet<QCMakeProperty>::iterator iter = mChanges.find(property);
+ if(iter != mChanges.end())
+ {
+ mChanges.erase(iter);
+ }
+ // now add the new item
+ mChanges.insert(property);
+ }
+}
+