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

« back to all changes in this revision

Viewing changes to tools/linguist/linguist/trwindow.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 TRWINDOW_H
 
30
#define TRWINDOW_H
 
31
 
 
32
#include "phrase.h"
 
33
 
 
34
#include <metatranslator.h>
 
35
#include <qmainwindow.h>
 
36
#include <qhash.h>
 
37
#include <qprinter.h>
 
38
 
 
39
class QModelIndex;
 
40
class QStringList;
 
41
class QPixmap;
 
42
class QAction;
 
43
class QDialog;
 
44
class QLabel;
 
45
class QMenu;
 
46
class QAssistantClient;
 
47
template <typename T> class QList;
 
48
class QIcon;
 
49
 
 
50
class QTreeView;
 
51
class PhraseModel;
 
52
class PhraseItem;
 
53
class MessageModel;
 
54
class MessageItem;
 
55
class ContextModel;
 
56
class ContextItem;
 
57
class FindDialog;
 
58
class MessageEditor;
 
59
class Statistics;
 
60
 
 
61
#define TREEVIEW_ODD_COLOR QColor(235,245,255)
 
62
 
 
63
class TrWindow : public QMainWindow
 
64
{
 
65
    Q_OBJECT
 
66
public:
 
67
    enum {PhraseCloseMenu, PhraseEditMenu, PhrasePrintMenu};
 
68
 
 
69
    static QPixmap *pxOn;
 
70
    static QPixmap *pxOff;
 
71
    static QPixmap *pxObsolete;
 
72
    static QPixmap *pxDanger;
 
73
    static QPixmap *pxWarning;
 
74
    static QPixmap *pxEmpty;
 
75
    static const QPixmap pageCurl();
 
76
 
 
77
    TrWindow();
 
78
    ~TrWindow();
 
79
 
 
80
    void openFile(const QString &name);
 
81
 
 
82
protected:
 
83
    void readConfig();
 
84
    void writeConfig();
 
85
    void closeEvent(QCloseEvent *);
 
86
 
 
87
signals:
 
88
    void statsChanged(int w, int c, int cs, int w2, int c2, int cs2);
 
89
 
 
90
private slots:
 
91
    void doneAndNext();
 
92
    void prev();
 
93
    void next();
 
94
    void recentFileActivated(QAction *action);
 
95
    void setupRecentFilesMenu();
 
96
    void open();
 
97
    void save();
 
98
    void saveAs();
 
99
    void release();
 
100
    void print();
 
101
    void find();
 
102
    void findAgain();
 
103
    void newPhraseBook();
 
104
    void openPhraseBook();
 
105
    void closePhraseBook(QAction *action);
 
106
    void editPhraseBook(QAction *action);
 
107
    void printPhraseBook(QAction *action);
 
108
    void manual();
 
109
    void revertSorting();
 
110
    void about();
 
111
    void aboutQt();
 
112
    void updateViewMenu();
 
113
 
 
114
    void setupPhrase();
 
115
    bool maybeSave();
 
116
    void updateCaption();
 
117
    void showNewScope(const QModelIndex &current, const QModelIndex &old);
 
118
    void showNewCurrent(const QModelIndex &current, const QModelIndex &old);
 
119
    void updateTranslation(const QString &translation);
 
120
    void updateFinished(bool finished);
 
121
    void toggleFinished(const QModelIndex &index);
 
122
    void prevUnfinished();
 
123
    void nextUnfinished();
 
124
    void findNext(const QString &text, int where, bool matchCase);
 
125
    void revalidate();
 
126
    void toggleGuessing();
 
127
    void focusSourceList();
 
128
    void focusPhraseList();
 
129
    void toggleStatistics();
 
130
    void updateStatistics();
 
131
    void onWhatsThis();
 
132
 
 
133
private:
 
134
 
 
135
    typedef QHash<QString, PhraseBook> PBD;
 
136
 
 
137
    static QString friendlyString(const QString &str);
 
138
 
 
139
    int findCurrentContextRow();
 
140
    int findCurrentMessageRow();
 
141
    bool setNextMessage(int *currentrow, bool checkUnfinished);
 
142
    bool setPrevMessage(int *currentrow, bool checkUnfinished);
 
143
    bool setNextContext(int *currentrow, bool checkUnfinished);
 
144
    bool setPrevContext(int *currentrow, bool checkUnfinished);
 
145
    bool next(bool checkUnfinished);
 
146
    bool prev(bool checkUnfinished);
 
147
 
 
148
    void addRecentlyOpenedFile(const QString &fn, QStringList &lst);
 
149
    void setupMenuBar();
 
150
    void setupToolBars();
 
151
    void setCurrentContextRow(int row);
 
152
    void setCurrentMessageRow(int row);
 
153
    void setCurrentContext(const QModelIndex &indx);
 
154
    void setCurrentMessage(const QModelIndex &indx);
 
155
    QString friendlyPhraseBookName(const PhraseBook &pb) const;
 
156
    PhraseBook phraseBookFromFileName(QString name) const;
 
157
    bool openPhraseBook(const QString &name);
 
158
    bool phraseBooksContains(QString name);
 
159
    bool savePhraseBook(QString &name, const PhraseBook &pb);
 
160
    void updateProgress();
 
161
    void updatePhraseDict();
 
162
    PhraseBook getPhrases(const QString &source);
 
163
    bool danger(const QString &source, const QString &translation,
 
164
        bool verbose = false);
 
165
 
 
166
    void insertMessage(MessageItem *m);
 
167
    void printDanger(MessageItem *m);
 
168
    bool updateDanger(MessageItem *m, bool verbose = false);
 
169
 
 
170
    bool searchItem(const QString &searchWhat, int c, int m);
 
171
    void doCharCounting( const QString& text, int& trW, int& trC, int& trCS );
 
172
 
 
173
    QAssistantClient *ac;
 
174
    QTreeView *tv;
 
175
    ContextModel *cmdl;
 
176
    QTreeView *stv;
 
177
    MessageModel *mmdl;
 
178
    QTreeView *ptv;
 
179
    PhraseModel *pmdl;
 
180
    MessageEditor * me;
 
181
    QLabel        * progress;
 
182
    QLabel        * modified;
 
183
    MetaTranslator tor;
 
184
    bool dirty;
 
185
    int  numFinished;
 
186
    int  numNonobsolete;
 
187
    int  numMessages;
 
188
    QStringList recentFiles;
 
189
    QString     filename;
 
190
    PBD phraseDict;
 
191
    QMap<QAction *, PhraseBook> phraseBooks[3];
 
192
    QPrinter printer;
 
193
 
 
194
    FindDialog *finddlg;
 
195
    QString findText;
 
196
    int findWhere;
 
197
    bool findMatchCase;
 
198
    int foundWhere;
 
199
    int foundOffset;
 
200
 
 
201
    QDockWidget *dwScope;
 
202
 
 
203
    QMenu *phrasep;
 
204
    QMenu *closePhraseBookp;
 
205
    QMenu *editPhraseBookp;
 
206
    QMenu *printPhraseBookp;
 
207
    QMenu *recentFilesMenu;
 
208
    QMenu *tbMenu;
 
209
 
 
210
    QAction *closePhraseBookId;
 
211
    QAction *editPhraseBookId;
 
212
    QAction *printPhraseBookId;
 
213
    QAction *openAct;
 
214
    QAction *saveAct;
 
215
    QAction *saveAsAct;
 
216
    QAction *releaseAct;
 
217
    QAction *printAct;
 
218
    QAction *exitAct;
 
219
    QAction *undoAct;
 
220
    QAction *redoAct;
 
221
    QAction *cutAct;
 
222
    QAction *copyAct;
 
223
    QAction *pasteAct;
 
224
    QAction *selectAllAct;
 
225
    QAction *findAct;
 
226
    QAction *findAgainAct;
 
227
    QAction *replaceAct;
 
228
    QAction *newPhraseBookAct;
 
229
    QAction *openPhraseBookAct;
 
230
    QAction *acceleratorsAct;
 
231
    QAction *endingPunctuationAct;
 
232
    QAction *phraseMatchesAct;
 
233
    QAction *revertSortingAct;
 
234
    QAction *aboutAct;
 
235
    QAction *aboutQtAct;
 
236
    QAction *manualAct;
 
237
    QAction *whatsThisAct;
 
238
    QAction *beginFromSourceAct;
 
239
    QAction *prevAct;
 
240
    QAction *nextAct;
 
241
    QAction *prevUnfinishedAct;
 
242
    QAction *nextUnfinishedAct;
 
243
    QAction *doneAndNextAct;
 
244
    QAction *doneAndNextAlt;
 
245
    QAction *doGuessesAct;
 
246
    QAction *toggleStats;
 
247
    Statistics *stats;
 
248
    int  srcWords;
 
249
    int  srcChars;
 
250
    int  srcCharsSpc;
 
251
};
 
252
 
 
253
#endif