Warning, file /office/calligra/libs/widgets/KoResourceModel.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) 2008 Jan Hambrecht <jaham@gmx.net>
0003  * Copyright (c) 2013 Sascha Suelzer <s.suelzer@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 KORESOURCEMODEL_H
0022 #define KORESOURCEMODEL_H
0023 
0024 #include <QSharedPointer>
0025 
0026 #include "KoResourceModelBase.h"
0027 #include "kowidgets_export.h"
0028 
0029 class KoAbstractResourceServerAdapter;
0030 class KoResource;
0031 
0032 /// The resource model managing the resource data
0033 class KOWIDGETS_EXPORT KoResourceModel : public KoResourceModelBase
0034 {
0035     Q_OBJECT
0036 public:
0037     explicit KoResourceModel(QSharedPointer<KoAbstractResourceServerAdapter> resourceAdapter, QObject * parent = 0);
0038     ~KoResourceModel() override;
0039 
0040     /// reimplemented
0041     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0042     /// reimplemented
0043     int columnCount ( const QModelIndex & parent = QModelIndex() ) const override;
0044     /// reimplemented
0045     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0046     /// reimplemented
0047     QModelIndex index ( int row, int column = 0, const QModelIndex & parent = QModelIndex() ) const override;
0048     /// Sets the number of columns to display
0049     void setColumnCount( int columnCount );
0050 
0051     /// Extensions to Qt::ItemDataRole.
0052     enum ItemDataRole
0053     {
0054         /// A larger thumbnail for displaying in a tooltip. 200x200 or so.
0055         LargeThumbnailRole = 33
0056     };
0057 
0058     QModelIndex indexFromResource(KoResource* resource) const override;
0059 
0060     /// facade for KoAbstractResourceServerAdapter
0061     QString extensions() const;
0062     void importResourceFile(const QString &filename);
0063     void importResourceFile(const QString &filename, bool fileCreation);
0064     bool removeResource(KoResource* resource) override;
0065     void removeResourceFile(const QString & filename);
0066     QStringList assignedTagsList(KoResource *resource) const override;
0067     void addTag(KoResource* resource, const QString& tag) override;
0068     void deleteTag( KoResource* resource, const QString& tag) override;
0069     QStringList tagNamesList() const override;
0070     QStringList searchTag(const QString& lineEditText);
0071     void enableResourceFiltering(bool enable) override;
0072     void setCurrentTag(const QString& currentTag) override;
0073     void searchTextChanged(const QString& searchString) override;
0074     void updateServer() override;
0075     int resourcesCount() const override;
0076     QList<KoResource *> currentlyVisibleResources() const override;
0077     QList<KoResource *> serverResources() const override;
0078     void tagCategoryMembersChanged() override;
0079     void tagCategoryAdded(const QString& tag) override;
0080     void tagCategoryRemoved(const QString& tag) override;
0081 
0082     QString serverType() const;
0083 
0084 Q_SIGNALS:
0085     /// XXX: not sure if this is the best place for these
0086     void tagBoxEntryModified();
0087     void tagBoxEntryAdded(const QString& tag);
0088     void tagBoxEntryRemoved(const QString& tag);
0089 
0090     void beforeResourcesLayoutReset(KoResource *activateAfterReformat);
0091     void afterResourcesLayoutReset();
0092 
0093 private:
0094     void doSafeLayoutReset(KoResource *activateAfterReformat);
0095 
0096 private Q_SLOTS:
0097     void resourceAdded(KoResource *resource) override;
0098     void resourceRemoved(KoResource *resource) override;
0099     void resourceChanged(KoResource *resource) override;
0100     void tagBoxEntryWasModified() override;
0101     void tagBoxEntryWasAdded(const QString& tag) override;
0102     void tagBoxEntryWasRemoved(const QString& tag) override;
0103 
0104 private:
0105     QSharedPointer<KoAbstractResourceServerAdapter> m_resourceAdapter;
0106     int m_columnCount;
0107     QString m_currentTag;
0108 };
0109 
0110 #endif // KORESOURCEMODEL_H