Warning, file /office/calligra/libs/pageapp/KoPADocumentModel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KOPADOCUMENTMODEL_H
0021 #define KOPADOCUMENTMODEL_H
0022 
0023 #include <KoDocumentSectionModel.h>
0024 
0025 class KoPADocument;
0026 class KoShape;
0027 class KoShapeContainer;
0028 class KoPAPageBase;
0029 
0030 #include "kopageapp_export.h"
0031 
0032 /**
0033  * Model class for the document structure widget (dsw). The dsw can
0034  * show the structure of a document as a three, as thumbnails or as
0035  * a list.
0036  *
0037  * XXX: implement beginInsertRows, endInsertRows, beginRemoveRows
0038  *      and endRemoveRows to make the widget react to page insertions
0039  *      and deletions.
0040  */
0041 class KOPAGEAPP_EXPORT KoPADocumentModel : public KoDocumentSectionModel
0042 {
0043     Q_OBJECT
0044 public:
0045     /// Constructs a new document section model using the specified documents data
0046     explicit KoPADocumentModel( QObject* parent, KoPADocument *document = 0 );
0047 
0048     /// Set the document used in the model
0049     void setDocument(KoPADocument* document);
0050     /// Set the mode to show, master page or normal page
0051     void setMasterMode(bool master);
0052 
0053     // from QAbstractItemModel
0054     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0055     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0056     QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
0057     QModelIndex parent( const QModelIndex &child ) const override;
0058     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0059     Qt::ItemFlags flags(const QModelIndex &index) const override;
0060     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0061     Qt::DropActions supportedDropActions() const override;
0062     QStringList mimeTypes() const override;
0063     QMimeData * mimeData( const QModelIndexList & indexes ) const override;
0064     bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent ) override;
0065     Qt::DropActions supportedDragActions() const override;
0066 
0067 public Q_SLOTS:
0068     /// Triggers an update of the complete model
0069     void update();
0070 
0071 Q_SIGNALS:
0072     void requestPageSelection(int start, int count);
0073 
0074 private:
0075     /// Returns properties of the given shape
0076     PropertyList properties( KoShape* shape ) const;
0077     /// Sets the properties on the given shape
0078     void setProperties( KoShape* shape, const PropertyList &properties );
0079     /// Creates a thumbnail image with the specified size from the given shape
0080     QImage createThumbnail( KoShape* shape, const QSize &thumbSize ) const;
0081     /// Returns the child shape with the given index from the parent shape
0082     KoShape * childFromIndex( KoShapeContainer *parent, int row ) const;
0083     /// Returns the zero based index of a child shape within its parent shape
0084     int indexFromChild( KoShapeContainer *parent, KoShape *child ) const;
0085     /// Returns the parent model index from the given child shape
0086     QModelIndex parentIndexFromShape( const KoShape * child );
0087     /// Creates a context menu when dropping pages to choose between copy or move action.
0088     bool doDrop(QList<KoPAPageBase *> pages, KoPAPageBase *pageAfter, Qt::DropAction action);
0089 
0090     KoPADocument *m_document; ///< the undelying data structure
0091     bool m_master;
0092     mutable QList<KoShape*> m_childs;
0093     mutable KoShapeContainer *m_lastContainer;
0094 };
0095 
0096 #endif // KODOCUMENTMODEL_H