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
****************************************************************************/
34
#include <metatranslator.h>
35
#include <qmainwindow.h>
46
class QAssistantClient;
47
template <typename T> class QList;
61
#define TREEVIEW_ODD_COLOR QColor(235,245,255)
63
class TrWindow : public QMainWindow
67
enum {PhraseCloseMenu, PhraseEditMenu, PhrasePrintMenu};
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();
80
void openFile(const QString &name);
85
void closeEvent(QCloseEvent *);
88
void statsChanged(int w, int c, int cs, int w2, int c2, int cs2);
94
void recentFileActivated(QAction *action);
95
void setupRecentFilesMenu();
103
void newPhraseBook();
104
void openPhraseBook();
105
void closePhraseBook(QAction *action);
106
void editPhraseBook(QAction *action);
107
void printPhraseBook(QAction *action);
109
void revertSorting();
112
void updateViewMenu();
116
void updateCaption();
117
void showNewScope(const QModelIndex ¤t, const QModelIndex &old);
118
void showNewCurrent(const QModelIndex ¤t, 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);
126
void toggleGuessing();
127
void focusSourceList();
128
void focusPhraseList();
129
void toggleStatistics();
130
void updateStatistics();
135
typedef QHash<QString, PhraseBook> PBD;
137
static QString friendlyString(const QString &str);
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);
148
void addRecentlyOpenedFile(const QString &fn, QStringList &lst);
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);
166
void insertMessage(MessageItem *m);
167
void printDanger(MessageItem *m);
168
bool updateDanger(MessageItem *m, bool verbose = false);
170
bool searchItem(const QString &searchWhat, int c, int m);
171
void doCharCounting( const QString& text, int& trW, int& trC, int& trCS );
173
QAssistantClient *ac;
188
QStringList recentFiles;
191
QMap<QAction *, PhraseBook> phraseBooks[3];
201
QDockWidget *dwScope;
204
QMenu *closePhraseBookp;
205
QMenu *editPhraseBookp;
206
QMenu *printPhraseBookp;
207
QMenu *recentFilesMenu;
210
QAction *closePhraseBookId;
211
QAction *editPhraseBookId;
212
QAction *printPhraseBookId;
224
QAction *selectAllAct;
226
QAction *findAgainAct;
228
QAction *newPhraseBookAct;
229
QAction *openPhraseBookAct;
230
QAction *acceleratorsAct;
231
QAction *endingPunctuationAct;
232
QAction *phraseMatchesAct;
233
QAction *revertSortingAct;
237
QAction *whatsThisAct;
238
QAction *beginFromSourceAct;
241
QAction *prevUnfinishedAct;
242
QAction *nextUnfinishedAct;
243
QAction *doneAndNextAct;
244
QAction *doneAndNextAlt;
245
QAction *doGuessesAct;
246
QAction *toggleStats;