Commit 56a25fff authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlDesigner.Navigator: LineInput now covers the whole item row

parent c124b0d1
......@@ -277,14 +277,11 @@ void NavigatorTreeModel::handleChangedItem(QStandardItem *item)
if (ModelNode::isValidId(item->text()))
node.setId(item->text());
else {
QMessageBox errorDialog;
errorDialog.setModal(true);
errorDialog.setText(tr("Invalid id.\nOnly alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter."));
errorDialog.exec();
QMessageBox::warning(0,"Invalid Id",tr("Invalid id.\nOnly alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter."));
item->setText(node.id());
}
} catch (InvalidIdException &) {
QMessageBox::warning(0,"Invalid Id",tr("Item id must be unique."));
item->setText(node.id());
}
} else if (item == itemRow.visibilityItem) {
......@@ -456,6 +453,20 @@ bool NavigatorTreeModel::blockItemChangedSignal(bool block)
return oldValue;
}
void NavigatorTreeModel::setId(const QModelIndex &index, const QString &id)
{
ModelNode node = nodeForIndex(index);
ItemRow itemRow = itemRowForNode(node);
itemRow.idItem->setText(id);
}
void NavigatorTreeModel::setVisible(const QModelIndex &index, bool visible)
{
ModelNode node = nodeForIndex(index);
ItemRow itemRow = itemRowForNode(node);
itemRow.visibilityItem->setCheckState(visible ? Qt::Checked : Qt::Unchecked);
}
}
......@@ -107,6 +107,9 @@ public:
void updateItemRow(const ModelNode &node);
void updateItemRowOrder(const ModelNode &node);
void setId(const QModelIndex &index, const QString &id);
void setVisible(const QModelIndex &index, bool visible);
private slots:
void handleChangedItem(QStandardItem *item);
......
......@@ -36,6 +36,7 @@
#include <nodeproperty.h>
#include "metainfo.h"
#include <QLineEdit>
namespace QmlDesigner {
......@@ -189,4 +190,30 @@ void IdItemDelegate::paint(QPainter *painter,
painter->restore();
}
QWidget *IdItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return new QLineEdit(parent);
}
void IdItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
ModelNode node = m_TreeModel->nodeForIndex(index);
QString value = node.id();
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
lineEdit->setText(value);
}
void IdItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
m_TreeModel->setId(index,lineEdit->text());
}
void IdItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
lineEdit->setGeometry(option.rect);
}
}
......@@ -78,6 +78,11 @@ class IdItemDelegate : public QStyledItemDelegate
void paint(QPainter *painter,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
NavigatorTreeModel *m_TreeModel;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment