File indexing completed on 2024-05-12 16:36:48
0001 /* This file is part of the KDE project 0002 * 0003 * Copyright (C) 2011 Paul Mendez <paulestebanms@gmail.com> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KPRSLIDESSORTERDOCUMENTMODEL_H 0022 #define KPRSLIDESSORTERDOCUMENTMODEL_H 0023 0024 #include <QAbstractListModel> 0025 0026 class KPrViewModeSlidesSorter; 0027 class KoPADocument; 0028 class KoPAPageBase; 0029 0030 /** 0031 * Class meant to hold the model for Slides Sorter 0032 * This model lets display slides as thumbnails in a List view, using standard QT 0033 * view/model framework. It supports copy and move of slides, and include a context 0034 * menu to present options when dropping. 0035 */ 0036 class KPrSlidesSorterDocumentModel: public QAbstractListModel 0037 { 0038 Q_OBJECT 0039 public: 0040 KPrSlidesSorterDocumentModel(KPrViewModeSlidesSorter *viewModeSlidesSorter, QWidget *parent, KoPADocument *document = 0); 0041 ~KPrSlidesSorterDocumentModel() override; 0042 0043 /** 0044 * Set the current document 0045 * @param document a KoPADocument that holds current document 0046 */ 0047 void setDocument(KoPADocument *document); 0048 0049 QModelIndex index(int row, int column, const QModelIndex &parent) const override; 0050 0051 QVariant data(const QModelIndex &index, int role) const override; 0052 0053 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; 0054 0055 int rowCount(const QModelIndex &parent) const override; 0056 0057 QStringList mimeTypes() const override; 0058 0059 QMimeData* mimeData(const QModelIndexList &indexes) const override; 0060 0061 Qt::DropActions supportedDragActions() const override; 0062 Qt::DropActions supportedDropActions() const override; 0063 0064 bool removeRows(int row, int count, const QModelIndex &parent) override; 0065 0066 Qt::ItemFlags flags(const QModelIndex &index) const override; 0067 0068 bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override; 0069 0070 /** 0071 * Drop selected slides (copy/move) if a modifier key is pressed 0072 * or display a context menu with alternatives. 0073 * @param slides list of slides to be dropped 0074 * @param pageAfter destination of the drop 0075 * @param action the drop action 0076 */ 0077 void doDrop(QList<KoPAPageBase *> slides, KoPAPageBase *pageAfter, Qt::DropAction action); 0078 0079 /** 0080 * @brief Return the page that match the give index in the list 0081 * 0082 / @param index the index of the slide to be retrived 0083 * @return a Page in the document if it was found or a null pointer if not. 0084 */ 0085 KoPAPageBase* pageByIndex(const QModelIndex &index) const; 0086 0087 /** 0088 * @brief Deletes a given list of slides from the current document 0089 * 0090 * @param slides list of slides to be removed 0091 * @return true if the command execution was successful 0092 */ 0093 bool removeSlides(const QList<KoPAPageBase *> &slides); 0094 0095 /** 0096 * @brief Add a new slide after the current active page 0097 * 0098 * @return true if the command execution was successful 0099 */ 0100 bool addNewSlide(); 0101 0102 /** 0103 * @brief copy a given list of slides 0104 * 0105 * @param slides list of slides to be copied 0106 * @return true if the command execution was successful 0107 */ 0108 bool copySlides(const QList<KoPAPageBase *> &slides); 0109 0110 /** 0111 * @brief Paste slides from clipboard 0112 * 0113 * @return true if the command execution was successful 0114 */ 0115 bool pasteSlides(); 0116 0117 /** 0118 * @brief Moves a given list of slides after pageAfter slide 0119 * 0120 * @param slides list of slides to be moved 0121 * @param pageAfter indicates where the slides will be moved 0122 * @return true if the command execution was successful 0123 */ 0124 bool moveSlides(const QList<KoPAPageBase *> &slides, KoPAPageBase *pageAfter); 0125 0126 public Q_SLOTS: 0127 /** emit signals indicating a change in the model layout or items */ 0128 void update(); 0129 0130 private: 0131 //A reference to current document 0132 KoPADocument *m_document; 0133 //A reference to Slides sorter class 0134 KPrViewModeSlidesSorter *m_viewModeSlidesSorter; 0135 }; 0136 0137 #endif // KPRSLIDESSORTERDOCUMENTMODEL_H