~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to kross/core/model.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 * model.h
 
3
 * This file is part of the KDE project
 
4
 * copyright (C) 2006 by Sebastian Sauer (mail@dipe.org)
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 * This program 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
 * You should have received a copy of the GNU Library General Public License
 
15
 * along with this program; see the file COPYING.  If not, write to
 
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
 
18
 ***************************************************************************/
 
19
 
 
20
#ifndef KROSS_MODEL_H
 
21
#define KROSS_MODEL_H
 
22
 
 
23
#include "krossconfig.h"
 
24
//#include "../core/action.h"
 
25
 
 
26
#include <QAbstractItemModel>
 
27
#include <QSortFilterProxyModel>
 
28
 
 
29
namespace Kross {
 
30
 
 
31
    // Forward declarations.
 
32
    class Action;
 
33
    class ActionCollection;
 
34
 
 
35
    /**
 
36
     * The ActionCollectionModel class implements a QAbstractItemModel to provide
 
37
     * a model for views of a \a ActionCollection instance that manages a
 
38
     * collection of \a Action instances.
 
39
     */
 
40
    class KROSSCORE_EXPORT ActionCollectionModel : public QAbstractItemModel
 
41
    {
 
42
        public:
 
43
            enum Mode {
 
44
                None = 0,
 
45
                Icons = 1,
 
46
                ToolTips = 2,
 
47
                UserCheckable = 4
 
48
                //Editable = 8
 
49
            };
 
50
 
 
51
            explicit ActionCollectionModel(QObject* parent, ActionCollection* collection = 0, Mode mode = Mode(Icons|ToolTips));
 
52
            virtual ~ActionCollectionModel();
 
53
 
 
54
            virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
 
55
            virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
 
56
            virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
 
57
            virtual QModelIndex parent(const QModelIndex& index) const;
 
58
            virtual Qt::ItemFlags flags(const QModelIndex &index) const;
 
59
            virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
 
60
            virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
 
61
 
 
62
            virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
 
63
            virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
 
64
            virtual bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
 
65
            virtual bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
 
66
 
 
67
            //Qt::DropActions supportedDragActions() const;
 
68
            virtual QStringList mimeTypes() const;
 
69
            virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
 
70
            virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
 
71
 
 
72
            virtual Qt::DropActions supportedDropActions() const;
 
73
 
 
74
            static Action* action(const QModelIndex& index);
 
75
            static ActionCollection* collection(const QModelIndex& index);
 
76
 
 
77
 
 
78
        private:
 
79
            /// \internal d-pointer class.
 
80
            class Private;
 
81
            /// \internal d-pointer instance.
 
82
            Private* const d;
 
83
    };
 
84
 
 
85
    /**
 
86
     * The ActionCollectionProxyModel class implements a QSortFilterProxyModel 
 
87
     * for a \a ActionCollectionModel instance.
 
88
     */
 
89
    class KROSSCORE_EXPORT ActionCollectionProxyModel : public QSortFilterProxyModel
 
90
    {
 
91
        public:
 
92
            ActionCollectionProxyModel(QObject* parent, ActionCollectionModel* model = 0);
 
93
            virtual ~ActionCollectionProxyModel();
 
94
 
 
95
        private:
 
96
            virtual void setSourceModel(QAbstractItemModel* sourceModel);
 
97
            virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
 
98
    };
 
99
 
 
100
}
 
101
 
 
102
#endif
 
103