[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] flow/src/plugins/dockers/shapeboxdocker
From:       Yue Liu <opuspace () gmail ! com>
Date:       2011-01-20 5:16:58
Message-ID: 20110120051658.E558BA6092 () git ! kde ! org
[Download RAW message or body]

Git commit 1b1b48a355f3d381d0916901f45c6657a73f20b4 by Yue Liu
Pushed by liu into branch master

fix wrong merge

D  +0    -122  flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.cpp     
D  +0    -72   flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.h     
D  +0    -120  flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.cpp     \
 D  +0    -39   flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.h     
D  +0    -344  flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.cpp     
D  +0    -82   flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.h     
D  +0    -433  flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.cpp     
D  +0    -109  flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.h     
D  +0    -341  flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.cpp     
D  +0    -108  flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.h     

http://commits.kde.org/47e7010d/1b1b48a355f3d381d0916901f45c6657a73f20b4

diff --git a/flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.cpp \
b/flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.cpp deleted file mode \
100644 index fddb2b1..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#include "CollectionItemModel.h"
-
-#include <KoShapeFactoryBase.h>
-
-#include <kdebug.h>
-
-#include <QMimeData>
-
-CollectionItemModel::CollectionItemModel(QObject* parent)
-    : QAbstractListModel(parent)
-{
-    setSupportedDragActions(Qt::CopyAction);
-}
-
-QVariant CollectionItemModel::data(const QModelIndex& index, int role) const
-{
-    if (!index.isValid() || index.row() > m_shapeTemplateList.count ())
-        return QVariant();
-
-    switch(role)
-    {
-        case Qt::ToolTipRole:
-            return m_shapeTemplateList[index.row()].toolTip;
-
-        case Qt::DecorationRole:
-            return m_shapeTemplateList[index.row()].icon;
-
-        case Qt::UserRole:
-            return m_shapeTemplateList[index.row()].id;
-
-        case Qt::DisplayRole:
-            return m_shapeTemplateList[index.row()].name;
-
-        default:
-            return QVariant();
-    }
-
-    return QVariant();
-}
-
-int CollectionItemModel::rowCount(const QModelIndex& parent) const
-{
-    Q_UNUSED(parent);
-    return m_shapeTemplateList.count();
-}
-
-void CollectionItemModel::setShapeTemplateList(const QList<KoCollectionItem>& \
                newlist)
-{
-    m_shapeTemplateList = newlist;
-    reset();
-}
-
-QMimeData* CollectionItemModel::mimeData(const QModelIndexList& indexes) const
-{
-    if(indexes.isEmpty())
-        return 0;
-
-    QModelIndex index = indexes.first();
-
-    if(!index.isValid())
-        return 0;
-
-    if(m_shapeTemplateList.isEmpty())
-        return 0;
-
-    QByteArray itemData;
-    QDataStream dataStream(&itemData, QIODevice::WriteOnly);
-    dataStream << m_shapeTemplateList[index.row()].id;
-    KoProperties *props = m_shapeTemplateList[index.row()].properties;
-
-    if(props)
-        dataStream << props->store("shapes");
-    else
-        dataStream << QString();
-
-    QMimeData* mimeData = new QMimeData;
-    mimeData->setData(SHAPETEMPLATE_MIMETYPE, itemData);
-
-    return mimeData;
-}
-
-QStringList CollectionItemModel::mimeTypes() const
-{
-    QStringList mimetypes;
-    mimetypes << SHAPETEMPLATE_MIMETYPE;
-
-    return mimetypes;
-}
-
-Qt::ItemFlags CollectionItemModel::flags(const QModelIndex& index) const
-{
-    if(index.isValid())
-        return QAbstractListModel::flags(index) | Qt::ItemIsDragEnabled;
-
-    return QAbstractListModel::flags(index);
-}
-
-KoProperties* CollectionItemModel::properties(const QModelIndex& index) const
-{
-    if (!index.isValid() || index.row() > m_shapeTemplateList.count())
-        return 0;
-
-    return m_shapeTemplateList[index.row()].properties;
-}
diff --git a/flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.h \
b/flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.h deleted file mode \
100644 index fbaa4a7..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/CollectionItemModel.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef FLOWSHAPETEMPLATEMODEL_H
-#define FLOWSHAPETEMPLATEMODEL_H
-
-#include <KoProperties.h>
-#include <KoShape.h>
-
-#include <QAbstractItemModel>
-#include <QList>
-#include <QString>
-#include <QIcon>
-
-/**
- * Struct containing the information stored in CollectionItemModel item
- */
-struct KoCollectionItem
-{
-    KoCollectionItem()
-    {
-        properties = 0;
-    }
-
-    QString id;
-    QString name;
-    QString toolTip;
-    QIcon icon;
-    KoProperties* properties;
-};
-
-class CollectionItemModel : public QAbstractListModel
-{
-    Q_OBJECT
-    public:
-        CollectionItemModel(QObject* parent = 0);
-
-        virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) \
                const;
-        virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
-        virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
-        virtual QStringList mimeTypes() const;
-        virtual Qt::ItemFlags flags(const QModelIndex& index) const;
-
-        /**
-         * Set the list of KoCollectionItem to be stored in the model
-         */
-        void setShapeTemplateList(const QList<KoCollectionItem>& newlist);
-        QList<KoCollectionItem> shapeTemplateList () const { return \
                m_shapeTemplateList; }
-
-        KoProperties* properties(const QModelIndex& index) const;
-
-    private:
-        QList<KoCollectionItem> m_shapeTemplateList;
-        QString m_family;
-};
-
-#endif //FLOWSHAPETEMPLATEMODEL_H
diff --git a/flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.cpp \
b/flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.cpp deleted file \
mode 100644 index 020e1af..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "CollectionShapeFactory.h"
-
-#include <KoShape.h>
-#include <KoDrag.h>
-#include <KoShapeOdfSaveHelper.h>
-#include <KoOdf.h>
-#include <KoShapeLoadingContext.h>
-#include <KoShapeControllerBase.h>
-#include <KoOdfLoadingContext.h>
-#include <KoStore.h>
-#include <KoOdfReadStore.h>
-#include <KoXmlNS.h>
-#include <KoShapeRegistry.h>
-
-#include <kdebug.h>
-
-#include <QMimeData>
-#include <QBuffer>
-
-CollectionShapeFactory::CollectionShapeFactory(const QString &id, KoShape* shape)
-    : KoShapeFactoryBase(id, shape->name()), m_shape(shape)
-{
-}
-
-CollectionShapeFactory::~CollectionShapeFactory()
-{
-    delete m_shape;
-}
-
-KoShape *CollectionShapeFactory::createDefaultShape(KoResourceManager \
                *documentResources) const
