/usr/include/nepomuk2/resourcemodel.h is in libnepomukwidgets-dev 4:4.13.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | /*
This file is part of the Nepomuk KDE project.
Copyright (C) 2007-2010 Sebastian Trueg <trueg@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _NEPOMUK_RESOUCE_MODEL_H_
#define _NEPOMUK_RESOUCE_MODEL_H_
#include <Nepomuk2/Resource>
#include <Nepomuk2/Query/Result>
#include <QtCore/QAbstractItemModel>
#include "nepomukwidgets_export.h"
namespace Nepomuk2 {
class Resource;
namespace Utils {
/**
* \class ResourceModel resourcemodel.h Nepomuk/Utils/ResourceModel
*
* \brief Base class for all models providing a plain list of resources.
*
* The %ResourceModel is a base class for models that handle a set of
* %Nepomuk Resource instances. This can be a simple list as in SimpleResourceModel
* or a set of query results as in ResultModel. It could also be a dynamic list
* which is updated while the user scrolls it.
*
* %ResourceModel cannot be instanciated by itself. Use one of the subclasses
* or derive your own subclass from it.
*
* At least the following methods need to be implemented in a subclass:
* \li resourceForIndex()
* \li indexForResource(),
* \li QAbstractItemModel::rowCount()
* \li QAbstractItemModel::index()
*
* \author Sebastian Trueg <trueg@kde.org>
*
* \since 4.6
*/
class NEPOMUKWIDGETS_EXPORT ResourceModel : public QAbstractItemModel
{
Q_OBJECT
public:
/**
* Constructor.
*/
ResourceModel( QObject* parent = 0 );
/**
* Destructor
*/
virtual ~ResourceModel();
/**
* The columns supported by ResourceModel are identified
* by this enumeration.
*/
enum ResourceModelColumns {
/// The first column displays the label of the resource and its icon
ResourceColumn = 0,
/// The second column displays the resource's type
ResourceTypeColumn = 1,
/// The number of columns
ResourceModelColumnCount = 2
};
/**
* Custom roles that can be accessed for example in delegates.
*/
enum ResourceRoles {
/**
* The resource itself, provided as a Nepomuk2::Resource instance.
*/
ResourceRole = 7766897,
/**
* The type of the resource, provided as a Nepomuk2::Types::Class
* instance.
*/
ResourceTypeRole = 687585,
/**
* The creation date of the resource.
*/
ResourceCreationDateRole = 7766898
};
/**
* Get the Resource which corresponds to \p index.
*
* \return The Resource which corresponds to \p index or an invalid Resource
* if \p index is invalid.
*/
virtual Resource resourceForIndex( const QModelIndex& index ) const;
/**
* Get the index for a resource.
*
* \return The index which corresponds to \p res of an invalid QModelIndex
* if \p res is not part of this model.
*/
virtual QModelIndex indexForResource( const Resource& res );
/**
* \return The number of resources added to the model for an invalid parent index.
*/
virtual int rowCount( const QModelIndex& parent = QModelIndex() ) const;
/**
* Creates an index for the cell at \p row and \p column.
*/
QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const;
/**
* Removes those resources from the model.
*/
bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
/**
* The default implementation returns an invalid QModelIndex, thus providing
* a plain list.
*/
virtual QModelIndex parent( const QModelIndex& child ) const;
/**
* The default implementation returns 2 with the first column representing the resource
* itself and the second one showing the type.
*/
virtual int columnCount( const QModelIndex& parent ) const;
/**
* Handles most roles typically used in applications like Qt::DisplayRole, Qt::ToolTipRole,
* and Qt::DecorationRole. Additionally KCategorizedSortFilterProxyModel roles are supported
* categorizing by resource types.
*/
virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
/**
* Provides header data for the supported columns.
*/
virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
/**
* Reimplemented to support dragging of resources out of the model.
*/
virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
/**
* Stores the resource URIs via KUrl::List::populateMimeData() and as a specific
* "application/x-nepomuk-resource-uri" mime type to indicate that these are URIs
* corresponding to actual %Nepomuk resources.
*/
virtual QMimeData* mimeData( const QModelIndexList& indexes ) const;
/**
* \return The KUrl mime types and "application/x-nepomuk-resource-uri".
*/
virtual QStringList mimeTypes() const;
/**
* Provided for future extensions.
*/
virtual bool setData( const QModelIndex& index, const QVariant& value, int role );
public Q_SLOTS:
/**
* Set the resources to be provided by the model to \p resources.
*/
void setResources( const QList<Nepomuk2::Resource>& resources );
/**
* Add \p resources to the list of resources being provided by the
* model.
*/
void addResources( const QList<Nepomuk2::Resource>& resources );
/**
* Add \p resource to the list of resources being provided by the
* model.
*/
void addResource( const Nepomuk2::Resource& resource );
/**
* This method is similar to setResources(). It is provided for
* allowing convenient connections from signals that provide
* Query::Result objects.
*/
void setResults( const QList<Nepomuk2::Query::Result>& results );
/**
* This method is similar to addResources(). It is provided for
* allowing convenient connections from signals that provide
* Query::Result objects like Query::QueryServiceClient::newResults().
*/
void addResults( const QList<Nepomuk2::Query::Result>& results );
/**
* This method is similar to addResource(). It is provided for
* allowing convenient connections from signals that provide
* Query::Result objects.
*/
void addResult( const Nepomuk2::Query::Result result );
/**
* Clear the model by removing all resources added via setResources() and friends.
*/
void clear();
private:
class Private;
Private* const d;
};
}
}
#endif
|