not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / applets / kickoff / core / applicationmodel.h
blobac974f24e63f271d984f7ab5683121d01aa3cc52
1 /*
2 Copyright 2007 Pino Toscano <pino@kde.org>
3 Copyright 2007 Robert Knight <robertknight@gmail.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 #ifndef APPLICATIONMODEL_H
22 #define APPLICATIONMODEL_H
24 #include "core/kickoff_export.h"
25 #include "core/kickoffabstractmodel.h"
27 namespace Kickoff
30 class ApplicationModelPrivate;
32 /**
33 * ApplicationModel provides a tree model containing all of the user's installed graphical programs.
34 * The applications are arranged into categories, based on the information in their .desktop files.
36 class KICKOFF_EXPORT ApplicationModel : public KickoffAbstractModel
38 Q_OBJECT
40 public:
41 ApplicationModel(QObject *parent = 0);
42 virtual ~ApplicationModel();
44 /**
45 * This enum describes the policy for
46 * handling duplicate applications (that is,
47 * two applications with the same name in the same group)
49 enum DuplicatePolicy {
50 /** Display duplicate entries. */
51 ShowDuplicatesPolicy,
52 /**
53 * Show only the entry for the most recent
54 * version of the application.
56 * Currently only a crude heuristic to determine whether the
57 * application is from KDE 3 or KDE 4 is used to determine
58 * recent-ness.
60 * eg. If MyGame/KDE 3 and MyGame/KDE 4 are found
61 * show only MyGame/KDE 4
63 ShowLatestOnlyPolicy
66 /**
67 * This enum describes the policy for
68 * handling applications that are configured to appear
69 * in the System tab.
71 enum SystemApplicationPolicy {
72 /** Display entries in Applications tab and System tab. */
73 ShowApplicationAndSystemPolicy,
74 /** Display entry only in System tab. */
75 ShowSystemOnlyPolicy
78 enum PrimaryNamePolicy {
79 AppNamePrimary,
80 GenericNamePrimary
83 /**
84 * Sets the policy for handling duplicate applications.
85 * See DuplicatePolicy
87 void setDuplicatePolicy(DuplicatePolicy policy);
88 /** See setDuplicatePolicy() */
89 DuplicatePolicy duplicatePolicy() const;
91 /**
92 * Sets the policy for handling System applications.
93 * See SystemApplicationPolicy
95 void setSystemApplicationPolicy(SystemApplicationPolicy policy);
96 /** See setSystemApplicationPolicy() */
97 SystemApplicationPolicy systemApplicationPolicy() const;
99 void setPrimaryNamePolicy(PrimaryNamePolicy policy);
100 PrimaryNamePolicy primaryNamePolicy() const;
102 // reimplemented from QAbstractItemModel
103 virtual bool canFetchMore(const QModelIndex &parent) const;
104 virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
105 virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
106 virtual void fetchMore(const QModelIndex &parent);
107 virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
108 virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
109 virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
110 virtual QModelIndex parent(const QModelIndex &index) const;
111 virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
113 public slots:
114 void reloadMenu();
115 void checkSycocaChange();
117 private:
118 friend class ApplicationModelPrivate;
119 ApplicationModelPrivate *const d;
121 Q_DISABLE_COPY(ApplicationModel)
126 #endif