-{
-    QList<KoShape*> shapes;
-
-    shapes << m_shape;
-
-    //kDebug() << m_shape->shapeId();
-
-    KoDrag drag;
-    KoShapeOdfSaveHelper saveHelper(shapes);
-    drag.setOdf(KoOdf::mimeType(KoOdf::Graphics), saveHelper);
-    QMimeData* data = drag.mimeData();
-
-    QByteArray arr = data->data(KoOdf::mimeType(KoOdf::Graphics));
-    KoShape* shape = 0;
-
-    if ( !arr.isEmpty() ) {
-        QBuffer buffer( &arr );
-        KoStore * store = KoStore::createStore( &buffer, KoStore::Read );
-        KoOdfReadStore odfStore( store ); // Note: KoDfReadstore will not delete the \
                KoStore *store;
-
-        QString errorMessage;
-        if ( ! odfStore.loadAndParse( errorMessage ) ) {
-            kError() << "loading and parsing failed:" << errorMessage << endl;
-            delete store;
-            return 0;
-        }
-
-        KoXmlElement content = odfStore.contentDoc().documentElement();
-        KoXmlElement realBody( KoXml::namedItemNS( content, KoXmlNS::office, "body" \
                ) );
-
-        if ( realBody.isNull() ) {
-            kError() << "No body tag found!" << endl;
-            delete store;
-            return 0;
-        }
-
-        KoXmlElement body = KoXml::namedItemNS( realBody, KoXmlNS::office, \
                KoOdf::bodyContentElement( KoOdf::Text, false ) );
-
-        if ( body.isNull() ) {
-            kError() << "No" << KoOdf::bodyContentElement(KoOdf::Text, true ) << \
                "tag found!" << endl;
-            delete store;
-            return 0;
-        }
-
-        KoOdfLoadingContext loadingContext(odfStore.styles(), odfStore.store());
-        KoShapeLoadingContext context(loadingContext, documentResources);
-
-        KoXmlElement element;
-
-        forEachElement(element, body)
-        {
-            KoShape * shape = KoShapeRegistry::instance()->createShapeFromOdf( \
                element, context );
-            if ( shape ) {
-                delete data;
-                delete store;
-                return shape;
-            }
-        }
-        delete store;
-    }
-
-    delete data;
-    return shape;
-}
-
-bool CollectionShapeFactory::supports(const KoXmlElement &e, KoShapeLoadingContext \
                &context) const
-{
-    Q_UNUSED(e);
-    Q_UNUSED(context);
-    return false;
-}
diff --git a/flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.h \
b/flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.h deleted file mode \
100644 index 870fe2e..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/CollectionShapeFactory.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef KOCOLLECTIONSHAPEFACTORY_H
-#define KOCOLLECTIONSHAPEFACTORY_H
-
-#include <KoShapeFactoryBase.h>
-
-class KoShapeControllerBase;
-
-class CollectionShapeFactory : public KoShapeFactoryBase
-{
-    public:
-        CollectionShapeFactory(const QString &id, KoShape* shape);
-        ~CollectionShapeFactory();
-
-        virtual KoShape *createDefaultShape(KoResourceManager *documentResources = \
                0) const;
-        virtual bool supports(const KoXmlElement &e, KoShapeLoadingContext &context) \
                const;
-
-    private:
-        KoShape* m_shape;
-};
-
-#endif //KOCOLLECTIONSHAPEFACTORY_H
diff --git a/flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.cpp \
b/flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.cpp deleted file mode \
100644 index 6216389..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- * Copyright (C) 2010 Yue Liu <opuspace@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "OdfCollectionLoader.h"
-
-#include <KoStore.h>
-#include <KoOdfReadStore.h>
-#include <KoOdfLoadingContext.h>
-#include <KoXmlNS.h>
-#include <KoShape.h>
-#include <KoShapeRegistry.h>
-#include <KoShapeLoadingContext.h>
-#include <KoFilterManager.h>
-#include <KoOdf.h>
-
-#include <klocale.h>
-#include <kdebug.h>
-#include <kmimetype.h>
-
-#include <QTimer>
-#include <QDir>
-#include <QFile>
-#include <QByteArray>
-
-OdfCollectionLoader::OdfCollectionLoader(const QString& path, const QString& family, \
                QObject* parent)
