1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the linguist application of the Qt Toolkit.
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.
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.
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.
21
** Contact info@trolltech.com if any conditions of this licensing are
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.
27
****************************************************************************/
29
#ifndef CONTEXTMODEL_H
30
#define CONTEXTMODEL_H
32
#include "messagemodel.h"
34
#include <qabstractitemmodel.h>
43
ContextItem(QString c);
46
inline bool danger() const {return dangerCount > 0;}
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());}
56
inline int unfinished() const {return unfinishedCount;}
57
inline int obsolete() const {return obsoleteCount;}
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;}
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();}
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;
74
Qt::SortOrder sortOrder;
81
QList<MessageItem *> msgItemList;
84
class ContextModel : public QAbstractTableModel
89
ContextModel(QObject *parent = 0);
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();}
96
void updateItem(QModelIndex indx);
98
void clearContextList();
100
static bool compare(const ContextItem *left, const ContextItem *right);
101
bool sortParameters(Qt::SortOrder &so, int &sc) const;
103
// from abstracttablemodel
104
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
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;
112
Qt::SortOrder sortOrder;
115
QList<ContextItem *> cntxtList;
118
#endif //CONTEXTMODEL_H