Commit 9a142208 authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner: remove dead code

Change-Id: I2f88af9ef449ee21e646dab7ca23b97836249764
Reviewed-on: http://codereview.qt-project.org/5128

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarMarco Bubke <marco.bubke@nokia.com>
parent 1086e387
......@@ -36,7 +36,6 @@ SOURCES += formeditoritem.cpp \
anchorcontroller.cpp \
anchorhandleitem.cpp \
dragtool.cpp \
itemcreatortool.cpp \
toolbox.cpp \
zoomaction.cpp \
formeditorgraphicsview.cpp \
......@@ -76,7 +75,6 @@ HEADERS += formeditorscene.h \
anchorcontroller.h \
anchorhandleitem.h \
dragtool.h \
itemcreatortool.cpp \
toolbox.h \
zoomaction.h \
formeditorgraphicsview.h \
......
......@@ -35,7 +35,6 @@
#include "resizetool.h"
#include "anchortool.h"
#include "dragtool.h"
#include "itemcreatortool.h"
#include "formeditorview.h"
#include "formeditorwidget.h"
#include "formeditornodeinstanceview.h"
......@@ -70,7 +69,6 @@ FormEditorView::FormEditorView(QObject *parent)
m_resizeTool(new ResizeTool(this)),
m_anchorTool(new AnchorTool(this)),
m_dragTool(new DragTool(this)),
m_itemCreatorTool(new ItemCreatorTool(this)),
m_currentTool(m_selectionTool),
m_transactionCounter(0)
{
......@@ -389,20 +387,6 @@ void FormEditorView::changeToSelectionTool()
m_currentTool->setItems(scene()->itemsForQmlItemNodes(selectedQmlItemNodes()));
}
void FormEditorView::changeToItemCreatorTool()
{
if(m_currentTool == m_itemCreatorTool)
return;
scene()->setPaintMode(FormEditorScene::NormalMode);
m_scene->updateAllFormEditorItems();
m_currentTool->clear();
m_currentTool = m_itemCreatorTool;
m_currentTool->clear();
setSelectedQmlItemNodes(QList<QmlItemNode>());
m_currentTool->setItems(scene()->itemsForQmlItemNodes(selectedQmlItemNodes()));
}
void FormEditorView::changeToSelectionTool(QGraphicsSceneMouseEvent *event)
{
if (m_currentTool == m_selectionTool)
......@@ -576,24 +560,6 @@ double FormEditorView::spacing() const
return m_formEditorWidget->spacing();
}
void FormEditorView::activateItemCreator(const QString &name)
{
if (m_currentTool == m_itemCreatorTool) {
m_itemCreatorTool->setItemString(name);
return;
}
changeToItemCreatorTool();
m_itemCreatorTool->setItemString(name);
}
void FormEditorView::deActivateItemCreator()
{
if (m_currentTool == m_itemCreatorTool) {
changeToSelectionTool();
emit ItemCreatorDeActivated();
}
}
QList<ModelNode> FormEditorView::adjustStatesForModelNodes(const QList<ModelNode> &nodeList) const
{
QList<ModelNode> adjustedNodeList;
......
......@@ -53,7 +53,6 @@ class SelectionTool;
class ResizeTool;
class AnchorTool;
class DragTool;
class ItemCreatorTool;
class ItemLibraryEntry;
class QmlItemNode;
......@@ -94,7 +93,6 @@ public:
bool changeToMoveTool(const QPointF &beginPoint);
void changeToDragTool();
void changeToSelectionTool();
void changeToItemCreatorTool();
void changeToSelectionTool(QGraphicsSceneMouseEvent *event);
void changeToResizeTool();
void changeToAnchorTool();
......@@ -120,12 +118,6 @@ public:
void actualStateChanged(const ModelNode &node);
public slots:
void activateItemCreator(const QString &name);
signals:
void ItemCreatorDeActivated();
protected:
void reset();
......@@ -149,7 +141,6 @@ private: //variables
ResizeTool *m_resizeTool;
AnchorTool *m_anchorTool;
DragTool *m_dragTool;
ItemCreatorTool *m_itemCreatorTool;
AbstractFormEditorTool *m_currentTool;
int m_transactionCounter;
};
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#include "itemcreatortool.h"
#include "formeditorscene.h"
#include "formeditorview.h"
#include <metainfo.h>
#include <itemlibrarywidget.h>
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
#include <QtDebug>
#include <QClipboard>
#include <variantproperty.h>
namespace QmlDesigner {
ItemCreatorTool::ItemCreatorTool(FormEditorView *editorView)
: AbstractFormEditorTool(editorView),
m_rubberbandSelectionManipulator(editorView->scene()->manipulatorLayerItem(), editorView)
{
}
ItemCreatorTool::~ItemCreatorTool()
{
}
void ItemCreatorTool::mousePressEvent(const QList<QGraphicsItem*> &/*itemList*/,
QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
m_rubberbandSelectionManipulator.begin(event->scenePos());
else
view()->deActivateItemCreator();
}
void ItemCreatorTool::mouseMoveEvent(const QList<QGraphicsItem*> &/*itemList*/,
QGraphicsSceneMouseEvent *event)
{
if (m_rubberbandSelectionManipulator.isActive()) {
m_rubberbandSelectionManipulator.update(event->scenePos());
} else {
}
}
void ItemCreatorTool::hoverMoveEvent(const QList<QGraphicsItem*> &/*itemList*/,
QGraphicsSceneMouseEvent * /*event*/)
{
}
void ItemCreatorTool::mouseReleaseEvent(const QList<QGraphicsItem*> &/*itemList*/,
QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
if (m_rubberbandSelectionManipulator.isActive()) {
QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->scenePos();
if (mouseMovementVector.toPoint().manhattanLength() < QApplication::startDragDistance()) {
m_rubberbandSelectionManipulator.update(event->scenePos());
} else {
m_rubberbandSelectionManipulator.update(event->scenePos());
QRectF rect(m_rubberbandSelectionManipulator.beginPoint(), event->scenePos());
createAtItem(rect);
m_rubberbandSelectionManipulator.end();
view()->deActivateItemCreator();
}
}
} else {
view()->deActivateItemCreator();
}
}
void ItemCreatorTool::mouseDoubleClickEvent(const QList<QGraphicsItem*> &/*itemList*/,
QGraphicsSceneMouseEvent * /*event*/)
{
}
void ItemCreatorTool::keyPressEvent(QKeyEvent *event)
{
switch(event->key()) {
case Qt::Key_Escape:
view()->deActivateItemCreator();
break;
}
}
void ItemCreatorTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
{
}
void ItemCreatorTool::dragLeaveEvent(QGraphicsSceneDragDropEvent * /*event*/)
{
}
void ItemCreatorTool::dragMoveEvent(QGraphicsSceneDragDropEvent * /*event*/)
{
}
void ItemCreatorTool::itemsAboutToRemoved(const QList<FormEditorItem*> &/*itemList*/)
{
}
void ItemCreatorTool::clear()
{
m_rubberbandSelectionManipulator.clear();
}
void ItemCreatorTool::selectedItemsChanged(const QList<FormEditorItem*> &/*itemList*/)
{
}
void ItemCreatorTool::formEditorItemsChanged(const QList<FormEditorItem*> &/*itemList*/)
{
}
void ItemCreatorTool::instancesCompleted(const QList<FormEditorItem*> &/*itemList*/)
{
}
void ItemCreatorTool::instancesParentChanged(const QList<FormEditorItem *> &/*itemList*/)
{
}
void ItemCreatorTool::setItemString(const QString &itemString)
{
m_itemString = itemString;
}
FormEditorItem* ItemCreatorTool::calculateContainer(const QPointF &point)
{
QList<QGraphicsItem *> list = scene()->items(point);
foreach (QGraphicsItem *item, list) {
FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
if (formEditorItem)
return formEditorItem;
}
return 0;
}
void ItemCreatorTool::createAtItem(const QRectF &rect)
{
QPointF pos = rect.topLeft();
QmlItemNode parentNode = view()->rootQmlItemNode();
if (!parentNode.isValid())
return;
FormEditorItem *parentItem = calculateContainer(pos);
if (parentItem) {
parentNode = parentItem->qmlItemNode();
pos = parentItem->mapFromScene(pos);
}
QStringList list = m_itemString.split(QLatin1Char('^'));
if (list.count() != 2)
return;
if (list.first() == "item") {
RewriterTransaction transaction = view()->beginRewriterTransaction();
Q_ASSERT(false); //this code is out of date
ItemLibraryEntry itemLibraryEntry; // = view()->model()->metaInfo().itemLibraryInfo()->entry(list.at(1));
QmlItemNode newNode = view()->createQmlItemNode(itemLibraryEntry, pos, parentNode);
newNode.modelNode().variantProperty("width") = rect.width();
newNode.modelNode().variantProperty("height") = rect.height();
QList<QmlItemNode> nodeList;
nodeList.append(newNode);
view()->setSelectedQmlItemNodes(nodeList);
} else if (list.first() == "image") {
RewriterTransaction transaction = view()->beginRewriterTransaction();
QmlItemNode newNode = view()->createQmlItemNodeFromImage(list.at(1), pos, parentNode);
newNode.modelNode().variantProperty("width") = rect.width();
newNode.modelNode().variantProperty("height") = rect.height();
QList<QmlItemNode> nodeList;
nodeList.append(newNode);
view()->setSelectedQmlItemNodes(nodeList);
}
}
} //QmlDesigner
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** GNU Lesser General Public License Usage
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
** If you have questions regarding the use of this file, please contact
** Nokia at info@qt.nokia.com.
**
**************************************************************************/
#ifndef ITEMCREATORTOOL_H
#define ITEMCREATORTOOL_H
#include "abstractformeditortool.h"
#include "rubberbandselectionmanipulator.h"
#include <QHash>
namespace QmlDesigner {
class ItemCreatorTool : public AbstractFormEditorTool
{
public:
ItemCreatorTool(FormEditorView* editorView);
~ItemCreatorTool();
void mousePressEvent(const QList<QGraphicsItem*> &itemList,
QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(const QList<QGraphicsItem*> &itemList,
QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(const QList<QGraphicsItem*> &itemList,
QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(const QList<QGraphicsItem*> &itemList,
QGraphicsSceneMouseEvent *event);
void hoverMoveEvent(const QList<QGraphicsItem*> &itemList,
QGraphicsSceneMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *keyEvent);
void dragLeaveEvent(QGraphicsSceneDragDropEvent * event);
void dragMoveEvent(QGraphicsSceneDragDropEvent * event);
void itemsAboutToRemoved(const QList<FormEditorItem*> &itemList);
void clear();
void selectedItemsChanged(const QList<FormEditorItem*> &itemList);
void formEditorItemsChanged(const QList<FormEditorItem*> &itemList);
void instancesCompleted(const QList<FormEditorItem*> &itemList);
void instancesParentChanged(const QList<FormEditorItem *> &itemList);
void setItemString(const QString &itemString);
FormEditorItem* calculateContainer(const QPointF &point);
void createAtItem(const QRectF &rect);
private:
RubberBandSelectionManipulator m_rubberbandSelectionManipulator;
QString m_itemString;
};
}
#endif // ITEMCREATORTOOL_H
......@@ -480,8 +480,6 @@ void DesignDocumentController::loadCurrentModel()
d->model->attachView(d->navigator.data());
d->itemLibraryView->widget()->setResourcePath(QFileInfo(d->fileName).absolutePath());
connect(d->itemLibraryView->widget(), SIGNAL(itemActivated(const QString&)), d->formEditorView.data(), SLOT(activateItemCreator(const QString&)));
d->model->attachView(d->formEditorView.data());
d->model->attachView(d->itemLibraryView.data());
......
Supports Markdown
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