-    : QObject(parent)
-{
-    m_family = family;
-    m_path = path;
-    m_odfStore = 0;
-    m_shapeLoadingContext = 0;
-    m_loadingContext = 0;
-    m_filterManager = 0;
-
-    m_loadingTimer = new QTimer(this);
-    m_loadingTimer->setInterval(0);
-    connect(m_loadingTimer, SIGNAL(timeout()),
-            this, SLOT(loadShape()));
-}
-
-OdfCollectionLoader::~OdfCollectionLoader()
-{
-    delete m_filterManager;
-    m_filterManager = 0;
-    delete m_shapeLoadingContext;
-    delete m_loadingContext;
-    m_shapeLoadingContext = 0;
-    m_loadingContext = 0;
-
-    if(m_odfStore)
-    {
-        delete m_odfStore->store();
-        delete m_odfStore;
-        m_odfStore = 0;
-    }
-}
-
-void OdfCollectionLoader::load()
-{
-    QDir dir(m_path);
-    m_fileList = dir.entryList(QStringList() << "*.odg" << "*.svg", QDir::Files);
-
-    if(m_fileList.isEmpty())
-    {
-        kError() << "Found no shapes in the collection!" << m_path;
-        emit loadingFailed(i18n("Found no shapes in the collection! %1", m_path));
-        return;
-    }
-
-    nextFile();
-}
-
-void OdfCollectionLoader::loadShape()
-{
-    //kDebug() << m_shape.tagName();
-    KoShape * shape = KoShapeRegistry::instance()->createShapeFromOdf(m_shape, \
                *m_shapeLoadingContext);
-
-    if (shape) {
-        if(!shape->parent()) {
-            //QString temp = shape->name().section(KGlobal::locale()->language(), 1, \
                1);
-            //shape->setName(temp.section(":", 0, 0));
-            m_shapeList.append(shape);
-        }
-    }
-
-    // TODO we need a next element here.
-    KoXmlNode child = m_shape.nextSibling();
-    m_shape = KoXmlElement();
-    while (!child.isNull()) {
-        m_shape = child.toElement();
-        if (!m_shape.isNull()) {
-            break;
-        }
-        child = child.nextSibling();
-    }
-
-    if(m_shape.isNull())
-    {
-        m_page = m_page.nextSibling().toElement();
-
-        if(m_page.isNull())
-        {
-            m_loadingTimer->stop();
-
-            if(m_fileList.isEmpty())
-            {
-                emit loadingFinished();
-            }
-            else
-            {
-                nextFile();
-            }
-        }
-        else
-        {
-            m_shape = m_page.firstChild().toElement();
-        }
-    }
-}
-
-void OdfCollectionLoader::nextFile()
-{
-    QString file = m_fileList.takeFirst();
-    QString filepath = m_path + file;
-    KUrl u;
-    u.setPath(filepath);
-    QString mimetype = findMimeTypeByUrl(u);
-
-    QString importedFile = filepath;
-
-    if(mimetype != KoOdf::mimeType(KoOdf::Graphics))
-    {
-        if(!m_filterManager)
-            m_filterManager = new \
                KoFilterManager(QByteArray(KoOdf::mimeType(KoOdf::Graphics)));
-        KoFilter::ConversionStatus status;
-        importedFile = m_filterManager->importDocument(filepath, status);
-        //kDebug() << "File:" << filepath << "Import:" << importedFile;
-
-        if(status != KoFilter::OK)
-        {
-            QString msg;
-
-            switch(status)
-            {
-                case KoFilter::OK: break;
-
-                case KoFilter::CreationError:
-                    msg = i18n( "Creation error" ); break;
-
-                case KoFilter::FileNotFound:
-                    msg = i18n( "File not found" ); break;
-
-                case KoFilter::StorageCreationError:
-                    msg = i18n( "Cannot create storage" ); break;
-
-                case KoFilter::BadMimeType:
-                    msg = i18n( "Bad MIME type" ); break;
-
-                case KoFilter::EmbeddedDocError:
-                    msg = i18n( "Error in embedded document" ); break;
-
-                case KoFilter::WrongFormat:
-                    msg = i18n( "Format not recognized" ); break;
-
-                case KoFilter::NotImplemented:
-                    msg = i18n( "Not implemented" ); break;
-
-                case KoFilter::ParsingError:
-                    msg = i18n( "Parsing error" ); break;
-
-                case KoFilter::PasswordProtected:
-                    msg = i18n( "Document is password protected" ); break;
-
-                case KoFilter::InternalError:
-                case KoFilter::UnexpectedEOF:
-                case KoFilter::UnexpectedOpcode:
-                case KoFilter::StupidError: // ?? what is this ??
-                case KoFilter::UsageError:
-                    msg = i18n( "Internal error" ); break;
-
-                case KoFilter::OutOfMemory:
-                    msg = i18n( "Out of memory" ); break;
-
-                case KoFilter::UserCancelled:
-                case KoFilter::BadConversionGraph:
-                    // intentionally we do not prompt the error message here
-                    break;
-
-                    default: msg = i18n( "Unknown error" ); break;
-            }
-
-            if(!msg.isEmpty())
-            {
-                QString errorMsg(i18n("Could not open\n%2.\nReason: %1", msg, \
                filepath));
-                emit loadingFailed(errorMsg);
-            }
-
-            return;
-        }
-    }
-
-    if(!importedFile.isEmpty()) // Something to load (tmp or native file) ?
-    {
-        loadNativeFile(importedFile);
-        if (importedFile != filepath)
-        {
-            QFile::remove(importedFile);
-        }
-    } else {
-        emit loadingFailed(i18n("Failed to import the file: %1", filepath));
-    }
-}
-
-void OdfCollectionLoader::loadNativeFile(const QString& path)
-{
-    delete m_shapeLoadingContext;
-    delete m_loadingContext;
-    m_shapeLoadingContext = 0;
-    m_loadingContext = 0;
-
-    if(m_odfStore)
-    {
-        delete m_odfStore->store();
-        delete m_odfStore;
-        m_odfStore = 0;
-    }
-
-    KoStore* store = KoStore::createStore(path, KoStore::Read);
-
-    if(store->bad())
-    {
-        emit loadingFailed(i18n("Not a valid KOffice file: %1", m_path));
-        delete store;
-        return;
-    }
-
-    store->disallowNameExpansion();
-    m_odfStore = new KoOdfReadStore(store);
-    QString errorMessage;
-
-    if(!m_odfStore->loadAndParse(errorMessage))
-    {
-        emit loadingFailed(errorMessage);
-        return;
-    }
-
-    KoOdfLoadingContext* m_loadingContext = new \
                KoOdfLoadingContext(m_odfStore->styles(), m_odfStore->store());
-    // it ok here to pass an empty resourceManager as we don't have a document
-    // tz: not sure if that is 100% correct what if an image is loaded in the \
                collection it needs a image collection
-    m_shapeLoadingContext = new KoShapeLoadingContext(*m_loadingContext, 0);
-
-    KoXmlElement content = m_odfStore->contentDoc().documentElement();
-    KoXmlElement realBody ( KoXml::namedItemNS( content, KoXmlNS::office, "body" ) \
                );
-
-    if (realBody.isNull()) {
-        kError() << "No body tag found!" << endl;
-        emit loadingFailed(i18n("No body tag found in file: %1", path));
-        return;
-    }
-
-    m_body = KoXml::namedItemNS(realBody, KoXmlNS::office, "drawing");
-
-    if (m_body.isNull()) {
-        kError() << "No office:drawing tag found!" << endl;
-        emit loadingFailed(i18n("No office:drawing tag found in file: %1", path));
-        return;
-    }
-
-    //m_page = m_body.firstChild().toElement();
-    m_page = KoXml::namedItemNS(m_body, KoXmlNS::draw, "page");
-
-    if (m_page.isNull()) {
-        kError() << "No page found!" << endl;
-        emit loadingFailed(i18n("No page found in file: %1", path));
-        return;
-    }
-
-    KoXmlNode child = m_page.firstChild();
-    while (!child.isNull()) {
-        m_shape = child.toElement();
-        if (!m_shape.isNull()) {
-            break;
-        }
-        child = child.nextSibling();
-    }
-
-    if (m_shape.isNull()) {
-        kError() << "No shapes found!" << endl;
-        emit loadingFailed(i18n("No shapes found in file: %1", path));
-        return;
-    }
-
-    m_loadingTimer->start();
-}
-
-QString OdfCollectionLoader::findMimeTypeByUrl(const KUrl& url)
-{
-    //
-    // The following code was copied from KoDocument::openFile()
-    //
-    QString typeName = KMimeType::findByUrl(url, 0, true)->name();
-
-    // Allow to open backup files, don't keep the mimetype application/x-trash.
-    if (typeName == "application/x-trash")
-    {
-        QString path = url.path();
-        KMimeType::Ptr mime = KMimeType::mimeType(typeName);
-        QStringList patterns = mime ? mime->patterns() : QStringList();
-
-        // Find the extension that makes it a backup file, and remove it
-        for(QStringList::Iterator it = patterns.begin(); it != patterns.end(); ++it) \
                {
-            QString ext = *it;
-            if (!ext.isEmpty() && ext[0] == '*')
-            {
-                ext.remove(0, 1);
-                if (path.endsWith(ext)) {
-                    path.truncate(path.length() - ext.length());
-                    break;
-                }
-            }
-        }
-
-        typeName = KMimeType::findByPath(path, 0, true)->name();
-    }
-
-    return typeName;
-}
diff --git a/flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.h \
b/flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.h deleted file mode \
100644 index a900a4a..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/OdfCollectionLoader.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* This file is part of the KDE project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- * Copyright (C) 2010 Yue Liu <opuspace@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef KOODFCOLLECTIONLOADER_H
-#define KOODFCOLLECTIONLOADER_H
-
-#include <kurl.h>
-
-#include <KoXmlReader.h>
-
-#include <QObject>
-#include <QList>
-#include <QStringList>
-
-class KoOdfReadStore;
-class KoOdfLoadingContext;
-class KoShapeLoadingContext;
-class QTimer;
-class KoShape;
-class KoFilterManager;
-
-class OdfCollectionLoader : public QObject
-{
-    Q_OBJECT
-    public:
-        explicit OdfCollectionLoader(const QString& path, const QString& family, \
                QObject* parent = 0);
-        ~OdfCollectionLoader();
-
-        void load();
-
-        QList<KoShape*> shapeList() const { return m_shapeList; }
-        QString collectionPath() const { return m_path; }
-        QString collectionFamily() const { return m_family; }
-    protected:
-        void nextFile();
-        void loadNativeFile(const QString& path);
-        QString findMimeTypeByUrl(const KUrl& url);
-
-    protected slots:
-        void loadShape();
-
-    private:
-        KoOdfReadStore* m_odfStore;
-        QTimer* m_loadingTimer;
-        KoOdfLoadingContext* m_loadingContext;
-        KoShapeLoadingContext* m_shapeLoadingContext;
-        KoXmlElement m_body;
-        KoXmlElement m_page;
-        KoXmlElement m_shape;
-        QList<KoShape*> m_shapeList;
-        QString m_family;
-        QString m_path;
-        QStringList m_fileList;
-        KoFilterManager* m_filterManager;
-
-    signals:
-        /**
-         * Emitted when the loading failed
-         * @param reason Reason the loading failed.
-         */
-        void loadingFailed(const QString& reason);
-
-        void loadingFinished();
-};
-
-#endif //KOODFCOLLECTIONLOADER_H
diff --git a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.cpp \
b/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.cpp deleted file mode 100644
index e87da8a..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.cpp
+++ /dev/null
@@ -1,433 +0,0 @@
-/* Part of the KOffice project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- * Copyright (C) 2010 Yue Liu <opuspace@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "ShapeBoxDocker.h"
-
-#include "OdfCollectionLoader.h"
-#include "CollectionShapeFactory.h"
-#include "ShapeBoxView.h"
-
-#include <KoShapeFactoryBase.h>
-#include <KoShapeRegistry.h>
-#include <KoCanvasController.h>
-#include <KoToolManager.h>
-#include <KoCreateShapesTool.h>
-#include <KoShape.h>
-#include <KoShapeGroup.h>
-#include <KoShapeBorderModel.h>
-#include <KoZoomHandler.h>
-
-#include <klocale.h>
-#include <kcombobox.h>
-#include <kdebug.h>
-#include <kiconloader.h>
-#include <kstandarddirs.h>
-#include <kcomponentdata.h>
-#include <kdesktopfile.h>
-#include <kconfiggroup.h>
-#include <kicon.h>
-#include <kmessagebox.h>
-#include <klineedit.h>
-
-#include <QVBoxLayout>
-#include <QListView>
-#include <QStandardItemModel>
-#include <QRegExp>
-#include <QSortFilterProxyModel>
-#include <QList>
-#include <QSize>
-#include <QToolButton>
-#include <QDir>
-#include <QMenu>
-#include <QPainter>
-
-//
-// ShapeBoxDockerFactory
-//
-
-ShapeBoxDockerFactory::ShapeBoxDockerFactory()
-    : KoDockFactoryBase()
-{
-}
-
-QString ShapeBoxDockerFactory::id() const
-{
-    return QString("FlowShapeBoxDocker");
-}
-
-QDockWidget* ShapeBoxDockerFactory::createDockWidget()
-{
-    ShapeBoxDocker* docker = new ShapeBoxDocker();
-    return docker;
-}
-
-//
-// ShapeBoxDocker
-//
-
-ShapeBoxDocker::ShapeBoxDocker(QWidget* parent)
-    : QDockWidget(parent)
-{
-    setWindowTitle(i18n("Shape Box"));
-    QWidget* mainWidget = new QWidget(this);
-    setWidget(mainWidget);
-
-    //menu is currently unfinished
-    m_menu = new QMenu();
-    QAction* getOnlineAction = m_menu->addAction(i18n("Download shape collections \
                online"));
-    QAction* installLocalAction = m_menu->addAction(i18n("Install local collection \
                file"));
-    QAction* createNewAction = m_menu->addAction(i18n("Create a new collection"));
-    connect(getOnlineAction, SIGNAL(triggered()), this, \
                SLOT(getCollectionOnline()));
-    connect(installLocalAction, SIGNAL(triggered()), this, \
                SLOT(installLocalCollection()));
-    connect(createNewAction, SIGNAL(triggered()), this, \
                SLOT(createNewCollection()));
-
-    m_button = new QToolButton;
-    m_button->setIcon(SmallIcon("list-add"));
-    m_button->setToolTip(i18n("More shapes"));
-    m_button->setMenu(m_menu);
-    m_button->setPopupMode(QToolButton::InstantPopup);
-
-    m_filterLineEdit = new KLineEdit;
-#if QT_VERSION >= 0x040700
-    m_filterLineEdit->setPlaceholderText(i18n("Filter"));
-#endif
-    m_filterLineEdit->setClearButtonShown(true);
-
-    m_treeWidget = new CollectionTreeWidget(mainWidget);
-    m_treeWidget->setSelectionMode(QListView::SingleSelection);
-    m_treeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
-    m_panelLayout = new QHBoxLayout();
-    m_panelLayout->addWidget(m_button);
-    m_panelLayout->addWidget(m_filterLineEdit);
-
-    m_layout = new QVBoxLayout(mainWidget);
-    m_layout->addLayout(m_panelLayout);
-    m_layout->addWidget(m_treeWidget);
-    
-    if(! KGlobal::activeComponent().dirs()->resourceDirs("app_shape_collections").isEmpty())
                
-    {
-        loadShapeCollections();
-    }
-    
-    loadDefaultShapes();
-    regenerateProxyMap();
-    m_treeWidget->setFamilyMap(m_proxyMap);
-
-    connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
-            this, SLOT(locationChanged(Qt::DockWidgetArea)));
-    connect(m_filterLineEdit, SIGNAL(textEdited(const QString &)), this, \
                SLOT(reapplyFilter()));
-}
-
-void ShapeBoxDocker::getCollectionOnline()
-{
-    ;//FIXME
-}
-
-void ShapeBoxDocker::installLocalCollection()
-{
-    ;//FIXME
-}
-
-void ShapeBoxDocker::createNewCollection()
-{
-    ;//FIXME
-}
-
-void ShapeBoxDocker::locationChanged(Qt::DockWidgetArea area)
-{
-    switch(area) {
-        case Qt::TopDockWidgetArea:
-        case Qt::BottomDockWidgetArea:
-            break;
-        case Qt::LeftDockWidgetArea:
-        case Qt::RightDockWidgetArea:
-            break;
-        default:
-            break;
-    }
-    m_layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
-    m_layout->invalidate();
-}
-
-void ShapeBoxDocker::reapplyFilter()
-{
-    QRegExp regExp(m_filterLineEdit->originalText(), Qt::CaseInsensitive, \
                QRegExp::RegExp2);
-    foreach(QSortFilterProxyModel* model, m_proxyMap)
-    {
-        model->setFilterRegExp(regExp);
-    }
-    m_treeWidget->filter();
-}
-
-void ShapeBoxDocker::regenerateProxyMap()
-{
-    QMapIterator<QString, CollectionItemModel*> i(m_modelMap);
-    while(i.hasNext())
-    {
-        i.next();
-        QSortFilterProxyModel* proxy = new QSortFilterProxyModel();
-        proxy->setSourceModel(i.value());
-        m_proxyMap.insert(i.key(), proxy);
-    }
-}
-
-/// Generate lists of shapes registered
-void ShapeBoxDocker::loadDefaultShapes()
-{
-    QMap<QString, QList<KoCollectionItem> > familyMap;
-    foreach( const QString & id, KoShapeRegistry::instance()->keys() )
-    {
-        KoShapeFactoryBase *factory = KoShapeRegistry::instance()->value(id);
-        // don't show hidden factories
-        if ( factory->hidden() )
-	{
-            continue;
-        }
-        bool oneAdded = false;
-
-        foreach( const KoShapeTemplate & shapeTemplate, factory->templates() )
-        {
-            oneAdded = true;
-            KoCollectionItem temp;
-            temp.id = shapeTemplate.id;
-            temp.name = shapeTemplate.name;
-            temp.toolTip = shapeTemplate.toolTip;
-            temp.icon = KIcon(shapeTemplate.icon);
-            temp.properties = shapeTemplate.properties;
-
-            if(familyMap.contains(shapeTemplate.family))
-            {
-                familyMap[shapeTemplate.family].append(temp);
-            }
-            else
-            {
-                QList<KoCollectionItem> list;
-                list.append(temp);
-                familyMap.insert(shapeTemplate.family, list);
-            }
-        }
-
-        if(!oneAdded)
-        {
-            KoCollectionItem temp;
-            temp.id = factory->id();
-            temp.name = factory->name();
-            temp.toolTip = factory->toolTip();
-            temp.icon = KIcon(factory->icon());
-            temp.properties = 0;
-
-            if(familyMap.contains(factory->family()))
-            {
-                familyMap[factory->family()].append(temp);
-            }
-            else
-            {
-                QList<KoCollectionItem> list;
-                list.append(temp);
-                familyMap.insert(factory->family(), list);
-            }
-        }
-    }
-
-    QMapIterator<QString, QList<KoCollectionItem> > i(familyMap);
-    while(i.hasNext())
-    {
-        i.next();
-        CollectionItemModel* model = new CollectionItemModel(this);
-        model->setShapeTemplateList(i.value());
-        m_modelMap.insert(i.key(), model);
-    }
-}
-
-/// Load shape collections to m_modelMap and register in the KoShapeRegistry
-void ShapeBoxDocker::loadShapeCollections()
-{
-    QStringList dirs = \
                KGlobal::activeComponent().dirs()->resourceDirs("app_shape_collections");
                
-    foreach(const QString& path, dirs)
-    {
-        QDir dir(path);
-        QStringList collectionDirs = dir.entryList(QDir::Dirs | \
                QDir::NoDotAndDotDot);
-        foreach(const QString & collectionDirName, collectionDirs) {
-            addCollection(path + collectionDirName);
-        }
-    }
-}
-
-bool ShapeBoxDocker::addCollection(const QString& path)
-{
-    QDir dir(path);
-
-    if(!dir.exists("collection.desktop"))
-        return false;
-
-    KDesktopFile collection(dir.absoluteFilePath("collection.desktop"));
-    KConfigGroup dg = collection.desktopGroup();
-    QString family = dg.readEntry("Name");
-    QString type = dg.readEntry("X-KDE-DirType");
-    //kDebug() << family << type;
-
-    if(type == "odg-collection") {
-        if(m_modelMap.contains(family))
-            return true;
-
-        CollectionItemModel* model = new CollectionItemModel(this);
-        m_modelMap.insert(family, model);
-
-        OdfCollectionLoader* loader = new OdfCollectionLoader(path + \
                QDir::separator(), family, this);
-        connect(loader, SIGNAL(loadingFailed(const QString&)),
-                this, SLOT(onLoadingFailed(const QString&)));
-        connect(loader, SIGNAL(loadingFinished()),
-                this, SLOT(onLoadingFinished()));
-
-        loader->load();
-        return true;
-    }
-    else {
-        return false;
-    }
-}
-
-void ShapeBoxDocker::onLoadingFailed(const QString& reason)
-{
-    OdfCollectionLoader* loader = qobject_cast<OdfCollectionLoader*>(sender());
-
-    if(loader)
-    {
-        removeCollection(loader->collectionPath());
-        QList<KoShape*> shapeList = loader->shapeList();
-        qDeleteAll(shapeList);
-        loader->deleteLater();
-    }
-
-    KMessageBox::error (this, reason, i18n("Collection Error"));
-}
-
-void ShapeBoxDocker::onLoadingFinished()
-{
-    OdfCollectionLoader* loader = qobject_cast<OdfCollectionLoader*>(sender());
-
-    if(!loader)
-    {
-        kWarning(31000) << "Not called by a OdfCollectionLoader!";
-        return;
-    }
-
-    QList<KoCollectionItem> templateList;
-    QList<KoShape*> shapeList = loader->shapeList();
-
-    foreach(KoShape* shape, shapeList)
-    {
-        KoCollectionItem temp;
-        temp.id = loader->collectionPath() + shape->name();
-        temp.name = shape->name();
-        temp.toolTip = shape->name();
-        temp.icon = generateShapeIcon(shape);
-        templateList.append(temp);
-        CollectionShapeFactory* factory =
-                new CollectionShapeFactory(loader->collectionPath() + shape->name(), \
                shape);
-        KoShapeRegistry::instance()->add(loader->collectionPath() + shape->name(), \
                factory);
-    }
-
-    CollectionItemModel* model = m_modelMap[loader->collectionFamily()];
-    model->setShapeTemplateList(templateList);
-
-    loader->deleteLater();
-}
-
-void ShapeBoxDocker::removeCollection(const QString& family)
-{
-    if(m_modelMap.contains(family))
-    {
-        CollectionItemModel* model = m_modelMap[family];
-        QList<KoCollectionItem> list = model->shapeTemplateList();
-        foreach(const KoCollectionItem & temp, list)
-        {
-            KoShapeFactoryBase* factory = KoShapeRegistry::instance()->get(temp.id);
-            KoShapeRegistry::instance()->remove(temp.id);
-            delete factory;
-        }
-
-        m_modelMap.remove(family);
-        delete model;
-    }
-}
-
-QIcon ShapeBoxDocker::generateShapeIcon(KoShape* shape)
-{
-    KoZoomHandler converter;
-    bool isGroup = (shape->size()==QSizeF(0,0)) ? true : false;
-
-    QRectF bound;
-    KoShapeGroup* group;
-    QList<KoShape*> sortedObjects;
-
-    if (isGroup == true) {
-        bool boundInitialized = false;
-        group = static_cast<KoShapeGroup*>(shape);
-        sortedObjects = group->shapes();
-        qSort(sortedObjects.begin(), sortedObjects.end(), \
                KoShape::compareShapeZIndex);
-        foreach(KoShape * subShape, sortedObjects) {
-            if (! boundInitialized) {
-                bound = subShape->boundingRect();
-                boundInitialized = true;
-            } else
-                bound = bound.united(subShape->boundingRect());
-        }
-    } else {
-        bound = shape->boundingRect();
-    }
-
-    qreal diffx = 30 / converter.documentToViewX(bound.width());
-    qreal diffy = 30 / converter.documentToViewY(bound.height());
-    converter.setZoom(qMin(diffx, diffy));
-
-    QPixmap pixmap(qRound(converter.documentToViewX(bound.width())) + 2, \
                qRound(converter.documentToViewY(bound.height())) + 2);
-    pixmap.fill(Qt::white);
-    QPainter painter(&pixmap);
-    painter.setRenderHint(QPainter::Antialiasing, true);
-
-    QTransform baseMatrix = shape->absoluteTransformation(&converter).inverted() * \
                painter.transform();
-    painter.translate(1, 1);
-
-    if (isGroup == true) {
-        foreach(KoShape * subShape, sortedObjects) {
-            //kDebug(30006) <<"KoShapeContainer::painting shape:" << \
                subShape->shapeId() <<"," << subShape->boundingRect();
-            if (!subShape->isVisible())
-                continue;
-            painter.save();
-            painter.setTransform(subShape->absoluteTransformation(&converter) * \
                baseMatrix);
-            subShape->paint(painter, converter);
-            painter.restore();
-            if (subShape->border()) {
-                painter.save();
-                painter.setTransform(subShape->absoluteTransformation(&converter) * \
                baseMatrix);
-                subShape->border()->paint(subShape, painter, converter);
-                painter.restore();
-            }
-        }
-    } else {
-        shape->paint(painter, converter);
-    }
-
-    painter.end();
-
-    return QIcon(pixmap);
-}
diff --git a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.h \
b/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.h deleted file mode 100644
index cb1f231..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxDocker.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* This file is part of the KOffice project
- * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
- * Copyright (C) 2010 Yue Liu <opuspace@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-#ifndef KOSHAPEBOXDOCKER_H
-#define KOSHAPEBOXDOCKER_H
-
-#include "CollectionItemModel.h"
-
-#include <QDockWidget>
-#include <QMap>
-#include <QIcon>
-
-#include <KoDockFactoryBase.h>
-
-class CollectionItemModel;
-class CollectionTreeWidget;
-class KoShape;
-
-class KLineEdit;
-
-class QToolButton;
-class QMenu;
-class QVBoxLayout;
-class QHBoxLayout;
-class QSortFilterProxyModel;
-
-class ShapeBoxDockerFactory : public KoDockFactoryBase
-{
-    public:
-        ShapeBoxDockerFactory();
-
-        QString id() const;
-        QDockWidget* createDockWidget();
-        DockPosition defaultDockPosition() const
-        {
-            return DockLeft;
-        }
-};
-
-class ShapeBoxDocker : public QDockWidget
-{
-    Q_OBJECT
-    public:
-        explicit ShapeBoxDocker(QWidget* parent = 0);
-
-    protected:
-        /**
-         * Load the default koffice shapes
-         */
-        void loadDefaultShapes();
-
-        /**
-         * Load odf shape collections
-         */
-        void loadShapeCollections();
-
-        bool addCollection(const QString& path);
-
-        void removeCollection(const QString& family);
-
-        /// Generate an icon from @p group
-        QIcon generateShapeIcon(KoShape* shape);
-
-    protected slots:
-        /// Called when an error occurred while loading a collection
-        void onLoadingFailed(const QString& reason);
-
-        /// Called when loading of a collection is finished
-        void onLoadingFinished();
-
-        /// Called when the docker changes area
-        void locationChanged(Qt::DockWidgetArea area);
-	
-    private:
-        QMap<QString, CollectionItemModel*> m_modelMap;
-        QMap<QString, QSortFilterProxyModel*> m_proxyMap;
-
-        CollectionTreeWidget *m_treeWidget;
-        QMenu* m_menu;
-        QToolButton* m_button;
-        KLineEdit* m_filterLineEdit;
-        QVBoxLayout* m_layout;
-        QHBoxLayout* m_panelLayout;
-
-    private slots:
-        void reapplyFilter();
-        void getCollectionOnline();
-        void installLocalCollection();
-        void createNewCollection();
-        void regenerateProxyMap();
-};
-
-#endif //KOSHAPECOLLECTIONDOCKER_H
diff --git a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.cpp \
b/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.cpp deleted file mode 100644
index 508cf77..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
-    Part of KDE project.
-    Copyright (C) 2010 Yue Liu <opuspace@gmail.com>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-#include "ShapeBoxView.h"
-#include "CollectionItemModel.h"
-
-#include <kdebug.h>
-#include <klocale.h>
-
-#include <QTreeWidgetItem>
-#include <QItemDelegate>
-#include <QApplication>
-#include <QTreeWidgetItem>
-#include <QContextMenuEvent>
-#include <QAction>
-#include <QActionGroup>
-#include <QMenu>
-#include <QHeaderView>
-#include <QSortFilterProxyModel>
-
-SheetDelegate::SheetDelegate(QTreeView *view, QWidget *parent)
-    : QItemDelegate(parent),
-      m_view(view)
-{
-}
-
-void SheetDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, \
                const QModelIndex &index) const
