ENH: Allow edit on single click. Fixes #9393. Also fix row heights to be consistent.

This commit is contained in:
Clinton Stimpson 2009-08-10 13:25:22 -04:00
parent 821247ef4d
commit 37805ff81c
2 changed files with 18 additions and 4 deletions

View File

@ -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;

View File

@ -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();