Copyright 2007 Robert Knight <robertknight@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 MODELS_H
#define MODELS_H
#include <KService>
#include <KComponentData>
class QStandardItem;
class KUrl;
class QModelIndex;
namespace Solid
{
class Device;
}
namespace Kickoff
{
class StandardItemFactoryData
{
public:
QHash<QString, Solid::Device> deviceByUrl;
};
StandardItemFactoryData* deviceFactoryData();
* List of applications contained in the DesktopFiles key in the
* SystemApplications group, used to populate the System model
* @return list of desktop entry names
*/
QStringList systemApplicationList();
* Additional data roles for data which the Kickoff models supply with their items
* for use when rendering the items and launching them.
*/
enum DataRole {
SubTitleRole = Qt::UserRole + 1,
FirstDataRole = SubTitleRole,
UrlRole = Qt::UserRole + 2,
DeviceUdiRole = Qt::UserRole + 3,
DiskUsedSpaceRole = Qt::UserRole + 4,
DiskFreeSpaceRole = Qt::UserRole + 5,
SubTitleMandatoryRole = Qt::UserRole + 6,
SeparatorRole = Qt::UserRole + 7,
RelPathRole = Qt::UserRole + 8,
IconNameRole = Qt::UserRole + 9,
GroupNameRole = Qt::UserRole + 10,
MimeDataRole = Qt::UserRole + 11,
LastDataRole = Qt::UserRole + 100
};
* This enum describes the policy for displaying
* Name of Application - Description
* Description - Name of Application
*/
enum DisplayOrder {
NameAfterDescription,
NameBeforeDescription
};
* Factory for creating QStandardItems with appropriate text, icons, URL
* and other Kickoff-specific information for a given URL or Service.
*/
class StandardItemFactory
{
public:
static QStandardItem *createItemForUrl(const QString& url, DisplayOrder displayOrder);
static QStandardItem *createItemForService(KService::Ptr service,
DisplayOrder displayOrder);
static QStandardItem *createItem(const QIcon & icon, const QString & title,
const QString & description, const QString & url, const QString & mimeData = QString());
private:
static void setSpecialUrlProperties(const KUrl& url, QStandardItem *item);
};
* Abstract base class for delegates which provide information about a model
* item's state in a particular view.
*/
class ItemStateProvider
{
public:
virtual ~ItemStateProvider() {}
* Returns true if a @p index should be drawn in the view or
* false if it should be hidden.
*/
virtual bool isVisible(const QModelIndex& index) const = 0;
};
bool isLaterVersion(KService::Ptr first , KService::Ptr second);
#if 0
void swapModelIndexes(QModelIndex& first, QModelIndex& second);
#endif
KComponentData componentData();
}
#endif