Commit 0546f805 authored by Thomas Hartmann's avatar Thomas Hartmann Committed by Thomas Hartmann

QmlDesigner: Extending navigator

Add support for exporting items as a property of the root item.
Show errors from the qml2puppet.

Change-Id: Id3d05201a20fce24f20e66f101818ac2231f38ee
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 03aa3672
......@@ -79,7 +79,8 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &styleOption,
const QModelIndex &modelIndex) const
{
const int offset = 2;
const int yOffset = (styleOption.rect.height() - onPixmap.height()) / 2;
const int xOffset = 2;
if (indexIsHolingModelNode(modelIndex)) {
painter->save();
if (styleOption.state & QStyle::State_Selected)
......@@ -91,9 +92,9 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
painter->setOpacity(0.5);
if (isChecked(m_navigatorTreeModel, modelIndex))
painter->drawPixmap(styleOption.rect.x() + offset, styleOption.rect.y() + offset, onPixmap);
painter->drawPixmap(styleOption.rect.x() + xOffset, styleOption.rect.y() + yOffset, onPixmap);
else
painter->drawPixmap(styleOption.rect.x() + offset, styleOption.rect.y() + offset, offPixmap);
painter->drawPixmap(styleOption.rect.x() + xOffset, styleOption.rect.y() + yOffset, offPixmap);
}
painter->restore();
......
......@@ -109,81 +109,37 @@ NameItemDelegate::NameItemDelegate(QObject *parent, NavigatorTreeModel *treeMode
{
}
static QIcon getTypeIcon(const ModelNode &modelNode)
{
QIcon icon;
if (modelNode.isValid()) {
// if node has no own icon, search for it in the itemlibrary
const ItemLibraryInfo *libraryInfo = modelNode.model()->metaInfo().itemLibraryInfo();
QList <ItemLibraryEntry> itemLibraryEntryList = libraryInfo->entriesForType(modelNode.type(),
modelNode.majorVersion(),
modelNode.minorVersion());
if (!itemLibraryEntryList.isEmpty())
return itemLibraryEntryList.first().typeIcon();
else if (modelNode.metaInfo().isValid())
return QIcon(QStringLiteral(":/ItemLibrary/images/item-default-icon.png"));
else
return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png"));
}
return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png"));
}
static int drawTypeIcon(QPainter *painter,
const QStyleOptionViewItem &styleOption,
const QModelIndex &modelIndex,
NavigatorTreeModel *navigatorTreeModel
)
static int drawIcon(QPainter *painter, const QStyleOptionViewItem &styleOption, const QModelIndex &modelIndex)
{
QIcon icon = modelIndex.data(Qt::DecorationRole).value<QIcon>();
int pixmapSize = 16;
if (navigatorTreeModel->hasNodeForIndex(modelIndex)) {
ModelNode modelNode = navigatorTreeModel->nodeForIndex(modelIndex);
// If no icon is present, leave an empty space of 24 pixels anyway
QPixmap pixmap = getTypeIcon(modelNode).pixmap(pixmapSize, pixmapSize);
painter->drawPixmap(styleOption.rect.x() +1 , styleOption.rect.y() + 2, pixmap);
}
QPixmap pixmap = icon.pixmap(pixmapSize, pixmapSize);
painter->drawPixmap(styleOption.rect.x() + 1 , styleOption.rect.y() + 2, pixmap);
return pixmapSize;
}
static QString getDisplayString(const QModelIndex &modelIndex, NavigatorTreeModel *navigatorTreeModel)
{
ModelNode modelNode = navigatorTreeModel->nodeForIndex(modelIndex);
if (modelNode.hasId())
return modelNode.id();
return modelNode.simplifiedTypeName();
}
static QRect drawText(QPainter *painter,
const QStyleOptionViewItem &styleOption,
const QModelIndex &modelIndex,
int iconOffset,
NavigatorTreeModel *navigatorTreeModel)
int iconOffset)
{
QString displayString;
QString displayString = modelIndex.data(Qt::DisplayRole).toString();
if (displayString.isEmpty())
displayString = modelIndex.data(NavigatorTreeModel::SimplifiedTypeNameRole).toString();
QPoint displayStringOffset;
int width = 0;
if (navigatorTreeModel->hasNodeForIndex(modelIndex)) {
if (navigatorTreeModel->isNodeInvisible( modelIndex ))
painter->setOpacity(0.5);
displayString = getDisplayString(modelIndex, navigatorTreeModel);
if (modelIndex.data(NavigatorTreeModel::InvisibleRole).toBool())
painter->setOpacity(0.5);
// Check text length does not exceed available space
int extraSpace = 12 + iconOffset;
// Check text length does not exceed available space
int extraSpace = 12 + iconOffset;
displayString = styleOption.fontMetrics.elidedText(displayString, Qt::ElideMiddle, styleOption.rect.width() - extraSpace);
displayStringOffset = QPoint(5 + iconOffset, -5);
width = styleOption.fontMetrics.width(displayString);
} else {
displayString = modelIndex.data(Qt::DisplayRole).toString();
displayStringOffset = QPoint(0, -2);
}
displayString = styleOption.fontMetrics.elidedText(displayString, Qt::ElideMiddle, styleOption.rect.width() - extraSpace);
displayStringOffset = QPoint(5 + iconOffset, -5);
width = styleOption.fontMetrics.width(displayString);
QPoint textPosition = styleOption.rect.bottomLeft() + displayStringOffset;
painter->drawText(textPosition, displayString);
......@@ -197,25 +153,17 @@ static QRect drawText(QPainter *painter,
static void drawRedWavyUnderLine(QPainter *painter,
const QStyleOptionViewItem &styleOption,
const QModelIndex &modelIndex,
const QRect &textFrame ,
NavigatorTreeModel *navigatorTreeModel)
const QRect &textFrame)
{
if (navigatorTreeModel->hasNodeForIndex(modelIndex)) {
ModelNode modelNode = navigatorTreeModel->nodeForIndex(modelIndex);
if (!modelNode.metaInfo().isValid()) {
painter->translate(0, textFrame.y() + 1);
QPen pen;
pen.setColor(Qt::red);
const qreal underlineOffset = styleOption.fontMetrics.underlinePos();
const QPixmap wave = getWavyPixmap(qMax(underlineOffset, pen.widthF()), pen);
const int descent = styleOption.fontMetrics.descent();
painter->setBrushOrigin(painter->brushOrigin().x(), 0);
painter->fillRect(textFrame.x(), 0, qCeil(textFrame.width()), qMin(wave.height(), descent), wave);
}
}
painter->translate(0, textFrame.y() + 1);
QPen pen;
pen.setColor(Qt::red);
const qreal underlineOffset = styleOption.fontMetrics.underlinePos();
const QPixmap wave = getWavyPixmap(qMax(underlineOffset, pen.widthF()), pen);
const int descent = styleOption.fontMetrics.descent();
painter->setBrushOrigin(painter->brushOrigin().x(), 0);
painter->fillRect(textFrame.x(), 0, qCeil(textFrame.width()), qMin(wave.height(), descent), wave);
}
void NameItemDelegate::paint(QPainter *painter,
......@@ -223,15 +171,15 @@ void NameItemDelegate::paint(QPainter *painter,
const QModelIndex &modelIndex) const
{
painter->save();
if (styleOption.state & QStyle::State_Selected)
NavigatorTreeView::drawSelectionBackground(painter, styleOption);
int iconOffset = drawTypeIcon(painter, styleOption, modelIndex, m_navigatorTreeModel);
int iconOffset = drawIcon(painter, styleOption, modelIndex);
QRect textFrame = drawText(painter, styleOption, modelIndex, iconOffset, m_navigatorTreeModel);
QRect textFrame = drawText(painter, styleOption, modelIndex, iconOffset);
drawRedWavyUnderLine(painter, styleOption, modelIndex, textFrame, m_navigatorTreeModel);
if (modelIndex.data(NavigatorTreeModel::ErrorRole).toBool())
drawRedWavyUnderLine(painter, styleOption, textFrame);
painter->restore();
}
......
......@@ -42,8 +42,8 @@ class NameItemDelegate : public QStyledItemDelegate
public:
explicit NameItemDelegate(QObject *parent, NavigatorTreeModel *treeModel);
void paint(QPainter *painter,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
void paint(QPainter *painter, const QStyleOptionViewItem &styleOption,
const QModelIndex &index) const;
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
......
......@@ -4,5 +4,10 @@
<file>arrowleft.png</file>
<file>arrowright.png</file>
<file>arrowup.png</file>
<file>export_checked.png</file>
<file>export_unchecked.png</file>
<file>eye_open.png</file>
<file>eye_closed.png</file>
<file>warning.png</file>
</qresource>
</RCC>
......@@ -30,6 +30,7 @@
#include "navigatortreemodel.h"
#include <bindingproperty.h>
#include <nodeabstractproperty.h>
#include <nodelistproperty.h>
#include <nodeproperty.h>
......@@ -261,21 +262,41 @@ static inline QString msgUnknownItem(const QString &t)
return NavigatorTreeModel::tr("Unknown item: %1").arg(t);
}
ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
static QIcon getTypeIcon(const ModelNode &modelNode)
{
Q_ASSERT(node.isValid());
if (modelNode.isValid()) {
// if node has no own icon, search for it in the itemlibrary
const ItemLibraryInfo *libraryInfo = modelNode.model()->metaInfo().itemLibraryInfo();
QList <ItemLibraryEntry> itemLibraryEntryList = libraryInfo->entriesForType(
modelNode.type(), modelNode.majorVersion(), modelNode.minorVersion());
if (!itemLibraryEntryList.isEmpty())
return itemLibraryEntryList.first().typeIcon();
else if (modelNode.metaInfo().isValid())
return QIcon(QStringLiteral(":/ItemLibrary/images/item-default-icon.png"));
}
const bool dropEnabled = node.metaInfo().isValid();
return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png"));
}
ItemRow NavigatorTreeModel::createItemRow(const ModelNode &modelNode)
{
Q_ASSERT(modelNode.isValid());
const bool dropEnabled = modelNode.metaInfo().isValid();
QStandardItem *idItem = new QStandardItem;
idItem->setDragEnabled(true);
idItem->setDropEnabled(dropEnabled);
idItem->setEditable(true);
idItem->setData(node.internalId(), InternalIdRole);
if (node.metaInfo().isValid())
idItem->setToolTip(node.type());
idItem->setData(modelNode.internalId(), InternalIdRole);
idItem->setData(modelNode.simplifiedTypeName(), SimplifiedTypeNameRole);
if (modelNode.hasId())
idItem->setText(modelNode.id());
idItem->setIcon(getTypeIcon(modelNode));
if (modelNode.metaInfo().isValid())
idItem->setToolTip(QString::fromLatin1(modelNode.type()));
else
idItem->setToolTip(msgUnknownItem(node.type()));
idItem->setToolTip(msgUnknownItem(QString::fromLatin1(modelNode.type())));
# ifdef _LOCK_ITEMS_
QStandardItem *lockItem = new QStandardItem;
lockItem->setDragEnabled(true);
......@@ -285,12 +306,24 @@ ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
lockItem->setData(hash, NavigatorRole);
# endif
QStandardItem *exportItem = new QStandardItem;
exportItem->setDropEnabled(dropEnabled);
exportItem->setCheckable(true);
exportItem->setEditable(false);
exportItem->setData(modelNode.internalId(), InternalIdRole);
exportItem->setToolTip(tr("Toggles whether this item is exported as an "
"alias property of the root item."));
if (modelNode.isRootNode())
exportItem->setCheckable(false);
QStandardItem *visibilityItem = new QStandardItem;
visibilityItem->setDropEnabled(dropEnabled);
visibilityItem->setCheckable(true);
visibilityItem->setEditable(false);
visibilityItem->setData(node.internalId(), InternalIdRole);
if (node.isRootNode())
visibilityItem->setData(modelNode.internalId(), InternalIdRole);
visibilityItem->setToolTip(tr("Toggles the visibility of this item in the form editor.\n"
"This is independent of the visibility property in QML."));
if (modelNode.isRootNode())
visibilityItem->setCheckable(false);
QMap<QString, QStandardItem *> propertyItems;
......@@ -310,25 +343,55 @@ ItemRow NavigatorTreeModel::createItemRow(const ModelNode &node)
# ifdef _LOCK_ITEMS_
ItemRow newRow = ItemRow(idItem, lockItem, visibilityItem, propertyItems);
# else
ItemRow newRow = ItemRow(idItem, visibilityItem, propertyItems);
ItemRow newRow = ItemRow(idItem, exportItem, visibilityItem, propertyItems);
# endif
m_nodeItemHash.insert(node, newRow);
updateItemRow(node, newRow);
m_nodeItemHash.insert(modelNode, newRow);
updateItemRow(modelNode, newRow);
return newRow;
}
void NavigatorTreeModel::updateItemRow(const ModelNode &node, ItemRow items)
static bool isModelNodeExported(const ModelNode &modelNode)
{
if (!modelNode.id().isEmpty()) {
PropertyName modelNodeId = modelNode.id().toLatin1();
ModelNode rootModelNode = modelNode.view()->rootModelNode();
Q_ASSERT(rootModelNode.isValid());
if (rootModelNode.hasBindingProperty(modelNodeId)
&& rootModelNode.bindingProperty(modelNodeId).isDynamic()
&& rootModelNode.bindingProperty(modelNodeId).expression().toLatin1() == modelNodeId)
return true;
}
return false;
}
void NavigatorTreeModel::updateItemRow(const ModelNode &modelNode, ItemRow items)
{
bool blockSignal = blockItemChangedSignal(true);
items.idItem->setText(node.id());
items.visibilityItem->setCheckState(node.auxiliaryData("invisible").toBool() ? Qt::Unchecked : Qt::Checked);
if (node.metaInfo().isValid())
items.idItem->setToolTip(node.type());
else
items.idItem->setToolTip(msgUnknownItem(node.type()));
items.idItem->setText(modelNode.id());
items.idItem->setData(modelNode.simplifiedTypeName(), SimplifiedTypeNameRole);
bool isInvisible = modelNode.auxiliaryData("invisible").toBool();
items.idItem->setData(isInvisible, InvisibleRole);
items.visibilityItem->setCheckState(isInvisible ? Qt::Unchecked : Qt::Checked);
items.exportItem->setCheckState(isModelNodeExported(modelNode) ? Qt::Checked : Qt::Unchecked);
QmlObjectNode currentQmlObjectNode(modelNode);
if (currentQmlObjectNode.hasError()) {
items.idItem->setData(true, ErrorRole);
items.idItem->setToolTip(currentQmlObjectNode.error());
items.idItem->setIcon(QIcon(":/navigator/icon/warning.png"));
} else {
items.idItem->setData(false, ErrorRole);
if (modelNode.metaInfo().isValid())
items.idItem->setToolTip(QString::fromLatin1(modelNode.type()));
else
items.idItem->setToolTip(msgUnknownItem(QString::fromLatin1(modelNode.type())));
}
blockItemChangedSignal(blockSignal);
}
......@@ -365,6 +428,30 @@ void NavigatorTreeModel::handleChangedIdItem(QStandardItem *idItem, ModelNode &m
}
}
void NavigatorTreeModel::handleChangedExportItem(QStandardItem *exportItem, ModelNode &modelNode)
{
bool exported = (exportItem->checkState() == Qt::Checked);
ModelNode rootModelNode = m_view->rootModelNode();
Q_ASSERT(rootModelNode.isValid());
PropertyName modelNodeId = modelNode.id().toLatin1();
if (rootModelNode.hasProperty(modelNodeId))
rootModelNode.removeProperty(modelNodeId);
if (exported) {
try {
RewriterTransaction transaction =
m_view->beginRewriterTransaction(QByteArrayLiteral("NavigatorTreeModel:exportItem"));
modelNode.validId();
modelNodeId = modelNode.id().toLatin1();
rootModelNode.bindingProperty(modelNodeId).setDynamicTypeNameAndExpression("alias", modelNodeId);
} catch (RewritingException &exception) { //better safe than sorry! There always might be cases where we fail
exception.showException();
}
}
}
void NavigatorTreeModel::handleChangedVisibilityItem(QStandardItem *visibilityItem, ModelNode &modelNode)
{
bool invisible = (visibilityItem->checkState() == Qt::Unchecked);
......@@ -383,6 +470,8 @@ void NavigatorTreeModel::handleChangedItem(QStandardItem *item)
ItemRow itemRow = itemRowForNode(modelNode);
if (item == itemRow.idItem) {
handleChangedIdItem(item, modelNode);
} else if (item == itemRow.exportItem) {
handleChangedExportItem(item, modelNode);
} else if (item == itemRow.visibilityItem) {
handleChangedVisibilityItem(item, modelNode);
}
......@@ -731,6 +820,14 @@ void NavigatorTreeModel::setVisible(const QModelIndex &index, bool visible)
itemRow.visibilityItem->setCheckState(visible ? Qt::Checked : Qt::Unchecked);
}
void NavigatorTreeModel::setExported(const QModelIndex &index, bool exported)
{
ModelNode node = nodeForIndex(index);
ItemRow itemRow = itemRowForNode(node);
itemRow.exportItem->setCheckState(exported ? Qt::Checked : Qt::Unchecked);
}
void NavigatorTreeModel::openContextMenu(const QPoint &position)
{
ModelNodeContextMenu::showContextMenu(m_view.data(), position, QPoint(), false);
......
......@@ -64,14 +64,15 @@ class ModelNode;
struct ItemRow {
ItemRow()
: idItem(0), visibilityItem(0) {}
ItemRow(QStandardItem *id, QStandardItem *visibility, const QMap<QString, QStandardItem *> &properties)
: idItem(id), visibilityItem(visibility), propertyItems(properties) {}
ItemRow(QStandardItem *id, QStandardItem *exportI, QStandardItem *visibility, const QMap<QString, QStandardItem *> &properties)
: idItem(id), exportItem(exportI), visibilityItem(visibility), propertyItems(properties) {}
QList<QStandardItem*> toList() const {
return QList<QStandardItem*>() << idItem << visibilityItem;
return QList<QStandardItem*>() << idItem << exportItem << visibilityItem;
}
QStandardItem *idItem;
QStandardItem *exportItem;
QStandardItem *visibilityItem;
QMap<QString, QStandardItem *> propertyItems;
};
......@@ -83,7 +84,10 @@ class NavigatorTreeModel : public QStandardItemModel
public:
enum {
InternalIdRole = Qt::UserRole
InternalIdRole = Qt::UserRole
,InvisibleRole = Qt::UserRole + 1
,SimplifiedTypeNameRole = Qt::UserRole + 2
,ErrorRole = Qt::UserRole + 3
};
......@@ -117,6 +121,7 @@ public:
void updateItemRow(const ModelNode &node);
void setId(const QModelIndex &index, const QString &id);
void setExported(const QModelIndex &index, bool exported);
void setVisible(const QModelIndex &index, bool visible);
void openContextMenu(const QPoint &p);
......@@ -131,6 +136,7 @@ private:
ItemRow createItemRow(const ModelNode &node);
void updateItemRow(const ModelNode &node, ItemRow row);
void handleChangedIdItem(QStandardItem *idItem, ModelNode &modelNode);
void handleChangedExportItem(QStandardItem *exportItem, ModelNode &modelNode);
void handleChangedVisibilityItem(QStandardItem *visibilityItem, ModelNode &modelNode);
void moveNodesInteractive(NodeAbstractProperty &parentProperty, const QList<ModelNode> &modelNodes, int targetIndex);
......
......@@ -37,6 +37,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/icore.h>
#include <bindingproperty.h>
#include <designmodecontext.h>
#include <nodeproperty.h>
#include <nodelistproperty.h>
......@@ -85,8 +86,13 @@ NavigatorView::NavigatorView(QObject* parent) :
NameItemDelegate *idDelegate = new NameItemDelegate(this,
m_treeModel.data());
IconCheckboxItemDelegate *showDelegate = new IconCheckboxItemDelegate(this,
":/qmldesigner/images/eye_open.png",
":/qmldesigner/images/placeholder.png",
QLatin1String(":/navigator/icon/eye_open.png"),
QLatin1String(":/navigator/icon/eye_closed.png"),
m_treeModel.data());
IconCheckboxItemDelegate *exportDelegate = new IconCheckboxItemDelegate(this,
QLatin1String(":/navigator/icon/export_checked.png"),
QLatin1String(":/navigator/icon/export_unchecked.png"),
m_treeModel.data());
#ifdef _LOCK_ITEMS_
......@@ -100,7 +106,8 @@ NavigatorView::NavigatorView(QObject* parent) :
treeWidget()->setItemDelegateForColumn(1,lockDelegate);
treeWidget()->setItemDelegateForColumn(2,showDelegate);
#else
treeWidget()->setItemDelegateForColumn(1,showDelegate);
treeWidget()->setItemDelegateForColumn(1,exportDelegate);
treeWidget()->setItemDelegateForColumn(2,showDelegate);
#endif
}
......@@ -155,6 +162,17 @@ void NavigatorView::importsChanged(const QList<Import> &/*addedImports*/, const
treeWidget()->update();
}
void NavigatorView::bindingPropertiesChanged(const QList<BindingProperty> & propertyList, PropertyChangeFlags /*propertyChange*/)
{
foreach (const BindingProperty &bindingProperty, propertyList) {
/* If a binding property that exports an item using an alias property has
* changed, we have to update the affected item.
*/
if (bindingProperty.isAliasExport())
m_treeModel->updateItemRow(modelNodeForId(bindingProperty.expression()));
}
}
void NavigatorView::nodeAboutToBeRemoved(const ModelNode &removedNode)
{
m_treeModel->removeSubTree(removedNode);
......@@ -220,6 +238,12 @@ void NavigatorView::auxiliaryDataChanged(const ModelNode &modelNode, const Prope
}
}
void NavigatorView::instanceErrorChange(const QVector<ModelNode> &errorNodeList)
{
foreach (const ModelNode &currentModelNode, errorNodeList)
m_treeModel->updateItemRow(currentModelNode);
}
void NavigatorView::nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &node, int /*oldIndex*/)
{
if (m_treeModel->isInTree(node)) {
......
......@@ -74,6 +74,9 @@ public:
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList ,
const QList<ModelNode> &lastSelectedNodeList) override;
void auxiliaryDataChanged(const ModelNode &node, const PropertyName &name, const QVariant &data) override;
void instanceErrorChange(const QVector<ModelNode> &errorNodeList) override;
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags);
private slots:
void changeSelection(const QItemSelection &selected, const QItemSelection &deselected);
......
......@@ -82,24 +82,24 @@ QList<QToolButton *> NavigatorWidget::createToolBarWidgets()
QList<QToolButton *> buttons;
buttons.append(new QToolButton());
buttons.last()->setIcon(QIcon(":/navigator/icon/arrowleft.png"));
buttons.last()->setIcon(QIcon(QLatin1String(":/navigator/icon/arrowleft.png")));
buttons.last()->setToolTip(tr("Become last sibling of parent (CTRL + Left)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Left | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(leftButtonClicked()));
buttons.append(new QToolButton());
buttons.last()->setIcon(QIcon(":/navigator/icon/arrowright.png"));
buttons.last()->setIcon(QIcon(QLatin1String(":/navigator/icon/arrowright.png")));
buttons.last()->setToolTip(tr("Become child of last sibling (CTRL + Right)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Right | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(rightButtonClicked()));
buttons.append(new QToolButton());
buttons.last()->setIcon(QIcon(":/navigator/icon/arrowdown.png"));
buttons.last()->setIcon(QIcon(QLatin1String(":/navigator/icon/arrowdown.png")));
buttons.last()->setToolTip(tr("Move down (CTRL + Down)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Down | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(downButtonClicked()));
buttons.append(new QToolButton());
buttons.last()->setIcon(QIcon(":/navigator/icon/arrowup.png"));
buttons.last()->setIcon(QIcon(QLatin1String(":/navigator/icon/arrowup.png")));
buttons.last()->setToolTip(tr("Move up (CTRL + Up)."));
buttons.last()->setShortcut(QKeySequence(Qt::Key_Up | Qt::CTRL));
connect(buttons.last(), SIGNAL(clicked()), this, SIGNAL(upButtonClicked()));
......
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