-{
-    const QAbstractItemModel *model = index.model();
-    Q_ASSERT(model);
-
-    if (!model->parent(index).isValid())
-    {
-        // this is a top-level item.
-        QStyleOptionButton buttonOption;
-
-        buttonOption.state = option.state;
-        #ifdef Q_WS_MAC
-        buttonOption.state |= QStyle::State_Raised;
-        #endif
-        buttonOption.state &= ~QStyle::State_HasFocus;
-
-        buttonOption.rect = option.rect;
-        buttonOption.palette = option.palette;
-        buttonOption.features = QStyleOptionButton::None;
-        m_view->style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter, \
                m_view);
-
-        QStyleOption branchOption;
-        static const int i = 9; // ### hardcoded in qcommonstyle.cpp
-        QRect r = option.rect;
-        branchOption.rect = QRect(r.left() + i/2, r.top() + (r.height() - i)/2, i, \
                i);
-        branchOption.palette = option.palette;
-        branchOption.state = QStyle::State_Children;
-
-        if (m_view->isExpanded(index))
-            branchOption.state |= QStyle::State_Open;
-
-        m_view->style()->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, \
                painter, m_view);
-
-        // draw text
-        QRect textrect = QRect(r.left() + i*2, r.top(), r.width() - ((5*i)/2), \
                r.height());
