allow in-line editing of watcher expressions

This commit is contained in:
hjk
2009-03-19 15:24:18 +01:00
parent 6cb5ea76f0
commit 00be68701e
9 changed files with 93 additions and 41 deletions

View File

@@ -375,23 +375,6 @@ WatchHandler::WatchHandler()
SIGNAL(triggered()), this, SLOT(removeWatchExpression()));
}
bool WatchHandler::setData(const QModelIndex &idx,
const QVariant &value, int role)
{
/*
Q_UNUSED(idx);
Q_UNUSED(value);
Q_UNUSED(role);
if (role == VisualRole) {
QString iname = inameFromIndex(index);
setDisplayedIName(iname, value.toBool());
return true;
}
return true;
*/
return QAbstractItemModel::setData(idx, value, role);
}
static QString niceType(QString type)
{
if (type.contains("std::")) {
@@ -457,6 +440,9 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
const WatchData &data = m_displaySet.at(node);
switch (role) {
case Qt::EditRole:
return data.exp;
case Qt::DisplayRole: {
switch (idx.column()) {
case 0: return data.name;
@@ -543,7 +529,7 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const
// enabled, editable, selectable, checkable, and can be used both as the
// source of a drag and drop operation and as a drop target.
static const ItemFlags DefaultNotEditable =
static const ItemFlags notEditable =
ItemIsSelectable
| ItemIsDragEnabled
| ItemIsDropEnabled
@@ -551,12 +537,15 @@ Qt::ItemFlags WatchHandler::flags(const QModelIndex &idx) const
// | ItemIsTristate
| ItemIsEnabled;
static const ItemFlags DefaultEditable =
DefaultNotEditable | ItemIsEditable;
static const ItemFlags editable = notEditable | ItemIsEditable;
const WatchData &data = m_displaySet.at(node);
return idx.column() == 1 &&
data.isWatcher() ? DefaultEditable : DefaultNotEditable;
if (data.isWatcher() && idx.column() == 0)
return editable; // watcher names are
if (idx.column() == 1)
return editable; // values are editable
return notEditable;
}
QVariant WatchHandler::headerData(int section, Qt::Orientation orientation,