summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2009-08-10 17:25:22 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2009-08-10 17:25:22 (GMT)
commit37805ff81cfdcf3bde10192f08062e4a2260dd5e (patch)
tree73aba6db042d0cd3414f8c0b3b888faa8eb79393 /Source
parent821247ef4d8dc95bf0bc8cb1ba25331593fb404c (diff)
downloadCMake-37805ff81cfdcf3bde10192f08062e4a2260dd5e.zip
CMake-37805ff81cfdcf3bde10192f08062e4a2260dd5e.tar.gz
CMake-37805ff81cfdcf3bde10192f08062e4a2260dd5e.tar.bz2
ENH: Allow edit on single click. Fixes #9393. Also fix row heights to be consistent.
Diffstat (limited to 'Source')
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx21
-rw-r--r--Source/QtDialog/QCMakeCacheView.h1
2 files changed, 18 insertions, 4 deletions
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index b98ffd3..d9b63c1 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -24,6 +24,7 @@
#include <QKeyEvent>
#include <QSortFilterProxyModel>
#include <QMetaProperty>
+#include <QApplication>
#include "QCMakeWidgets.h"
@@ -139,10 +140,9 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p)
QCMakeCacheModelDelegate* delegate = new QCMakeCacheModelDelegate(this);
this->setItemDelegate(delegate);
- this->setEditTriggers(QAbstractItemView::DoubleClicked |
- QAbstractItemView::SelectedClicked |
- QAbstractItemView::EditKeyPressed |
- QAbstractItemView::AnyKeyPressed);
+ this->setUniformRowHeights(true);
+
+ this->setEditTriggers(QAbstractItemView::AllEditTriggers);
// tab, backtab doesn't step through items
this->setTabKeyNavigation(false);
@@ -664,6 +664,19 @@ void QCMakeCacheModelDelegate::setModelData(QWidget* editor,
const_cast<QCMakeCacheModelDelegate*>(this)->recordChange(model, index);
}
+QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+{
+ QSize sz = QItemDelegate::sizeHint(option, index);
+ QStyle *style = QApplication::style();
+
+ // increase to checkbox size
+ QStyleOptionButton opt;
+ opt.QStyleOption::operator=(option);
+ sz = sz.expandedTo(style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL).size());
+
+ return sz;
+}
+
QSet<QCMakeProperty> QCMakeCacheModelDelegate::changes() const
{
return mChanges;
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index d5005d0..431cab0 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -150,6 +150,7 @@ public:
const QStyleOptionViewItem& option, const QModelIndex& index);
bool eventFilter(QObject* object, QEvent* event);
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const;
+ QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
QSet<QCMakeProperty> changes() const;
void clearChanges();