~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to tools/linguist/linguist/contextmodel.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the linguist application of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef CONTEXTMODEL_H
 
30
#define CONTEXTMODEL_H
 
31
 
 
32
#include "messagemodel.h"
 
33
 
 
34
#include <qabstractitemmodel.h>
 
35
#include <qlist.h>
 
36
 
 
37
class MessageModel;
 
38
class ContextModel;
 
39
 
 
40
class ContextItem
 
41
{
 
42
public:
 
43
    ContextItem(QString c);
 
44
    ~ContextItem();
 
45
 
 
46
    inline bool danger() const {return dangerCount > 0;}
 
47
 
 
48
    void appendToComment(const QString& x);
 
49
    inline void incrementUnfinishedCount() {++unfinishedCount;}
 
50
    inline void decrementUnfinishedCount() {--unfinishedCount;}
 
51
    inline void incrementDangerCount() {++dangerCount;}
 
52
    inline void decrementDangerCount() {--dangerCount;}
 
53
    inline void incrementObsoleteCount() {++obsoleteCount;}
 
54
    inline bool isContextObsolete() const {return (obsoleteCount == msgItemList.count());}
 
55
 
 
56
    inline int unfinished() const {return unfinishedCount;}
 
57
    inline int obsolete() const {return obsoleteCount;}
 
58
 
 
59
    inline QString context() const {return ctxt;}
 
60
    inline QString comment() const {return com;}
 
61
    inline QString fullContext() const {return com.trimmed();}
 
62
    inline bool finished() const {return unfinishedCount == 0;}
 
63
 
 
64
    MessageItem *messageItem(int i);
 
65
    inline const QList<MessageItem *> messageItemList() const {return msgItemList;}
 
66
    inline void appendMessageItem(MessageItem *msgItem) {msgItemList.append(msgItem);}
 
67
    inline int messageItemsInList() const {return msgItemList.count();}
 
68
 
 
69
    static bool compare(const MessageItem *left, const MessageItem *right);
 
70
    void sortMessages(int column, Qt::SortOrder order);
 
71
    bool sortParameters(Qt::SortOrder &so, int &sc) const;
 
72
 
 
73
private:
 
74
    Qt::SortOrder sortOrder;
 
75
    int sortColumn;
 
76
    QString com;
 
77
    QString ctxt;
 
78
    int unfinishedCount;
 
79
    int dangerCount;
 
80
    int obsoleteCount;
 
81
    QList<MessageItem *> msgItemList;
 
82
};
 
83
 
 
84
class ContextModel : public QAbstractTableModel
 
85
{
 
86
    Q_OBJECT
 
87
 
 
88
public:
 
89
    ContextModel(QObject *parent = 0);
 
90
 
 
91
    ContextItem *contextItem(const QModelIndex &indx) const;
 
92
    inline const QList<ContextItem *> contextList() const {return cntxtList;}
 
93
    inline void appendContextItem(ContextItem *cntxtItem) {cntxtList.append(cntxtItem);}
 
94
    inline int contextsInList() const {return cntxtList.count();}
 
95
 
 
96
    void updateItem(QModelIndex indx);
 
97
    void updateAll();
 
98
    void clearContextList();
 
99
 
 
100
    static bool compare(const ContextItem *left, const ContextItem *right);
 
101
    bool sortParameters(Qt::SortOrder &so, int &sc) const;
 
102
 
 
103
    // from abstracttablemodel
 
104
    void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
 
105
 
 
106
    int rowCount(const QModelIndex &) const;
 
107
    int columnCount(const QModelIndex &) const;
 
108
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
 
109
    QVariant headerData(int section, Qt::Orientation orientation,
 
110
                        int role = Qt::DisplayRole) const;
 
111
private:
 
112
    Qt::SortOrder sortOrder;
 
113
    int sortColumn;
 
114
 
 
115
    QList<ContextItem *> cntxtList;
 
116
};
 
117
 
 
118
#endif //CONTEXTMODEL_H