~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/desktop/applets/kickoff/core/applicationmodel.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2007 Pino Toscano <pino@kde.org>
 
3
    Copyright 2007 Robert Knight <robertknight@gmail.com>
 
4
 
 
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.
 
9
 
 
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.
 
14
 
 
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.
 
19
*/
 
20
 
 
21
#ifndef APPLICATIONMODEL_H
 
22
#define APPLICATIONMODEL_H
 
23
 
 
24
#include "core/kickoff_export.h"
 
25
#include "core/kickoffabstractmodel.h"
 
26
#include "core/models.h"
 
27
 
 
28
namespace Kickoff
 
29
{
 
30
 
 
31
class ApplicationModelPrivate;
 
32
 
 
33
/**
 
34
 * ApplicationModel provides a tree model containing all of the user's installed graphical programs.
 
35
 * The applications are arranged into categories, based on the information in their .desktop files.
 
36
 */
 
37
class KICKOFF_EXPORT ApplicationModel : public KickoffAbstractModel
 
38
{
 
39
    Q_OBJECT
 
40
 
 
41
public:
 
42
    ApplicationModel(QObject *parent = 0, bool allowSeparators = false);
 
43
    virtual ~ApplicationModel();
 
44
 
 
45
    /**
 
46
     * This enum describes the policy for
 
47
     * handling duplicate applications (that is,
 
48
     * two applications with the same name in the same group)
 
49
     */
 
50
    enum DuplicatePolicy {
 
51
        /** Display duplicate entries. */
 
52
        ShowDuplicatesPolicy,
 
53
        /**
 
54
         * Show only the entry for the most recent
 
55
         * version of the application.
 
56
         *
 
57
         * Currently only a crude heuristic to determine whether the
 
58
         * application is from KDE 3 or KDE 4 is used to determine
 
59
         * recent-ness.
 
60
         *
 
61
         * eg.  If MyGame/KDE 3 and MyGame/KDE 4 are found
 
62
         * show only MyGame/KDE 4
 
63
         */
 
64
        ShowLatestOnlyPolicy
 
65
    };
 
66
 
 
67
    /**
 
68
     * This enum describes the policy for
 
69
     * handling applications that are configured to appear
 
70
     * in the System tab.
 
71
     */
 
72
    enum SystemApplicationPolicy {
 
73
        /** Display entries in Applications tab and System tab. */
 
74
        ShowApplicationAndSystemPolicy,
 
75
        /** Display entry only in System tab. */
 
76
        ShowSystemOnlyPolicy
 
77
    };
 
78
 
 
79
    enum PrimaryNamePolicy {
 
80
        AppNamePrimary,
 
81
        GenericNamePrimary
 
82
    };
 
83
 
 
84
    void setNameDisplayOrder(DisplayOrder displayOrder);
 
85
    DisplayOrder nameDisplayOrder() const;
 
86
    //DisplayOrder m_displayOrder;
 
87
    /**
 
88
     * Sets the policy for handling duplicate applications.
 
89
     * See DuplicatePolicy
 
90
     */
 
91
    void setDuplicatePolicy(DuplicatePolicy policy);
 
92
    /** See setDuplicatePolicy() */
 
93
    DuplicatePolicy duplicatePolicy() const;
 
94
 
 
95
    /**
 
96
     * Sets the policy for handling System applications.
 
97
     * See SystemApplicationPolicy
 
98
     */
 
99
    void setSystemApplicationPolicy(SystemApplicationPolicy policy);
 
100
    /** See setSystemApplicationPolicy() */
 
101
    SystemApplicationPolicy systemApplicationPolicy() const;
 
102
 
 
103
    void setPrimaryNamePolicy(PrimaryNamePolicy policy);
 
104
    PrimaryNamePolicy primaryNamePolicy() const;
 
105
 
 
106
    // reimplemented from QAbstractItemModel
 
107
    virtual bool canFetchMore(const QModelIndex &parent) const;
 
108
    virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
 
109
    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
110
    virtual void fetchMore(const QModelIndex &parent);
 
111
    virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
 
112
    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
 
113
    virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
 
114
    virtual QModelIndex parent(const QModelIndex &index) const;
 
115
    virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
 
116
 
 
117
public slots:
 
118
    void reloadMenu();
 
119
    void delayedReloadMenu();
 
120
    void checkSycocaChange(const QStringList &changes);
 
121
 
 
122
private:
 
123
    bool nameAfterDescription(const QModelIndex &index) const;
 
124
 
 
125
    friend class ApplicationModelPrivate;
 
126
    ApplicationModelPrivate *const d;
 
127
 
 
128
    Q_DISABLE_COPY(ApplicationModel)
 
129
};
 
130
 
 
131
}
 
132
 
 
133
#endif