Commit 64a167c2 authored by Marco Bubke's avatar Marco Bubke
Browse files

Add option in the toolbar to toogle selection of items with no content

parent 4959230c
......@@ -10,4 +10,7 @@
<file>snapping.png</file>
<file>boundingrect.png</file>
</qresource>
<qresource prefix="/icon/selection">
<file>selectonlycontentitems.png</file>
</qresource>
</RCC>
......@@ -68,6 +68,8 @@ FormEditorView::FormEditorView(QObject *parent)
{
connect(widget()->zoomAction(), SIGNAL(zoomLevelChanged(double)), SLOT(updateGraphicsIndicators()));
connect(widget()->showBoundingRectAction(), SIGNAL(toggled(bool)), scene(), SLOT(setShowBoundingRects(bool)));
connect(widget()->selectOnlyContentItemsAction(), SIGNAL(toggled(bool)), this, SLOT(setSelectOnlyContentItemsAction(bool)));
}
FormEditorScene* FormEditorView::scene() const
......@@ -519,6 +521,12 @@ void FormEditorView::updateGraphicsIndicators()
m_currentTool->formEditorItemsChanged(scene()->allFormEditorItems());
}
void FormEditorView::setSelectOnlyContentItemsAction(bool selectOnlyContentItems)
{
m_selectionTool->setSelectOnlyContentItems(selectOnlyContentItems);
}
void FormEditorView::updateItem(const QmlObjectNode &qmlObjectNode)
{
......
......@@ -118,6 +118,7 @@ protected:
protected slots:
QList<ModelNode> adjustStatesForModelNodes(const QList<ModelNode> &nodeList) const;
void updateGraphicsIndicators();
void setSelectOnlyContentItemsAction(bool selectOnlyContentItems);
private: //functions
void setupFormEditorItemTree(const QmlItemNode &qmlItemNode);
......
......@@ -121,7 +121,20 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view)
connect(m_zoomAction.data(), SIGNAL(zoomLevelChanged(double)), SLOT(setZoomLevel(double)));
addAction(m_zoomAction.data());
QAction *separatorAction = new QAction(toolActionGroup());
QAction *separatorAction = new QAction(this);
separatorAction->setSeparator(true);
addAction(separatorAction);
m_selectOnlyContentItemsAction = layoutActionGroup->addAction("Select Only Items with Content (Press Key T)");
m_selectOnlyContentItemsAction->setShortcut(Qt::Key_T);
m_selectOnlyContentItemsAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
m_selectOnlyContentItemsAction->setCheckable(true);
m_selectOnlyContentItemsAction->setChecked(true);
m_selectOnlyContentItemsAction->setIcon(QPixmap(":/icon/selection/selectonlycontentitems.png"));
addAction(m_selectOnlyContentItemsAction.data());
separatorAction = new QAction(toolActionGroup());
separatorAction->setSeparator(true);
addAction(separatorAction);
......@@ -192,6 +205,11 @@ QAction *FormEditorWidget::showBoundingRectAction() const
return m_showBoundingRectAction.data();
}
QAction *FormEditorWidget::selectOnlyContentItemsAction() const
{
return m_selectOnlyContentItemsAction.data();
}
void FormEditorWidget::setZoomLevel(double zoomLevel)
{
m_graphicsView->resetTransform();
......
......@@ -54,6 +54,8 @@ public:
QAction *anchorToolAction() const;
QAction *transformToolAction() const;
QAction *showBoundingRectAction() const;
QAction *selectOnlyContentItemsAction() const;
void setScene(FormEditorScene *scene);
ToolBox *toolBox() const;
......@@ -85,6 +87,7 @@ private:
QWeakPointer<NumberSeriesAction> m_snappingMarginAction;
QWeakPointer<NumberSeriesAction> m_snappingSpacingAction;
QWeakPointer<QAction> m_showBoundingRectAction;
QWeakPointer<QAction> m_selectOnlyContentItemsAction;
};
......
......@@ -49,8 +49,8 @@ SelectionTool::SelectionTool(FormEditorView *editorView)
m_rubberbandSelectionManipulator(editorView->scene()->manipulatorLayerItem(), editorView),
m_singleSelectionManipulator(editorView),
m_selectionIndicator(editorView->scene()->manipulatorLayerItem()),
m_resizeIndicator(editorView->scene()->manipulatorLayerItem())
m_resizeIndicator(editorView->scene()->manipulatorLayerItem()),
m_selectOnlyContentItems(true)
{
// view()->setCursor(Qt::CrossCursor);
}
......@@ -69,21 +69,21 @@ void SelectionTool::mousePressEvent(const QList<QGraphicsItem*> &itemList,
m_singleSelectionManipulator.begin(event->scenePos());
if (event->modifiers().testFlag(Qt::ControlModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, m_selectOnlyContentItems);
else if (event->modifiers().testFlag(Qt::ShiftModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, m_selectOnlyContentItems);
else
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, m_selectOnlyContentItems);
} else {
if (event->modifiers().testFlag(Qt::AltModifier)) {
m_singleSelectionManipulator.begin(event->scenePos());
if (event->modifiers().testFlag(Qt::ControlModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, m_selectOnlyContentItems);
else if (event->modifiers().testFlag(Qt::ShiftModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, m_selectOnlyContentItems);
else
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, m_selectOnlyContentItems);
m_singleSelectionManipulator.end(event->scenePos());
view()->changeToMoveTool(event->scenePos());
......@@ -149,11 +149,11 @@ void SelectionTool::mouseReleaseEvent(const QList<QGraphicsItem*> &/*itemList*/,
m_singleSelectionManipulator.begin(event->scenePos());
if (event->modifiers().testFlag(Qt::ControlModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, m_selectOnlyContentItems);
else if (event->modifiers().testFlag(Qt::ShiftModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, m_selectOnlyContentItems);
else
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, m_selectOnlyContentItems);
m_singleSelectionManipulator.end(event->scenePos());
} else {
......@@ -226,6 +226,11 @@ void SelectionTool::pasteClipBoard()
// QClipboard *clipboard = QApplication::clipboard();
}
void SelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems)
{
m_selectOnlyContentItems = selectOnlyContentItems;
}
void SelectionTool::itemsAboutToRemoved(const QList<FormEditorItem*> &/*itemList*/)
{
......@@ -270,11 +275,11 @@ void SelectionTool::selectUnderPoint(QGraphicsSceneMouseEvent *event)
m_singleSelectionManipulator.begin(event->scenePos());
if (event->modifiers().testFlag(Qt::ControlModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::RemoveFromSelection, m_selectOnlyContentItems);
else if (event->modifiers().testFlag(Qt::ShiftModifier))
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::AddToSelection, m_selectOnlyContentItems);
else
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection);
m_singleSelectionManipulator.select(SingleSelectionManipulator::InvertSelection, m_selectOnlyContentItems);
m_singleSelectionManipulator.end(event->scenePos());
}
......
......@@ -81,12 +81,16 @@ public:
void copySelectedNodeToClipBoard();
void cutSelectedNodeToClipBoard();
void pasteClipBoard();
void setSelectOnlyContentItems(bool selectOnlyContentItems);
private:
RubberBandSelectionManipulator m_rubberbandSelectionManipulator;
SingleSelectionManipulator m_singleSelectionManipulator;
SelectionIndicator m_selectionIndicator;
ResizeIndicator m_resizeIndicator;
QTime m_mousePressTimer;
bool m_selectOnlyContentItems;
};
}
......
......@@ -69,7 +69,7 @@ void SingleSelectionManipulator::end(const QPointF &/*updatePoint*/)
m_isActive = false;
}
void SingleSelectionManipulator::select(SelectionType selectionType)
void SingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems)
{
QList<QGraphicsItem*> itemList = m_editorView->scene()->items(m_beginPoint);
......@@ -81,7 +81,7 @@ void SingleSelectionManipulator::select(SelectionType selectionType)
if (formEditorItem
&& !formEditorItem->qmlItemNode().isRootNode()
&& (formEditorItem->qmlItemNode().hasShowContent()))
&& (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems))
{
selectedNode = formEditorItem->qmlItemNode();
break;
......
......@@ -53,7 +53,7 @@ public:
void update(const QPointF& updatePoint);
void end(const QPointF& updatePoint);
void select(SelectionType selectionType);
void select(SelectionType selectionType, bool selectOnlyContentItems);
void clear();
......
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