1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/* This file is part of the KDE project
* Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net>
* Copyright (c) 2013 Sascha Suelzer <s.suelzer@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 KORESOURCEMODEL_H
#define KORESOURCEMODEL_H
#include <QSharedPointer>
#include "KoResourceModelBase.h"
#include "kowidgets_export.h"
class KoAbstractResourceServerAdapter;
class KoResource;
/// The resource model managing the resource data
class KOWIDGETS_EXPORT KoResourceModel : public KoResourceModelBase
{
Q_OBJECT
public:
explicit KoResourceModel(QSharedPointer<KoAbstractResourceServerAdapter> resourceAdapter, QObject * parent = 0);
virtual ~KoResourceModel();
/// reimplemented
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
/// reimplemented
virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
/// reimplemented
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
/// reimplemented
virtual QModelIndex index ( int row, int column = 0, const QModelIndex & parent = QModelIndex() ) const;
/// Sets the number of columns to display
void setColumnCount( int columnCount );
/// Extensions to Qt::ItemDataRole.
enum ItemDataRole
{
/// A larger thumbnail for displaying in a tooltip. 200x200 or so.
LargeThumbnailRole = 33
};
QModelIndex indexFromResource(KoResource* resource) const;
/// facade for KoAbstractResourceServerAdapter
QString extensions() const;
void importResourceFile(const QString &filename);
void importResourceFile(const QString &filename, bool fileCreation);
bool removeResource(KoResource* resource);
void removeResourceFile(const QString & filename);
QStringList assignedTagsList(KoResource *resource) const;
void addTag(KoResource* resource, const QString& tag);
void deleteTag( KoResource* resource, const QString& tag);
QStringList tagNamesList() const;
QStringList searchTag(const QString& lineEditText);
void enableResourceFiltering(bool enable);
void setCurrentTag(const QString& currentTag);
void searchTextChanged(const QString& searchString);
void updateServer();
int resourcesCount() const;
QList<KoResource *> currentlyVisibleResources() const;
QList<KoResource *> serverResources() const;
void tagCategoryMembersChanged();
void tagCategoryAdded(const QString& tag);
void tagCategoryRemoved(const QString& tag);
QString serverType() const;
Q_SIGNALS:
/// XXX: not sure if this is the best place for these
void tagBoxEntryModified();
void tagBoxEntryAdded(const QString& tag);
void tagBoxEntryRemoved(const QString& tag);
void beforeResourcesLayoutReset(KoResource *activateAfterReformat);
void afterResourcesLayoutReset();
private:
void doSafeLayoutReset(KoResource *activateAfterReformat);
private Q_SLOTS:
void resourceAdded(KoResource *resource);
void resourceRemoved(KoResource *resource);
void resourceChanged(KoResource *resource);
void tagBoxEntryWasModified();
void tagBoxEntryWasAdded(const QString& tag);
void tagBoxEntryWasRemoved(const QString& tag);
private:
QSharedPointer<KoAbstractResourceServerAdapter> m_resourceAdapter;
int m_columnCount;
QString m_currentTag;
};
#endif // KORESOURCEMODEL_H
|