-        QString text = elidedText(option.fontMetrics, textrect.width(), \
                Qt::ElideMiddle,
-            model->data(index, Qt::DisplayRole).toString());
-        m_view->style()->drawItemText(painter, textrect, Qt::AlignCenter,
-            option.palette, m_view->isEnabled(), text);
-
-    }
-    else
-    {
-        QItemDelegate::paint(painter, option, index);
-    }
-}
-
-QSize SheetDelegate::sizeHint(const QStyleOptionViewItem &opt, const QModelIndex \
                &index) const
-{
-    QStyleOptionViewItem option = opt;
-    QSize sz = QItemDelegate::sizeHint(opt, index) + QSize(2, 2);
-    return sz;
-}
-
-ShapeListView::ShapeListView(QWidget* parent) :
-    QListView(parent)
-{
-    setFocusPolicy(Qt::NoFocus);
-    setFrameShape(QFrame::NoFrame);
-    setIconSize(QSize(22, 22));
-    setSpacing(1);
-    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-    setResizeMode(QListView::Adjust);
-    setUniformItemSizes(true);
-    //setSelectionMode(QAbstractItemView::NoSelection);
-    setDragDropMode(QAbstractItemView::DragDrop);
-    setDropIndicatorShown(true);
-
-    //connect(this, SIGNAL(pressed(QModelIndex)), this, \
                SLOT(slotPressed(QModelIndex)));
