[cmake-commits] clinton committed QCMakeCacheView.cxx 1.16 1.17
QCMakeCacheView.h 1.14 1.15
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Nov 13 00:17:12 EST 2007
Update of /cvsroot/CMake/CMake/Source/QtDialog
In directory public:/mounts/ram/cvs-serv11604
Modified Files:
QCMakeCacheView.cxx QCMakeCacheView.h
Log Message:
ENH: Allow clicking anywhere in field to toggle check boxes.
Index: QCMakeCacheView.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- QCMakeCacheView.h 13 Nov 2007 04:54:49 -0000 1.14
+++ QCMakeCacheView.h 13 Nov 2007 05:17:10 -0000 1.15
@@ -105,6 +105,8 @@
/// create our own editors for cache properties
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
const QModelIndex& index ) const;
+ bool editorEvent (QEvent* event, QAbstractItemModel* model,
+ const QStyleOptionViewItem& option, const QModelIndex& index);
};
/// Editor widget for editing paths or file paths
Index: QCMakeCacheView.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.cxx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- QCMakeCacheView.cxx 13 Nov 2007 04:54:49 -0000 1.16
+++ QCMakeCacheView.cxx 13 Nov 2007 05:17:10 -0000 1.17
@@ -314,11 +314,14 @@
return false;
}
-QModelIndex QCMakeCacheModel::buddy ( const QModelIndex& idx ) const
+QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const
{
if(idx.column() == 0)
{
- return this->index(idx.row(), 1);
+ if(this->Properties[idx.row()].Type != QCMakeCacheProperty::BOOL)
+ {
+ return this->index(idx.row(), 1);
+ }
}
return idx;
}
@@ -387,6 +390,49 @@
return new QLineEdit(p);
}
+bool QCMakeCacheModelDelegate::editorEvent(QEvent* event, QAbstractItemModel* model,
+ const QStyleOptionViewItem& option, const QModelIndex& index)
+{
+ Qt::ItemFlags flags = model->flags(index);
+ if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled)
+ || !(flags & Qt::ItemIsEnabled))
+ {
+ return false;
+ }
+
+ QVariant value = index.data(Qt::CheckStateRole);
+ if (!value.isValid())
+ {
+ return false;
+ }
+
+ if ((event->type() == QEvent::MouseButtonRelease)
+ || (event->type() == QEvent::MouseButtonDblClick))
+ {
+ // eat the double click events inside the check rect
+ if (event->type() == QEvent::MouseButtonDblClick)
+ {
+ return true;
+ }
+ }
+ else if (event->type() == QEvent::KeyPress)
+ {
+ if(static_cast<QKeyEvent*>(event)->key() != Qt::Key_Space &&
+ static_cast<QKeyEvent*>(event)->key() != Qt::Key_Select)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
+
+ Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+ ? Qt::Unchecked : Qt::Checked);
+ return model->setData(index, state, Qt::CheckStateRole);
+}
+
QCMakeCacheFileEditor::QCMakeCacheFileEditor(QWidget* p)
: QLineEdit(p)
{
More information about the Cmake-commits
mailing list