File indexing completed on 2024-05-12 16:34:42

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2008 Peter Simonsson <peter.simonsson@gmail.com>
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 COLLECTIONITEMMODEL_H
0021 #define COLLECTIONITEMMODEL_H
0022 
0023 #include <KoShape.h>
0024 
0025 #include <QAbstractItemModel>
0026 #include <QList>
0027 #include <QListView>
0028 #include <QString>
0029 #include <QIcon>
0030 
0031 class KoProperties;
0032 
0033 /**
0034  * Struct containing the information stored in CollectionItemModel item
0035  */
0036 struct KoCollectionItem
0037 {
0038     KoCollectionItem()
0039     {
0040         properties = 0;
0041     }
0042 
0043     QString id;
0044     QString name;
0045     QString toolTip;
0046     QIcon icon;
0047     const KoProperties* properties;
0048 };
0049 
0050 class CollectionItemModel : public QAbstractListModel
0051 {
0052     Q_OBJECT
0053     public:
0054         explicit CollectionItemModel(QObject *parent = 0);
0055 
0056         QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
0057         int rowCount(const QModelIndex& parent = QModelIndex()) const override;
0058         QMimeData* mimeData(const QModelIndexList& indexes) const override;
0059         QStringList mimeTypes() const override;
0060         Qt::ItemFlags flags(const QModelIndex& index) const override;
0061 
0062         /**
0063          * Set the list of KoCollectionItem to be stored in the model
0064          */
0065         void setShapeTemplateList(const QList<KoCollectionItem>& newlist);
0066         QList<KoCollectionItem> shapeTemplateList () { return m_shapeTemplateList; }
0067 
0068         void setViewMode(QListView::ViewMode vm);
0069         QListView::ViewMode viewMode() const;
0070         const KoProperties* properties(const QModelIndex& index) const;
0071 
0072     private:
0073         QList<KoCollectionItem> m_shapeTemplateList;
0074         QString m_family;
0075         QListView::ViewMode m_viewMode;
0076 };
0077 
0078 #endif // COLLECTIONITEMMODEL_H