-    setEditTriggers(QAbstractItemView::AnyKeyPressed);
-}
-
-/*void ShapeListView::mousePressEvent(QMouseEvent *event)
-{
-    if (event->button() == Qt::LeftButton)
-    {
-        m_startPos = event->pos();
-    }
-    QListView::mousePressEvent(event);
-}
-
-void ShapeListView::mouseMoveEvent(QMouseEvent *event)
-{
-    if (event->buttons() & Qt::LeftButton)
-    {
-        int distance = (event->pos() - m_startPos).manhattanLength();
-        if (distance >= QApplication::startDragDistance())
-        {
-            ;//performDrag();
-        }
-    }
-    QListView::mouseMoveEvent(event);
-}
-
-void ShapeListView::performDrag()
-{
-    QListViewItem *item = currentItem();
-    if (item) {
-        QMimeData *mimeData = new QMimeData;
-        mimeData->setText(item->text());
-
-        QDrag *drag = new QDrag(this);
-        drag->setMimeData(mimeData);
-        drag->setPixmap(QPixmap(":/images/person.png"));
-        if (drag->exec(Qt::MoveAction) == Qt::MoveAction)
-            delete item;
-    }
-}*/
-
-CollectionTreeWidget::CollectionTreeWidget(QWidget* parent): QTreeWidget(parent)
-{
-    header()->hide();
-    header()->setResizeMode(QHeaderView::Stretch);
-    setRootIsDecorated(false);
-    setItemsExpandable(true);
-    setFocusPolicy(Qt::NoFocus);
-    setIndentation(0);
-    setColumnCount(1);
-    setVerticalScrollMode(ScrollPerPixel);
-    restoreViewMode();
-
-    setItemDelegate(new SheetDelegate(this, this));
-
-    //expandAll();
-
-    connect(this, SIGNAL(itemPressed(QTreeWidgetItem*,int)),
-            this, SLOT(handleMousePress(QTreeWidgetItem*)));
-}
-
-CollectionTreeWidget::~CollectionTreeWidget()
-{
-    saveViewMode();
-}
-
-void CollectionTreeWidget::setFamilyMap(QMap<QString, QSortFilterProxyModel*> map)
-{
-    QMapIterator<QString, QSortFilterProxyModel*> i(map);
-    while (i.hasNext())
-    {
-         i.next();
-         QTreeWidgetItem *category = new QTreeWidgetItem(this);
-         category->setText(0, i.key());
-         addCategoryView(category, m_iconMode, i.value());
-    }
-}
-
-//Link a ShapeListView to each TreeWidgetItem
-void CollectionTreeWidget::addCategoryView(QTreeWidgetItem *parent,
-                                                     bool iconMode, \
                QSortFilterProxyModel *model)
