forked from qt-creator/qt-creator
QmlDesigner.Navigator: LineInput now covers the whole item row
This commit is contained in:
@@ -277,14 +277,11 @@ void NavigatorTreeModel::handleChangedItem(QStandardItem *item)
|
|||||||
if (ModelNode::isValidId(item->text()))
|
if (ModelNode::isValidId(item->text()))
|
||||||
node.setId(item->text());
|
node.setId(item->text());
|
||||||
else {
|
else {
|
||||||
QMessageBox errorDialog;
|
QMessageBox::warning(0,"Invalid Id",tr("Invalid id.\nOnly alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter."));
|
||||||
errorDialog.setModal(true);
|
|
||||||
errorDialog.setText(tr("Invalid id.\nOnly alphanumeric characters and underscore allowed.\nIds must begin with a lowercase letter."));
|
|
||||||
errorDialog.exec();
|
|
||||||
|
|
||||||
item->setText(node.id());
|
item->setText(node.id());
|
||||||
}
|
}
|
||||||
} catch (InvalidIdException &) {
|
} catch (InvalidIdException &) {
|
||||||
|
QMessageBox::warning(0,"Invalid Id",tr("Item id must be unique."));
|
||||||
item->setText(node.id());
|
item->setText(node.id());
|
||||||
}
|
}
|
||||||
} else if (item == itemRow.visibilityItem) {
|
} else if (item == itemRow.visibilityItem) {
|
||||||
@@ -456,6 +453,20 @@ bool NavigatorTreeModel::blockItemChangedSignal(bool block)
|
|||||||
return oldValue;
|
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 updateItemRow(const ModelNode &node);
|
||||||
void updateItemRowOrder(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:
|
private slots:
|
||||||
void handleChangedItem(QStandardItem *item);
|
void handleChangedItem(QStandardItem *item);
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
#include <nodeproperty.h>
|
#include <nodeproperty.h>
|
||||||
#include "metainfo.h"
|
#include "metainfo.h"
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
@@ -189,4 +190,30 @@ void IdItemDelegate::paint(QPainter *painter,
|
|||||||
painter->restore();
|
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,
|
void paint(QPainter *painter,
|
||||||
const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
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:
|
private:
|
||||||
NavigatorTreeModel *m_TreeModel;
|
NavigatorTreeModel *m_TreeModel;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user