Commit 7df5ce2d authored by Thomas Hartmann's avatar Thomas Hartmann
Browse files

QmlDesigner.itemLibrary: turn the item library into a full view.

This is more consistent with the whole architecture and allows
the item library to listen to imports.
parent d3619e80
......@@ -35,7 +35,8 @@
#include "model/viewlogger.h"
#include <allpropertiesbox.h>
#include <itemlibrary.h>
#include <itemlibraryview.h>
#include <itemlibrarywidget.h>
#include <navigatorview.h>
#include <stateseditorview.h>
#include <formeditorview.h>
......@@ -84,7 +85,7 @@ class DesignDocumentControllerPrivate {
public:
QWeakPointer<FormEditorView> formEditorView;
QWeakPointer<ItemLibrary> itemLibrary;
QWeakPointer<ItemLibraryView> itemLibraryView;
QWeakPointer<NavigatorView> navigator;
QWeakPointer<AllPropertiesBox> allPropertiesBox;
QWeakPointer<StatesEditorView> statesEditorView;
......@@ -190,9 +191,9 @@ QList<RewriterView::Error> DesignDocumentController::qmlErrors() const
return m_d->rewriterView->errors();
}
void DesignDocumentController::setItemLibrary(ItemLibrary* itemLibrary)
void DesignDocumentController::setItemLibraryView(ItemLibraryView* itemLibraryView)
{
m_d->itemLibrary = itemLibrary;
m_d->itemLibraryView = itemLibraryView;
}
void DesignDocumentController::setNavigator(NavigatorView* navigatorView)
......@@ -246,8 +247,8 @@ void DesignDocumentController::setFileName(const QString &fileName)
if (m_d->model)
m_d->model->setFileUrl(m_d->searchPath);
if (m_d->itemLibrary)
m_d->itemLibrary->setResourcePath(QFileInfo(fileName).absolutePath());
if (m_d->itemLibraryView)
m_d->itemLibraryView->widget()->setResourcePath(QFileInfo(fileName).absolutePath());
emit displayNameChanged(displayName());
}
......@@ -354,8 +355,8 @@ void DesignDocumentController::loadCurrentModel()
m_d->model->attachView(m_d->nodeInstanceView.data());
m_d->model->attachView(m_d->navigator.data());
m_d->itemLibrary->setItemLibraryInfo(m_d->model->metaInfo().itemLibraryInfo());
m_d->itemLibrary->setResourcePath(QFileInfo(m_d->fileName).absolutePath());
m_d->itemLibraryView->widget()->setItemLibraryInfo(m_d->model->metaInfo().itemLibraryInfo());
m_d->itemLibraryView->widget()->setResourcePath(QFileInfo(m_d->fileName).absolutePath());
if (!m_d->componentAction) {
m_d->componentAction = new ComponentAction(m_d->formEditorView->widget());
......@@ -366,9 +367,10 @@ void DesignDocumentController::loadCurrentModel()
// Disable switching between in file components for the time being
m_d->componentAction->setVisible(false);
connect(m_d->itemLibrary.data(), SIGNAL(itemActivated(const QString&)), m_d->formEditorView.data(), SLOT(activateItemCreator(const QString&)));
connect(m_d->itemLibraryView->widget(), SIGNAL(itemActivated(const QString&)), m_d->formEditorView.data(), SLOT(activateItemCreator(const QString&)));
m_d->model->attachView(m_d->formEditorView.data());
m_d->model->attachView(m_d->itemLibraryView.data());
if (!m_d->textEdit->parent()) // hack to prevent changing owner of external text edit
......
......@@ -51,7 +51,7 @@ class ModelNode;
class TextModifier;
class QmlObjectNode;
class RewriterView;
class ItemLibrary;
class ItemLibraryView;
class NavigatorView;
class AllPropertiesBox;
class StatesEditorView;
......@@ -89,7 +89,7 @@ public:
QString contextHelpId() const;
QList<RewriterView::Error> qmlErrors() const;
void setItemLibrary(ItemLibrary* itemLibrary);
void setItemLibraryView(ItemLibraryView* itemLibraryView);
void setNavigator(NavigatorView* navigatorView);
void setAllPropertiesBox(AllPropertiesBox* allPropertiesBox);
void setStatesEditorView(StatesEditorView* statesEditorView);
......
......@@ -39,7 +39,7 @@ QT_END_NAMESPACE
namespace QmlDesigner {
class ItemLibrary;
class ItemLibraryWidget;
class FormWindowManager;
class PluginManager;
class CorePrivate;
......
......@@ -6,8 +6,8 @@ VPATH += $$PWD
INCLUDEPATH += $$PWD
# Input
HEADERS += itemlibrary.h customdraganddrop.h itemlibrarymodel.h itemlibrarywidgets.h itemlibraryimageprovider.h
SOURCES += itemlibrary.cpp customdraganddrop.cpp itemlibrarymodel.cpp itemlibrarywidgets.cpp itemlibraryimageprovider.cpp
HEADERS += itemlibraryview.h itemlibrarywidget.h customdraganddrop.h itemlibrarymodel.h itemlibrarycomponents.h itemlibraryimageprovider.h
SOURCES += itemlibraryview.cpp itemlibrarywidget.cpp customdraganddrop.cpp itemlibrarymodel.cpp itemlibrarycomponents.cpp itemlibraryimageprovider.cpp
RESOURCES += itemlibrary.qrc
OTHER_FILES += \
......
......@@ -27,8 +27,7 @@
**
**************************************************************************/
#include "itemlibrarywidgets.h"
#include "itemlibrary.h"
#include "itemlibrarycomponents.h"
#include "customdraganddrop.h"
#include <QtCore/QMimeData>
......
#include "itemlibraryview.h"
#include "itemlibrarywidget.h"
namespace QmlDesigner {
ItemLibraryView::ItemLibraryView(QObject* parent) : AbstractView(parent), m_widget(new ItemLibraryWidget)
{
}
ItemLibraryView::~ItemLibraryView()
{
}
ItemLibraryWidget *ItemLibraryView::widget()
{
return m_widget.data();
}
void ItemLibraryView::modelAttached(Model *model)
{
AbstractView::modelAttached(model);
}
void ItemLibraryView::modelAboutToBeDetached(Model *model)
{
AbstractView::modelAboutToBeDetached(model);
}
void ItemLibraryView::importAdded(const Import &import)
{
}
void ItemLibraryView::importRemoved(const Import &import)
{
}
void ItemLibraryView::nodeCreated(const ModelNode &)
{
}
void ItemLibraryView::nodeRemoved(const ModelNode &, const NodeAbstractProperty &, PropertyChangeFlags)
{
}
void ItemLibraryView::propertiesRemoved(const QList<AbstractProperty> &)
{
}
void ItemLibraryView::variantPropertiesChanged(const QList<VariantProperty> &, PropertyChangeFlags)
{
}
void ItemLibraryView::bindingPropertiesChanged(const QList<BindingProperty> &, PropertyChangeFlags)
{
}
void ItemLibraryView::nodeAboutToBeRemoved(const ModelNode &)
{
}
void ItemLibraryView::nodeOrderChanged(const NodeListProperty &, const ModelNode &, int)
{
}
void ItemLibraryView::nodeAboutToBeReparented(const ModelNode &, const NodeAbstractProperty &, const NodeAbstractProperty &, AbstractView::PropertyChangeFlags)
{
}
void ItemLibraryView::nodeReparented(const ModelNode &, const NodeAbstractProperty &, const NodeAbstractProperty &, AbstractView::PropertyChangeFlags)
{
}
void ItemLibraryView::rootNodeTypeChanged(const QString &, int , int )
{
}
void ItemLibraryView::nodeIdChanged(const ModelNode &, const QString &, const QString& )
{
}
void ItemLibraryView::propertiesAboutToBeRemoved(const QList<AbstractProperty>& )
{
}
void ItemLibraryView::selectedNodesChanged(const QList<ModelNode> &,
const QList<ModelNode> &)
{
}
void ItemLibraryView::auxiliaryDataChanged(const ModelNode &, const QString &, const QVariant &)
{
}
void ItemLibraryView::scriptFunctionsChanged(const ModelNode &, const QStringList &)
{
}
void ItemLibraryView::instancePropertyChange(const QList<QPair<ModelNode, QString> > &)
{
}
void ItemLibraryView::instancesCompleted(const QVector<ModelNode> &)
{
}
} //QmlDesigner
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef ITEMLIBRARYVIEW_H
#define ITEMLIBRARYVIEW_H
#include <abstractview.h>
#include <QWeakPointer>
namespace QmlDesigner {
class ItemLibraryWidget;
class ItemLibraryView : public AbstractView
{
Q_OBJECT
public:
ItemLibraryView(QObject* parent = 0);
~ItemLibraryView();
ItemLibraryWidget *widget();
// AbstractView
void modelAttached(Model *model);
void modelAboutToBeDetached(Model *model);
void importAdded(const Import &import);
void importRemoved(const Import &import);
void nodeCreated(const ModelNode &createdNode);
void nodeRemoved(const ModelNode &removedNode, const NodeAbstractProperty &parentProperty, PropertyChangeFlags propertyChange);
void propertiesRemoved(const QList<AbstractProperty> &propertyList);
void variantPropertiesChanged(const QList<VariantProperty> &propertyList, PropertyChangeFlags propertyChange);
void bindingPropertiesChanged(const QList<BindingProperty> &propertyList, PropertyChangeFlags propertyChange);
void nodeAboutToBeRemoved(const ModelNode &removedNode);
void nodeOrderChanged(const NodeListProperty &listProperty, const ModelNode &movedNode, int oldIndex);
void nodeAboutToBeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
void nodeReparented(const ModelNode &node, const NodeAbstractProperty &newPropertyParent, const NodeAbstractProperty &oldPropertyParent, AbstractView::PropertyChangeFlags propertyChange);
void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion);
void nodeIdChanged(const ModelNode& node, const QString& newId, const QString& oldId);
void propertiesAboutToBeRemoved(const QList<AbstractProperty>& propertyList);
void selectedNodesChanged(const QList<ModelNode> &selectedNodeList,
const QList<ModelNode> &lastSelectedNodeList);
void auxiliaryDataChanged(const ModelNode &node, const QString &name, const QVariant &data);
void scriptFunctionsChanged(const ModelNode &node, const QStringList &scriptFunctionList);
void instancePropertyChange(const QList<QPair<ModelNode, QString> > &propertyList);
void instancesCompleted(const QVector<ModelNode> &completedNodeList);
private:
QWeakPointer<ItemLibraryWidget> m_widget;
};
}
#endif // ITEMLIBRARYVIEW_H
......@@ -27,10 +27,10 @@
**
**************************************************************************/
#include "itemlibrary.h"
#include "itemlibrarywidget.h"
#include <utils/filterlineedit.h>
#include "itemlibrarywidgets.h"
#include "itemlibrarycomponents.h"
#include "itemlibrarymodel.h"
#include "itemlibraryimageprovider.h"
#include "customdraganddrop.h"
......@@ -92,9 +92,9 @@ private:
// ---------- ItemLibraryPrivate
class ItemLibraryPrivate {
class ItemLibraryWidgetPrivate {
public:
ItemLibraryPrivate(QObject *object);
ItemLibraryWidgetPrivate(QObject *object);
Internal::ItemLibraryModel *m_itemLibraryModel;
QDirModel *m_resourcesDirModel;
......@@ -109,7 +109,7 @@ public:
MyFileIconProvider m_iconProvider;
};
ItemLibraryPrivate::ItemLibraryPrivate(QObject *object) :
ItemLibraryWidgetPrivate::ItemLibraryWidgetPrivate(QObject *object) :
m_itemLibraryModel(0),
m_resourcesDirModel(0),
m_stackedWidget(0),
......@@ -123,9 +123,9 @@ ItemLibraryPrivate::ItemLibraryPrivate(QObject *object) :
Q_UNUSED(object);
}
ItemLibrary::ItemLibrary(QWidget *parent) :
ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) :
QFrame(parent),
m_d(new ItemLibraryPrivate(this))
m_d(new ItemLibraryWidgetPrivate(this))
{
setWindowTitle(tr("Library", "Title of library view"));
......@@ -230,7 +230,7 @@ ItemLibrary::ItemLibrary(QWidget *parent) :
}
}
ItemLibrary::~ItemLibrary()
ItemLibraryWidget::~ItemLibraryWidget()
{
/* workaround: delete the items view before the model is deleted.
This prevents qml warnings when the item library is destructed. */
......@@ -239,7 +239,7 @@ ItemLibrary::~ItemLibrary()
delete m_d;
}
void ItemLibrary::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
void ItemLibraryWidget::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
{
if (m_d->m_itemLibraryInfo.data() == itemLibraryInfo)
return;
......@@ -256,7 +256,7 @@ void ItemLibrary::setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo)
updateSearch();
}
void ItemLibrary::setSearchFilter(const QString &searchFilter)
void ItemLibraryWidget::setSearchFilter(const QString &searchFilter)
{
if (m_d->m_stackedWidget->currentIndex() == 0) {
m_d->m_itemLibraryModel->setSearchText(searchFilter);
......@@ -279,25 +279,25 @@ void ItemLibrary::setSearchFilter(const QString &searchFilter)
}
}
void ItemLibrary::updateModel()
void ItemLibraryWidget::updateModel()
{
m_d->m_itemLibraryModel->update(m_d->m_itemLibraryInfo.data());
updateSearch();
}
void ItemLibrary::updateSearch()
void ItemLibraryWidget::updateSearch()
{
setSearchFilter(m_d->m_lineEdit->text());
}
void ItemLibrary::setResourcePath(const QString &resourcePath)
void ItemLibraryWidget::setResourcePath(const QString &resourcePath)
{
if (m_d->m_resourcesView->model() == m_d->m_resourcesDirModel)
m_d->m_resourcesView->setRootIndex(m_d->m_resourcesDirModel->index(resourcePath));
updateSearch();
}
void ItemLibrary::startDragAndDrop(int itemLibId)
void ItemLibraryWidget::startDragAndDrop(int itemLibId)
{
QMimeData *mimeData = m_d->m_itemLibraryModel->getMimeData(itemLibId);
CustomItemLibraryDrag *drag = new CustomItemLibraryDrag(this);
......@@ -313,12 +313,12 @@ void ItemLibrary::startDragAndDrop(int itemLibId)
drag->exec();
}
void ItemLibrary::showItemInfo(int /*itemLibId*/)
void ItemLibraryWidget::showItemInfo(int /*itemLibId*/)
{
// qDebug() << "showing item info about id" << itemLibId;
}
void ItemLibrary::wheelEvent(QWheelEvent *event)
void ItemLibraryWidget::wheelEvent(QWheelEvent *event)
{
if (m_d->m_stackedWidget->currentIndex() == 0 &&
m_d->m_itemsView->rect().contains(event->pos())) {
......
......@@ -27,26 +27,26 @@
**
**************************************************************************/
#ifndef ITEMLIBRARY_H
#define ITEMLIBRARY_H
#ifndef ITEMLIBRARYWIDGET_H
#define ITEMLIBRARYWIDGET_H
#include "itemlibraryinfo.h"
#include <QtGui/QFrame>
namespace QmlDesigner {
class ItemLibraryPrivate;
class ItemLibraryWidgetPrivate;
class MetaInfo;
class ItemLibraryEntry;
class ItemLibrary : public QFrame
class ItemLibraryWidget : public QFrame
{
Q_OBJECT
Q_DISABLE_COPY(ItemLibrary)
Q_DISABLE_COPY(ItemLibraryWidget)
public:
ItemLibrary(QWidget *parent = 0);
virtual ~ItemLibrary();
ItemLibraryWidget(QWidget *parent = 0);
virtual ~ItemLibraryWidget();
void setItemLibraryInfo(ItemLibraryInfo *itemLibraryInfo);
......@@ -69,10 +69,10 @@ signals:
void resetItemsView();
private:
ItemLibraryPrivate *m_d;
ItemLibraryWidgetPrivate *m_d;
};
}
#endif // ITEMLIBRARY_H
#endif // ITEMLIBRARYWIDGET_H
......@@ -36,6 +36,8 @@
#include <rewriterview.h>
#include <formeditorwidget.h>
#include <stateseditorwidget.h>
#include <itemlibrarywidget.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/modemanager.h>
......@@ -263,7 +265,7 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
newDocument->setAllPropertiesBox(m_allPropertiesBox.data());
newDocument->setNavigator(m_navigator.data());
newDocument->setStatesEditorView(m_statesEditorView.data());
newDocument->setItemLibrary(m_itemLibrary.data());
newDocument->setItemLibraryView(m_itemLibraryView.data());
newDocument->setFormEditorView(m_formEditorView.data());
......@@ -626,7 +628,7 @@ void DesignModeWidget::setup()
// Sidebar takes ownership
m_navigator = new NavigatorView;
m_allPropertiesBox = new AllPropertiesBox;
m_itemLibrary = new ItemLibrary;
m_itemLibraryView = new ItemLibraryView(this);
m_statesEditorView = new StatesEditorView(this);
......@@ -642,7 +644,7 @@ void DesignModeWidget::setup()
m_warningWidget->setVisible(false);
Core::SideBarItem *navigatorItem = new Core::SideBarItem(m_navigator->widget(), QLatin1String(SB_NAVIGATOR));
Core::SideBarItem *libraryItem = new Core::SideBarItem(m_itemLibrary.data(), QLatin1String(SB_LIBRARY));
Core::SideBarItem *libraryItem = new Core::SideBarItem(m_itemLibraryView->widget(), QLatin1String(SB_LIBRARY));
Core::SideBarItem *propertiesItem = new Core::SideBarItem(m_allPropertiesBox.data(), QLatin1String(SB_PROPERTIES));
// default items
......
......@@ -38,7 +38,7 @@
#include <allpropertiesbox.h>
#include <designdocumentcontroller.h>
#include <itemlibrary.h>
#include <itemlibraryview.h>
#include <navigatorwidget.h>
#include <navigatorview.h>
#include <stateseditorview.h>
......@@ -174,7 +174,7 @@ private:
QAction *m_toggleLeftSidebarAction;
QAction *m_toggleRightSidebarAction;
QWeakPointer<ItemLibrary> m_itemLibrary;
QWeakPointer<ItemLibraryView> m_itemLibraryView;
QWeakPointer<NavigatorView> m_navigator;
QWeakPointer<AllPropertiesBox> m_allPropertiesBox;
QWeakPointer<StatesEditorView> m_statesEditorView;
......
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