/usr/include/kross/ui/model.h is in kdelibs5-dev 4:4.14.16-0ubuntu3.
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 | /***************************************************************************
* model.h
* This file is part of the KDE project
* copyright (C) 2006-2007 by Sebastian Sauer (mail@dipe.org)
*
* This program 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 program 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 program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
***************************************************************************/
#ifndef KROSS_MODEL_H
#define KROSS_MODEL_H
#include <kross/core/krossconfig.h>
#include <QtCore/QModelIndex>
#include <QtGui/QSortFilterProxyModel>
namespace Kross {
// Forward declarations.
class Action;
class ActionCollection;
class ActionCollectionModelItem;
/**
* The ActionCollectionModel class implements a QAbstractItemModel to provide
* a model for views of a \a ActionCollection instance that manages a
* collection of \a Action instances.
*
* Important implementation detatils:
* \li An action can not have children.
* \li A collection can have both collections and actions as children.
* \li This model lists actions before collections.
* \li The internalPointer() of QModelIndex is used to hold a pointer to the parent collection.
*/
class KROSSUI_EXPORT ActionCollectionModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum Mode {
None = 0,
Icons = 1,
ToolTips = 2,
UserCheckable = 4
//Editable = 8
};
explicit ActionCollectionModel(QObject* parent, ActionCollection* collection = 0, Mode mode = Mode(Icons|ToolTips));
virtual ~ActionCollectionModel();
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
virtual QModelIndex parent(const QModelIndex& index) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
virtual bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex());
virtual bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex());
virtual bool insertColumns(int column, int count, const QModelIndex& parent = QModelIndex());
virtual bool removeColumns(int column, int count, const QModelIndex& parent = QModelIndex());
//Qt::DropActions supportedDragActions() const;
virtual QStringList mimeTypes() const;
virtual QMimeData* mimeData(const QModelIndexList& indexes) const;
virtual bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
virtual Qt::DropActions supportedDropActions() const;
QModelIndex indexForCollection( ActionCollection *collection ) const;
QModelIndex indexForAction( Action *action ) const;
/// Return the root collection
ActionCollection *rootCollection() const;
/**
* \return the \a Action instance the as argument passed QModelIndex
* represents or NULL if the QModelIndex is not a \a Action .
*/
static Action* action(const QModelIndex& index);
/**
* \return the \a ActionCollection instance the as argument passed QModelIndex
* represents or NULL if the QModelIndex is not a \a ActionCollection .
*/
static ActionCollection* collection(const QModelIndex& index);
protected:
/// @returns the row number of the @p collection
int rowNumber( ActionCollection *collection ) const;
private Q_SLOTS:
void slotUpdated();
void slotDataChanged( ActionCollection* );
void slotDataChanged( Action* );
void slotCollectionToBeInserted( ActionCollection* child, ActionCollection* parent );
void slotCollectionInserted( ActionCollection* child, ActionCollection* parent );
void slotCollectionToBeRemoved( ActionCollection* child, ActionCollection* parent );
void slotCollectionRemoved( ActionCollection* child, ActionCollection* parent );
void slotActionToBeInserted( Action* child, ActionCollection* parent );
void slotActionInserted( Action* child, ActionCollection* parent );
void slotActionToBeRemoved( Action* child, ActionCollection* parent );
void slotActionRemoved( Action* child, ActionCollection* parent );
private:
/// \internal d-pointer class.
class Private;
/// \internal d-pointer instance.
Private* const d;
};
/**
* The ActionCollectionProxyModel class implements a QSortFilterProxyModel
* for a \a ActionCollectionModel instance.
*/
class KROSSUI_EXPORT ActionCollectionProxyModel : public QSortFilterProxyModel
{
public:
explicit ActionCollectionProxyModel(QObject* parent, ActionCollectionModel* model = 0);
virtual ~ActionCollectionProxyModel();
private:
/// Set the \a ActionCollectionModel source model we are proxy for.
virtual void setSourceModel(QAbstractItemModel* sourceModel);
/// Implements a filter for the QModelIndex instances.
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
};
}
#endif
|