-{
-    QTreeWidgetItem *embed_item = new QTreeWidgetItem(parent);
-    embed_item->setFlags(Qt::ItemIsEnabled);
-    ShapeListView *categoryView = new ShapeListView();
-    categoryView->setViewMode(iconMode ? QListView::IconMode : QListView::ListMode);
-    setItemWidget(embed_item, 0, categoryView);
-    categoryView->setModel(model);
-}
-
-ShapeListView* CollectionTreeWidget::categoryViewAt(int idx) const
-{
-    ShapeListView *rc = 0;
-    if (QTreeWidgetItem *cat_item = topLevelItem(idx))
-    {
-        if (QTreeWidgetItem *embedItem = cat_item->child(0))
-        {
-            rc = qobject_cast<ShapeListView*>(itemWidget(embedItem, 0));
-        }
-    }
-    Q_ASSERT(rc);
-    return rc;
-}
-
-void CollectionTreeWidget::saveViewMode()
-{
-    //FIXME
-}
-
-void  CollectionTreeWidget::restoreViewMode()
-{
-    //FIXME
-    m_iconMode = 0;
-}
-
-void CollectionTreeWidget::handleMousePress(QTreeWidgetItem *item)
-{
-    if (item == 0)
-        return;
-
-    if (QApplication::mouseButtons() != Qt::LeftButton)
-        return;
-
-    if (item->parent() == 0) {
-        setItemExpanded(item, !isItemExpanded(item));
-        return;
-    }
-}
-
-void CollectionTreeWidget::slotListMode()
-{
-    m_iconMode = false;
-    updateViewMode();
-}
-
-void CollectionTreeWidget::slotIconMode()
-{
-    m_iconMode = true;
-    updateViewMode();
-}
-
-void CollectionTreeWidget::updateViewMode()
-{
-    if (const int numTopLevels = topLevelItemCount())
-    {
-        for (int i = numTopLevels - 1; i >= 0; --i)
-        {
-            const QListView::ViewMode viewMode  = m_iconMode ? QListView::IconMode : \
                QListView::ListMode;
-            ShapeListView *categoryView = categoryViewAt(i);
-
-            if (viewMode != categoryView->viewMode())
-            {
-                categoryView->setViewMode(viewMode);
-                adjustSubListSize(topLevelItem(i));
-            }
-        }
-    }
-    updateGeometries();
-}
-
-void CollectionTreeWidget::adjustSubListSize(QTreeWidgetItem *cat_item)
-{
-    QTreeWidgetItem *embedItem = cat_item->child(0);
-    if (embedItem == 0)
-        return;
-
-    ShapeListView *list_widget = static_cast<ShapeListView*>(itemWidget(embedItem, \
                0));
-    list_widget->setFixedWidth(header()->width());
-    list_widget->doItemsLayout();
-    const int height = qMax(list_widget->contentsSize().height() ,1);
-    list_widget->setFixedHeight(height);
-    embedItem->setSizeHint(0, QSize(-1, height - 1));
-}
-
-void CollectionTreeWidget::filter()
-{
-    const int numTopLevels = topLevelItemCount();
-    for (int i = 0; i < numTopLevels; i++)
-    {
-        QTreeWidgetItem *tl = topLevelItem(i);
-        ShapeListView *categoryView = categoryViewAt(i);
-        QAbstractItemModel *model = categoryView->model();
-        const bool categoryEnabled = model->rowCount() > 0;
-        if (categoryEnabled) {
-            categoryView->adjustSize();
-            adjustSubListSize(tl);
-        }
-        setRowHidden(i, QModelIndex(), !categoryEnabled);
-    }
-    updateGeometries();
-}
-
-void CollectionTreeWidget::resizeEvent(QResizeEvent *e)
-{
-    QTreeWidget::resizeEvent(e);
-    if (const int numTopLevels = topLevelItemCount()) {
-        for (int i = numTopLevels - 1; i >= 0; --i)
-        {
-            adjustSubListSize(topLevelItem(i));
-        }
-    }
-}
-
-void CollectionTreeWidget::contextMenuEvent(QContextMenuEvent *e)
-{
-    QMenu menu;
-    menu.addAction(i18n("Expand all"), this, SLOT(expandAll()));
-    menu.addAction(i18n("Collapse all"), this, SLOT(collapseAll()));
-    menu.addSeparator();
-
-    QAction *listModeAction = menu.addAction(i18n("List View"));
-    QAction *iconModeAction = menu.addAction(i18n("Icon View"));
-    listModeAction->setCheckable(true);
-    iconModeAction->setCheckable(true);
-    QActionGroup *viewModeGroup = new QActionGroup(&menu);
-    viewModeGroup->addAction(listModeAction);
-    viewModeGroup->addAction(iconModeAction);
-    if (m_iconMode) {
-        iconModeAction->setChecked(true);
-    }
-    else {
-        listModeAction->setChecked(true);
-    }
-    connect(listModeAction, SIGNAL(triggered()), SLOT(slotListMode()));
-    connect(iconModeAction, SIGNAL(triggered()), SLOT(slotIconMode()));
-
-    e->accept();
-    menu.exec(mapToGlobal(e->pos()));
-}
diff --git a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.h \
b/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.h deleted file mode 100644
index f6c88e2..0000000
--- a/flow/src/plugins/dockers/shapeboxdocker/ShapeBoxView.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-    Part of Koffice project.
-    Copyright (C) 2010 Yue Liu <opuspace@gmail.com>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-*/
-
-#ifndef SHAPEBOXVIEW_H
-#define SHAPEBOXVIEW_H
-
-#include <QTreeWidget>
-#include <QItemDelegate>
-#include <QListView>
-
-class QIcon;
-class QSortFilterProxyModel;
-class ShapeListView;
-
-///A delegate from qt designer, used to paint category item in the treewidget.
-class SheetDelegate: public QItemDelegate
-{
-    Q_OBJECT
-public:
-    SheetDelegate(QTreeView *view, QWidget *parent);
-
-    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const \
                QModelIndex &index) const;
