~ubuntu-branches/debian/sid/kexi/sid

« back to all changes in this revision

Viewing changes to src/widget/navigator/KexiProjectModel.h

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2017-06-24 20:10:10 UTC
  • Revision ID: package-import@ubuntu.com-20170624201010-5lrzd5r2vwthwifp
Tags: upstream-3.0.1.1
Import upstream version 3.0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2010-2011 Adam Pigg <adam@piggz.co.uk>
 
3
   Copyright (C) 2010-2014 Jarosław Staniek <staniek@kde.org>
 
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 version 2 as published by the Free Software Foundation.
 
8
 
 
9
   This library is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
   Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  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 KEXIPROJECTMODEL_H
 
21
#define KEXIPROJECTMODEL_H
 
22
 
 
23
#include "kexiextwidgets_export.h"
 
24
 
 
25
#include <kexipart.h>
 
26
#include <KexiSearchableModel.h>
 
27
 
 
28
#include <QModelIndex>
 
29
#include <QAbstractItemModel>
 
30
 
 
31
class KexiProjectModelItem;
 
32
class KexiProject;
 
33
 
 
34
class KEXIEXTWIDGETS_EXPORT KexiProjectModel : public QAbstractItemModel, public KexiSearchableModel
 
35
{
 
36
    Q_OBJECT
 
37
public:
 
38
    explicit KexiProjectModel(QObject* parent = 0);
 
39
    virtual ~KexiProjectModel();
 
40
 
 
41
    enum ExtraRoles {
 
42
        SearchHighlight = Qt::UserRole + 0 //!< item is highlighted when corresponding global search
 
43
                                           //!< completion is highlighted
 
44
    };
 
45
 
 
46
    KexiProject* project() const;
 
47
    void setProject(KexiProject* prj, const QString& itemsPartClass, QString* partManagerErrorMessages);
 
48
    QString itemsPartClass() const;
 
49
    //! @return number of objects
 
50
    int objectsCount() const;
 
51
 
 
52
    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
 
53
    virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
 
54
    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
 
55
    virtual QModelIndex parent(const QModelIndex& child) const;
 
56
    virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
 
57
    virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const;
 
58
    virtual Qt::ItemFlags flags(const QModelIndex& index) const;
 
59
 
 
60
    void updateItemName(KexiPart::Item& item, bool dirty);
 
61
    QModelIndex indexFromItem(KexiProjectModelItem *item) const;
 
62
    KexiProjectModelItem *modelItemFromItem(const KexiPart::Item &item) const;
 
63
    KexiProjectModelItem *modelItemFromName(const QString &name) const;
 
64
 
 
65
    void clear();
 
66
 
 
67
    //! @return index of first part item (looking from the top) or invalid item
 
68
    //! if there are no part items
 
69
    QModelIndex firstPartItem() const;
 
70
 
 
71
    //! Implemented for KexiSearchableModel
 
72
    virtual int searchableObjectCount() const;
 
73
 
 
74
    //! Implemented for KexiSearchableModel
 
75
    virtual QModelIndex sourceIndexForSearchableObject(int objectIndex) const;
 
76
 
 
77
    //! Implemented for KexiSearchableModel
 
78
    virtual QVariant searchableData(const QModelIndex &sourceIndex, int role) const;
 
79
 
 
80
    //! Implemented for KexiSearchableModel
 
81
    virtual QString pathFromIndex(const QModelIndex &sourceIndex) const;
 
82
 
 
83
    //! Implemented for KexiSearchableModel
 
84
    virtual bool highlightSearchableObject(const QModelIndex &index);
 
85
 
 
86
    //! Implemented for KexiSearchableModel
 
87
    virtual bool activateSearchableObject(const QModelIndex &index);
 
88
 
 
89
    QPersistentModelIndex itemWithSearchHighlight() const;
 
90
 
 
91
    bool renameItem(KexiPart::Item *item, const QString& newName);
 
92
    bool setItemCaption(KexiPart::Item *item, const QString& newCaption);
 
93
 
 
94
public Q_SLOTS:
 
95
    void slotAddItem(KexiPart::Item *item);
 
96
    void slotRemoveItem(const KexiPart::Item &item);
 
97
 
 
98
Q_SIGNALS:
 
99
    void renameItem(KexiPart::Item *item, const QString& newName, bool *succes);
 
100
    void changeItemCaption(KexiPart::Item *item, const QString& newCaption, bool *succes);
 
101
    void highlightSearchedItem(const QModelIndex &index);
 
102
    void activateSearchedItem(const QModelIndex &index);
 
103
 
 
104
private:
 
105
    KexiProjectModelItem* addGroup(KexiPart::Info *info, KexiProjectModelItem *parent) const;
 
106
    KexiProjectModelItem* addItem(KexiPart::Info *info, KexiPart::Item *item,
 
107
                                  KexiProjectModelItem *parent) const;
 
108
 
 
109
    //! @return index of first part item within children of parentIndex (recursively)
 
110
    QModelIndex firstChildPartItem(const QModelIndex &parentIndex) const;
 
111
 
 
112
    class Private;
 
113
    Private * const d;
 
114
};
 
115
 
 
116
#endif // KEXIPROJECTMODEL_H