-    virtual QSize sizeHint(const QStyleOptionViewItem &opt, const QModelIndex \
                &index) const;
-
-private:
-    QTreeView *m_view;
-};
-
-class ShapeListView : public QListView
-{
-    Q_OBJECT
-    
-public:
-    using QListView::contentsSize;
-
-    explicit ShapeListView(QWidget *parent = 0);
-
-signals:
-    void pressed(const QString &name, const QString &xml, const QPoint &globalPos);
-    //void itemRemoved();
-    //void lastItemRemoved();
-
-protected:
-    //void mousePressEvent(QMouseEvent *event);
-    //void mouseMoveEvent(QMouseEvent *event);
-
-//private slots:
-    //void removeCurrentItem();
-    //void editCurrentItem();
-
-private:
-    //void performDrag();
-    //QPoint m_startPos;
-    //int mapRowToSource(int filterRow) const;
-    //CollectionItemModel *m_model;
-};
-
-class CollectionTreeWidget : public QTreeWidget
-{
-    Q_OBJECT
-    
-    public:
-        explicit CollectionTreeWidget(QWidget *parent);
-        ~CollectionTreeWidget();
-        bool loadContents(const QString &contents);
-        bool save();
-        void setFamilyMap(QMap<QString, QSortFilterProxyModel*> map);
-
-        void filter();
-
-    protected:
-	void contextMenuEvent(QContextMenuEvent *e);
-	void resizeEvent(QResizeEvent *e);
-	
-    private:
-        bool m_iconMode;
-        ShapeListView* categoryViewAt(int idx) const;
-        void addCategoryView(QTreeWidgetItem *parent, bool iconMode, \
                QSortFilterProxyModel *model);
-	void adjustSubListSize(QTreeWidgetItem *cat_item);
-	void updateViewMode();
-	void saveViewMode();
-	void restoreViewMode();
-	void addWidgetItem(QString itemPath);
-	
-    private slots:
-	void handleMousePress(QTreeWidgetItem *item);
-	void slotListMode();
-        void slotIconMode();
-};
-
-#endif // SHAPEBOXVIEW_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic