diff options
Diffstat (limited to 'experimental/tqtinterface/qt4/tools/linguist/linguist')
76 files changed, 8330 insertions, 0 deletions
diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/about.ui b/experimental/tqtinterface/qt4/tools/linguist/linguist/about.ui new file mode 100644 index 000000000..4d57398a2 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/about.ui @@ -0,0 +1,223 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>AboutDialog</class> +<comment>********************************************************************* +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +*********************************************************************</comment> +<widget class="TQDialog"> + <property name="name"> + <cstring>AboutDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>484</width> + <height>640</height> + </rect> + </property> + <property name="caption"> + <string>Qt Linguist</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>PixmapLabel1</cstring> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="pixmap"> + <pixmap>splash.png</pixmap> + </property> + <property name="scaledContents"> + <bool>false</bool> + </property> + <property name="tqalignment"> + <set>AlignCenter</set> + </property> + <property name="hAlign" stdset="0"> + </property> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>versionLabel</cstring> + </property> + <property name="tqalignment"> + <set>AlignCenter</set> + </property> + <property name="hAlign" stdset="0"> + </property> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel1_2</cstring> + </property> + <property name="text"> + <string>Copyright (C) 2000-2008 Trolltech ASA. All Rights Reserved.</string> + </property> + <property name="tqalignment"> + <set>AlignCenter</set> + </property> + <property name="hAlign" stdset="0"> + </property> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>TextLabel1_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><p>Qt Commercial Edition license holders: This program is licensed to you under the terms of the Qt Commercial License Agreement. For details, see the file LICENSE that came with this software distribution.</p><p></p><p>Qt Open Source Edition users: This program is licensed to you under the terms of the GNU General Public License Version 2. For details, see the file LICENSE.GPL that came with this software distribution.</p><p>The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</p></string> + </property> + <property name="tqalignment"> + <set>WordBreak|AlignVCenter|AlignLeft</set> + </property> + <property name="wordwrap" stdset="0"> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>Layout1</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer> + <property name="name"> + <cstring>Spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton"> + <property name="name"> + <cstring>PushButton1</cstring> + </property> + <property name="text"> + <string>OK</string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>PushButton1</sender> + <signal>clicked()</signal> + <receiver>AboutDialog</receiver> + <slot>accept()</slot> + </connection> +</connections> +<Q_SLOTS> + <slot access="protected">init()</slot> + <slot access="protected">destroy()</slot> +</Q_SLOTS> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/finddialog.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/finddialog.cpp new file mode 100644 index 000000000..6dc876cc6 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/finddialog.cpp @@ -0,0 +1,183 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +/* TRANSLATOR FindDialog + + Choose Edit|Find from the menu bar or press Ctrl+F to pop up the + Find dialog +*/ + +#include "finddialog.h" + +#include <tqcheckbox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqlineedit.h> +#include <tqpushbutton.h> +#include <tqwhatsthis.h> + +FindDialog::FindDialog( bool tqreplace, TQWidget *tqparent, const char *name, + bool modal ) + : TQDialog( tqparent, name, modal ) +{ + sourceText = 0; + + led = new TQLineEdit( this, "tqfind line edit" ); + TQLabel *tqfindWhat = new TQLabel( led, tr("Fi&nd what:"), this, "tqfind what" ); + TQLabel *tqreplaceWith = 0; + TQPushButton *tqfindNxt = new TQPushButton( tr("&Find Next"), this, + "tqfind next" ); + tqfindNxt->setDefault( TRUE ); + connect( tqfindNxt, TQT_SIGNAL(clicked()), this, TQT_SLOT(emitFindNext()) ); + TQPushButton *cancel = new TQPushButton( tr("Cancel"), this, "cancel tqfind" ); + connect( cancel, TQT_SIGNAL(clicked()), this, TQT_SLOT(reject()) ); + + TQVBoxLayout *bl = new TQVBoxLayout( 6, "tqfind button tqlayout" ); + bl->addWidget( tqfindNxt ); + + matchCase = new TQCheckBox( tr("&Match case"), this, "tqfind match case" ); + matchCase->setChecked( FALSE ); + + if ( tqreplace ) { + TQWhatsThis::add( this, tr("This window allows you to search and tqreplace" + " some text in the translations.") ); + + red = new TQLineEdit( this, "tqreplace line edit" ); + tqreplaceWith = new TQLabel( red, tr("Replace &with:"), this, + "tqreplace with" ); + setTabOrder( led, red ); + + TQPushButton *tqreplace = new TQPushButton( tr("&Replace"), this, + "tqreplace" ); + connect( tqreplace, TQT_SIGNAL(clicked()), this, TQT_SLOT(emitReplace()) ); + TQPushButton *tqreplaceAll = new TQPushButton( tr("Replace &All"), this, + "tqreplace all" ); + connect( tqreplaceAll, TQT_SIGNAL(clicked()), this, TQT_SLOT(emitReplaceAll()) ); + setTabOrder( tqfindNxt, tqreplace ); + setTabOrder( tqreplace, tqreplaceAll ); + setTabOrder( tqreplaceAll, cancel ); + + TQWhatsThis::add( tqreplace, tr("Click here to tqreplace the next occurrence" + " of the text you typed in.") ); + TQWhatsThis::add( tqreplaceAll, tr("Click here to tqreplace all occurrences" + " of the text you typed in.") ); + + bl->addWidget( tqreplace ); + bl->addWidget( tqreplaceAll ); + + TQGridLayout *gl = new TQGridLayout( this, 4, 3, 11, 11, + "tqfind outer tqlayout" ); + gl->addWidget( tqfindWhat, 0, 0 ); + gl->addWidget( led, 0, 1 ); + gl->addWidget( tqreplaceWith, 1, 0 ); + gl->addWidget( red, 1, 1 ); + gl->addMultiCellWidget( matchCase, 2, 2, 0, 1 ); + gl->addMultiCell( bl, 0, 3, 3, 3 ); + } else { + TQWhatsThis::add( this, tr("This window allows you to search for some" + " text in the translation source file.") ); + + sourceText = new TQCheckBox( tr("&Source texts"), this, + "tqfind in source texts" ); + sourceText->setChecked( TRUE ); + translations = new TQCheckBox( tr("&Translations"), this, + "tqfind in translations" ); + translations->setChecked( TRUE ); + comments = new TQCheckBox( tr("&Comments"), this, "tqfind in comments" ); + comments->setChecked( TRUE ); + + TQWhatsThis::add( sourceText, tr("Source texts are searched when" + " checked.") ); + TQWhatsThis::add( translations, tr("Translations are searched when" + " checked.") ); + TQWhatsThis::add( comments, tr("Comments and contexts are searched when" + " checked.") ); + + TQVBoxLayout *cl = new TQVBoxLayout( 6, "tqfind checkbox tqlayout" ); + + TQGridLayout *gl = new TQGridLayout( this, 3, 4, 11, 11, + "tqfind outer tqlayout" ); + gl->addWidget( tqfindWhat, 0, 0 ); + gl->addMultiCellWidget( led, 0, 0, 1, 2 ); + gl->addWidget( matchCase, 1, 2 ); + gl->addMultiCell( bl, 0, 2, 3, 3 ); + gl->addMultiCell( cl, 1, 2, 0, 1 ); + gl->setColStretch( 0, 0 ); + gl->addColSpacing( 1, 40 ); + gl->setColStretch( 2, 1 ); + gl->setColStretch( 3, 0 ); + + cl->addWidget( sourceText ); + cl->addWidget( translations ); + cl->addWidget( comments ); + cl->addStretch( 1 ); + } + + TQWhatsThis::add( led, tr("Type in the text to search for.") ); + + TQWhatsThis::add( matchCase, tr("Texts such as 'TeX' and 'tex' are" + " considered as different when checked.") ); + TQWhatsThis::add( tqfindNxt, tr("Click here to tqfind the next occurrence of the" + " text you typed in.") ); + TQWhatsThis::add( cancel, tr("Click here to close this window.") ); + + bl->addWidget( cancel ); + bl->addStretch( 1 ); + + resize( 400, 1 ); + setMaximumHeight( height() ); + + led->setFocus(); +} + +void FindDialog::emitFindNext() +{ + int where; + if ( sourceText != 0 ) + where = ( sourceText->isChecked() ? SourceText : 0 ) | + ( translations->isChecked() ? Translations : 0 ) | + ( comments->isChecked() ? Comments : 0 ); + else + where = Translations; + emit tqfindNext( led->text(), where, matchCase->isChecked() ); +} + +void FindDialog::emitReplace() +{ + emit tqreplace( led->text(), red->text(), matchCase->isChecked(), FALSE ); +} + +void FindDialog::emitReplaceAll() +{ + emit tqreplace( led->text(), red->text(), matchCase->isChecked(), TRUE ); +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/finddialog.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/finddialog.h new file mode 100644 index 000000000..2cf8e4307 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/finddialog.h @@ -0,0 +1,69 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef FINDDIALOG_H +#define FINDDIALOG_H + +#include <tqdialog.h> + +class TQCheckBox; +class TQLineEdit; + +class FindDialog : public TQDialog +{ + Q_OBJECT + TQ_OBJECT +public: + enum { SourceText = 0x1, Translations = 0x2, Comments = 0x4 }; + + FindDialog( bool tqreplace, TQWidget *tqparent = 0, const char *name = 0, bool modal = FALSE ); + +Q_SIGNALS: + void tqfindNext( const TQString& text, int where, bool matchCase ); + void tqreplace( const TQString& before, const TQString& after, bool matchCase, bool all ); + +private Q_SLOTS: + void emitFindNext(); + void emitReplace(); + void emitReplaceAll(); + +private: + TQLineEdit *led; + TQLineEdit *red; + TQCheckBox *sourceText; + TQCheckBox *translations; + TQCheckBox *comments; + TQCheckBox *matchCase; +}; + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/accelerator.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/accelerator.png Binary files differnew file mode 100644 index 000000000..173adb4f8 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/accelerator.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/appicon.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/appicon.png Binary files differnew file mode 100644 index 000000000..90e143b65 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/appicon.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/book.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/book.png Binary files differnew file mode 100644 index 000000000..dd850abb0 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/book.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_accelerator.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_accelerator.png Binary files differnew file mode 100644 index 000000000..eaa2be614 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_accelerator.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_book.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_book.png Binary files differnew file mode 100644 index 000000000..b61d61172 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_book.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_doneandnext.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_doneandnext.png Binary files differnew file mode 100644 index 000000000..e3a3fe107 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_doneandnext.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editcopy.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editcopy.png Binary files differnew file mode 100644 index 000000000..578b59112 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editcopy.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editcut.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editcut.png Binary files differnew file mode 100644 index 000000000..8d50ae0a0 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editcut.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editpaste.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editpaste.png Binary files differnew file mode 100644 index 000000000..78cab1048 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_editpaste.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_fileopen.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_fileopen.png Binary files differnew file mode 100644 index 000000000..ddbd33d98 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_fileopen.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_filesave.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_filesave.png Binary files differnew file mode 100644 index 000000000..5d1476d28 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_filesave.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_next.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_next.png Binary files differnew file mode 100644 index 000000000..f455e1fdb --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_next.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_nextunfinished.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_nextunfinished.png Binary files differnew file mode 100644 index 000000000..c2b06ecaf --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_nextunfinished.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_phrase.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_phrase.png Binary files differnew file mode 100644 index 000000000..acdd2535e --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_phrase.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_prev.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_prev.png Binary files differnew file mode 100644 index 000000000..a68fe54fa --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_prev.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_prevunfinished.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_prevunfinished.png Binary files differnew file mode 100644 index 000000000..ce956a7b5 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_prevunfinished.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_print.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_print.png Binary files differnew file mode 100644 index 000000000..b2791a7b5 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_print.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_punctuation.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_punctuation.png Binary files differnew file mode 100644 index 000000000..8eebab8bf --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_punctuation.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_redo.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_redo.png Binary files differnew file mode 100644 index 000000000..6e993cc67 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_redo.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_danger.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_danger.png Binary files differnew file mode 100644 index 000000000..3fadeb146 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_danger.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_obs.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_obs.png Binary files differnew file mode 100644 index 000000000..4836e2ffd --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_obs.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_off.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_off.png Binary files differnew file mode 100644 index 000000000..58f7fb667 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_off.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_on.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_on.png Binary files differnew file mode 100644 index 000000000..4836e2ffd --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_s_check_on.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_searchfind.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_searchfind.png Binary files differnew file mode 100644 index 000000000..e85e33fe0 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_searchfind.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_undo.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_undo.png Binary files differnew file mode 100644 index 000000000..22ac97f27 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/d_undo.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/doneandnext.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/doneandnext.png Binary files differnew file mode 100644 index 000000000..1cf8888ec --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/doneandnext.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editcopy.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editcopy.png Binary files differnew file mode 100644 index 000000000..804c98ce5 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editcopy.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editcut.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editcut.png Binary files differnew file mode 100644 index 000000000..a911482df --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editcut.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editpaste.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editpaste.png Binary files differnew file mode 100644 index 000000000..193814121 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/editpaste.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/fileopen.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/fileopen.png Binary files differnew file mode 100644 index 000000000..300529013 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/fileopen.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/filesave.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/filesave.png Binary files differnew file mode 100644 index 000000000..c137165b0 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/filesave.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/next.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/next.png Binary files differnew file mode 100644 index 000000000..4b29ff454 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/next.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/nextunfinished.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/nextunfinished.png Binary files differnew file mode 100644 index 000000000..9892b6580 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/nextunfinished.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/pagecurl.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/pagecurl.png Binary files differnew file mode 100644 index 000000000..2d3f2ff8e --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/pagecurl.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/phrase.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/phrase.png Binary files differnew file mode 100644 index 000000000..d7dfcb5bf --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/phrase.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/prev.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/prev.png Binary files differnew file mode 100644 index 000000000..4e3556c8d --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/prev.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/prevunfinished.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/prevunfinished.png Binary files differnew file mode 100644 index 000000000..a3bed548b --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/prevunfinished.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/print.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/print.png Binary files differnew file mode 100644 index 000000000..cc083edf7 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/print.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/punctuation.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/punctuation.png Binary files differnew file mode 100644 index 000000000..849d4a9a0 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/punctuation.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/redo.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/redo.png Binary files differnew file mode 100644 index 000000000..abdad26c9 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/redo.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_danger.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_danger.png Binary files differnew file mode 100644 index 000000000..700530438 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_danger.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_obs.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_obs.png Binary files differnew file mode 100644 index 000000000..b171b2ab8 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_obs.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_off.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_off.png Binary files differnew file mode 100644 index 000000000..cf45bc090 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_off.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_on.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_on.png Binary files differnew file mode 100644 index 000000000..b5238f768 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/s_check_on.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/searchfind.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/searchfind.png Binary files differnew file mode 100644 index 000000000..3f369fdb3 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/searchfind.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/splash.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/splash.png Binary files differnew file mode 100644 index 000000000..8e807185d --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/splash.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/undo.png b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/undo.png Binary files differnew file mode 100644 index 000000000..839a823f6 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/undo.png diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/images/whatsthis.xpm b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/whatsthis.xpm new file mode 100644 index 000000000..e45dc2668 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/images/whatsthis.xpm @@ -0,0 +1,24 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"16 16 3 1", +" c None", +"o c #000000000000", +"a c #000000008000", +/* pixels */ +"o aaaaa ", +"oo aaa aaa ", +"ooo aaa aaa", +"oooo aa aa", +"ooooo aa aa", +"oooooo a aaa", +"ooooooo aaa ", +"oooooooo aaa ", +"ooooooooo aaa ", +"ooooo aaa ", +"oo ooo ", +"o ooo aaa ", +" ooo aaa ", +" ooo ", +" ooo ", +" ooo "}; diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.icns b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.icns Binary files differnew file mode 100644 index 000000000..f51565ecc --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.icns diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.ico b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.ico Binary files differnew file mode 100644 index 000000000..2816c7cc2 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.ico diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.pro b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.pro new file mode 100644 index 000000000..bd51ac3a5 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.pro @@ -0,0 +1,109 @@ +TEMPLATE = app +LANGUAGE = C++ +CONFIG += qt warn_on + + +SOURCES += finddialog.cpp \ + main.cpp \ + msgedit.cpp \ + phrase.cpp \ + phrasebookbox.cpp \ + phraselv.cpp \ + printout.cpp \ + simtexth.cpp \ + trwindow.cpp \ + listviews.cpp \ + ../shared/metatranslator.cpp +HEADERS += finddialog.h \ + msgedit.h \ + phrase.h \ + phrasebookbox.h \ + phraselv.h \ + printout.h \ + trwindow.h \ + listviews.h \ + ../shared/metatranslator.h + + +TRANSLATIONS = linguist_de.ts \ + linguist_fr.ts + +DEFINES += QT_INTERNAL_XML +include( ../../../src/qt_professional.pri ) + +DESTDIR = ../../../bin +TARGET = linguist + + +LIBS += -L$$QT_BUILD_TREE/lib -ltqassistantclient + +win32:RC_FILE = linguist.rc + +mac { + staticlib:CONFIG -= global_init_link_order #yuck + RC_FILE = linguist.icns +} + +PROJECTNAME = Qt Linguist + +target.path=$$bins.path +INSTALLS += target + +linguisttranslations.files = *.qm +linguisttranslations.path = $$translations.path +INSTALLS += linguisttranslations + +phrasebooks.path=$$data.path/phrasebooks +phrasebooks.files = ../phrasebooks/* +INSTALLS += phrasebooks +FORMS = about.ui \ + statistics.ui +IMAGES = images/accelerator.png \ + images/book.png \ + images/s_check_danger.png \ + images/s_check_obs.png \ + images/s_check_off.png \ + images/s_check_on.png \ + images/d_s_check_danger.png \ + images/d_s_check_obs.png \ + images/d_s_check_off.png \ + images/d_s_check_on.png \ + images/d_accelerator.png \ + images/d_book.png \ + images/d_doneandnext.png \ + images/d_editcopy.png \ + images/d_editcut.png \ + images/d_editpaste.png \ + images/d_fileopen.png \ + images/d_filesave.png \ + images/d_next.png \ + images/d_nextunfinished.png \ + images/d_prev.png \ + images/d_prevunfinished.png \ + images/d_phrase.png \ + images/d_print.png \ + images/d_punctuation.png \ + images/d_redo.png \ + images/d_searchfind.png \ + images/d_undo.png \ + images/doneandnext.png \ + images/editcopy.png \ + images/editcut.png \ + images/editpaste.png \ + images/punctuation.png \ + images/fileopen.png \ + images/filesave.png \ + images/appicon.png \ + images/next.png \ + images/nextunfinished.png \ + images/pagecurl.png \ + images/phrase.png \ + images/prev.png \ + images/prevunfinished.png \ + images/print.png \ + images/redo.png \ + images/searchfind.png \ + images/splash.png \ + images/undo.png \ + images/whatsthis.xpm +INCLUDEPATH += ../shared diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.rc b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.rc new file mode 100644 index 000000000..865e021c4 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "linguist.ico" diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist_de.ts b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist_de.ts new file mode 100644 index 000000000..31e6737e8 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist_de.ts @@ -0,0 +1,993 @@ +<!DOCTYPE TS><TS> +<context> + <name>AboutDialog</name> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copyright (C) 2000-2008 Trolltech ASA. All Rights Reserved.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><p>This program is licensed to you under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation. This gives you legal permission to copy, distribute and/or modify this software under certain conditions. For details, see the file 'LICENSE.GPL' that came with this software distribution. If you did not get the file, send email to info@trolltech.com.</p> +<p>The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</p></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>OK</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>EditorPage</name> + <message> + <source>Source text</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>FindDialog</name> + <comment>Choose Edit|Find from the menu bar or press Ctrl+F to pop up the Find dialog</comment> + <message> + <source>Fi&nd what:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Find Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cancel</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Match case</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This window allows you to search and tqreplace some text in the translations.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Replace &with:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Replace</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Replace &All</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to tqreplace the next occurrence of the text you typed in.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to tqreplace all occurrences of the text you typed in.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This window allows you to search for some text in the translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Source texts</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Translations</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Comments</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Source texts are searched when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translations are searched when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Comments and contexts are searched when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Type in the text to search for.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Texts such as 'TeX' and 'tex' are considered as different when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to tqfind the next occurrence of the text you typed in.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to close this window.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>MessageEditor</name> + <message> + <source>bell</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>backspace</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>new page</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>new line</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>carriage return</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>tab</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Source text</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrases</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrases and guesses:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This whole panel allows you to view and edit the translation of some source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This area shows the source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This area shows a comment that may guide you, and the context in which the text occurs.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is where you can enter or modify the translation of some source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Guess</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Guess (%1)</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>PageCurl</name> + <message> + <source>Next unfinished phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Previous unfinished phrase</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>PhraseBookBox</name> + <comment>Go to Phrase > Edit Phrase Book... The dialog that pops up is a PhraseBookBox.</comment> + <message> + <source>S&ource phrase:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Translation:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Definition:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&New Phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Remove Phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Save</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Close</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This window allows you to add, modify, or delete phrases in a phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is the phrase in the source language.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is the phrase in the target language corresponding to the source phrase.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is a definition for the source phrase.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to add the phrase to the phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to remove the phrase from the phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to save the changes made.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to close this window.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot save phrase book '%1'.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>PhraseLV</name> + <comment>The phrase list in the right panel of the main window (with Source phrase, Target phrase, and Definition in its header) is a PhraseLV object.</comment> + <message> + <source>(New Phrase)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is a list of phrase entries relevant to the source text. Each phrase is supplemented with a suggested translation and a definition.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><p><u>%1:</u>&nbsp;&nbsp;%2</p><p><u>%3:</u>&nbsp;&nbsp;%4</p><p><u>%5:</u>&nbsp;&nbsp;%6</p></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Source phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Definition</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>TQT_BASE_OBJECT_NAME</name> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>TrWindow</name> + <comment>This is the application's main window.</comment> + <message> + <source>Context</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Items</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>MOD</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This panel lists the source contexts.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This panel lists the source texts. Items that violate validation rules are marked with a warning.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Loading...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>%1 source phrase(s) loaded.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot open '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt translation source (*.ts) +All files (*)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>File saved.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot save '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt message files for released applications (*.qm) +All files (*)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Release</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>File created.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Context: %1</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>finished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>unresolved</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>obsolete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing... (page %1)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing completed</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing aborted</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Search wrapped.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot tqfind the string '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt phrase books (*.qph) +All files (*)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Create New Phrase Book</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>A file called '%1' already exists. Please choose another name.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrase book created.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>%1 phrase(s) loaded.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>%1 - %2</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Do you want to save '%1'?</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt Linguist by Trolltech</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>No phrase to translate.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>No untranslated phrases left.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&File</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Edit</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>V&alidation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Phrases</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&View</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Help</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Open...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+O</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Save</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+S</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save &As...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Release...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Print...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+P</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Re&cently opened files</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>E&xit</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Q</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Undo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Z</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Redo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Y</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cu&t</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+X</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Copy</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+C</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Paste</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+V</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select &All</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+A</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Find...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+F</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Find &Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Replace...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+H</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Prev Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+K</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Next Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+L</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>P&rev</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Shift+K</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ne&xt</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Shift+L</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done and &Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Enter</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Return</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Begin from Source</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+B</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&New Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+N</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Open Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Close Phrase Book</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Edit Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Print Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Accelerators</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Ending Punctuation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Phrase Matches</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Revert Sorting</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Display guesses</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Vie&ws</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Toolbars</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Manual</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&About</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>About &Qt</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&What's This?</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open a Qt translation source file (TS file) for editing.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save changes made to this Qt translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save changes made to this Qt translationsource file into a new file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Create a Qt message file suitable for released applications from the current message file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Print a list of all the phrases in the current Qt translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Close this window and exit.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Undo the last editing operation performed on the translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Redo an undone editing operation performed on the translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copy the selected translation text to the clipboard and deletes it.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copy the selected translation text to the clipboard.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Paste the clipboard text into the translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select the whole translation text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Search for some text in the translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Continue the search where it was left.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Search for some text in the translation source file and tqreplace it by another text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Create a new phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open a phrase book to assist translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Toggle validity checks of accelerators.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Toggle validity checks of ending punctuation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Toggle checking that phrase suggestions are used.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Sort the items back in the same order as in the message file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Set whether or not to display translation guesses.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Display the manual for %1.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Display information about %1.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Display information about the Qt toolkit by Trolltech.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Enter What's This? mode.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copies the source text into the translation field.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the next item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the previous item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the next unfinished item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the previous unfinished item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Marks this item as done and moves to the next unfinished item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>File</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Edit</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Validation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Help</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Print</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open Phrase Book</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Undo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Redo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cut</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copy</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Paste</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Find</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Replace</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Prev</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Prev Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Next Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done and Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Accelerators</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Punctuation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrases</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>What's This?</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot read from phrase book '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Close this phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Allow you to add, modify, or delete phrases of this phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Print the entries of the phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot create phrase book '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Accelerator possibly superfluous in translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Accelerator possibly missing in translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation does not end with the same punctuation as the source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>A phrase book suggestion for '%1' was ignored.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Version %1</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist_fr.ts b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist_fr.ts new file mode 100644 index 000000000..31e6737e8 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/linguist_fr.ts @@ -0,0 +1,993 @@ +<!DOCTYPE TS><TS> +<context> + <name>AboutDialog</name> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copyright (C) 2000-2008 Trolltech ASA. All Rights Reserved.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><p>This program is licensed to you under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation. This gives you legal permission to copy, distribute and/or modify this software under certain conditions. For details, see the file 'LICENSE.GPL' that came with this software distribution. If you did not get the file, send email to info@trolltech.com.</p> +<p>The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.</p></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>OK</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>EditorPage</name> + <message> + <source>Source text</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>FindDialog</name> + <comment>Choose Edit|Find from the menu bar or press Ctrl+F to pop up the Find dialog</comment> + <message> + <source>Fi&nd what:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Find Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cancel</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Match case</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This window allows you to search and tqreplace some text in the translations.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Replace &with:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Replace</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Replace &All</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to tqreplace the next occurrence of the text you typed in.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to tqreplace all occurrences of the text you typed in.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This window allows you to search for some text in the translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Source texts</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Translations</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Comments</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Source texts are searched when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translations are searched when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Comments and contexts are searched when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Type in the text to search for.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Texts such as 'TeX' and 'tex' are considered as different when checked.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to tqfind the next occurrence of the text you typed in.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to close this window.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>MessageEditor</name> + <message> + <source>bell</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>backspace</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>new page</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>new line</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>carriage return</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>tab</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Source text</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrases</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrases and guesses:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This whole panel allows you to view and edit the translation of some source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This area shows the source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This area shows a comment that may guide you, and the context in which the text occurs.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is where you can enter or modify the translation of some source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Guess</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Guess (%1)</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>PageCurl</name> + <message> + <source>Next unfinished phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Previous unfinished phrase</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>PhraseBookBox</name> + <comment>Go to Phrase > Edit Phrase Book... The dialog that pops up is a PhraseBookBox.</comment> + <message> + <source>S&ource phrase:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Translation:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Definition:</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&New Phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Remove Phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Save</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Close</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This window allows you to add, modify, or delete phrases in a phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is the phrase in the source language.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is the phrase in the target language corresponding to the source phrase.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is a definition for the source phrase.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to add the phrase to the phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to remove the phrase from the phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to save the changes made.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Click here to close this window.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot save phrase book '%1'.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>PhraseLV</name> + <comment>The phrase list in the right panel of the main window (with Source phrase, Target phrase, and Definition in its header) is a PhraseLV object.</comment> + <message> + <source>(New Phrase)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This is a list of phrase entries relevant to the source text. Each phrase is supplemented with a suggested translation and a definition.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source><p><u>%1:</u>&nbsp;&nbsp;%2</p><p><u>%3:</u>&nbsp;&nbsp;%4</p><p><u>%5:</u>&nbsp;&nbsp;%6</p></source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Source phrase</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Definition</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>TQT_BASE_OBJECT_NAME</name> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>TrWindow</name> + <comment>This is the application's main window.</comment> + <message> + <source>Context</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Items</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>MOD</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt Linguist</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This panel lists the source contexts.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>This panel lists the source texts. Items that violate validation rules are marked with a warning.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Loading...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>%1 source phrase(s) loaded.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot open '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt translation source (*.ts) +All files (*)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>File saved.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot save '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt message files for released applications (*.qm) +All files (*)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Release</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>File created.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Context: %1</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>finished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>unresolved</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>obsolete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing... (page %1)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing completed</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Printing aborted</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Search wrapped.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot tqfind the string '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt phrase books (*.qph) +All files (*)</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Create New Phrase Book</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>A file called '%1' already exists. Please choose another name.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrase book created.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>%1 phrase(s) loaded.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>%1 - %2</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Do you want to save '%1'?</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Qt Linguist by Trolltech</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>No phrase to translate.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>No untranslated phrases left.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&File</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Edit</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>V&alidation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Phrases</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&View</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Help</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Open...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+O</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Save</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+S</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save &As...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Release...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Print...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+P</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Re&cently opened files</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>E&xit</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Q</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Undo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Z</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Redo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Y</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cu&t</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+X</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Copy</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+C</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Paste</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+V</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select &All</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+A</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Find...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+F</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Find &Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Replace...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+H</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Prev Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+K</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Next Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+L</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>P&rev</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Shift+K</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ne&xt</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Shift+L</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done and &Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Enter</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+Return</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Begin from Source</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+B</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&New Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Ctrl+N</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Open Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Close Phrase Book</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Edit Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Print Phrase Book...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Accelerators</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Ending Punctuation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Phrase Matches</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Revert Sorting</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Display guesses</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Vie&ws</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Toolbars</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&Manual</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&About</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>About &Qt</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>&What's This?</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open a Qt translation source file (TS file) for editing.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save changes made to this Qt translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save changes made to this Qt translationsource file into a new file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Create a Qt message file suitable for released applications from the current message file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Print a list of all the phrases in the current Qt translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Close this window and exit.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Undo the last editing operation performed on the translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Redo an undone editing operation performed on the translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copy the selected translation text to the clipboard and deletes it.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copy the selected translation text to the clipboard.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Paste the clipboard text into the translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Select the whole translation text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Search for some text in the translation source file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Continue the search where it was left.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Search for some text in the translation source file and tqreplace it by another text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Create a new phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open a phrase book to assist translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Toggle validity checks of accelerators.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Toggle validity checks of ending punctuation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Toggle checking that phrase suggestions are used.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Sort the items back in the same order as in the message file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Set whether or not to display translation guesses.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Display the manual for %1.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Display information about %1.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Display information about the Qt toolkit by Trolltech.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Enter What's This? mode.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copies the source text into the translation field.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the next item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the previous item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the next unfinished item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Moves to the previous unfinished item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Marks this item as done and moves to the next unfinished item.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>File</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Edit</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Validation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Help</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Save</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Print</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Open Phrase Book</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Undo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Redo</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cut</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Copy</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Paste</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Find</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Replace</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Prev</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Prev Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Next Unfinished</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Done and Next</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Accelerators</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Punctuation</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Phrases</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>What's This?</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot read from phrase book '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Close this phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Allow you to add, modify, or delete phrases of this phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Print the entries of the phrase book.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Cannot create phrase book '%1'.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Accelerator possibly superfluous in translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Accelerator possibly missing in translation.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Translation does not end with the same punctuation as the source text.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>A phrase book suggestion for '%1' was ignored.</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>...</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Version %1</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/listviews.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/listviews.cpp new file mode 100644 index 000000000..5c298b2eb --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/listviews.cpp @@ -0,0 +1,350 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "listviews.h" + +#include <tqpainter.h> + +static const int Text0MaxLen = 150; +static const int Text1MaxLen = 150; + +/* + LVI implementation +*/ + +static TQString rho( int n ) +{ + TQString s; + s.sprintf( "%.10d", n ); + return s; +} + +int LVI::count = 0; + +LVI::LVI( TQListView * tqparent, TQString text ) + : TQListViewItem( tqparent, text ) +{ + setText( 0, rho(count++) ); +} + +LVI::LVI( TQListViewItem * tqparent, TQString text ) + : TQListViewItem( tqparent, text ) +{ + setText( 0, rho(count++) ); +} + +/* + This is a cut-down version of TQListViewItem::paintCell() - + it is needed to produce the effect we want on obsolete items + */ +void LVI::drawObsoleteText( TQPainter * p, const TQColorGroup & cg, int column, + int width, int align ) +{ + TQListView * lv = listView(); + int marg = lv ? lv->itemMargin() : 1; + int r = marg; + p->fillRect( 0, 0, width, height(), cg.brush( TQColorGroup::Base ) ); + if ( isSelected() && (column==0 || listView()->allColumnsShowFocus()) ) + p->fillRect( r - marg, 0, width - r + marg, height(), + cg.brush( TQColorGroup::Highlight ) ); + + // Do the ellipsis thingy + TQString t = text( column ); + TQString tmp; + int i = 0; + if ( p->fontMetrics().width( t ) > width ) { + tmp = "..."; + while ( p->fontMetrics().width( tmp + t[i] ) < width ) + tmp += t[ i++ ]; + tmp.remove( (uint)0, 3 ); + if ( tmp.isEmpty() ) + tmp = t.left( 1 ); + tmp += "..."; + t = tmp; + } + if ( isSelected() ) + p->setPen( lv->tqpalette().disabled().highlightedText() ); + else + p->setPen( lv->tqpalette().disabled().text() ); + + if ( !t.isEmpty() ) { + p->drawText( r, 0, width-marg-r, height(), + align | AlignVCenter | SingleLine, t ); + } + +} + +int LVI::compare( TQListViewItem *other, int column, bool ascending ) const +{ + TQString thisKey = key( column, ascending ); + TQString otherKey = other->key( column, ascending ); + + if ( thisKey.tqcontains('&') || otherKey.tqcontains('&') ) { + TQString nicerThisKey = thisKey; + TQString nicerOtherKey = otherKey; + + nicerThisKey.tqreplace( "&", "" ); + nicerOtherKey.tqreplace( "&", "" ); + + int delta = nicerThisKey.localeAwareCompare( nicerOtherKey ); + if ( delta != 0 ) + return delta; + } + return thisKey.localeAwareCompare( otherKey ); +} + +static TQString fixEllipsis( const TQString & str, int len ) +{ + TQString shortened = str.simplifyWhiteSpace(); + if ( (int) shortened.length() > len ) { + TQString dots = TrWindow::tr( "..." ); + shortened.truncate( len - dots.length() ); + shortened.append( dots ); + } + return shortened; +} + +/* + MessageLVI implementation +*/ +MessageLVI::MessageLVI( TQListView *tqparent, + const MetaTranslatorMessage & message, + const TQString& text, const TQString& comment, + ContextLVI * c ) + : LVI( tqparent ), m( message ), tx( text ), com( comment ), ctxt( c ) +{ + if ( m.translation().isEmpty() ) { + TQString t = ""; + m.setTranslation( t ); + } + setText( 1, fixEllipsis( text, Text0MaxLen ) ); + fini = TRUE; + d = FALSE; + + if( m.type() == MetaTranslatorMessage::Unfinished ) + setFinished( FALSE ); +} + +void MessageLVI::updateTranslationText() +{ + setText( 2, fixEllipsis( m.translation(), Text1MaxLen ) ); +} + +void MessageLVI::paintCell( TQPainter * p, const TQColorGroup & cg, int column, + int width, int align ) +{ + if ( column == 0 ) { + int x = (width/2) - TrWindow::pxOn->width()/2; + int y = (height()/2) - TrWindow::pxOn->height()/2; + + int marg = listView() ? listView()->itemMargin() : 1; + int r = marg; + + if ( isSelected() ) + p->fillRect( r - marg, 0, width - r + marg, height(), + cg.brush( TQColorGroup::Highlight ) ); + else + p->fillRect( 0, 0, width, height(), + cg.brush( TQColorGroup::Base ) ); + + if ( m.type() == MetaTranslatorMessage::Unfinished && danger() ) + p->drawPixmap( x, y, *TrWindow::pxDanger ); + else if ( m.type() == MetaTranslatorMessage::Finished ) + p->drawPixmap( x, y, *TrWindow::pxOn ); + else if ( m.type() == MetaTranslatorMessage::Unfinished ) + p->drawPixmap( x, y, *TrWindow::pxOff ); + else if ( m.type() == MetaTranslatorMessage::Obsolete ) + p->drawPixmap( x, y, *TrWindow::pxObsolete ); + } else { + if ( m.type() == MetaTranslatorMessage::Obsolete ) + drawObsoleteText( p, cg, column, width, align ); + else + TQListViewItem::paintCell( p, cg, column, width, align ); + } +} + + +void MessageLVI::setTranslation( const TQString& translation ) +{ + m.setTranslation( translation ); +} + +void MessageLVI::setFinished( bool finished ) +{ + if ( !fini && finished ) { + m.setType( MetaTranslatorMessage::Finished ); + tqrepaint(); + ctxt->decrementUnfinishedCount(); + } else if ( fini && !finished ) { + m.setType( MetaTranslatorMessage::Unfinished ); + tqrepaint(); + ctxt->incrementUnfinishedCount(); + } + fini = finished; +} + +void MessageLVI::setDanger( bool danger ) +{ + if ( !d && danger ) { + ctxt->incrementDangerCount(); + tqrepaint(); + } else if ( d && !danger ) { + ctxt->decrementDangerCount(); + tqrepaint(); + } + d = danger; +} + +TQString MessageLVI::context() const +{ + return TQString( m.context() ); +} + +MetaTranslatorMessage MessageLVI::message() const +{ + return m; +} + +/* + ContextLVI implementation +*/ +ContextLVI::ContextLVI( TQListView *lv, const TQString& context ) + : LVI( lv ), com( "" ) +{ + messageItems.setAutoDelete( TRUE ); + + unfinishedCount = 0; + dangerCount = 0; + obsoleteCount = 0; + itemCount = 0; + setText( 1, context ); +} + +void ContextLVI::instantiateMessageItem( TQListView * lv, MessageLVI * i ) +{ + itemCount++; + appendMessageItem( lv, i ); +} + +void ContextLVI::appendMessageItem( TQListView * lv, MessageLVI * i ) +{ + lv->takeItem( i ); + messageItems.append( i ); +} + +void ContextLVI::updatetqStatus() +{ + TQString s; + s.sprintf( "%d/%d", itemCount - unfinishedCount - obsoleteCount, + itemCount - obsoleteCount ); + setText( 2, s ); +} + +void ContextLVI::paintCell( TQPainter * p, const TQColorGroup & cg, int column, + int width, int align ) +{ + if ( column == 0 ) { + int x = (width/2) - TrWindow::pxOn->width()/2; + int y = (height()/2) - TrWindow::pxOn->height()/2; + + int marg = listView() ? listView()->itemMargin() : 1; + int r = marg; + + if ( isSelected() ) + p->fillRect( r - marg, 0, width - r + marg, height(), + cg.brush( TQColorGroup::Highlight ) ); + else + p->fillRect( 0, 0, width, height(), + cg.brush( TQColorGroup::Base ) ); + + if ( isContextObsolete() ) + p->drawPixmap( x, y, *TrWindow::pxObsolete ); + else if ( unfinishedCount == 0 ) + p->drawPixmap( x, y, *TrWindow::pxOn ); + else + p->drawPixmap( x, y, *TrWindow::pxOff ); + + } else { + if ( isContextObsolete() ) + drawObsoleteText( p, cg, column, width, align ); + else + TQListViewItem::paintCell( p, cg, column, width, align ); + } +} + +void ContextLVI::appendToComment( const TQString& x ) +{ + if ( !com.isEmpty() ) + com += TQString( "\n\n" ); + com += x; +} + +void ContextLVI::incrementUnfinishedCount() +{ + if ( unfinishedCount++ == 0 ) + tqrepaint(); +} + +void ContextLVI::decrementUnfinishedCount() +{ + if ( --unfinishedCount == 0 ) + tqrepaint(); +} + +void ContextLVI::incrementDangerCount() +{ + if ( dangerCount++ == 0 ) + tqrepaint(); +} + +void ContextLVI::decrementDangerCount() +{ + if ( --dangerCount == 0 ) + tqrepaint(); +} + +void ContextLVI::incrementObsoleteCount() +{ + if ( obsoleteCount++ == 0 ) + tqrepaint(); +} + +bool ContextLVI::isContextObsolete() +{ + return (obsoleteCount == itemCount); +} + +TQString ContextLVI::fullContext() const +{ + return comment().stripWhiteSpace(); +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/listviews.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/listviews.h new file mode 100644 index 000000000..de37b6658 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/listviews.h @@ -0,0 +1,135 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef LISTVIEWS_H +#define LISTVIEWS_H + +#include "msgedit.h" + +#include <tqstring.h> +#include <tqptrlist.h> +#include <tqregexp.h> +#include <tqlistview.h> + +class LVI : public TQListViewItem +{ +public: + LVI( TQListView *tqparent, TQString text = TQString() ); + LVI( TQListViewItem *tqparent, TQString text = TQString() ); + virtual int compare( TQListViewItem *other, int column, + bool ascending ) const; + virtual bool danger() const { return FALSE; } + +protected: + void drawObsoleteText( TQPainter * p, const TQColorGroup & cg, int column, + int width, int align ); + +private: + static int count; +}; + +class MessageLVI; +class ContextLVI : public LVI +{ +public: + ContextLVI( TQListView *lv, const TQString& context ); + + virtual bool danger() const { return dangerCount > 0; } + + void appendToComment( const TQString& x ); + void incrementUnfinishedCount(); + void decrementUnfinishedCount(); + void incrementDangerCount(); + void decrementDangerCount(); + void incrementObsoleteCount(); + bool isContextObsolete(); + void updatetqStatus(); + + TQString context() const { return text( 1 ); } + TQString comment() const { return com; } + TQString fullContext() const; + bool finished() const { return unfinishedCount == 0; } + + MessageLVI * firstMessageItem() { return messageItems.first(); } + MessageLVI * nextMessageItem() { return messageItems.next(); } + MessageLVI * takeMessageItem( int i ) { return messageItems.take( i ); } + void appendMessageItem( TQListView * lv, MessageLVI * i ); + void instantiateMessageItem( TQListView * lv, MessageLVI * i ); + int messageItemsInList() { return messageItems.count(); } + + void paintCell( TQPainter * p, const TQColorGroup & cg, int column, + int width, int align ); +private: + TQPtrList<MessageLVI> messageItems; + TQString com; + int unfinishedCount; + int dangerCount; + int obsoleteCount; + int itemCount; +}; + +class MessageLVI : public LVI +{ +public: + MessageLVI( TQListView *tqparent, const MetaTranslatorMessage & message, + const TQString& text, const TQString& comment, ContextLVI * c ); + + virtual bool danger() const { return d; } + + void setTranslation( const TQString& translation ); + void setFinished( bool finished ); + void setDanger( bool danger ); + + void setContextLVI( ContextLVI * c ) { ctxt = c; } + ContextLVI * contextLVI() const { return ctxt; } + void updateTranslationText(); + + TQString context() const; + TQString sourceText() const { return tx; } + TQString comment() const { return com; } + TQString translation() const { return m.translation(); } + bool finished() const { return fini; } + MetaTranslatorMessage message() const; + + void paintCell( TQPainter * p, const TQColorGroup & cg, int column, + int width, int align ); +private: + MetaTranslatorMessage m; + TQString tx; + TQString com; + bool fini; + bool d; + ContextLVI * ctxt; +}; + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/main.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/main.cpp new file mode 100644 index 000000000..13dd5258f --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/main.cpp @@ -0,0 +1,89 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "trwindow.h" + +#include <tqapplication.h> +#include <tqlabel.h> +#include <tqpixmap.h> +#include <tqtimer.h> +#include <tqtextcodec.h> +#include <tqtranslator.h> +#include <tqsettings.h> +#include <tqsplashscreen.h> + +int main( int argc, char **argv ) +{ + TQApplication app( argc, argv ); + TQApplication::setOverrideCursor( Qt::WaitCursor ); + + + TQTranslator translator( 0 ); + translator.load( TQString( "linguist_" ) + TQTextCodec::locale(), "." ); + app.installTranslator( &translator ); + + bool showSplash = TRUE; + + TQString keybase("/TQt Linguist/3.1/"); + TQSettings config; + config.insertSearchPath( TQSettings::Windows, "/Trolltech" ); + + TQRect r( TQApplication::desktop()->screenGeometry() ); + r.setX( config.readNumEntry( keybase + "Geometry/MainwindowX", r.x() ) ); + r.setY( config.readNumEntry( keybase + "Geometry/MainwindowY", r.y() ) ); + r.setWidth( config.readNumEntry( keybase + "Geometry/MainwindowWidth", r.width() ) ); + r.setHeight( config.readNumEntry( keybase + "Geometry/MainwindowHeight", r.height() ) ); + + TQSplashScreen *splash = 0; + if ( showSplash ) { + splash = new TQSplashScreen( TQPixmap::fromMimeSource("splash.png"), + (WFlags)TQt::WDestructiveClose ); + splash->show(); + } + + TrWindow *tw = new TrWindow; + app.setMainWidget( tw ); + + if ( app.argc() > 1 ) + tw->openFile( TQString(app.argv()[app.argc() - 1]) ); + + if ( config.readBoolEntry( keybase + "Geometry/MainwindowMaximized", FALSE ) ) + tw->showMaximized(); + else + tw->show(); + if ( splash ) + splash->finish( tw ); + TQApplication::restoreOverrideCursor(); + + return app.exec(); +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/msgedit.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/msgedit.cpp new file mode 100644 index 000000000..744cd16ab --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/msgedit.cpp @@ -0,0 +1,835 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +/* TRANSLATOR MsgEdit + + This is the right panel of the main window. +*/ + +#include "msgedit.h" + +#include "trwindow.h" +#include "phraselv.h" +#include "simtexth.h" + +#include <tqapplication.h> +#include <tqcheckbox.h> +#include <tqclipboard.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqtextedit.h> +#include <tqpalette.h> +#include <tqpushbutton.h> +#include <tqstring.h> +#include <tqtextview.h> +#include <tqwhatsthis.h> +#include <tqvbox.h> +#include <tqmainwindow.h> +#include <tqheader.h> +#include <tqregexp.h> +#include <tqdockarea.h> +#include <tqdockwindow.h> +#include <tqscrollview.h> +#include <tqfont.h> +#include <tqaccel.h> +#include <tqpainter.h> +#include <private/tqrichtext_p.h> + +static const int MaxCandidates = 5; + +class MED : public TQTextEdit +{ +public: + MED( TQWidget *tqparent, const char *name = 0 ) + : TQTextEdit( tqparent, name ) {} + + int cursorX() const { return textCursor()->x(); } + int cursorY() const { return textCursor()->paragraph()->rect().y() + + textCursor()->y(); } +}; + + +TQString richMeta( const TQString& text ) +{ + return TQString( "<small><font color=blue>(" ) + text + + TQString( ")</font></small>" ); +} + +TQString richText( const TQString& text ) +{ + const char backTab[] = "\a\b\f\n\r\t"; + const char * const friendlyBackTab[] = { + TQT_TRANSLATE_NOOP( "MessageEditor", "bell" ), + TQT_TRANSLATE_NOOP( "MessageEditor", "backspace" ), + TQT_TRANSLATE_NOOP( "MessageEditor", "new page" ), + TQT_TRANSLATE_NOOP( "MessageEditor", "new line" ), + TQT_TRANSLATE_NOOP( "MessageEditor", "carriage return" ), + TQT_TRANSLATE_NOOP( "MessageEditor", "tab" ) + }; + TQString rich; + + for ( int i = 0; i < (int) text.length(); i++ ) { + int ch = text[i].tqunicode(); + + if ( ch < 0x20 ) { + const char *p = strchr( backTab, ch ); + if ( p == 0 ) + rich += richMeta( TQString::number(ch, 16) ); + else + rich += richMeta( MessageEditor::tr(friendlyBackTab[p - backTab]) ); + } else if ( ch == '<' ) { + rich += TQString( "<" ); + } else if ( ch == '>' ) { + rich += TQString( ">" ); + } else if ( ch == '&' ) { + rich += TQString( "&" ); + } else if ( ch == ' ' ) { + if ( i == 0 || i == (text.length()-1) || text[i - 1] == ' ' || text[i + 1] == ' ' ) { + rich += richMeta( MessageEditor::tr("sp") ); + } else { + rich += ' '; + } + } else { + rich += TQChar( ch ); + } + if ( ch == '\n' ) + rich += TQString( "<br>" ); + } + return rich; +} + +/* + ShadowWidget class impl. + + Used to create a shadow like effect for a widget +*/ +ShadowWidget::ShadowWidget( TQWidget * tqparent, const char * name ) + : TQWidget( tqparent, name ), sWidth( 10 ), wMargin( 3 ), childWgt( 0 ) +{ +} + +ShadowWidget::ShadowWidget( TQWidget * child, TQWidget * tqparent, + const char * name ) + : TQWidget( tqparent, name ), sWidth( 10 ), wMargin( 3 ), childWgt( 0 ) +{ + setWidget( child ); +} + +void ShadowWidget::setWidget( TQWidget * child ) +{ + childWgt = child; + if ( childWgt && TQT_BASE_OBJECT(childWgt->tqparent()) != TQT_BASE_OBJECT(this) ) { + childWgt->reparent( this, TQPoint( 0, 0 ), TRUE ); + } +} + +void ShadowWidget::resizeEvent( TQResizeEvent * ) +{ + if( childWgt ) { + childWgt->move( wMargin, wMargin ); + childWgt->resize( width() - sWidth - wMargin, height() - sWidth - + wMargin ); + } +} + +void ShadowWidget::paintEvent( TQPaintEvent * e ) +{ + TQPainter p; + int w = width() - sWidth; + int h = height() - sWidth; + + + if ( !((w > 0) && (h > 0)) ) + return; + + if ( p.begin( this ) ) { + p.setPen( tqcolorGroup().shadow() ); + + p.drawPoint( w + 5, 6 ); + p.drawLine( w + 3, 6, w + 5, 8 ); + p.drawLine( w + 1, 6, w + 5, 10 ); + int i; + for( i=7; i < h; i += 2 ) + p.drawLine( w, i, w + 5, i + 5 ); + for( i = w - i + h; i > 6; i -= 2 ) + p.drawLine( i, h, i + 5, h + 5 ); + for( ; i > 0 ; i -= 2 ) + p.drawLine( 6, h + 6 - i, i + 5, h + 5 ); + +// p.eraseRect( w, 0, sWidth, 45 ); // Cheap hack for the page curl.. + p.end(); + } + TQWidget::paintEvent( e ); +} + +/* + EditorPage class impl. + + A frame that tqcontains the source text, translated text and any + source code comments and hints. +*/ +EditorPage::EditorPage( TQWidget * tqparent, const char * name ) + : TQFrame( tqparent, name ) +{ + setLineWidth( 1 ); + setFrameStyle( TQFrame::Box | TQFrame::Plain ); + + // Use white explicitly as the background color for the editor page. + TQPalette p = palette(); + p.setColor( TQPalette::Active, TQColorGroup::Base, TQColor( Qt::white ) ); + p.setColor( TQPalette::Inactive, TQColorGroup::Base, TQColor( Qt::white ) ); + p.setColor( TQPalette::Disabled, TQColorGroup::Base, TQColor( Qt::white ) ); + p.setColor( TQPalette::Active, TQColorGroup::Background, + p.active().color( TQColorGroup::Base ) ); + p.setColor( TQPalette::Inactive, TQColorGroup::Background, + p.inactive().color( TQColorGroup::Base ) ); + p.setColor( TQPalette::Disabled, TQColorGroup::Background, + p.disabled().color( TQColorGroup::Base ) ); + setPalette( p ); + + srcTextLbl = new TQLabel( tr("Source text"), this, "source text label" ); + transLbl = new TQLabel( tr("Translation"), this, "translation label" ); + + TQFont fnt = font(); + fnt.setBold( TRUE ); + srcTextLbl->setFont( fnt ); + transLbl->setFont( fnt ); + + srcText = new TQTextView( this, "source text view" ); + srcText->setFrameStyle( TQFrame::NoFrame ); + srcText->tqsetSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding, + TQSizePolicy::Minimum ) ); + srcText->setResizePolicy( TQScrollView::AutoOne ); + srcText->setHScrollBarMode( TQScrollView::AlwaysOff ); + srcText->setVScrollBarMode( TQScrollView::AlwaysOff ); + p = srcText->palette(); + p.setColor( TQPalette::Disabled, TQColorGroup::Base, p.active().base() ); + srcText->setPalette( p ); + connect( srcText, TQT_SIGNAL(textChanged()), TQT_SLOT(handleSourceChanges()) ); + + cmtText = new TQTextView( this, "comment/context view" ); + cmtText->setFrameStyle( TQFrame::NoFrame ); + cmtText->tqsetSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding, + TQSizePolicy::Minimum ) ); + cmtText->setResizePolicy( TQScrollView::AutoOne ); + cmtText->setHScrollBarMode( TQScrollView::AlwaysOff ); + cmtText->setVScrollBarMode( TQScrollView::AlwaysOff ); + p = cmtText->palette(); + p.setColor( TQPalette::Active, TQColorGroup::Base, TQColor( 236,245,255 ) ); + p.setColor( TQPalette::Inactive, TQColorGroup::Base, TQColor( 236,245,255 ) ); + cmtText->setPalette( p ); + connect( cmtText, TQT_SIGNAL(textChanged()), TQT_SLOT(handleCommentChanges()) ); + + translationMed = new MED( this, "translation editor" ); + translationMed->setFrameStyle( TQFrame::NoFrame ); + translationMed->tqsetSizePolicy( TQSizePolicy( TQSizePolicy::MinimumExpanding, + TQSizePolicy::MinimumExpanding ) ); + translationMed->setHScrollBarMode( TQScrollView::AlwaysOff ); + translationMed->setVScrollBarMode( TQScrollView::AlwaysOff ); + translationMed->setResizePolicy( TQScrollView::AutoOne ); + translationMed->setWrapPolicy( TQTextView::AtWhiteSpace ); + translationMed->setWordWrap( TQTextView::WidgetWidth ); + translationMed->setTextFormat( TQt::PlainText ); + p = translationMed->palette(); + p.setColor( TQPalette::Disabled, TQColorGroup::Base, p.active().base() ); + translationMed->setPalette( p ); + connect( translationMed, TQT_SIGNAL(textChanged()), + TQT_SLOT(handleTranslationChanges()) ); + + pageCurl = new PageCurl( this, "page curl" ); + + // Focus + setFocusPolicy( Qt::StrongFocus ); + transLbl->setFocusProxy( translationMed ); + srcTextLbl->setFocusProxy( translationMed ); + cmtText->setFocusProxy( translationMed ); + srcText->setFocusProxy( translationMed ); + setFocusProxy( translationMed ); + + updateCommentField(); +} + +/* + Don't show the comment field if there are no comments. +*/ +void EditorPage::updateCommentField() +{ + if( cmtText->text().isEmpty() ) + cmtText->hide(); + else + cmtText->show(); + + layoutWidgets(); +} + +/* + Handle the widget tqlayout manually +*/ +void EditorPage::layoutWidgets() + { + int margin = 6; + int space = 2; + int w = width(); + + pageCurl->move( width() - pageCurl->width(), 0 ); + + TQFontMetrics fm( srcTextLbl->font() ); + srcTextLbl->move( margin, margin ); + srcTextLbl->resize( fm.width( srcTextLbl->text() ), srcTextLbl->height() ); + + srcText->move( margin, srcTextLbl->y() + srcTextLbl->height() + space ); + srcText->resize( w - margin*2, srcText->height() ); + + cmtText->move( margin, srcText->y() + srcText->height() + space ); + cmtText->resize( w - margin*2, cmtText->height() ); + + if( cmtText->isHidden() ) + transLbl->move( margin, srcText->y() + srcText->height() + space ); + else + transLbl->move( margin, cmtText->y() + cmtText->height() + space ); + transLbl->resize( w - margin*2, transLbl->height() ); + + translationMed->move( margin, transLbl->y() + transLbl->height() + space ); + translationMed->resize( w - margin*2, translationMed->height() ); + + // Calculate the total height for the editor page - emit a signal + // if the actual page size is larger/smaller + int totHeight = margin + srcTextLbl->height() + + srcText->height() + space + + transLbl->height() + space + + translationMed->height() + space + + frameWidth()*lineWidth()*2 + space * 3; + + if( !cmtText->isHidden() ) + totHeight += cmtText->height() + space; + + if( height() != totHeight ) + emit pageHeightUpdated( totHeight ); +} + +void EditorPage::resizeEvent( TQResizeEvent * ) +{ + handleTranslationChanges(); + handleSourceChanges(); + handleCommentChanges(); + layoutWidgets(); +} + +void EditorPage::handleTranslationChanges() +{ + calculateFieldHeight( (TQTextView *) translationMed ); +} + +void EditorPage::handleSourceChanges() +{ + calculateFieldHeight( srcText ); +} + +void EditorPage::handleCommentChanges() +{ + calculateFieldHeight( cmtText ); +} + +/* + Check if the translation text field is big enough to show all text + that has been entered. If it isn't, resize it. +*/ +void EditorPage::calculateFieldHeight( TQTextView * field ) +{ + field->sync(); // make sure the text formatting is done! + int contentsHeight = field->contentsHeight(); + + if( contentsHeight != field->height() ) { + int oldHeight = field->height(); + if( contentsHeight < 30 ) + contentsHeight = 30; + field->resize( field->width(), contentsHeight ); + emit pageHeightUpdated( height() + (field->height() - oldHeight) ); + } +} + +void EditorPage::fontChange( const TQFont & ) +{ + TQFont fnt = font(); + + fnt.setBold( TRUE ); + TQFontMetrics fm( fnt ); + srcTextLbl->setFont( fnt ); + srcTextLbl->resize( fm.width( srcTextLbl->text() ), srcTextLbl->height() ); + transLbl->setFont( fnt ); + transLbl->resize( fm.width( transLbl->text() ), transLbl->height() ); + update(); +} + +/* + MessageEditor class impl. + + Handle tqlayout of dock windows and the editor page. +*/ +MessageEditor::MessageEditor( MetaTranslator * t, TQWidget * tqparent, + const char * name ) + : TQWidget( tqparent, name ), + tor( t ) +{ + doGuesses = TRUE; + v = new TQVBoxLayout( this ); + topDock = new TQDockArea( Qt::Horizontal, TQDockArea::Normal, this, + "top dock area" ); + topDock->setMinimumHeight( 10 ); + topDock->tqsetSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, + TQSizePolicy::Minimum) ); + + topDockWnd = new TQDockWindow( TQDockWindow::InDock, topDock, + "top dock window" ); + TQMainWindow *mw = (TQMainWindow*)tqtopLevelWidget(); + if ( mw ) { + mw->setDockEnabled( topDockWnd, TQt::DockTop, TRUE ); + mw->setDockEnabled( topDockWnd, TQt::DockLeft, TRUE ); + mw->setDockEnabled( topDockWnd, TQt::DockRight, TRUE ); + mw->setDockEnabled( topDockWnd, TQt::DockBottom, TRUE ); + } + + topDockWnd->setCaption( tr("Source text") ); + topDockWnd->setCloseMode( TQDockWindow::Always ); + topDockWnd->setResizeEnabled( TRUE ); + topDockWnd->setFixedExtentHeight( 110 ); + + srcTextList = new TQListView( topDockWnd, "source text list view" ); + srcTextList->setShowSortIndicator( TRUE ); + srcTextList->setAllColumnsShowFocus( TRUE ); + srcTextList->setSorting( 0 ); + TQFontMetrics fm( font() ); + srcTextList->addColumn( tr("Done"), fm.width( tr("Done") ) + 10 ); + srcTextList->addColumn( tr("Source text") ); + srcTextList->addColumn( tr("Translation"), 300 ); + srcTextList->setColumnAlignment( 0, TQt::AlignCenter ); + srcTextList->setColumnWidthMode( 1, TQListView::Manual ); + srcTextList->header()->setStretchEnabled( TRUE, 1 ); + srcTextList->setMinimumSize( TQSize( 50, 50 ) ); + srcTextList->setHScrollBarMode( TQScrollView::AlwaysOff ); + srcTextList->installEventFilter( this ); + topDockWnd->setWidget( srcTextList ); + + sv = new TQScrollView( this, "scroll view" ); + sv->setHScrollBarMode( TQScrollView::AlwaysOff ); + sv->viewport()->setBackgroundMode( TQt::PaletteBackground ); + + editorPage = new EditorPage( sv, "editor page" ); + connect( editorPage, TQT_SIGNAL(pageHeightUpdated(int)), + TQT_SLOT(updatePageHeight(int)) ); + + editorPage->translationMed->installEventFilter( this ); + + sw = new ShadowWidget( editorPage, sv, "editor page shadow" ); + sw->tqsetSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, + TQSizePolicy::Expanding) ); + sw->setMinimumSize( TQSize( 100, 150 ) ); + sv->addChild( sw ); + + bottomDock = new TQDockArea( Qt::Horizontal, TQDockArea::Reverse, + this, "bottom dock area" ); + bottomDock->setMinimumHeight( 10 ); + bottomDock->tqsetSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, + TQSizePolicy::Minimum) ); + bottomDockWnd = new TQDockWindow( TQDockWindow::InDock, bottomDock, + "bottom dock window" ); + if ( mw ) { + mw->setDockEnabled( bottomDockWnd, TQt::DockTop, TRUE ); + mw->setDockEnabled( bottomDockWnd, TQt::DockLeft, TRUE ); + mw->setDockEnabled( bottomDockWnd, TQt::DockRight, TRUE ); + mw->setDockEnabled( bottomDockWnd, TQt::DockBottom, TRUE ); + } + bottomDockWnd->setCaption( tr("Phrases") ); + bottomDockWnd->setCloseMode( TQDockWindow::Always ); + bottomDockWnd->setResizeEnabled( TRUE ); + + TQWidget * w = new TQWidget( bottomDockWnd ); + w->tqsetSizePolicy( TQSizePolicy( TQSizePolicy::Minimum, + TQSizePolicy::Minimum ) ); + TQHBoxLayout *hl = new TQHBoxLayout( w, 6 ); + TQVBoxLayout *vl = new TQVBoxLayout( 6 ); + + phraseLbl = new TQLabel( tr("Phrases and guesses:"), w ); + phraseLv = new PhraseLV( w, "phrase list view" ); + phraseLv->setSorting( PhraseLVI::DefinitionText ); + phraseLv->installEventFilter( this ); + hl->addLayout( vl ); + vl->addWidget( phraseLbl ); + vl->addWidget( phraseLv ); + + accel = new TQAccel( this, "accel" ); + connect( accel, TQT_SIGNAL(activated(int)), this, TQT_SLOT(guessActivated(int)) ); + for ( int i = 0; i < 9; i++ ) + accel->insertItem( Qt::CTRL + (Qt::Key_1 + i), i + 1 ); + + bottomDockWnd->setWidget( w ); + + v->addWidget( topDock ); + v->addWidget( sv ); + v->addWidget( bottomDock ); + + // Signals + connect( editorPage->pageCurl, TQT_SIGNAL(nextPage()), + TQT_SIGNAL(nextUnfinished()) ); + connect( editorPage->pageCurl, TQT_SIGNAL(prevPage()), + TQT_SIGNAL(prevUnfinished()) ); + + connect( editorPage->translationMed, TQT_SIGNAL(textChanged()), + this, TQT_SLOT(emitTranslationChanged()) ); + connect( editorPage->translationMed, TQT_SIGNAL(textChanged()), + this, TQT_SLOT(updateButtons()) ); + connect( editorPage->translationMed, TQT_SIGNAL(undoAvailable(bool)), + this, TQT_SIGNAL(undoAvailable(bool)) ); + connect( editorPage->translationMed, TQT_SIGNAL(redoAvailable(bool)), + this, TQT_SIGNAL(redoAvailable(bool)) ); + connect( editorPage->translationMed, TQT_SIGNAL(copyAvailable(bool)), + this, TQT_SIGNAL(cutAvailable(bool)) ); + connect( editorPage->translationMed, TQT_SIGNAL(copyAvailable(bool)), + this, TQT_SIGNAL(copyAvailable(bool)) ); + connect( tqApp->clipboard(), TQT_SIGNAL(dataChanged()), + this, TQT_SLOT(updateCanPaste()) ); + connect( phraseLv, TQT_SIGNAL(doubleClicked(TQListViewItem *)), + this, TQT_SLOT(insertPhraseInTranslation(TQListViewItem *)) ); + connect( phraseLv, TQT_SIGNAL(returnPressed(TQListViewItem *)), + this, TQT_SLOT(insertPhraseInTranslationAndLeave(TQListViewItem *)) ); + + // What's this + TQWhatsThis::add( this, tr("This whole panel allows you to view and edit " + "the translation of some source text.") ); + TQWhatsThis::add( editorPage->srcText, + tr("This area shows the source text.") ); + TQWhatsThis::add( editorPage->cmtText, tr("This area shows a comment that" + " may guide you, and the context in which the text" + " occurs.") ); + TQWhatsThis::add( editorPage->translationMed, + tr("This is where you can enter or modify" + " the translation of some source text.") ); +} + +void MessageEditor::toggleFinished() +{ + if ( itemFinished ) + itemFinished = FALSE; + else + itemFinished = TRUE; + emit finished( itemFinished ); +} + +bool MessageEditor::eventFilter( TQObject *o, TQEvent *e ) +{ + // Handle keypresses in the message editor - scroll the view if the current + // line is hidden. + if ( e->type() == TQEvent::KeyPress || e->type() == TQEvent::KeyRelease ) { + TQKeyEvent * ke = (TQKeyEvent*)e; + const int k = ke->key(); + + if ( ::tqqt_cast<TQTextEdit*>(o) ) { + if ( e->type() == TQEvent::KeyPress ) { + // Hardcode the Tab key to do focus changes when pressed + // inside the editor + if ( k == TQt::Key_BackTab ) { + emit focusSourceList(); + return TRUE; + } + } else if ( e->type() == TQEvent::KeyRelease ) { + MED * ed = (MED *) o; + switch( k ) { + case Qt::Key_Up: + if (ed->cursorY() < 10) + sv->verticalScrollBar()->subtractLine(); + break; + + case Qt::Key_Down: + if (ed->cursorY() >= ed->height() - 20) + sv->verticalScrollBar()->addLine(); + break; + + case Qt::Key_PageUp: + if (ed->cursorY() < 10) + sv->verticalScrollBar()->subtractPage(); + break; + + case Qt::Key_PageDown: + if (ed->cursorY() >= ed->height() - 50) + sv->verticalScrollBar()->addPage(); + break; + default: + sv->ensureVisible( sw->margin() + ed->x() + ed->cursorX(), + sw->margin() + ed->y() + ed->cursorY() ); + break; + } + } + } else if ( ::tqqt_cast<TQListView*>(o) ) { + // handle the ESC key in the list views + if ( e->type() == TQEvent::KeyRelease && k == Key_Escape ) + editorPage->translationMed->setFocus(); + } + } + return TQWidget::eventFilter( o, e ); +} + +void MessageEditor::updatePageHeight( int height ) +{ + sw->resize( sw->width(), height + sw->margin() + sw->shadowWidth() ); +} + +void MessageEditor::resizeEvent( TQResizeEvent * ) +{ + sw->resize( sv->viewport()->width(), sw->height() ); +} + +TQListView * MessageEditor::sourceTextList() const +{ + return srcTextList; +} + +TQListView * MessageEditor::phraseList() const +{ + return phraseLv; +} + +void MessageEditor::showNothing() +{ + editorPage->srcText->setText( "" ); + showContext( TQString(""), FALSE ); +} + +void MessageEditor::showContext( const TQString& context, bool finished ) +{ + setEditionEnabled( FALSE ); + sourceText = TQString(); + guesses.clear(); + + if( context.isEmpty() ) + editorPage->cmtText->setText(""); + else + editorPage->cmtText->setText( richText(context.simplifyWhiteSpace()) ); + setTranslation( TQString(""), FALSE ); + setFinished( finished ); + phraseLv->clear(); + editorPage->handleSourceChanges(); + editorPage->handleCommentChanges(); + editorPage->handleTranslationChanges(); + editorPage->updateCommentField(); +} + +void MessageEditor::showMessage( const TQString& text, + const TQString& comment, + const TQString& fullContext, + const TQString& translation, + MetaTranslatorMessage::Type type, + const TQValueList<Phrase>& phrases ) +{ + bool obsolete = ( type == MetaTranslatorMessage::Obsolete ); + setEditionEnabled( !obsolete ); + sourceText = text; + guesses.clear(); + + editorPage->srcText->setText( TQString("<p>") + richText( text ) + + TQString("</p>") ); + + if ( !fullContext.isEmpty() && !comment.isEmpty() ) + editorPage->cmtText->setText( richText(fullContext.simplifyWhiteSpace()) + + "\n" + richText(comment.simplifyWhiteSpace()) ); + else if ( !fullContext.isEmpty() && comment.isEmpty() ) + editorPage->cmtText->setText(richText(fullContext.simplifyWhiteSpace() ) ); + else if ( fullContext.isEmpty() && !comment.isEmpty() ) + editorPage->cmtText->setText( richText(comment.simplifyWhiteSpace() ) ); + else + editorPage->cmtText->setText( "" ); + + setTranslation( translation, FALSE ); + setFinished( type != MetaTranslatorMessage::Unfinished ); + TQValueList<Phrase>::ConstIterator p; + phraseLv->clear(); + for ( p = phrases.begin(); p != phrases.end(); ++p ) + (void) new PhraseLVI( phraseLv, *p ); + + if ( doGuesses && !sourceText.isEmpty() ) { + CandidateList cl = similarTextHeuristicCandidates( tor, + sourceText.latin1(), + MaxCandidates ); + int n = 0; + TQValueList<Candidate>::Iterator it = cl.begin(); + while ( it != cl.end() ) { + TQString def; + if ( n < 9 ) + def = tr( "Guess (%1)" ).arg( TQString(TQKeySequence(Qt::CTRL | (Qt::Key_0 + (n + 1)))) ); + else + def = tr( "Guess" ); + (void) new PhraseLVI( phraseLv, + Phrase((*it).source, (*it).target, def), + n + 1 ); + n++; + ++it; + } + } + editorPage->handleSourceChanges(); + editorPage->handleCommentChanges(); + editorPage->handleTranslationChanges(); + editorPage->updateCommentField(); +} + +void MessageEditor::setTranslation( const TQString& translation, bool emitt ) +{ + // Block Q_SIGNALS so that 'textChanged()' is not emitted when + // for example a new source text item is selected and *not* + // the actual translation. + editorPage->translationMed->blockSignals( !emitt ); + editorPage->translationMed->setText( translation ); + editorPage->translationMed->blockSignals( FALSE ); + if ( !emitt ) + updateButtons(); + emit cutAvailable( FALSE ); + emit copyAvailable( FALSE ); +} + +void MessageEditor::setEditionEnabled( bool enabled ) +{ + editorPage->transLbl->setEnabled( enabled ); + editorPage->translationMed->setReadOnly( !enabled ); + + phraseLbl->setEnabled( enabled ); + phraseLv->setEnabled( enabled ); + updateCanPaste(); +} + +void MessageEditor::undo() +{ + editorPage->translationMed->undo(); +} + +void MessageEditor::redo() +{ + editorPage->translationMed->redo(); +} + +void MessageEditor::cut() +{ + editorPage->translationMed->cut(); +} + +void MessageEditor::copy() +{ + editorPage->translationMed->copy(); +} + +void MessageEditor::paste() +{ + editorPage->translationMed->paste(); +} + +void MessageEditor::del() +{ + editorPage->translationMed->del(); +} + +void MessageEditor::selectAll() +{ + editorPage->translationMed->selectAll(); +} + +void MessageEditor::emitTranslationChanged() +{ + emit translationChanged( editorPage->translationMed->text() ); +} + +void MessageEditor::guessActivated( int accelKey ) +{ + TQListViewItem *item = phraseLv->firstChild(); + while ( item != 0 && ((PhraseLVI *) item)->accelKey() != accelKey ) + item = item->nextSibling(); + if ( item != 0 ) + insertPhraseInTranslation( item ); +} + +void MessageEditor::insertPhraseInTranslation( TQListViewItem *item ) +{ + editorPage->translationMed->insert(((PhraseLVI *) item)->phrase().target()); + emit translationChanged( editorPage->translationMed->text() ); +} + +void MessageEditor::insertPhraseInTranslationAndLeave( TQListViewItem *item ) +{ + editorPage->translationMed->insert(((PhraseLVI *) item)->phrase().target()); + emit translationChanged( editorPage->translationMed->text() ); + editorPage->translationMed->setFocus(); +} + +void MessageEditor::updateButtons() +{ + bool overwrite = ( !editorPage->translationMed->isReadOnly() && + (editorPage->translationMed->text().stripWhiteSpace().isEmpty() || + mayOverwriteTranslation) ); + mayOverwriteTranslation = FALSE; + emit updateActions( overwrite ); +} + +void MessageEditor::beginFromSource() +{ + mayOverwriteTranslation = TRUE; + setTranslation( sourceText, TRUE ); + if ( !editorPage->hasFocus() ) + editorPage->setFocus(); +} + +void MessageEditor::finishAndNext() +{ + setFinished( TRUE ); + emit nextUnfinished(); + if ( !editorPage->hasFocus() ) + editorPage->setFocus(); +} + +void MessageEditor::updateCanPaste() +{ + bool oldCanPaste = canPaste; + canPaste = ( !editorPage->translationMed->isReadOnly() && + !tqApp->clipboard()->text().isNull() ); + if ( canPaste != oldCanPaste ) + emit pasteAvailable( canPaste ); +} + +void MessageEditor::setFinished( bool finished ) +{ + if ( !finished != !itemFinished ) + toggleFinished(); +} + +void MessageEditor::toggleGuessing() +{ + doGuesses = !doGuesses; + if ( !doGuesses ) { + phraseLv->clear(); + } +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/msgedit.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/msgedit.h new file mode 100644 index 000000000..21e6710e3 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/msgedit.h @@ -0,0 +1,247 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef MSGEDIT_H +#define MSGEDIT_H + +#include "trwindow.h" +#include "phrase.h" + +#include <metatranslator.h> + +#include <tqsplitter.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqvaluelist.h> +#include <tqscrollview.h> +#include <tqpixmap.h> +#include <tqbitmap.h> +#include <tqtooltip.h> + +class TQAccel; +class TQDockArea; +class TQDockWindow; +class TQLabel; +class TQListView; +class TQListViewItem; +class TQTextView; +class TQVBoxLayout; + +class EditorPage; +class MED; +class PhraseLV; + +class PageCurl : public TQWidget +{ + Q_OBJECT + TQ_OBJECT +public: + PageCurl( TQWidget * tqparent = 0, const char * name = 0, + WFlags f = 0 ) + : TQWidget( tqparent, name, f ) + { + TQPixmap px = TrWindow::pageCurl(); + if ( px.tqmask() ) { + setMask( *px.tqmask() ); + } + setBackgroundPixmap( px ); + setFixedSize( px.size() ); + + TQRect r( 34, 0, width()-34, 19 ); + TQToolTip::add( this, r, tr("Next unfinished phrase") ); + r.setSize( TQSize(width()-34, height()-20) ); + r.setX( 0 ); + r.setY( 20 ); + TQToolTip::add( this, r, tr("Previous unfinished phrase") ); + } + +protected: + void mouseReleaseEvent( TQMouseEvent * e ) + { + int x = e->pos().x() - 14; + int y = e->pos().y() - 8; + + if ( y <= x ) + emit nextPage(); + else + emit prevPage(); + } + +Q_SIGNALS: + void prevPage(); + void nextPage(); +}; + +class ShadowWidget : public TQWidget +{ +public: + ShadowWidget( TQWidget * tqparent = 0, const char * name = 0 ); + ShadowWidget( TQWidget * child, TQWidget * tqparent = 0, const char * name = 0 ); + + void setShadowWidth( int width ) { sWidth = width; } + int shadowWidth() const { return sWidth; } + void setMargin( int margin ){ wMargin = margin; } + int margin() const { return wMargin; } + void setWidget( TQWidget * child); + +protected: + void resizeEvent( TQResizeEvent * e ); + void paintEvent( TQPaintEvent * e ); + +private: + int sWidth; + int wMargin; + TQWidget * childWgt; +}; + +class EditorPage : public TQFrame +{ + Q_OBJECT + TQ_OBJECT +public: + EditorPage( TQWidget * tqparent = 0, const char * name = 0 ); + +protected: + void resizeEvent( TQResizeEvent * ); + void layoutWidgets(); + void updateCommentField(); + void calculateFieldHeight( TQTextView * field ); + void fontChange( const TQFont & ); + +private: + PageCurl * pageCurl; + TQLabel * srcTextLbl; + TQLabel * transLbl; + TQTextView * srcText; + TQTextView * cmtText; + MED * translationMed; + + friend class MessageEditor; + +private Q_SLOTS: + void handleTranslationChanges(); + void handleSourceChanges(); + void handleCommentChanges(); + +Q_SIGNALS: + void pageHeightUpdated( int height ); +}; + +class MessageEditor : public TQWidget +{ + Q_OBJECT + TQ_OBJECT +public: + MessageEditor( MetaTranslator * t, TQWidget * tqparent = 0, + const char * name = 0 ); + TQListView * sourceTextList() const; + TQListView * phraseList() const; + + void showNothing(); + void showContext( const TQString& context, bool finished ); + void showMessage( const TQString& text, const TQString& comment, + const TQString& fullContext, const TQString& translation, + MetaTranslatorMessage::Type type, + const TQValueList<Phrase>& phrases ); + void setFinished( bool finished ); + bool eventFilter( TQObject *, TQEvent * ); + +Q_SIGNALS: + void translationChanged( const TQString& translation ); + void finished( bool finished ); + void prevUnfinished(); + void nextUnfinished(); + void updateActions( bool enable ); + + void undoAvailable( bool avail ); + void redoAvailable( bool avail ); + void cutAvailable( bool avail ); + void copyAvailable( bool avail ); + void pasteAvailable( bool avail ); + + void focusSourceList(); + void focusPhraseList(); + +public Q_SLOTS: + void undo(); + void redo(); + void cut(); + void copy(); + void paste(); + void del(); + void selectAll(); + void beginFromSource(); + void toggleGuessing(); + void finishAndNext(); + +private Q_SLOTS: + void emitTranslationChanged(); + void guessActivated( int accelKey ); + void insertPhraseInTranslation( TQListViewItem *item ); + void insertPhraseInTranslationAndLeave( TQListViewItem *item ); + void updateButtons(); + void updateCanPaste(); + void toggleFinished(); + + void updatePageHeight( int height ); + +protected: + void resizeEvent( TQResizeEvent * ); + +private: + void setTranslation( const TQString& translation, bool emitt ); + void setEditionEnabled( bool enabled ); + + TQListView * srcTextList; + TQDockArea * topDock, * bottomDock; + TQDockWindow * topDockWnd, *bottomDockWnd; + EditorPage * editorPage; + TQVBoxLayout * v; + + TQLabel * phraseLbl; + PhraseLV * phraseLv; + TQAccel * accel; + bool itemFinished; + + ShadowWidget * sw; + TQScrollView * sv; + + MetaTranslator *tor; + TQString sourceText; + TQStringList guesses; + bool mayOverwriteTranslation; + bool canPaste; + bool doGuesses; +}; + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/phrase.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrase.cpp new file mode 100644 index 000000000..95b4fc2e7 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrase.cpp @@ -0,0 +1,189 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "phrase.h" + +#include <tqapplication.h> +#include <tqcstring.h> +#include <tqfile.h> +#include <tqmessagebox.h> +#include <tqregexp.h> +#include <tqtextstream.h> +#include <tqxml.h> + +static TQString protect( const TQString& str ) +{ + TQString p = str; + p.tqreplace( "&", "&" ); + p.tqreplace( "\"", """ ); + p.tqreplace( ">", ">" ); + p.tqreplace( "<", "<" ); + p.tqreplace( "'", "'" ); + return p; +} + +Phrase::Phrase( const TQString& source, const TQString& target, + const TQString& definition ) + : s( source ), t( target ), d( definition ) +{ +} + +bool operator==( const Phrase& p, const Phrase& q ) +{ + return p.source() == q.source() && p.target() == q.target() && + p.definition() == q.definition(); +} + +class QphHandler : public TQXmlDefaultHandler +{ +public: + QphHandler( PhraseBook *phraseBook ) + : pb( phraseBook ), ferrorCount( 0 ) { } + + virtual bool startElement( const TQString& namespaceURI, + const TQString& localName, const TQString& qName, + const TQXmlAttributes& atts ); + virtual bool endElement( const TQString& namespaceURI, + const TQString& localName, const TQString& qName ); + virtual bool characters( const TQString& ch ); + virtual bool fatalError( const TQXmlParseException& exception ); + +private: + PhraseBook *pb; + TQString source; + TQString target; + TQString definition; + + TQString accum; + int ferrorCount; +}; + +bool QphHandler::startElement( const TQString& /* namespaceURI */, + const TQString& /* localName */, + const TQString& qName, + const TQXmlAttributes& /* atts */ ) +{ + if ( qName == TQString("phrase") ) { + source.truncate( 0 ); + target.truncate( 0 ); + definition.truncate( 0 ); + } + accum.truncate( 0 ); + return TRUE; +} + +bool QphHandler::endElement( const TQString& /* namespaceURI */, + const TQString& /* localName */, + const TQString& qName ) +{ + if ( qName == TQString("source") ) + source = accum; + else if ( qName == TQString("target") ) + target = accum; + else if ( qName == TQString("definition") ) + definition = accum; + else if ( qName == TQString("phrase") ) + pb->append( Phrase(source, target, definition) ); + return TRUE; +} + +bool QphHandler::characters( const TQString& ch ) +{ + accum += ch; + return TRUE; +} + +bool QphHandler::fatalError( const TQXmlParseException& exception ) +{ + if ( ferrorCount++ == 0 ) { + TQString msg; + msg.sprintf( "Parse error at line %d, column %d (%s).", + exception.lineNumber(), exception.columnNumber(), + exception.message().latin1() ); + TQMessageBox::information( tqApp->mainWidget(), + TQObject::tr("TQt Linguist"), msg ); + } + return FALSE; +} + +bool PhraseBook::load( const TQString& filename ) +{ + TQFile f( filename ); + if ( !f.open(IO_ReadOnly) ) + return FALSE; + + TQTextStream t( &f ); + TQXmlInputSource in( t ); + TQXmlSimpleReader reader; + // don't click on these! + reader.setFeature( "http://xml.org/sax/features/namespaces", FALSE ); + reader.setFeature( "http://xml.org/sax/features/namespace-prefixes", TRUE ); + reader.setFeature( "http://trolltech.com/xml/features/report-whitespace" + "-only-CharData", FALSE ); + TQXmlDefaultHandler *hand = new QphHandler( this ); + reader.setContentHandler( hand ); + reader.setErrorHandler( hand ); + + bool ok = reader.parse( in ); + reader.setContentHandler( 0 ); + reader.setErrorHandler( 0 ); + delete hand; + f.close(); + if ( !ok ) + clear(); + return ok; +} + +bool PhraseBook::save( const TQString& filename ) const +{ + TQFile f( filename ); + if ( !f.open(IO_WriteOnly) ) + return FALSE; + + TQTextStream t( &f ); + t.setEncoding(TQTextStream::UnicodeUTF8); + t << "<!DOCTYPE TQPH><TQPH>\n"; + ConstIterator p; + for ( p = begin(); p != end(); ++p ) { + t << "<phrase>\n"; + t << " <source>" << protect( (*p).source() ) << "</source>\n"; + t << " <target>" << protect( (*p).target() ) << "</target>\n"; + if ( !(*p).definition().isEmpty() ) + t << " <definition>" << protect( (*p).definition() ) + << "</definition>\n"; + t << "</phrase>\n"; + } + t << "</TQPH>\n"; + f.close(); + return TRUE; +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/phrase.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrase.h new file mode 100644 index 000000000..6152cd56e --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrase.h @@ -0,0 +1,74 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef PHRASE_H +#define PHRASE_H + +#include <tqstring.h> +#include <tqvaluelist.h> + +class Phrase +{ +public: + Phrase() { } + Phrase( const TQString& source, const TQString& target, + const TQString& definition ); + + TQString source() const { return s; } + void setSource( const TQString& ns ) { s = ns; } + TQString target() const { return t; } + void setTarget( const TQString& nt ) { t = nt; } + TQString definition() const { return d; } + void setDefinition ( const TQString& nd ) { d = nd; } + +private: + TQString s; + TQString t; + TQString d; +}; + +bool operator==( const Phrase& p, const Phrase& q ); +inline bool operator!=( const Phrase& p, const Phrase& q ) { + return !( p == q ); +} + +class PhraseBook : public TQValueList<Phrase> +{ +public: + PhraseBook() { } + + bool load( const TQString& filename ); + bool save( const TQString& filename ) const; +}; + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/phrasebookbox.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrasebookbox.cpp new file mode 100644 index 000000000..2c0c6404c --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrasebookbox.cpp @@ -0,0 +1,244 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +/* TRANSLATOR PhraseBookBox + + Go to Phrase > Edit Phrase Book... The dialog that pops up is a + PhraseBookBox. +*/ + +#include "phrasebookbox.h" +#include "phraselv.h" + +#include <tqapplication.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqlineedit.h> +#include <tqmessagebox.h> +#include <tqpushbutton.h> +#include <tqwhatsthis.h> + +PhraseBookBox::PhraseBookBox( const TQString& filename, + const PhraseBook& phraseBook, TQWidget *tqparent, + const char *name, bool modal ) + : TQDialog( tqparent, name, modal ), fn( filename ), pb( phraseBook ) +{ + TQGridLayout *gl = new TQGridLayout( this, 4, 3, 11, 11, + "phrase book outer tqlayout" ); + TQVBoxLayout *bl = new TQVBoxLayout( 6, "phrase book button tqlayout" ); + + sourceLed = new TQLineEdit( this, "source line edit" ); + TQLabel *source = new TQLabel( sourceLed, tr("S&ource phrase:"), this, + "source label" ); + targetLed = new TQLineEdit( this, "target line edit" ); + TQLabel *target = new TQLabel( targetLed, tr("&Translation:"), this, + "target label" ); + definitionLed = new TQLineEdit( this, "definition line edit" ); + TQLabel *definition = new TQLabel( definitionLed, tr("&Definition:"), this, + "target label" ); + lv = new PhraseLV( this, "phrase book list view" ); + + newBut = new TQPushButton( tr("&New Phrase"), this ); + newBut->setDefault( TRUE ); + + removeBut = new TQPushButton( tr("&Remove Phrase"), this ); + removeBut->setEnabled( FALSE ); + TQPushButton *saveBut = new TQPushButton( tr("&Save"), this ); + TQPushButton *closeBut = new TQPushButton( tr("Close"), this ); + + gl->addWidget( source, 0, 0 ); + gl->addWidget( sourceLed, 0, 1 ); + gl->addWidget( target, 1, 0 ); + gl->addWidget( targetLed, 1, 1 ); + gl->addWidget( definition, 2, 0 ); + gl->addWidget( definitionLed, 2, 1 ); + gl->addMultiCellWidget( lv, 3, 3, 0, 1 ); + gl->addMultiCell( bl, 0, 3, 2, 2 ); + + bl->addWidget( newBut ); + bl->addWidget( removeBut ); + bl->addWidget( saveBut ); + bl->addWidget( closeBut ); + bl->addStretch( 1 ); + + connect( sourceLed, TQT_SIGNAL(textChanged(const TQString&)), + this, TQT_SLOT(sourceChanged(const TQString&)) ); + connect( targetLed, TQT_SIGNAL(textChanged(const TQString&)), + this, TQT_SLOT(targetChanged(const TQString&)) ); + connect( definitionLed, TQT_SIGNAL(textChanged(const TQString&)), + this, TQT_SLOT(definitionChanged(const TQString&)) ); + connect( lv, TQT_SIGNAL(selectionChanged(TQListViewItem *)), + this, TQT_SLOT(selectionChanged(TQListViewItem *)) ); + connect( newBut, TQT_SIGNAL(clicked()), this, TQT_SLOT(newPhrase()) ); + connect( removeBut, TQT_SIGNAL(clicked()), this, TQT_SLOT(removePhrase()) ); + connect( saveBut, TQT_SIGNAL(clicked()), this, TQT_SLOT(save()) ); + connect( closeBut, TQT_SIGNAL(clicked()), this, TQT_SLOT(accept()) ); + + PhraseBook::ConstIterator it; + for ( it = phraseBook.begin(); it != phraseBook.end(); ++it ) + (void) new PhraseLVI( lv, (*it) ); + enableDisable(); + + TQWhatsThis::add( this, tr("This window allows you to add, modify, or delete" + " phrases in a phrase book.") ); + TQWhatsThis::add( sourceLed, tr("This is the phrase in the source" + " language.") ); + TQWhatsThis::add( targetLed, tr("This is the phrase in the target language" + " corresponding to the source phrase.") ); + TQWhatsThis::add( definitionLed, tr("This is a definition for the source" + " phrase.") ); + TQWhatsThis::add( newBut, tr("Click here to add the phrase to the phrase" + " book.") ); + TQWhatsThis::add( removeBut, tr("Click here to remove the phrase from the" + " phrase book.") ); + TQWhatsThis::add( saveBut, tr("Click here to save the changes made.") ); + TQWhatsThis::add( closeBut, tr("Click here to close this window.") ); +} + +void PhraseBookBox::keyPressEvent( TQKeyEvent *ev ) +{ + if ( ev->key() == Qt::Key_Down || ev->key() == Qt::Key_Up || + ev->key() == TQt::Key_Next || ev->key() == TQt::Key_Prior ) + TQApplication::sendEvent( lv, + new TQKeyEvent(ev->type(), ev->key(), ev->ascii(), ev->state(), + ev->text(), ev->isAutoRepeat(), ev->count()) ); + else + TQDialog::keyPressEvent( ev ); +} + +void PhraseBookBox::newPhrase() +{ + Phrase ph; + ph.setSource( NewPhrase ); + TQListViewItem *item = new PhraseLVI( lv, ph ); + selectItem( item ); +} + +void PhraseBookBox::removePhrase() +{ + TQListViewItem *item = lv->currentItem(); + TQListViewItem *next = item->itemBelow() != 0 ? item->itemBelow() + : item->itemAbove(); + delete item; + if ( next != 0 ) + selectItem( next ); + enableDisable(); +} + +void PhraseBookBox::save() +{ + pb.clear(); + TQListViewItem *item = lv->firstChild(); + while ( item != 0 ) { + if ( !item->text(PhraseLVI::SourceTextShown).isEmpty() && + item->text(PhraseLVI::SourceTextShown) != NewPhrase ) + pb.append( Phrase(((PhraseLVI *) item)->phrase()) ); + item = item->nextSibling(); + } + if ( !pb.save( fn ) ) + TQMessageBox::warning( this, tr("TQt Linguist"), + tr("Cannot save phrase book '%1'.").arg(fn) ); +} + +void PhraseBookBox::sourceChanged( const TQString& source ) +{ + if ( lv->currentItem() != 0 ) { + lv->currentItem()->setText( PhraseLVI::SourceTextShown, + source.stripWhiteSpace() ); + lv->currentItem()->setText( PhraseLVI::SourceTextOriginal, source ); + lv->sort(); + lv->ensureItemVisible( lv->currentItem() ); + } +} + +void PhraseBookBox::targetChanged( const TQString& target ) +{ + if ( lv->currentItem() != 0 ) { + lv->currentItem()->setText( PhraseLVI::TargetTextShown, + target.stripWhiteSpace() ); + lv->currentItem()->setText( PhraseLVI::TargetTextOriginal, target ); + lv->sort(); + lv->ensureItemVisible( lv->currentItem() ); + } +} + +void PhraseBookBox::definitionChanged( const TQString& definition ) +{ + if ( lv->currentItem() != 0 ) { + lv->currentItem()->setText( PhraseLVI::DefinitionText, definition ); + lv->sort(); + lv->ensureItemVisible( lv->currentItem() ); + } +} + +void PhraseBookBox::selectionChanged( TQListViewItem * /* item */ ) +{ + enableDisable(); +} + +void PhraseBookBox::selectItem( TQListViewItem *item ) +{ + lv->setSelected( item, TRUE ); + lv->ensureItemVisible( item ); +} + +void PhraseBookBox::enableDisable() +{ + TQListViewItem *item = lv->currentItem(); + + sourceLed->blockSignals( TRUE ); + targetLed->blockSignals( TRUE ); + definitionLed->blockSignals( TRUE ); + + if ( item == 0 ) { + sourceLed->setText( TQString() ); + targetLed->setText( TQString() ); + definitionLed->setText( TQString() ); + } else { + sourceLed->setText( item->text(0) ); + targetLed->setText( item->text(1) ); + definitionLed->setText( item->text(2) ); + } + sourceLed->setEnabled( item != 0 ); + targetLed->setEnabled( item != 0 ); + definitionLed->setEnabled( item != 0 ); + removeBut->setEnabled( item != 0 ); + + sourceLed->blockSignals( FALSE ); + targetLed->blockSignals( FALSE ); + definitionLed->blockSignals( FALSE ); + + TQLineEdit *led = ( sourceLed->text() == NewPhrase ? sourceLed : targetLed ); + led->setFocus(); + led->selectAll(); +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/phrasebookbox.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrasebookbox.h new file mode 100644 index 000000000..bf3261b45 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/phrasebookbox.h @@ -0,0 +1,85 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef PHRASEBOOKBOX_H +#define PHRASEBOOKBOX_H + +#include "phrase.h" + +#include <tqdialog.h> +#include <tqvaluelist.h> + +class TQLineEdit; +class TQPushButton; +class TQListViewItem; + +class PhraseLV; + +class PhraseBookBox : public TQDialog +{ + Q_OBJECT + TQ_OBJECT +public: + PhraseBookBox( const TQString& filename, const PhraseBook& phraseBook, + TQWidget *tqparent = 0, const char *name = 0, + bool modal = FALSE ); + + const PhraseBook& phraseBook() const { return pb; } + +protected: + virtual void keyPressEvent( TQKeyEvent *ev ); + +private Q_SLOTS: + void newPhrase(); + void removePhrase(); + void save(); + void sourceChanged( const TQString& source ); + void targetChanged( const TQString& target ); + void definitionChanged( const TQString& definition ); + void selectionChanged( TQListViewItem *item ); + +private: + void selectItem( TQListViewItem *item ); + void enableDisable(); + + TQLineEdit *sourceLed; + TQLineEdit *targetLed; + TQLineEdit *definitionLed; + TQPushButton *newBut; + TQPushButton *removeBut; + PhraseLV *lv; + TQString fn; + PhraseBook pb; +}; + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/phraselv.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/phraselv.cpp new file mode 100644 index 000000000..15177c06e --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/phraselv.cpp @@ -0,0 +1,171 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +/* TRANSLATOR PhraseLV + + The phrase list in the right panel of the main window (with Source phrase, + Target phrase, and Definition in its header) is a PhraseLV object. +*/ + +#include "phraselv.h" + +#include <tqregexp.h> +#include <tqwhatsthis.h> +#include <tqheader.h> + +class WhatPhrase : public TQWhatsThis +{ +public: + WhatPhrase( PhraseLV *w ); + + virtual TQString text( const TQPoint& p ); + +private: + PhraseLV *tqparent; +}; + +WhatPhrase::WhatPhrase( PhraseLV *w ) + : TQWhatsThis( w ) +{ + tqparent = w; +} + +TQString WhatPhrase::text( const TQPoint& p ) +{ + TQListViewItem *item = tqparent->itemAt( p ); + if ( item == 0 ) + return PhraseLV::tr( "This is a list of phrase entries relevant to the" + " source text. Each phrase is supplemented with a suggested" + " translation and a definition." ); + else + return TQString( PhraseLV::tr("<p><u>%1:</u> %2</p>" + "<p><u>%3:</u> %4</p>" + "<p><u>%5:</u> %6</p>") ) + .arg( tqparent->columnText(PhraseLVI::SourceTextShown) ) + .arg( item->text(PhraseLVI::SourceTextShown) ) + .arg( tqparent->columnText(PhraseLVI::TargetTextShown) ) + .arg( item->text(PhraseLVI::TargetTextShown) ) + .arg( tqparent->columnText(PhraseLVI::DefinitionText) ) + .arg( item->text(PhraseLVI::DefinitionText) ); +} + +PhraseLVI::PhraseLVI( PhraseLV *tqparent, const Phrase& phrase, int accelKey ) + : TQListViewItem( tqparent ), + akey( accelKey ) +{ + setPhrase( phrase ); +} + +TQString PhraseLVI::key( int column, bool ascending ) const +{ + if ( column == SourceTextShown ) { + if ( sourceTextKey.isEmpty() ) { + if ( ascending ) { + return ""; + } else { + return TQString(); + } + } else { + return sourceTextKey; + } + } else if ( column == TargetTextShown ) { + return targetTextKey; + } else { + return TQChar( '0' + akey ) + text( column ); + } +} + +void PhraseLVI::setText( int column, const TQString& text ) +{ + if ( column == SourceTextShown ) { + sourceTextKey = makeKey( text ); + } else if ( column == TargetTextShown ) { + targetTextKey = makeKey( text ); + } + TQListViewItem::setText( column, text ); +} + +void PhraseLVI::setPhrase( const Phrase& phrase ) +{ + setText( SourceTextShown, phrase.source().simplifyWhiteSpace() ); + setText( TargetTextShown, phrase.target().simplifyWhiteSpace() ); + setText( DefinitionText, phrase.definition() ); + setText( SourceTextOriginal, phrase.source() ); + setText( TargetTextOriginal, phrase.target() ); +} + +Phrase PhraseLVI::phrase() const +{ + return Phrase( text(SourceTextOriginal), text(TargetTextOriginal), + text(DefinitionText) ); +} + +TQString PhraseLVI::makeKey( const TQString& text ) const +{ + if ( text == NewPhrase ) + return TQString(); + + TQString key; + for ( int i = 0; i < (int) text.length(); i++ ) { + if ( text[i] != TQChar('&') ) + key += text[i].lower(); + } + // see Section 5, Exercise 4 of The Art of Computer Programming + key += TQChar::null; + key += text; + return key; +} + +PhraseLV::PhraseLV( TQWidget *tqparent, const char *name ) + : TQListView( tqparent, name ) +{ + setAllColumnsShowFocus( TRUE ); + setShowSortIndicator( TRUE ); + for ( int i = 0; i < 3; i++ ) + addColumn( TQString(), 120 ); + setColumnText( PhraseLVI::SourceTextShown, tr("Source phrase") ); + setColumnText( PhraseLVI::TargetTextShown, tr("Translation") ); + setColumnText( PhraseLVI::DefinitionText, tr("Definition") ); + header()->setStretchEnabled( TRUE, -1 ); + what = new WhatPhrase( this ); +} + +PhraseLV::~PhraseLV() +{ +// delete what; +} + +TQSize PhraseLV::tqsizeHint() const +{ + return TQSize( TQListView::tqsizeHint().width(), 50 ); +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/phraselv.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/phraselv.h new file mode 100644 index 000000000..e6fedd622 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/phraselv.h @@ -0,0 +1,83 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef PHRASELV_H +#define PHRASELV_H + +#include "phrase.h" + +#include <tqlistview.h> + +class TQWhatsThis; + +class PhraseLV; + +#define NewPhrase PhraseLV::tr( "(New Phrase)" ) + +class PhraseLVI : public TQListViewItem +{ +public: + enum { SourceTextShown, TargetTextShown, DefinitionText, SourceTextOriginal, + TargetTextOriginal }; + + PhraseLVI( PhraseLV *tqparent, const Phrase& phrase, int accelKey = 0 ); + + virtual void setText( int column, const TQString& text ); + virtual TQString key( int column, bool ascending ) const; + + void setPhrase( const Phrase& phrase ); + Phrase phrase() const; + int accelKey() const { return akey; } + +private: + TQString makeKey( const TQString& text ) const; + + int akey; + TQString sourceTextKey; + TQString targetTextKey; +}; + +class PhraseLV : public TQListView +{ + TQ_OBJECT +public: + PhraseLV( TQWidget *tqparent, const char *name ); + ~PhraseLV(); + + virtual TQSize tqsizeHint() const; + +private: + TQWhatsThis *what; +}; + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/printout.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/printout.cpp new file mode 100644 index 000000000..1aae5921e --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/printout.cpp @@ -0,0 +1,182 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "printout.h" + +#include <tqprinter.h> +#include <tqfontmetrics.h> + +PrintOut::PrintOut( TQPrinter *printer ) + : pr( printer ), pdmetrics( printer ), nextRule( NoRule ), page( 0 ) +{ + p.begin( pr ); + TQFont f( "Arial" ); + f8 = f; + f8.setPointSize( 8 ); + f10 = f; + f10.setPointSize( 10 ); + p.setFont( f10 ); + fmetrics = new TQFontMetrics( p.fontMetrics() ); + hmargin = 5 * pdmetrics.width() / pdmetrics.widthMM(); // 5 mm + vmargin = 5 * pdmetrics.height() / pdmetrics.heightMM(); // 5 mm + hsize = pdmetrics.width() - 2 * hmargin; + vsize = pdmetrics.height() - vmargin; + dateTime = TQDateTime::tqcurrentDateTime(); + breakPage(); + vsize -= voffset; + cp = Paragraph( TQPoint(hmargin, voffset) ); +} + +PrintOut::~PrintOut() +{ + flushLine(); + delete fmetrics; + p.end(); +} + +void PrintOut::setRule( Rule rule ) +{ + if ( (int) nextRule < (int) rule ) + nextRule = rule; +} + +void PrintOut::setGuide( const TQString& guide ) +{ + g = guide; +} + +void PrintOut::vskip() +{ + if ( !firstParagraph ) + voffset += 14; +} + +void PrintOut::flushLine( bool /* mayBreak */ ) +{ + if ( voffset + cp.rect.height() > vsize ) + breakPage(); + else if ( !firstParagraph ) + drawRule( nextRule ); + + for ( int i = 0; i < (int) cp.boxes.count(); i++ ) { + Box b = cp.boxes[i]; + b.rect.moveBy( 0, voffset ); + TQRect r = b.rect; + p.setFont( b.font ); + p.drawText( r, b.align, b.text ); + } + voffset += cp.rect.height(); + + nextRule = NoRule; + cp = Paragraph( TQPoint(hmargin, voffset) ); + firstParagraph = FALSE; +} + +void PrintOut::addBox( int percent, const TQString& text, Style style, + int halign ) +{ + int align = halign | TQt::AlignTop; + TQFont f = f10; + if ( style == Strong ) + f.setBold( TRUE ); + else if ( style == Emphasis ) + f.setItalic( TRUE ); + int wd = hsize * percent / 100; + TQRect r( cp.rect.x() + cp.rect.width(), 0, wd, vsize ); + int ht = p.boundingRect( r, align, text ).height(); + + Box b( r, text, f, align ); + cp.boxes.append( b ); + cp.rect.setSize( TQSize(cp.rect.width() + wd, TQMAX(cp.rect.height(), ht)) ); +} + +void PrintOut::breakPage() +{ + static const int LeftAlign = TQt::AlignLeft | TQt::AlignTop; + static const int RightAlign = TQt::AlignRight | TQt::AlignTop; + TQRect r1, r2; + int h1 = 0; + int h2 = 0; + + if ( page++ > 0 ) + pr->newPage(); + voffset = 0; + + p.setFont( f10 ); + r1 = TQRect( hmargin, voffset, 3 * hsize / 4, vsize ); + r2 = TQRect( r1.x() + r1.width(), voffset, hsize - r1.width(), vsize ); + h1 = p.boundingRect( r1, LeftAlign, pr->docName() ).height(); + p.drawText( r1, LeftAlign, pr->docName() ); + h2 = p.boundingRect( r2, RightAlign, TQString::number(page) ).height(); + p.drawText( r2, RightAlign, TQString::number(page) ); + voffset += TQMAX( h1, h2 ); + + r1 = TQRect( hmargin, voffset, hsize / 2, LeftAlign ); + p.setFont( f8 ); + h1 = p.boundingRect( r1, LeftAlign, dateTime.toString() ).height(); + p.drawText( r1, LeftAlign, dateTime.toString() ); + p.setFont( f10 ); + voffset += TQMAX( h1, h2 ); + + voffset += 4; + p.drawLine( TQPoint(hmargin, voffset), TQPoint(hmargin + hsize, voffset) ); + voffset += 14; + firstParagraph = TRUE; +} + +void PrintOut::drawRule( Rule rule ) +{ + TQPen pen; + + switch ( rule ) { + case NoRule: + voffset += 5; + break; + case ThinRule: + pen.setColor( TQColor(192, 192, 192) ); + pen.setStyle( Qt::DotLine ); + pen.setWidth( 0 ); + p.setPen( pen ); + voffset += 5; + p.drawLine( TQPoint(hmargin, voffset), + TQPoint(hmargin + hsize, voffset) ); + p.setPen( TQPen() ); + voffset += 2; + break; + case ThickRule: + voffset += 7; + p.drawLine( TQPoint(hmargin, voffset), + TQPoint(hmargin + hsize, voffset) ); + voffset += 4; + } +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/printout.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/printout.h new file mode 100644 index 000000000..efcb4d10a --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/printout.h @@ -0,0 +1,126 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef PRINTOUT_H +#define PRINTOUT_H + +#include <tqfont.h> +#include <tqpaintdevicemetrics.h> +#include <tqpainter.h> +#include <tqrect.h> +#include <tqvaluelist.h> +#include <tqdatetime.h> + +class TQPrinter; +class TQFontMetrics; + +class PrintOut +{ +public: + enum Rule { NoRule, ThinRule, ThickRule }; + enum Style { Normal, Strong, Emphasis }; + + PrintOut( TQPrinter *printer ); + ~PrintOut(); + + void setRule( Rule rule ); + void setGuide( const TQString& guide ); + void vskip(); + void flushLine( bool mayBreak = FALSE ); + void addBox( int percent, const TQString& text = TQString(), + Style style = Normal, + int halign = TQt::AlignLeft | TQt::WordBreak ); + + int pageNum() const { return page; } + + struct Box + { + TQRect rect; + TQString text; + TQFont font; + int align; + + Box() : align( 0 ) { } + Box( const TQRect& r, const TQString& t, const TQFont& f, int a ) + : rect( r ), text( t ), font( f ), align( a ) { } + Box( const Box& b ) + : rect( b.rect ), text( b.text ), font( b.font ), + align( b.align ) { } + + Box& operator=( const Box& b ) { + rect = b.rect; + text = b.text; + font = b.font; + align = b.align; + return *this; + } + + bool operator==( const Box& b ) const { + return rect == b.rect && text == b.text && font == b.font && + align == b.align; + } + }; + +private: + void breakPage(); + void drawRule( Rule rule ); + + struct Paragraph { + TQRect rect; + TQValueList<Box> boxes; + + Paragraph() { } + Paragraph( TQPoint p ) : rect( p, TQSize(0, 0) ) { } + }; + + TQPrinter *pr; + TQPainter p; + TQFont f8; + TQFont f10; + TQFontMetrics *fmetrics; + TQPaintDeviceMetrics pdmetrics; + Rule nextRule; + Paragraph cp; + int page; + bool firstParagraph; + TQString g; + TQDateTime dateTime; + + int hmargin; + int vmargin; + int voffset; + int hsize; + int vsize; +}; + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/simtexth.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/simtexth.cpp new file mode 100644 index 000000000..2d139651e --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/simtexth.cpp @@ -0,0 +1,239 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "simtexth.h" + +#include <metatranslator.h> + +#include <tqcstring.h> +#include <tqdict.h> +#include <tqmap.h> +#include <tqstring.h> +#include <tqstringlist.h> +#include <tqvaluelist.h> + +#include <string.h> + +typedef TQValueList<MetaTranslatorMessage> TML; + +/* + How similar are two texts? The approach used here relies on co-occurrence + matrices and is very efficient. + + Let's see with an example: how similar are "here" and "hither"? The + co-occurrence matrix M for "here" is M[h,e] = 1, M[e,r] = 1, M[r,e] = 1, and 0 + elsewhere; the matrix N for "hither" is N[h,i] = 1, N[i,t] = 1, ..., + N[h,e] = 1, N[e,r] = 1, and 0 elsewhere. The union U of both matrices is the + matrix U[i,j] = max { M[i,j], N[i,j] }, and the intersection V is + V[i,j] = min { M[i,j], N[i,j] }. The score for a pair of texts is + + score = (sum of V[i,j] over all i, j) / (sum of U[i,j] over all i, j), + + a formula suggested by Arnt Gulbrandsen. Here we have + + score = 2 / 6, + + or one third. + + The implementation differs from this in a few details. Most importantly, + repetitions are ignored; for input "xxx", M[x,x] equals 1, not 2. +*/ + +/* + Every character is assigned to one of 20 buckets so that the co-occurrence + matrix requires only 20 * 20 = 400 bits, not 256 * 256 = 65536 bits or even + more if we want the whole Unicode. Which character falls in which bucket is + arbitrary. + + The second half of the table is a replica of the first half, because of + laziness. +*/ +static const int indexOf[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// ! " # $ % & ' ( ) * + , - . / + 0, 2, 6, 7, 10, 12, 15, 19, 2, 6, 7, 10, 12, 15, 19, 0, +// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? + 1, 3, 4, 5, 8, 9, 11, 13, 14, 16, 2, 6, 7, 10, 12, 15, +// @ A B C D E F G H I J K L M N O + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, +// P Q R S T U V W X Y Z [ \ ] ^ _ + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, +// ` a b c d e f g h i j k l m n o + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, +// p q r s t u v w x y z { | } ~ + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 6, 7, 10, 12, 15, 19, 2, 6, 7, 10, 12, 15, 19, 0, + 1, 3, 4, 5, 8, 9, 11, 13, 14, 16, 2, 6, 7, 10, 12, 15, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 10, 11, 12, 13, 14, + 15, 12, 16, 17, 18, 19, 2, 10, 15, 7, 19, 2, 6, 7, 10, 0 +}; + +/* + The entry bitCount[i] (for i between 0 and 255) is the number of bits used to + represent i in binary. +*/ +static const int bitCount[256] = { + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, + 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 +}; + +struct CoMatrix +{ + /* + The matrix has 20 * 20 = 400 entries. This requires 50 bytes, or 13 + words. Some operations are performed on words for more efficiency. + */ + union { + TQ_UINT8 b[52]; + TQ_UINT32 w[13]; + }; + + CoMatrix() { memset( b, 0, 52 ); } + CoMatrix( const char *text ) { + char c = '\0', d; + memset( b, 0, 52 ); + /* + The Knuth books are not in the office only for show; they help make + loops 30% faster and 20% as readable. + */ + while ( (d = *text) != '\0' ) { + setCoocc( c, d ); + if ( (c = *++text) != '\0' ) { + setCoocc( d, c ); + text++; + } + } + } + + void setCoocc( char c, char d ) { + int k = indexOf[(uchar) c] + 20 * indexOf[(uchar) d]; + b[k >> 3] |= k & 0x7; + } + + int worth() const { + int w = 0; + for ( int i = 0; i < 50; i++ ) + w += bitCount[b[i]]; + return w; + } +}; + +static inline CoMatrix reunion( const CoMatrix& m, const CoMatrix& n ) +{ + CoMatrix p; + for ( int i = 0; i < 13; i++ ) + p.w[i] = m.w[i] | n.w[i]; + return p; +} + +static inline CoMatrix intersection( const CoMatrix& m, const CoMatrix& n ) +{ + CoMatrix p; + for ( int i = 0; i < 13; i++ ) + p.w[i] = m.w[i] & n.w[i]; + return p; +} + +CandidateList similarTextHeuristicCandidates( const MetaTranslator *tor, + const char *text, + int maxCandidates ) +{ + TQValueList<int> scores; + CandidateList candidates; + CoMatrix cmTarget( text ); + int targetLen = tqstrlen( text ); + + TML all = tor->translatedMessages(); + TML::Iterator it; + + for ( it = all.begin(); it != all.end(); ++it ) { + if ( (*it).type() == MetaTranslatorMessage::Unfinished || + (*it).translation().isEmpty() ) + continue; + + TQString s = tor->toUnicode( (*it).sourceText(), (*it).utf8() ); + CoMatrix cm( s.latin1() ); + int delta = TQABS( (int) s.length() - targetLen ); + + /* + Here is the score formula. A comment above tqcontains a + discussion on a similar (but simpler) formula. + */ + int score = ( (intersection(cm, cmTarget).worth() + 1) << 10 ) / + ( reunion(cm, cmTarget).worth() + (delta << 1) + 1 ); + + if ( (int) candidates.count() == maxCandidates && + score > scores[maxCandidates - 1] ) + candidates.remove( candidates.last() ); + if ( (int) candidates.count() < maxCandidates && score >= 190 ) { + Candidate cand( s, (*it).translation() ); + + int i; + for ( i = 0; i < (int) candidates.count(); i++ ) { + if ( score >= scores[i] ) { + if ( score == scores[i] ) { + if ( candidates[i] == cand ) + goto continue_outer_loop; + } else { + break; + } + } + } + scores.insert( scores.at(i), score ); + candidates.insert( candidates.at(i), cand ); + } + continue_outer_loop: + ; + } + return candidates; +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/simtexth.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/simtexth.h new file mode 100644 index 000000000..e28cdf7b4 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/simtexth.h @@ -0,0 +1,64 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef SIMTEXTH_H +#define SIMTEXTH_H + +#include <tqstring.h> +#include <tqvaluelist.h> + +class MetaTranslator; + +struct Candidate { + TQString source; + TQString target; + + Candidate() { } + Candidate( const TQString& source0, const TQString& target0 ) + : source( source0 ), target( target0 ) { } +}; + +inline bool operator==( const Candidate& c, const Candidate& d ) { + return c.target == d.target && c.source == d.source; +} +inline bool operator!=( const Candidate& c, const Candidate& d ) { + return !operator==( c, d ); +} + +typedef TQValueList<Candidate> CandidateList; + +CandidateList similarTextHeuristicCandidates( const MetaTranslator *tor, + const char *text, + int maxCandidates ); + +#endif diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/statistics.ui b/experimental/tqtinterface/qt4/tools/linguist/linguist/statistics.ui new file mode 100644 index 000000000..1d304d7c0 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/statistics.ui @@ -0,0 +1,259 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>Statistics</class> +<comment>********************************************************************* +** Copyright (C) 2002-2008 Trolltech ASA. All rights reserved. +** +** This file is part of Qt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free Qt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +*********************************************************************</comment> +<widget class="TQDialog"> + <property name="name"> + <cstring>Statistics</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>336</width> + <height>164</height> + </rect> + </property> + <property name="caption"> + <string>Statistics</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget" row="1" column="0"> + <property name="name"> + <cstring>tqlayout2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer4_2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQPushButton"> + <property name="name"> + <cstring>closeBtn</cstring> + </property> + <property name="text"> + <string>&Close</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="tqsizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="TQFrame" row="0" column="0"> + <property name="name"> + <cstring>frame4</cstring> + </property> + <property name="frameShape"> + <enum>GroupBoxPanel</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="2"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="text"> + <string>Translation</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="TQLabel" row="0" column="1"> + <property name="name"> + <cstring>textLabel5</cstring> + </property> + <property name="text"> + <string>Source</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="TQLabel" row="1" column="1"> + <property name="name"> + <cstring>untrWords</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="TQLabel" row="1" column="2"> + <property name="name"> + <cstring>trWords</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Words:</string> + </property> + </widget> + <widget class="TQLabel" row="2" column="2"> + <property name="name"> + <cstring>trChars</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="TQLabel" row="2" column="1"> + <property name="name"> + <cstring>untrChars</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Characters:</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="0"> + <property name="name"> + <cstring>textLabel6</cstring> + </property> + <property name="text"> + <string>Characters (with spaces):</string> + </property> + </widget> + <widget class="TQLabel" row="3" column="2"> + <property name="name"> + <cstring>trCharsSpc</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="TQLabel" row="3" column="1"> + <property name="name"> + <cstring>untrCharsSpc</cstring> + </property> + <property name="text"> + <string>0</string> + </property> + <property name="tqalignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>closeBtn</sender> + <signal>clicked()</signal> + <receiver>Statistics</receiver> + <slot>close()</slot> + </connection> +</connections> +<includes> + <include location="local" impldecl="in implementation">statistics.ui.h</include> +</includes> +<Q_SIGNALS> + <signal>closed()</signal> +</Q_SIGNALS> +<Q_SLOTS> + <slot>updateStats( int w1, int c1, int cs1, int w2, int c2, int cs2 )</slot> + <slot>closeEvent( TQCloseEvent * e )</slot> +</Q_SLOTS> +<functions> + <function access="private" specifier="non virtual">init()</function> +</functions> +<pixmapinproject/> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/statistics.ui.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/statistics.ui.h new file mode 100644 index 000000000..0207d0ab8 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/statistics.ui.h @@ -0,0 +1,53 @@ +/********************************************************************** +** Copyright (C) 2005-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +void Statistics::init() +{ + setFixedHeight( tqsizeHint().height() ); +} + +void Statistics::updateStats( int w1, int c1, int cs1, int w2, int c2, int cs2 ) +{ + untrWords->setText( TQString::number( w1 ) ); + untrChars->setText( TQString::number( c1 ) ); + untrCharsSpc->setText( TQString::number( cs1 ) ); + trWords->setText( TQString::number( w2 ) ); + trChars->setText( TQString::number( c2 ) ); + trCharsSpc->setText( TQString::number( cs2 ) ); +} + +void Statistics::closeEvent( TQCloseEvent * e ) +{ + emit closed(); + TQDialog::closeEvent( e ); +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/trwindow.cpp b/experimental/tqtinterface/qt4/tools/linguist/linguist/trwindow.cpp new file mode 100644 index 000000000..8ebc932a3 --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/trwindow.cpp @@ -0,0 +1,2072 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +/* TRANSLATOR TrWindow + + This is the application's main window. +*/ + +#include "trwindow.h" +#include "listviews.h" +#include "finddialog.h" +#include "msgedit.h" +#include "phrasebookbox.h" +#include "printout.h" +#include "about.h" +#include "phraselv.h" +#include "statistics.h" + +#include <tqaccel.h> +#include <tqaction.h> +#include <tqapplication.h> +#include <tqbitmap.h> +#include <tqdict.h> +#include <tqdockarea.h> +#include <tqdockwindow.h> +#include <tqfile.h> +#include <tqfiledialog.h> +#include <tqfileinfo.h> +#include <tqheader.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqmenubar.h> +#include <tqmessagebox.h> +#include <tqpopupmenu.h> +#include <tqregexp.h> +#include <tqsettings.h> +#include <tqstatusbar.h> +#include <tqtoolbar.h> +#include <tqwhatsthis.h> +#include <tqprocess.h> +#include <tqobject.h> +#include <tqassistantclient.h> + +#include <stdlib.h> + +#define pagecurl_mask_width 53 +#define pagecurl_mask_height 51 +static const uchar pagecurl_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0f, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0xfe, 0xff, + 0xff, 0xff, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, + 0xc0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, + 0x0f, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0xff, + 0xff, 0xff, 0x0f, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, + 0xfc, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x0f, + 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, + 0xff, 0x0f, 0x00, 0x00, 0xf0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xf0, + 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, + 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, + 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, + 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, + 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, + 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, + 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, + 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, + 0x00, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, + 0x0f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfc, + 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0x0f, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08 }; + +typedef TQValueList<MetaTranslatorMessage> TML; + +static const int ErrorMS = 600000; // for error messages +static const int MessageMS = 2500; + +TQPixmap * TrWindow::pxOn = 0; +TQPixmap * TrWindow::pxOff = 0; +TQPixmap * TrWindow::pxObsolete = 0; +TQPixmap * TrWindow::pxDanger = 0; + +enum Ending { End_None, End_FullStop, End_Interrobang, End_Colon, + End_Ellipsis }; + +static Ending ending( TQString str ) +{ + str = str.simplifyWhiteSpace(); + int ch = 0; + if ( !str.isEmpty() ) + ch = str.right( 1 )[0].tqunicode(); + + switch ( ch ) { + case 0x002e: // full stop + if ( str.endsWith(TQString("...")) ) + return End_Ellipsis; + else + return End_FullStop; + case 0x0589: // armenian full stop + case 0x06d4: // arabic full stop + case 0x3002: // ideographic full stop + return End_FullStop; + case 0x0021: // exclamation mark + case 0x003f: // question mark + case 0x00a1: // inverted exclamation mark + case 0x00bf: // inverted question mark + case 0x01c3: // latin letter retroflex click + case 0x037e: // greek question mark + case 0x061f: // arabic question mark + case 0x203c: // double exclamation mark + case 0x203d: // interrobang + case 0x2048: // question exclamation mark + case 0x2049: // exclamation question mark + case 0x2762: // heavy exclamation mark ornament + return End_Interrobang; + case 0x003a: // colon + return End_Colon; + case 0x2026: // horizontal ellipsis + return End_Ellipsis; + default: + return End_None; + } +} + +class Action : public TQAction +{ +public: + Action( TQPopupMenu *pop, const TQString& menuText, TQObject *receiver, + const char *member, const TQString &imageName = TQString(), + int accel = 0, bool toggle = FALSE ); + Action( TQPopupMenu *pop, const TQString& menuText, int accel = 0, + bool toggle = FALSE ); + + virtual void setWhatsThis( const TQString& whatsThis ); + + bool addToToolbar( TQToolBar *tb, const TQString& text ); +}; + +Action::Action( TQPopupMenu *pop, const TQString& menuText, TQObject *receiver, + const char *member, const TQString &imageName, int accel, + bool toggle ) + : TQAction( pop->tqparent(), (const char *) 0, toggle ) +{ + setMenuText( menuText ); + setAccel( accel ); + + if ( !imageName.isEmpty() ) { + TQPixmap enabledPix = TQPixmap::fromMimeSource( imageName ); + TQIconSet s( enabledPix ); + if ( imageName != "whatsthis.xpm" ) { + TQPixmap disabledPix = TQPixmap::fromMimeSource( "d_" + imageName ); + s.setPixmap( disabledPix, TQIconSet::Small, TQIconSet::Disabled ); + } + setIconSet( s ); + } + TQAction::addTo( pop ); + connect( this, TQT_SIGNAL(activated()), receiver, member ); +} + +Action::Action( TQPopupMenu *pop, const TQString& menuText, int accel, + bool toggle ) + : TQAction( pop->tqparent(), (const char *) 0, toggle ) +{ + TQAction::addTo( pop ); + setMenuText( menuText ); + setAccel( accel ); +} + +void Action::setWhatsThis( const TQString& whatsThis ) +{ + TQAction::setWhatsThis( whatsThis ); + setStatusTip( whatsThis ); +} + +bool Action::addToToolbar( TQToolBar *tb, const TQString& text ) +{ + setText( text ); + return TQAction::addTo( tb ); +} + +const TQPixmap TrWindow::pageCurl() +{ + TQPixmap pixmap; + pixmap = TQPixmap::fromMimeSource( "pagecurl.png" ); + if ( !pixmap.isNull() ) { + TQBitmap pageCurlMask( pagecurl_mask_width, pagecurl_mask_height, + pagecurl_mask_bits, TRUE ); + pixmap.setMask( pageCurlMask ); + } + + return pixmap; +} + +TrWindow::TrWindow() + : TQMainWindow( 0, "translation window", (WFlags)(TQt::WType_TopLevel | TQt::WDestructiveClose) ) +{ + +#ifndef TQ_WS_MACX + setIcon( TQPixmap::fromMimeSource( "appicon.png" ) ); +#endif + + // Create the application global listview symbols + pxOn = new TQPixmap( TQPixmap::fromMimeSource( "s_check_on.png" ) ); + pxOff = new TQPixmap( TQPixmap::fromMimeSource( "s_check_off.png" ) ); + pxObsolete = new TQPixmap( TQPixmap::fromMimeSource( "d_s_check_obs.png" ) ); + pxDanger = new TQPixmap( TQPixmap::fromMimeSource( "s_check_danger.png" ) ); + + // Set up the Scope dock window + TQDockWindow * dwScope = new TQDockWindow( TQDockWindow::InDock, this, + "context"); + dwScope->setResizeEnabled( TRUE ); + dwScope->setCloseMode( TQDockWindow::Always ); + addDockWindow( dwScope, tqtr("Context"), TQt::DockLeft ); + dwScope->setCaption( tqtr("Context") ); + dwScope->setFixedExtentWidth( 200 ); + lv = new TQListView( dwScope, "context list view" ); + lv->setShowSortIndicator( TRUE ); + lv->setAllColumnsShowFocus( TRUE ); + lv->header()->setStretchEnabled( TRUE, 1 ); + TQFontMetrics fm( font() ); + lv->addColumn( tqtr("Done"), fm.width( tqtr("Done") ) + 10 ); + lv->addColumn( tqtr("Context") ); + lv->addColumn( tqtr("Items"), 55 ); + lv->setColumnAlignment( 0, TQt::AlignCenter ); + lv->setColumnAlignment( 2, TQt::AlignRight ); + lv->setSorting( 0 ); + lv->setHScrollBarMode( TQScrollView::AlwaysOff ); + dwScope->setWidget( lv ); + + messageIsShown = FALSE; + me = new MessageEditor( &tor, this, "message editor" ); + setCentralWidget( me ); + slv = me->sourceTextList(); + plv = me->phraseList(); + + setupMenuBar(); + setupToolBars(); + + progress = new TQLabel( statusBar(), "progress" ); + statusBar()->addWidget( progress, 0, TRUE ); + modified = new TQLabel( TQString(" %1 ").arg(tqtr("MOD")), statusBar(), + "modified?" ); + statusBar()->addWidget( modified, 0, TRUE ); + + dirtyItem = -1; + numFinished = 0; + numNonobsolete = 0; + numMessages = 0; + updateProgress(); + + dirty = FALSE; + updateCaption(); + + phraseBooks.setAutoDelete( TRUE ); + + f = new FindDialog( FALSE, this, "tqfind", FALSE ); + f->setCaption( tqtr("TQt Linguist") ); + h = new FindDialog( TRUE, this, "tqreplace", FALSE ); + h->setCaption( tqtr("TQt Linguist") ); + tqfindMatchCase = FALSE; + tqfindWhere = 0; + foundItem = 0; + foundScope = 0; + foundWhere = 0; + foundOffset = 0; + + connect( lv, TQT_SIGNAL(selectionChanged(TQListViewItem *)), + this, TQT_SLOT(showNewScope(TQListViewItem *)) ); + + connect( slv, TQT_SIGNAL(currentChanged(TQListViewItem *)), + this, TQT_SLOT(showNewCurrent(TQListViewItem *)) ); + + connect( slv, TQT_SIGNAL(clicked(TQListViewItem *, const TQPoint&, int)), + this, TQT_SLOT(showNewCurrent(TQListViewItem *)) ); + + connect( slv, TQT_SIGNAL(clicked(TQListViewItem *, const TQPoint&, int)), + this, TQT_SLOT(toggleFinished(TQListViewItem *, const TQPoint&, int)) ); + + connect( me, TQT_SIGNAL(translationChanged(const TQString&)), + this, TQT_SLOT(updateTranslation(const TQString&)) ); + connect( me, TQT_SIGNAL(finished(bool)), this, TQT_SLOT(updateFinished(bool)) ); + connect( me, TQT_SIGNAL(prevUnfinished()), this, TQT_SLOT(prevUnfinished()) ); + connect( me, TQT_SIGNAL(nextUnfinished()), this, TQT_SLOT(nextUnfinished()) ); + connect( me, TQT_SIGNAL(focusSourceList()), this, TQT_SLOT(focusSourceList()) ); + connect( me, TQT_SIGNAL(focusPhraseList()), this, TQT_SLOT(focusPhraseList()) ); + connect( f, TQT_SIGNAL(tqfindNext(const TQString&, int, bool)), + this, TQT_SLOT(tqfindNext(const TQString&, int, bool)) ); + + TQWhatsThis::add( lv, tqtr("This panel lists the source contexts.") ); + + TQWhatsThis::add( slv, tqtr("This panel lists the source texts. " + "Items that violate validation rules " + "are marked with a warning.") ); + showNewCurrent( 0 ); + + TQSize as( tqApp->desktop()->size() ); + as -= TQSize( 30, 30 ); + resize( TQSize( 1000, 800 ).boundedTo( as ) ); + readConfig(); + stats = 0; + srcWords = 0; + srcChars = 0; + srcCharsSpc = 0; +} + +TrWindow::~TrWindow() +{ + writeConfig(); + delete stats; +} + +void TrWindow::openFile( const TQString& name ) +{ + if ( !name.isEmpty() ) { + statusBar()->message( tqtr("Loading...") ); + tqApp->processEvents(); + tor.clear(); + if ( tor.load(name) ) { + slv->clear(); + slv->tqrepaint(); + slv->viewport()->tqrepaint(); + slv->setUpdatesEnabled( FALSE ); + slv->viewport()->setUpdatesEnabled( FALSE ); + lv->clear(); + lv->tqrepaint(); + lv->viewport()->tqrepaint(); + lv->setUpdatesEnabled( FALSE ); + lv->viewport()->setUpdatesEnabled( FALSE ); + setEnabled( FALSE ); + numFinished = 0; + numNonobsolete = 0; + numMessages = 0; + foundScope = 0; + + TML all = tor.messages(); + TML::Iterator it; + TQDict<ContextLVI> contexts( 1009 ); + + srcWords = 0; + srcChars = 0; + srcCharsSpc = 0; + for ( it = all.begin(); it != all.end(); ++it ) { + tqApp->processEvents(); + ContextLVI *c = contexts.tqfind( TQString((*it).context()) ); + if ( c == 0 ) { + c = new ContextLVI( lv, tor.toUnicode((*it).context(), + (*it).utf8()) ); + contexts.insert( TQString((*it).context()), c ); + } + if ( TQCString((*it).sourceText()) == ContextComment ) { + c->appendToComment( tor.toUnicode((*it).comment(), + (*it).utf8()) ); + } else { + MessageLVI * tmp = new MessageLVI( slv, *it, + tor.toUnicode((*it).sourceText(), + (*it).utf8()), + tor.toUnicode((*it).comment(), + (*it).utf8()), c ); + tmp->setDanger( danger(tmp->sourceText(), + tmp->translation()) && + tmp->message().type() == + MetaTranslatorMessage::Finished ); + c->instantiateMessageItem( slv, tmp ); + if ( (*it).type() != MetaTranslatorMessage::Obsolete ) { + numNonobsolete++; + if ( (*it).type() == MetaTranslatorMessage::Finished ) + numFinished++; + doCharCounting( tmp->sourceText(), srcWords, srcChars, srcCharsSpc ); + } else { + c->incrementObsoleteCount(); + } + numMessages++; + } + c->updatetqStatus(); + } + slv->viewport()->setUpdatesEnabled( TRUE ); + slv->setUpdatesEnabled( TRUE ); + lv->viewport()->setUpdatesEnabled( TRUE ); + lv->setUpdatesEnabled( TRUE ); + setEnabled( TRUE ); + slv->tqrepaint(); + slv->viewport()->tqrepaint(); + lv->triggerUpdate(); + updateProgress(); + filename = name; + dirty = FALSE; + updateCaption(); + me->showNothing(); + doneAndNextAct->setEnabled( FALSE ); + doneAndNextAlt->setEnabled( FALSE ); + messageIsShown = FALSE; + statusBar()->message( + tqtr("%1 source phrase(s) loaded.").arg(numMessages), + MessageMS ); + + foundItem = 0; + foundWhere = 0; + foundOffset = 0; + if ( lv->childCount() > 0 ) { + tqfindAct->setEnabled( TRUE ); + tqfindAgainAct->setEnabled( FALSE ); +#ifdef notyet + tqreplaceAct->setEnabled( TRUE ); +#endif + lv->setCurrentItem( lv->firstChild() ); + } + addRecentlyOpenedFile( name, recentFiles ); + updateStatistics(); + } else { + statusBar()->clear(); + TQMessageBox::warning( this, tqtr("TQt Linguist"), + tqtr("Cannot open '%1'.").arg(name) ); + } + } +} + +void TrWindow::open() +{ + if ( maybeSave() ) { + TQString newFilename = TQFileDialog::getOpenFileName( filename, + tqtr("TQt translation source (*.ts)\n" + "All files (*)"), + this, "open" ); + openFile( newFilename ); + } +} + +void TrWindow::save() +{ + if ( filename.isEmpty() ) + return; + + if ( tor.save(filename) ) { + dirty = FALSE; + updateCaption(); + statusBar()->message( tqtr("File saved."), MessageMS ); + } else { + TQMessageBox::warning( this, tqtr("TQt Linguist"), tqtr("Cannot save '%1'.") + .arg(filename) ); + } +} + +void TrWindow::saveAs() +{ + TQString newFilename = TQFileDialog::getSaveFileName( filename, + tqtr( "TQt translation source (*.ts)\n" + "All files (*)"), + this, "save_as" ); + if ( !newFilename.isEmpty() ) { + filename = newFilename; + save(); + updateCaption(); + } +} + +void TrWindow::release() +{ + TQString newFilename = filename; + newFilename.tqreplace( TQRegExp(".ts$"), "" ); + newFilename += TQString( ".qm" ); + + newFilename = TQFileDialog::getSaveFileName( newFilename, + tqtr("TQt message files for released applications (*.qm)\n" + "All files (*)"), + this, "release", + tqtr("Release") ); + if ( !newFilename.isEmpty() ) { + if ( tor.release(newFilename) ) + statusBar()->message( tqtr("File created."), MessageMS ); + else + TQMessageBox::warning( this, tqtr("TQt Linguist"), + tqtr("Cannot save '%1'.").arg(newFilename) ); + } +} + +void TrWindow::print() +{ + int pageNum = 0; + + if ( printer.setup(this) ) { + TQApplication::setOverrideCursor( WaitCursor ); + printer.setDocName( filename ); + statusBar()->message( tqtr("Printing...") ); + PrintOut pout( &printer ); + ContextLVI *c = (ContextLVI *) lv->firstChild(); + while ( c != 0 ) { + setCurrentContextItem( c ); + pout.vskip(); + pout.setRule( PrintOut::ThickRule ); + pout.setGuide( c->context() ); + pout.addBox( 100, tqtr("Context: %1").arg(c->context()), + PrintOut::Strong ); + pout.flushLine(); + pout.addBox( 4 ); + pout.addBox( 92, c->comment(), PrintOut::Emphasis ); + pout.flushLine(); + pout.setRule( PrintOut::ThickRule ); + + MessageLVI *m = (MessageLVI *) slv->firstChild(); + while ( m != 0 ) { + pout.setRule( PrintOut::ThinRule ); + + TQString type; + switch ( m->message().type() ) { + case MetaTranslatorMessage::Finished: + type = tqtr( "finished" ); + break; + case MetaTranslatorMessage::Unfinished: + type = m->danger() ? tqtr( "unresolved" ) : TQString( "unfinished" ); + break; + case MetaTranslatorMessage::Obsolete: + type = tqtr( "obsolete" ); + break; + default: + type = TQString( "" ); + } + pout.addBox( 40, m->sourceText() ); + pout.addBox( 4 ); + pout.addBox( 40, m->translation() ); + pout.addBox( 4 ); + pout.addBox( 12, type, PrintOut::Normal, TQt::AlignRight ); + if ( !m->comment().isEmpty() ) { + pout.flushLine(); + pout.addBox( 4 ); + pout.addBox( 92, m->comment(), PrintOut::Emphasis ); + } + pout.flushLine( TRUE ); + + if ( pout.pageNum() != pageNum ) { + pageNum = pout.pageNum(); + statusBar()->message( tqtr("Printing... (page %1)") + .arg(pageNum) ); + } + m = (MessageLVI *) m->nextSibling(); + } + c = (ContextLVI *) c->nextSibling(); + } + pout.flushLine( TRUE ); + TQApplication::restoreOverrideCursor(); + statusBar()->message( tqtr("Printing completed"), MessageMS ); + } else { + statusBar()->message( tqtr("Printing aborted"), MessageMS ); + } +} + +void TrWindow::tqfind() +{ + h->hide(); + f->show(); + f->setActiveWindow(); + f->raise(); +} + +void TrWindow::tqfindAgain() +{ + int pass = 0; + int oldItemNo = itemToIndex( slv, slv->currentItem() ); + TQString delayedMsg; + TQListViewItem * j = foundScope; + TQListViewItem * k = indexToItem( slv, foundItem ); + TQListViewItem * oldScope = lv->currentItem(); + + if ( lv->childCount() == 0 ) + return; +#if 1 + /* + As long as we don't implement highlighting of the text in the TQTextView, + we may have only one match per message. + */ + foundOffset = (int) 0x7fffffff; +#else + foundOffset++; +#endif + slv->setUpdatesEnabled( FALSE ); + do { + // Iterate through every item in all contexts + if ( j == 0 ) { + j = lv->firstChild(); + setCurrentContextItem( j ); + if ( foundScope != 0 ) + delayedMsg = tqtr("Search wrapped."); + } + if ( k == 0 ) + k = slv->firstChild(); + + while ( k ) { + MessageLVI * m = (MessageLVI *) k; + switch ( foundWhere ) { + case 0: + foundWhere = FindDialog::SourceText; + foundOffset = 0; + // fall-through + case FindDialog::SourceText: + if ( searchItem( m->sourceText(), j, k ) ) { + f->hide(); + if ( !delayedMsg.isEmpty() ) + statusBar()->message( delayedMsg, MessageMS ); + return; + } + foundWhere = FindDialog::Translations; + foundOffset = 0; + // fall-through + case FindDialog::Translations: + if ( searchItem( m->translation(), j, k ) ) { + f->hide(); + if ( !delayedMsg.isEmpty() ) + statusBar()->message( delayedMsg, MessageMS ); + return; + } + foundWhere = FindDialog::Comments; + foundOffset = 0; + // fall-through + case FindDialog::Comments: + if ( searchItem( ((ContextLVI *) j)->fullContext(), j, k) ) { + f->hide(); + if ( !delayedMsg.isEmpty() ) + statusBar()->message( delayedMsg, MessageMS ); + return; + } + foundWhere = 0; + foundOffset = 0; + } + k = k->nextSibling(); + } + + j = j->nextSibling(); + if ( j ) { + setCurrentContextItem( j ); + k = slv->firstChild(); + } + } while ( pass++ != lv->childCount() ); + + // This is just to keep the current scope and source text item + // selected after a search failed. + if ( oldScope ) { + setCurrentContextItem( oldScope ); + TQListViewItem * tmp = indexToItem( slv, oldItemNo ); + if( tmp ) + setCurrentMessageItem( tmp ); + } else { + if( lv->firstChild() ) + setCurrentContextItem( lv->firstChild() ); + if( slv->firstChild() ) + setCurrentMessageItem( slv->firstChild() ); + } + + slv->setUpdatesEnabled( TRUE ); + slv->triggerUpdate(); + tqApp->beep(); + TQMessageBox::warning( this, tqtr("TQt Linguist"), + TQString( tqtr("Cannot tqfind the string '%1'.") ).arg(tqfindText) ); + foundItem = 0; + foundWhere = 0; + foundOffset = 0; +} + +void TrWindow::tqreplace() +{ + f->hide(); + h->show(); + h->setActiveWindow(); + h->raise(); +} + +int TrWindow::itemToIndex( TQListView * view, TQListViewItem * item ) +{ + int no = 0; + TQListViewItem * tmp; + + if( view && item ){ + if( (tmp = view->firstChild()) != 0 ) + do { + no++; + tmp = tmp->nextSibling(); + } while( tmp && (tmp != item) ); + } + return no; +} + +TQListViewItem * TrWindow::indexToItem( TQListView * view, int index ) +{ + TQListViewItem * item = 0; + + if ( view && index > 0 ) { + item = view->firstChild(); + while( item && index-- > 0 ) + item = item->nextSibling(); + } + return item; +} + +bool TrWindow::searchItem( const TQString & searchWhat, TQListViewItem * j, + TQListViewItem * k ) +{ + if ( (tqfindWhere & foundWhere) != 0 ) { + foundOffset = searchWhat.tqfind( tqfindText, foundOffset, tqfindMatchCase ); + if ( foundOffset >= 0 ) { + foundItem = itemToIndex( slv, k ); + foundScope = j; + setCurrentMessageItem( k ); + slv->setUpdatesEnabled( TRUE ); + slv->triggerUpdate(); + return TRUE; + } + } + foundOffset = 0; + return FALSE; +} + +void TrWindow::newPhraseBook() +{ + TQString name; + for (;;) { + name = TQFileDialog::getSaveFileName( TQString(), + tqtr("TQt phrase books (*.qph)\n" + "All files (*)"), + this, "new_phrasebook", + tqtr("Create New Phrase Book") ); + if ( !TQFile::exists(name) ) + break; + TQMessageBox::warning( this, tqtr("TQt Linguist"), + tqtr("A file called '%1' already exists." + " Please choose another name.").arg(name) ); + } + if ( !name.isEmpty() ) { + PhraseBook pb; + if ( savePhraseBook(name, pb) ) { + if ( openPhraseBook(name) ) + statusBar()->message( tqtr("Phrase book created."), MessageMS ); + } + } +} + +void TrWindow::openPhraseBook() +{ + TQString phrasebooks( qInstallPathData() ); + TQString name = TQFileDialog::getOpenFileName( phrasebooks + "/phrasebooks", + tqtr("TQt phrase books (*.qph)\n" + "All files (*)"), + this, "open_phrasebook", + tqtr("Open Phrase Book") ); + if ( !name.isEmpty() && !phraseBookNames.tqcontains(name) ) { + if ( openPhraseBook(name) ) { + int n = (int)(phraseBooks.at( phraseBooks.count() - 1 )->count()); + statusBar()->message( tqtr("%1 phrase(s) loaded.").arg(n), + MessageMS ); + } + } +} + +void TrWindow::closePhraseBook( int id ) +{ + int index = closePhraseBookp->indexOf( id ); + phraseBooks.remove( index ); + phraseBookNames.remove( phraseBookNames.at(index) ); + updatePhraseDict(); + + dirtyItem = index; // remove the item next time the menu is opened + editPhraseBookp->removeItem( editPhraseBookp->idAt(index) ); + printPhraseBookp->removeItem( printPhraseBookp->idAt(index) ); +} + +void TrWindow::editPhraseBook( int id ) +{ + int index = editPhraseBookp->indexOf( id ); + PhraseBookBox box( phraseBookNames[index], *phraseBooks.at(index), this, + "phrase book box", TRUE ); + box.setCaption( tqtr("%1 - %2").arg(tqtr("TQt Linguist")) + .arg(friendlyPhraseBookName(index)) ); + box.resize( 500, 300 ); + box.exec(); + *phraseBooks.at( index ) = box.phraseBook(); + updatePhraseDict(); +} + +void TrWindow::printPhraseBook( int id ) +{ + int index = printPhraseBookp->indexOf( id ); + int pageNum = 0; + + if ( printer.setup(this) ) { + printer.setDocName( phraseBookNames[index] ); + statusBar()->message( tqtr("Printing...") ); + PrintOut pout( &printer ); + PhraseBook *phraseBook = phraseBooks.at( index ); + PhraseBook::Iterator p; + pout.setRule( PrintOut::ThinRule ); + for ( p = phraseBook->begin(); p != phraseBook->end(); ++p ) { + pout.setGuide( (*p).source() ); + pout.addBox( 29, (*p).source() ); + pout.addBox( 4 ); + pout.addBox( 29, (*p).target() ); + pout.addBox( 4 ); + pout.addBox( 34, (*p).definition(), PrintOut::Emphasis ); + + if ( pout.pageNum() != pageNum ) { + pageNum = pout.pageNum(); + statusBar()->message( tqtr("Printing... (page %1)") + .arg(pageNum) ); + } + pout.setRule( PrintOut::NoRule ); + pout.flushLine( TRUE ); + } + pout.flushLine( TRUE ); + statusBar()->message( tqtr("Printing completed"), MessageMS ); + } else { + statusBar()->message( tqtr("Printing aborted"), MessageMS ); + } +} + +void TrWindow::revertSorting() +{ + lv->setSorting( 0 ); + slv->setSorting( 0 ); +} + +void TrWindow::manual() +{ + TQAssistantClient *ac = new TQAssistantClient( qInstallPathBins(), TQT_TQOBJECT(this) ); + ac->showPage( TQString( qInstallPathDocs() ) + "/html/linguist-manual.html" ); +} + +void TrWindow::about() +{ + AboutDialog about( this, 0, TRUE ); + about.versionLabel->setText( tqtr("Version %1").arg(TQT_VERSION_STR) ); + about.exec(); +} + +void TrWindow::aboutTQt() +{ + TQMessageBox::aboutTQt( this, tqtr("TQt Linguist") ); +} + +void TrWindow::setupPhrase() +{ + bool enabled = !phraseBooks.isEmpty(); + phrasep->setItemEnabled( closePhraseBookId, enabled ); + phrasep->setItemEnabled( editPhraseBookId, enabled ); + phrasep->setItemEnabled( printPhraseBookId, enabled ); +} + +void TrWindow::closeEvent( TQCloseEvent *e ) +{ + if ( maybeSave() ) + e->accept(); + else + e->ignore(); +} + +bool TrWindow::maybeSave() +{ + if ( dirty ) { + switch ( TQMessageBox::information(this, tqtr("TQt Linguist"), + tqtr("Do you want to save '%1'?") + .arg(filename), + TQMessageBox::Yes | TQMessageBox::Default, + TQMessageBox::No, + TQMessageBox::Cancel | TQMessageBox::Escape ) ) + { + case TQMessageBox::Cancel: + return FALSE; + case TQMessageBox::Yes: + save(); + return !dirty; + case TQMessageBox::No: + break; + } + } + return TRUE; +} + +void TrWindow::updateCaption() +{ + TQString cap; + bool enable = !filename.isEmpty(); + saveAct->setEnabled( enable ); + saveAsAct->setEnabled( enable ); + releaseAct->setEnabled( enable ); + printAct->setEnabled( enable ); + acceleratorsAct->setEnabled( enable ); + endingPunctuationAct->setEnabled( enable ); + phraseMatchesAct->setEnabled( enable ); + revertSortingAct->setEnabled( enable ); + + if ( filename.isEmpty() ) + cap = tqtr( "TQt Linguist by Trolltech" ); + else + cap = tqtr( "%1 - %2" ).arg( tqtr("TQt Linguist by Trolltech") ) + .arg( filename ); + setCaption( cap ); + modified->setEnabled( dirty ); +} + +// +// New scope selected - build a new list of source text items +// for that scope. +// +void TrWindow::showNewScope( TQListViewItem *item ) +{ + static ContextLVI * oldContext = 0; + + if( item != 0 ) { + ContextLVI * c = (ContextLVI *) item; + bool upe = slv->isUpdatesEnabled(); + slv->setUpdatesEnabled( FALSE ); + slv->viewport()->setUpdatesEnabled( FALSE ); + if ( oldContext != 0 ) { + MessageLVI * tmp; + slv->blockSignals( TRUE ); + while ( (tmp = (MessageLVI *) slv->firstChild()) != 0 ) + oldContext->appendMessageItem( slv, tmp ); + slv->blockSignals( FALSE ); + } + MessageLVI * tmp; + while ( c->messageItemsInList() ) { + tmp = c->takeMessageItem( c->messageItemsInList() - 1); + slv->insertItem( tmp ); + tmp->updateTranslationText(); + } + + // Make sure that we update the source text and translation text. Use the first message in the new scope. + setCurrentMessageItem(slv->firstChild()); + // This must be explicitly called since the signal is not emitted if the context only tqcontains one item + showNewCurrent(slv->firstChild()); + slv->viewport()->setUpdatesEnabled( upe ); + slv->setUpdatesEnabled( upe ); + if( upe ) + slv->triggerUpdate(); + oldContext = (ContextLVI *) item; + statusBar()->clear(); + } +} + +void TrWindow::showNewCurrent( TQListViewItem *item ) +{ + messageIsShown = (item != 0); + MessageLVI *m = (MessageLVI *) item; + ContextLVI *c = (ContextLVI *) m ? m->contextLVI() : 0; + + if ( messageIsShown ) { + me->showMessage( m->sourceText(), m->comment(), c->fullContext(), + m->translation(), m->message().type(), + getPhrases(m->sourceText()) ); + if ( (m->message().type() != MetaTranslatorMessage::Finished) && + m->danger() ) + danger( m->sourceText(), m->translation(), TRUE ); + else + statusBar()->clear(); + + doneAndNextAct->setEnabled( m->message().type() != + MetaTranslatorMessage::Obsolete ); + } else { + if ( item == 0 ) + me->showNothing(); + else + me->showContext( c->fullContext(), c->finished() ); + doneAndNextAct->setEnabled( FALSE ); + } + doneAndNextAlt->setEnabled( doneAndNextAct->isEnabled() ); + + selectAllAct->setEnabled( messageIsShown ); +} + +void TrWindow::updateTranslation( const TQString& translation ) +{ + TQListViewItem *item = slv->currentItem(); + if ( item != 0 ) { + MessageLVI *m = (MessageLVI *) item; + if ( translation != m->translation() ) { + bool dngr; + m->setTranslation( translation ); + if ( m->finished() && + (dngr = danger( m->sourceText(), m->translation(), TRUE )) ) { + numFinished -= 1; + m->setDanger( dngr ); + m->setFinished( FALSE ); + m->contextLVI()->updatetqStatus(); + updateProgress(); + } + tor.insert( m->message() ); + if ( !dirty ) { + dirty = TRUE; + updateCaption(); + } + m->updateTranslationText(); + } + } +} + +void TrWindow::updateFinished( bool finished ) +{ + TQListViewItem *item = slv->currentItem(); + if ( item != 0 ) { + MessageLVI *m = (MessageLVI *) item; + if ( finished != m->finished() ) { + numFinished += finished ? +1 : -1; + updateProgress(); + m->setFinished( finished ); + bool oldDanger = m->danger(); + m->setDanger( /*m->finished() &&*/ + danger(m->sourceText(), m->translation(), + !oldDanger) ); + if ( !oldDanger && m->danger() ) + tqApp->beep(); + tor.insert( m->message() ); + if ( !dirty ) { + dirty = TRUE; + updateCaption(); + } + } + } +} + +void TrWindow::doneAndNext() +{ + MessageLVI * m = (MessageLVI *) slv->currentItem(); + bool dngr = FALSE; + + if ( !m ) return; + dngr = danger( m->sourceText(), m->translation(), TRUE ); + if ( !dngr ) { + me->finishAndNext(); + m->contextLVI()->updatetqStatus(); + } else { + if ( m->danger() != dngr ) + m->setDanger( dngr ); + tor.insert( m->message() ); + if ( !dirty ) { + dirty = TRUE; + updateCaption(); + } + tqApp->beep(); + } + updateStatistics(); +} + +void TrWindow::toggleFinished( TQListViewItem *item, const TQPoint& /* p */, + int column ) +{ + if ( item != 0 && column == 0 ) { + MessageLVI *m = (MessageLVI *) item; + bool dngr = FALSE; + + if ( m->message().type() == MetaTranslatorMessage::Unfinished ) { + dngr = danger( m->sourceText(), m->translation(), TRUE ); + } + if ( !dngr && m->message().type() != MetaTranslatorMessage::Obsolete) { + setCurrentMessageItem( m ); + me->setFinished( !m->finished() ); + m->contextLVI()->updatetqStatus(); + } else { + bool oldDanger = m->danger(); + m->setDanger( danger(m->sourceText(), m->translation(), + !oldDanger) ); + if ( !oldDanger && m->danger() ) + tqApp->beep(); + tor.insert( m->message() ); + if ( !dirty ) { + dirty = TRUE; + updateCaption(); + } + } + updateStatistics(); + } +} + +void TrWindow::nextUnfinished() +{ + if ( nextUnfinishedAct->isEnabled() ) { + // Select a message to translate, grab the first available if + // there are no current selection. + TQListViewItem * cItem = lv->currentItem(); // context item + TQListViewItem * mItem = slv->currentItem(); // message item + + // Make sure an item is selected from both the context and the + // message list. + if( (mItem == 0) && !(mItem = slv->firstChild()) ) { + if( (cItem == 0) && !(cItem = lv->firstChild()) ) { + statusBar()->message( tqtr("No phrase to translate."), + MessageMS ); + tqApp->beep(); + return; + } else { + showNewScope( cItem ); + while( cItem && !(mItem = slv->firstChild()) ) { + // no tqchildren in this node - try next one + cItem = cItem->nextSibling(); + showNewScope( cItem ); + } + setCurrentContextItem( cItem ); + if( mItem ) { + setCurrentMessageItem( mItem ); + } else { + statusBar()->message( tqtr("No phrase to translate."), + MessageMS ); + tqApp->beep(); + return; + } + } + } else { + setCurrentMessageItem( mItem ); + } + + MessageLVI * m = (MessageLVI *) mItem; + MessageLVI * n; + ContextLVI * p = (ContextLVI *) cItem; + ContextLVI * q; + + // Find the next Unfinished sibling within the same context. + m = (MessageLVI *) mItem->nextSibling(); + n = m; + do { + if ( n == 0 ) + break; + if ( n && !n->finished() && n != mItem ) { + setCurrentMessageItem( n ); + return; + } + n = (MessageLVI *) n->nextSibling(); + } while ( n != m ); + + // If all siblings are Finished or Obsolete, look in the first + // Unfinished context. + p = (ContextLVI *) p->nextSibling(); + q = p; + do { + if ( q == 0 ) + q = (ContextLVI *) lv->firstChild(); + if ( q && !q->finished() ) { + showNewScope( q ); + setCurrentContextItem( q ); + n = (MessageLVI *) slv->firstChild(); + while ( n && n->finished() ) + n = (MessageLVI *) n->nextSibling(); + if ( n && q ) { + setCurrentMessageItem( n ); + showNewCurrent( n ); + return; + } + } + q = (ContextLVI *) q->nextSibling(); + } while ( q != p ); + } + + // If no Unfinished message is left, the user has finished the job. We + // congratulate on a job well done with this ringing bell. + statusBar()->message( tqtr("No untranslated phrases left."), MessageMS ); + tqApp->beep(); +} + +static TQListViewItem * lastChild( TQListView * view ) +{ + if ( view ) { + TQListViewItem * ret, * tmp; + ret = view->firstChild(); + while ( ret ) { + tmp = ret->nextSibling(); + if ( tmp == 0 ) + return ret; + ret = tmp; + } + } + return 0; +} + +void TrWindow::prevUnfinished() +{ + if ( prevUnfinishedAct->isEnabled() ) { + // Select a message to translate, grab the first available if + // there are no current selection. + TQListViewItem * cItem = lv->currentItem(); // context item + TQListViewItem * mItem = slv->currentItem(); // message item + + // Make sure an item is selected from both the context and the + // message list. + if( (mItem == 0) && !(mItem = slv->firstChild()) ) { + if( (cItem == 0) && !(cItem = lv->firstChild()) ) { + statusBar()->message( tqtr("No phrase to translate."), + MessageMS ); + tqApp->beep(); + return; + } else { + showNewScope( cItem ); + while( cItem && !(mItem = slv->firstChild()) ) { + // no tqchildren in this node - try next one + cItem = cItem->nextSibling(); + showNewScope( cItem ); + } + setCurrentContextItem( cItem ); + if( mItem ) { + setCurrentMessageItem( cItem ); + } else { + statusBar()->message( tqtr("No phrase to translate."), + MessageMS ); + tqApp->beep(); + return; + } + } + } else { + setCurrentMessageItem( mItem ); + } + + MessageLVI * m = (MessageLVI *) mItem; + MessageLVI * n; + ContextLVI * p = (ContextLVI *) cItem; + ContextLVI * q; + + // Find the next Unfinished sibling within the same context. + n = m; + do { + n = (MessageLVI * ) n->itemAbove(); + if ( n == 0 ) + break; + if ( n && !n->finished() ) { + setCurrentMessageItem( n ); + return; + } + } while ( !((ContextLVI *) cItem)->finished() && n != 0 ); + + // If all siblings are Finished or Obsolete, look in the prev + // Unfinished context. + q = p; + do { + q = (ContextLVI *) q->itemAbove(); + if ( q == 0 ) + q = (ContextLVI *) lastChild( lv ); + if ( q && !q->finished() ) { + showNewScope( q ); + setCurrentContextItem( q ); + n = (MessageLVI *) lastChild( slv ); + while ( n && n->finished() ) + n = (MessageLVI *) n->itemAbove(); + if ( n && q ) { + setCurrentMessageItem( n ); + return; + } + } + } while ( q != 0 ); + } + statusBar()->message( tqtr("No untranslated phrases left."), MessageMS ); + tqApp->beep(); +} + +void TrWindow::prev() +{ + TQListViewItem * cItem = lv->currentItem(); // context item + TQListViewItem * mItem = slv->currentItem(); // message item + TQListViewItem * tmp; + + if ( !cItem ) { + cItem = lv->firstChild(); + if ( !cItem ) return; + setCurrentContextItem( cItem ); + } + + if ( !mItem ) { + mItem = lastChild( slv ); + if ( !mItem ) return; + setCurrentMessageItem( mItem ); + } else { + if ( (tmp = mItem->itemAbove()) != 0 ) { + setCurrentMessageItem( tmp ); + return; + } else { + if ( (tmp = cItem->itemAbove()) == 0 ) { + tmp = lastChild( lv ); + } + if ( !tmp ) return; + setCurrentContextItem( tmp ); + setCurrentMessageItem( lastChild( slv ) ); + } + } +} + +void TrWindow::next() +{ + TQListViewItem * cItem = lv->currentItem(); // context item + TQListViewItem * mItem = slv->currentItem(); // message item + TQListViewItem * tmp; + + if ( !cItem ) { + cItem = lv->firstChild(); + if ( !cItem ) return; + setCurrentContextItem( cItem ); + } + + if ( !mItem ) { + mItem = slv->firstChild(); + if ( !mItem ) return; + setCurrentMessageItem( mItem ); + } else { + if ( (tmp = mItem->nextSibling()) != 0 ) { + setCurrentMessageItem( tmp ); + return; + } else { + if ( (tmp = cItem->nextSibling()) == 0 ) { + tmp = lv->firstChild(); + } + if ( !tmp ) return; + setCurrentContextItem( tmp ); + setCurrentMessageItem( slv->firstChild() ); + } + } +} + + +void TrWindow::tqfindNext( const TQString& text, int where, bool matchCase ) +{ + tqfindText = text; + if ( tqfindText.isEmpty() ) + tqfindText = TQString( "magicwordthatyoushouldavoid" ); + tqfindWhere = where; + tqfindMatchCase = matchCase; + tqfindAgainAct->setEnabled( TRUE ); + tqfindAgain(); +} + +void TrWindow::revalidate() +{ + ContextLVI *c = (ContextLVI *) lv->firstChild(); + TQListViewItem * oldScope = lv->currentItem(); + int oldItemNo = itemToIndex( slv, slv->currentItem() ); + slv->setUpdatesEnabled( FALSE ); + + while ( c != 0 ) { + showNewScope( c ); + MessageLVI *m = (MessageLVI *) slv->firstChild(); + while ( m != 0 ) { + m->setDanger( danger(m->sourceText(), m->translation()) && + m->message().type() == MetaTranslatorMessage::Finished ); + m = (MessageLVI *) m->nextSibling(); + } + c = (ContextLVI *) c->nextSibling(); + } + + if ( oldScope ){ + showNewScope( oldScope ); + TQListViewItem * tmp = indexToItem( slv, oldItemNo ); + if( tmp ) + setCurrentMessageItem( tmp ); + } + slv->setUpdatesEnabled( TRUE ); + slv->triggerUpdate(); +} + +TQString TrWindow::friendlyString( const TQString& str ) +{ + TQString f = str.lower(); + f.tqreplace( TQRegExp(TQString("[.,:;!?()-]")), TQString(" ") ); + f.tqreplace( "&", TQString("") ); + f = f.simplifyWhiteSpace(); + f = f.lower(); + return f; +} + +void TrWindow::setupMenuBar() +{ + TQMenuBar * m = menuBar(); + TQPopupMenu * filep = new TQPopupMenu( this ); + TQPopupMenu * editp = new TQPopupMenu( this ); + TQPopupMenu * translationp = new TQPopupMenu( this ); + TQPopupMenu * validationp = new TQPopupMenu( this ); + validationp->setCheckable( TRUE ); + phrasep = new TQPopupMenu( this ); + closePhraseBookp = new TQPopupMenu( this ); + editPhraseBookp = new TQPopupMenu( this ); + printPhraseBookp = new TQPopupMenu( this ); + TQPopupMenu * viewp = new TQPopupMenu( this ); + viewp->setCheckable( TRUE ); + TQPopupMenu * helpp = new TQPopupMenu( this ); + + m->insertItem( tqtr("&File"), filep ); + m->insertItem( tqtr("&Edit"), editp ); + m->insertItem( tqtr("&Translation"), translationp ); + m->insertItem( tqtr("V&alidation"), validationp ); + m->insertItem( tqtr("&Phrases"), phrasep ); + m->insertItem( tqtr("&View"), viewp ); + m->insertSeparator(); + m->insertItem( tqtr("&Help"), helpp ); + + connect( closePhraseBookp, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(closePhraseBook(int)) ); + connect( closePhraseBookp, TQT_SIGNAL(aboutToShow()), + this, TQT_SLOT(updateClosePhraseBook()) ); + connect( editPhraseBookp, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(editPhraseBook(int)) ); + connect( printPhraseBookp, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(printPhraseBook(int)) ); + // File menu + openAct = new Action( filep, tqtr("&Open..."), TQT_TQOBJECT(this), TQT_SLOT(open()), + "fileopen.png", TQAccel::stringToKey(tqtr("Ctrl+O")) ); + + filep->insertSeparator(); + + saveAct = new Action( filep, tqtr("&Save"), TQT_TQOBJECT(this), TQT_SLOT(save()), + "filesave.png", TQAccel::stringToKey(tqtr("Ctrl+S")) ); + saveAsAct = new Action( filep, tqtr("Save &As..."), TQT_TQOBJECT(this), TQT_SLOT(saveAs()) ); + releaseAct = new Action( filep, tqtr("&Release..."), TQT_TQOBJECT(this), TQT_SLOT(release()) ); + filep->insertSeparator(); + printAct = new Action( filep, tqtr("&Print..."), TQT_TQOBJECT(this), TQT_SLOT(print()), + "print.png", TQAccel::stringToKey(tqtr("Ctrl+P")) ); + + filep->insertSeparator(); + + recentFilesMenu = new TQPopupMenu( this ); + filep->insertItem( tqtr("Re¢ly opened files"), recentFilesMenu ); + connect( recentFilesMenu, TQT_SIGNAL(aboutToShow()), this, + TQT_SLOT(setupRecentFilesMenu()) ); + connect( recentFilesMenu, TQT_SIGNAL(activated( int )), this, + TQT_SLOT(recentFileActivated( int )) ); + + filep->insertSeparator(); + + exitAct = new Action( filep, tqtr("E&xit"), TQT_TQOBJECT(this), TQT_SLOT(close()), + TQString(), TQAccel::stringToKey(tqtr("Ctrl+Q")) ); + // Edit menu + undoAct = new Action( editp, tqtr("&Undo"), TQT_TQOBJECT(me), TQT_SLOT(undo()), + "undo.png", TQAccel::stringToKey(tqtr("Ctrl+Z")) ); + undoAct->setEnabled( FALSE ); + connect( me, TQT_SIGNAL(undoAvailable(bool)), undoAct, TQT_SLOT(setEnabled(bool)) ); + redoAct = new Action( editp, tqtr("&Redo"), TQT_TQOBJECT(me), TQT_SLOT(redo()), + "redo.png", TQAccel::stringToKey(tqtr("Ctrl+Y")) ); + redoAct->setEnabled( FALSE ); + connect( me, TQT_SIGNAL(redoAvailable(bool)), redoAct, TQT_SLOT(setEnabled(bool)) ); + editp->insertSeparator(); + cutAct = new Action( editp, tqtr("Cu&t"), TQT_TQOBJECT(me), TQT_SLOT(cut()), + "editcut.png", TQAccel::stringToKey(tqtr("Ctrl+X")) ); + cutAct->setEnabled( FALSE ); + connect( me, TQT_SIGNAL(cutAvailable(bool)), cutAct, TQT_SLOT(setEnabled(bool)) ); + copyAct = new Action( editp, tqtr("&Copy"), TQT_TQOBJECT(me), TQT_SLOT(copy()), + "editcopy.png", TQAccel::stringToKey(tqtr("Ctrl+C")) ); + copyAct->setEnabled( FALSE ); + connect( me, TQT_SIGNAL(copyAvailable(bool)), copyAct, TQT_SLOT(setEnabled(bool)) ); + pasteAct = new Action( editp, tqtr("&Paste"), TQT_TQOBJECT(me), TQT_SLOT(paste()), + "editpaste.png", TQAccel::stringToKey(tqtr("Ctrl+V")) ); + pasteAct->setEnabled( FALSE ); + connect( me, TQT_SIGNAL(pasteAvailable(bool)), + pasteAct, TQT_SLOT(setEnabled(bool)) ); + selectAllAct = new Action( editp, tqtr("Select &All"), TQT_TQOBJECT(me), TQT_SLOT(selectAll()), + TQString(), TQAccel::stringToKey(tqtr("Ctrl+A")) ); + selectAllAct->setEnabled( FALSE ); + editp->insertSeparator(); + tqfindAct = new Action( editp, tqtr("&Find..."), TQT_TQOBJECT(this), TQT_SLOT(tqfind()), + "searchfind.png", TQAccel::stringToKey(tqtr("Ctrl+F")) ); + tqfindAct->setEnabled( FALSE ); + tqfindAgainAct = new Action( editp, tqtr("Find &Next"), + TQT_TQOBJECT(this), TQT_SLOT(tqfindAgain()), TQString(), Qt::Key_F3 ); + tqfindAgainAct->setEnabled( FALSE ); +#ifdef notyet + tqreplaceAct = new Action( editp, tqtr("&Replace..."), TQT_TQOBJECT(this), TQT_SLOT(tqreplace()), + TQAccel::stringToKey(tqtr("Ctrl+H")) ); + tqreplaceAct->setEnabled( FALSE ); +#endif + + // Translation menu + // when updating the accelerators, remember the status bar + prevUnfinishedAct = new Action( translationp, tqtr("&Prev Unfinished"), + TQT_TQOBJECT(this), TQT_SLOT(prevUnfinished()), + "prevunfinished.png", TQAccel::stringToKey(tqtr("Ctrl+K")) ); + nextUnfinishedAct = new Action( translationp, tqtr("&Next Unfinished"), + TQT_TQOBJECT(this), TQT_SLOT(nextUnfinished()), + "nextunfinished.png", TQAccel::stringToKey(tqtr("Ctrl+L")) ); + + prevAct = new Action( translationp, tqtr("P&rev"), + TQT_TQOBJECT(this), TQT_SLOT(prev()), "prev.png", + TQAccel::stringToKey(tqtr("Ctrl+Shift+K")) ); + nextAct = new Action( translationp, tqtr("Ne&xt"), + TQT_TQOBJECT(this), TQT_SLOT(next()), "next.png", + TQAccel::stringToKey(tqtr("Ctrl+Shift+L")) ); + doneAndNextAct = new Action( translationp, tqtr("Done and &Next"), + TQT_TQOBJECT(this), TQT_SLOT(doneAndNext()), "doneandnext.png", + TQAccel::stringToKey(tqtr("Ctrl+Enter")) ); + doneAndNextAlt = new TQAction( this ); + doneAndNextAlt->setAccel( TQAccel::stringToKey(tqtr("Ctrl+Return")) ); + connect( doneAndNextAlt, TQT_SIGNAL(activated()), this, TQT_SLOT(doneAndNext()) ); + beginFromSourceAct = new Action( translationp, tqtr("&Begin from Source"), + TQT_TQOBJECT(me), TQT_SLOT(beginFromSource()), + TQString(), TQAccel::stringToKey(tqtr("Ctrl+B")) ); + connect( me, TQT_SIGNAL(updateActions(bool)), beginFromSourceAct, + TQT_SLOT(setEnabled(bool)) ); + + // Phrasebook menu + newPhraseBookAct = new Action( phrasep, tqtr("&New Phrase Book..."), + TQT_TQOBJECT(this), TQT_SLOT(newPhraseBook()), + TQString(), TQAccel::stringToKey(tqtr("Ctrl+N")) ); + openPhraseBookAct = new Action( phrasep, tqtr("&Open Phrase Book..."), + TQT_TQOBJECT(this), TQT_SLOT(openPhraseBook()), + "book.png", TQAccel::stringToKey(tqtr("Ctrl+H")) ); + closePhraseBookId = phrasep->insertItem( tqtr("&Close Phrase Book"), + closePhraseBookp ); + phrasep->insertSeparator(); + editPhraseBookId = phrasep->insertItem( tqtr("&Edit Phrase Book..."), + editPhraseBookp ); + printPhraseBookId = phrasep->insertItem( tqtr("&Print Phrase Book..."), + printPhraseBookp ); + connect( phrasep, TQT_SIGNAL(aboutToShow()), this, TQT_SLOT(setupPhrase()) ); + + // Validation menu + acceleratorsAct = new Action( validationp, tqtr("&Accelerators"), + TQT_TQOBJECT(this), TQT_SLOT(revalidate()), "accelerator.png", 0, TRUE ); + acceleratorsAct->setOn( TRUE ); + endingPunctuationAct = new Action( validationp, tqtr("&Ending Punctuation"), + TQT_TQOBJECT(this), TQT_SLOT(revalidate()), "punctuation.png", 0, TRUE ); + endingPunctuationAct->setOn( TRUE ); + phraseMatchesAct = new Action( validationp, tqtr("&Phrase Matches"), + TQT_TQOBJECT(this), TQT_SLOT(revalidate()), "phrase.png", 0, TRUE ); + phraseMatchesAct->setOn( TRUE ); + + // View menu + revertSortingAct = new Action( viewp, tqtr("&Revert Sorting"), + TQT_TQOBJECT(this), TQT_SLOT(revertSorting()) ); + doGuessesAct = new Action( viewp, tqtr("&Display guesses"), + TQT_TQOBJECT(this), TQT_SLOT(toggleGuessing()) ); + doGuessesAct->setToggleAction( TRUE ); + doGuessesAct->setOn( TRUE ); + toggleStats = new Action( viewp, tqtr("&Statistics"), TQT_TQOBJECT(this), TQT_SLOT(toggleStatistics()) ); + toggleStats->setToggleAction( TRUE ); + viewp->insertSeparator(); + viewp->insertItem( tqtr("Vie&ws"), createDockWindowMenu( NoToolBars ) ); + viewp->insertItem( tqtr("&Toolbars"), createDockWindowMenu( OnlyToolBars ) ); + + // Help + manualAct = new Action( helpp, tqtr("&Manual"), TQT_TQOBJECT(this), TQT_SLOT(manual()), 0, + Qt::Key_F1 ); + helpp->insertSeparator(); + aboutAct = new Action( helpp, tqtr("&About"), TQT_TQOBJECT(this), TQT_SLOT(about()) ); + aboutTQtAct = new Action( helpp, tqtr("About &TQt"), TQT_TQOBJECT(this), TQT_SLOT(aboutTQt()) ); + helpp->insertSeparator(); + whatsThisAct = new Action( helpp, tqtr("&What's This?"), + TQT_TQOBJECT(this), TQT_SLOT(whatsThis()), "whatsthis.xpm", Qt::SHIFT + Qt::Key_F1 ); + + openAct->setWhatsThis( tqtr("Open a TQt translation source file (TS file) for" + " editing.") ); + saveAct->setWhatsThis( tqtr("Save changes made to this TQt translation " + "source file.") ); + saveAsAct->setWhatsThis( tqtr("Save changes made to this TQt translation" + "source file into a new file.") ); + releaseAct->setWhatsThis( tqtr("Create a TQt message file suitable for" + " released applications" + " from the current message file.") ); + printAct->setWhatsThis( tqtr("Print a list of all the phrases in the current" + " TQt translation source file.") ); + exitAct->setWhatsThis( tqtr("Close this window and exit.") ); + + undoAct->setWhatsThis( tqtr("Undo the last editing operation performed on the" + " translation.") ); + redoAct->setWhatsThis( tqtr("Redo an undone editing operation performed on" + " the translation.") ); + cutAct->setWhatsThis( tqtr("Copy the selected translation text to the" + " clipboard and deletes it.") ); + copyAct->setWhatsThis( tqtr("Copy the selected translation text to the" + " clipboard.") ); + pasteAct->setWhatsThis( tqtr("Paste the clipboard text into the" + " translation.") ); + selectAllAct->setWhatsThis( tqtr("Select the whole translation text.") ); + tqfindAct->setWhatsThis( tqtr("Search for some text in the translation " + "source file.") ); + tqfindAgainAct->setWhatsThis( tqtr("Continue the search where it was left.") ); +#ifdef notyet + tqreplaceAct->setWhatsThis( tqtr("Search for some text in the translation" + " source file and tqreplace it by another" + " text.") ); +#endif + + newPhraseBookAct->setWhatsThis( tqtr("Create a new phrase book.") ); + openPhraseBookAct->setWhatsThis( tqtr("Open a phrase book to assist" + " translation.") ); + acceleratorsAct->setWhatsThis( tqtr("Toggle validity checks of" + " accelerators.") ); + endingPunctuationAct->setWhatsThis( tqtr("Toggle validity checks" + " of ending punctuation.") ); + phraseMatchesAct->setWhatsThis( tqtr("Toggle checking that phrase" + " suggestions are used.") ); + + revertSortingAct->setWhatsThis( tqtr("Sort the items back in the same order" + " as in the message file.") ); + + doGuessesAct->setWhatsThis( tqtr("Set whether or not to display translation guesses.") ); + manualAct->setWhatsThis( tqtr("Display the manual for %1.") + .arg(tqtr("TQt Linguist")) ); + aboutAct->setWhatsThis( tqtr("Display information about %1.") + .arg(tqtr("TQt Linguist")) ); + aboutTQtAct->setWhatsThis( tqtr("Display information about the TQt toolkit by" + " Trolltech.") ); + whatsThisAct->setWhatsThis( tqtr("Enter What's This? mode.") ); + + beginFromSourceAct->setWhatsThis( tqtr("Copies the source text into" + " the translation field.") ); + nextAct->setWhatsThis( tqtr("Moves to the next item.") ); + prevAct->setWhatsThis( tqtr("Moves to the previous item.") ); + nextUnfinishedAct->setWhatsThis( tqtr("Moves to the next unfinished item.") ); + prevUnfinishedAct->setWhatsThis( tqtr("Moves to the previous unfinished item.") ); + doneAndNextAct->setWhatsThis( tqtr("Marks this item as done and moves to the" + " next unfinished item.") ); + doneAndNextAlt->setWhatsThis( doneAndNextAct->whatsThis() ); +} + +void TrWindow::setupToolBars() +{ + TQToolBar *filet = new TQToolBar( tqtr("File"), this ); + TQToolBar *editt = new TQToolBar( tqtr("Edit"), this ); + TQToolBar *translationst = new TQToolBar( tqtr("Translation"), this ); + TQToolBar *validationt = new TQToolBar( tqtr("Validation"), this ); + TQToolBar *helpt = new TQToolBar( tqtr("Help"), this ); + + openAct->addToToolbar( filet, tqtr("Open") ); + saveAct->addToToolbar( filet, tqtr("Save") ); + printAct->addToToolbar( filet, tqtr("Print") ); + filet->addSeparator(); + openPhraseBookAct->addToToolbar( filet, tqtr("Open Phrase Book") ); + + undoAct->addToToolbar( editt, tqtr("Undo") ); + redoAct->addToToolbar( editt, tqtr("Redo") ); + editt->addSeparator(); + cutAct->addToToolbar( editt, tqtr("Cut") ); + copyAct->addToToolbar( editt, tqtr("Copy") ); + pasteAct->addToToolbar( editt, tqtr("Paste") ); + editt->addSeparator(); + tqfindAct->addToToolbar( editt, tqtr("Find") ); +#ifdef notyet + tqreplaceAct->addToToolbar( editt, tqtr("Replace") ); +#endif + + // beginFromSourceAct->addToToolbar( translationst, + // tqtr("Begin from Source"), "searchtqfind" ); + prevAct->addToToolbar( translationst, tqtr("Prev") ); + nextAct->addToToolbar( translationst, tqtr("Next") ); + prevUnfinishedAct->addToToolbar( translationst, tqtr("Prev Unfinished") ); + nextUnfinishedAct->addToToolbar( translationst, tqtr("Next Unfinished") ); + doneAndNextAct->addToToolbar( translationst, tqtr("Done and Next") ); + + acceleratorsAct->addToToolbar( validationt, tqtr("Accelerators") ); + endingPunctuationAct->addToToolbar( validationt, tqtr("Punctuation") ); + phraseMatchesAct->addToToolbar( validationt, tqtr("Phrases") ); + + whatsThisAct->addToToolbar( helpt, tqtr("What's This?") ); +} + +void TrWindow::setCurrentContextItem( TQListViewItem *item ) +{ + lv->ensureItemVisible( item ); + lv->setSelected( item, TRUE ); +} + +void TrWindow::setCurrentMessageItem( TQListViewItem *item ) +{ + slv->ensureItemVisible( item ); + slv->setSelected( item, TRUE ); +} + +TQString TrWindow::friendlyPhraseBookName( int k ) +{ + return TQFileInfo( phraseBookNames[k] ).fileName(); +} + +bool TrWindow::openPhraseBook( const TQString& name ) +{ + PhraseBook *pb = new PhraseBook; + if ( !pb->load(name) ) { + TQMessageBox::warning( this, tqtr("TQt Linguist"), + tqtr("Cannot read from phrase book '%1'.") + .arg(name) ); + return FALSE; + } + + int index = (int) phraseBooks.count(); + phraseBooks.append( pb ); + phraseBookNames.append( name ); + int id = closePhraseBookp->insertItem( friendlyPhraseBookName(index) ); + closePhraseBookp->TQMenuData::setWhatsThis( id, tqtr("Close this phrase book.") ); + id = editPhraseBookp->insertItem( friendlyPhraseBookName(index) ); + editPhraseBookp->TQMenuData::setWhatsThis( id, tqtr("Allow you to add, modify, or delete" + " phrases of this phrase book.") ); + id = printPhraseBookp->insertItem( friendlyPhraseBookName(index) ); + printPhraseBookp->TQMenuData::setWhatsThis( id, tqtr("Print the entries of the phrase" + " book.") ); + updatePhraseDict(); + return TRUE; +} + +bool TrWindow::savePhraseBook( TQString& name, const PhraseBook& pb ) +{ + if ( !name.tqcontains( ".qph" ) && !name.tqcontains(".") ) + name += ".qph"; + + if ( !pb.save(name) ) { + TQMessageBox::warning( this, tqtr("TQt Linguist"), + tqtr("Cannot create phrase book '%1'.") + .arg(name) ); + return FALSE; + } + return TRUE; +} + +void TrWindow::updateProgress() +{ + if ( numNonobsolete == 0 ) + progress->setText( TQString(" " " ") ); + else + progress->setText( TQString(" %1/%2 ").arg(numFinished) + .arg(numNonobsolete) ); + prevUnfinishedAct->setEnabled( numFinished != numNonobsolete ); + nextUnfinishedAct->setEnabled( numFinished != numNonobsolete ); + prevAct->setEnabled( lv->firstChild() != 0 ); + nextAct->setEnabled( lv->firstChild() != 0 ); +} + +void TrWindow::updatePhraseDict() +{ + TQPtrListIterator<PhraseBook> pb = phraseBooks; + PhraseBook::Iterator p; + PhraseBook *ent; + phraseDict.clear(); + while ( pb.current() != 0 ) { + for ( p = (*pb)->begin(); p != (*pb)->end(); ++p ) { + TQString f = friendlyString( (*p).source() ); + if ( f.length() > 0 ) { + f = TQStringList::split( TQChar(' '), f ).first(); + ent = phraseDict.tqfind( f ); + if ( ent == 0 ) { + ent = new PhraseBook; + phraseDict.insert( f, ent ); + } + ent->append( *p ); + } + } + ++pb; + } + revalidate(); +} + +PhraseBook TrWindow::getPhrases( const TQString& source ) +{ + PhraseBook phrases; + TQString f = friendlyString( source ); + TQStringList lookupWords = TQStringList::split( TQChar(' '), f ); + TQStringList::Iterator w; + PhraseBook::Iterator p; + + for ( w = lookupWords.begin(); w != lookupWords.end(); ++w ) { + PhraseBook *ent = phraseDict.tqfind( *w ); + if ( ent != 0 ) { + for ( p = ent->begin(); p != ent->end(); ++p ) { + if ( f.tqfind(friendlyString((*p).source())) >= 0 ) + phrases.append( *p ); + } + } + } + return phrases; +} + +bool TrWindow::danger( const TQString& source, const TQString& translation, + bool verbose ) +{ + if ( acceleratorsAct->isOn() ) { + int sk = TQAccel::shortcutKey( source ); + int tk = TQAccel::shortcutKey( translation ); + if ( sk == 0 && tk != 0 ) { + if ( verbose ) + statusBar()->message( tqtr("Accelerator possibly superfluous in" + " translation."), ErrorMS ); + return TRUE; + } else if ( sk != 0 && tk == 0 ) { + if ( verbose ) + statusBar()->message( tqtr("Accelerator possibly missing in" + " translation."), ErrorMS ); + return TRUE; + } + } + if ( endingPunctuationAct->isOn() ) { + if ( ending(source) != ending(translation) ) { + if ( verbose ) + statusBar()->message( tqtr("Translation does not end with the" + " same punctuation as the source" + " text."), ErrorMS ); + return TRUE; + } + } + if ( phraseMatchesAct->isOn() ) { + TQString fsource = friendlyString( source ); + TQString ftranslation = friendlyString( translation ); + TQStringList lookupWords = TQStringList::split( TQChar(' '), fsource ); + TQStringList::Iterator w; + PhraseBook::Iterator p; + + for ( w = lookupWords.begin(); w != lookupWords.end(); ++w ) { + PhraseBook *ent = phraseDict.tqfind( *w ); + if ( ent != 0 ) { + for ( p = ent->begin(); p != ent->end(); ++p ) { + if ( fsource.tqfind(friendlyString((*p).source())) < 0 || + ftranslation.tqfind(friendlyString((*p).target())) >= 0 ) + break; + } + if ( p == ent->end() ) { + if ( verbose ) + statusBar()->message( tqtr("A phrase book suggestion for" + " '%1' was ignored.") + .arg(*w), ErrorMS ); + return TRUE; + } + } + } + } + if ( verbose ) + statusBar()->clear(); + + return FALSE; +} + +void TrWindow::readConfig() +{ + TQString keybase( "/TQt Linguist/" + + TQString::number( (TQT_VERSION >> 16) & 0xff ) + + "." + TQString::number( (TQT_VERSION >> 8) & 0xff ) + "/" ); + TQSettings config; + + config.insertSearchPath( TQSettings::Windows, "/Trolltech" ); + + TQRect r( pos(), size() ); + recentFiles = config.readListEntry( keybase + "RecentlyOpenedFiles" ); + if ( !config.readBoolEntry( keybase + "Geometry/MainwindowMaximized", FALSE ) ) { + r.setX( config.readNumEntry( keybase + "Geometry/MainwindowX", r.x() ) ); + r.setY( config.readNumEntry( keybase + "Geometry/MainwindowY", r.y() ) ); + r.setWidth( config.readNumEntry( keybase + "Geometry/MainwindowWidth", r.width() ) ); + r.setHeight( config.readNumEntry( keybase + "Geometry/MainwindowHeight", r.height() ) ); + + TQRect desk = TQApplication::desktop()->tqgeometry(); + TQRect inter = desk.intersect( r ); + resize( r.size() ); + if ( inter.width() * inter.height() > ( r.width() * r.height() / 20 ) ) { + move( r.topLeft() ); + } + } + + TQDockWindow * dw; + dw = (TQDockWindow *) lv->tqparent(); + int place; + place = config.readNumEntry( keybase + "Geometry/ContextwindowInTQt::Dock" ); + r.setX( config.readNumEntry( keybase + "Geometry/ContextwindowX" ) ); + r.setY( config.readNumEntry( keybase + "Geometry/ContextwindowY" ) ); + r.setWidth( config.readNumEntry( keybase + + "Geometry/ContextwindowWidth" ) ); + r.setHeight( config.readNumEntry( keybase + + "Geometry/ContextwindowHeight" ) ); + if ( place == TQDockWindow::OutsideDock ) { + dw->undock(); + dw->show(); + } + dw->setGeometry( r ); + + dw = (TQDockWindow *) slv->tqparent(); + place = config.readNumEntry( keybase + "Geometry/SourcewindowInTQt::Dock" ); + r.setX( config.readNumEntry( keybase + "Geometry/SourcewindowX" ) ); + r.setY( config.readNumEntry( keybase + "Geometry/SourcewindowY" ) ); + r.setWidth( config.readNumEntry( keybase + + "Geometry/SourcewindowWidth" ) ); + r.setHeight( config.readNumEntry( keybase + + "Geometry/SourcewindowHeight" ) ); + if ( place == TQDockWindow::OutsideDock ) { + dw->undock(); + dw->show(); + } + dw->setGeometry( r ); + + dw = (TQDockWindow *) plv->tqparent()->tqparent(); + place = config.readNumEntry( keybase + "Geometry/PhrasewindowInTQt::Dock" ); + r.setX( config.readNumEntry( keybase + "Geometry/PhrasewindowX" ) ); + r.setY( config.readNumEntry( keybase + "Geometry/PhrasewindowY" ) ); + r.setWidth( config.readNumEntry( keybase + + "Geometry/PhrasewindowWidth" ) ); + r.setHeight( config.readNumEntry( keybase + + "Geometry/PhrasewindowHeight" ) ); + if ( place == TQDockWindow::OutsideDock ) { + dw->undock(); + dw->show(); + } + dw->setGeometry( r ); + TQApplication::sendPostedEvents(); +} + +void TrWindow::writeConfig() +{ + TQString keybase( "/TQt Linguist/" + + TQString::number( (TQT_VERSION >> 16) & 0xff ) + + "." + TQString::number( (TQT_VERSION >> 8) & 0xff ) + "/" ); + TQSettings config; + + config.insertSearchPath( TQSettings::Windows, "/Trolltech" ); + config.writeEntry( keybase + "RecentlyOpenedFiles", recentFiles ); + config.writeEntry( keybase + "Geometry/MainwindowMaximized", isMaximized() ); + config.writeEntry( keybase + "Geometry/MainwindowX", x() ); + config.writeEntry( keybase + "Geometry/MainwindowY", y() ); + config.writeEntry( keybase + "Geometry/MainwindowWidth", width() ); + config.writeEntry( keybase + "Geometry/MainwindowHeight", height() ); + + TQDockWindow * dw =(TQDockWindow *) lv->tqparent(); + config.writeEntry( keybase + "Geometry/ContextwindowInTQt::Dock", dw->place() ); + config.writeEntry( keybase + "Geometry/ContextwindowX", dw->x() ); + config.writeEntry( keybase + "Geometry/ContextwindowY", dw->y() ); + config.writeEntry( keybase + "Geometry/ContextwindowWidth", dw->width() ); + config.writeEntry( keybase + "Geometry/ContextwindowHeight", dw->height() ); + + dw =(TQDockWindow *) slv->tqparent(); + config.writeEntry( keybase + "Geometry/SourcewindowInTQt::Dock", + dw->place() ); + config.writeEntry( keybase + "Geometry/SourcewindowX", dw->tqgeometry().x() ); + config.writeEntry( keybase + "Geometry/SourcewindowY", dw->tqgeometry().y() ); + config.writeEntry( keybase + "Geometry/SourcewindowWidth", dw->width() ); + config.writeEntry( keybase + "Geometry/SourcewindowHeight", dw->height() ); + + dw =(TQDockWindow *) plv->tqparent()->tqparent(); + config.writeEntry( keybase + "Geometry/PhrasewindowInTQt::Dock", + dw->place() ); + config.writeEntry( keybase + "Geometry/PhrasewindowX", dw->tqgeometry().x() ); + config.writeEntry( keybase + "Geometry/PhrasewindowY", dw->tqgeometry().y() ); + config.writeEntry( keybase + "Geometry/PhrasewindowWidth", dw->width() ); + config.writeEntry( keybase + "Geometry/PhrasewindowHeight", dw->height() ); +} + +void TrWindow::setupRecentFilesMenu() +{ + recentFilesMenu->clear(); + int id = 0; + TQStringList::Iterator it = recentFiles.begin(); + for ( ; it != recentFiles.end(); ++it ) + { + recentFilesMenu->insertItem( *it, id ); + id++; + } +} + +void TrWindow::recentFileActivated( int id ) +{ + if ( id != -1 ) { + if ( maybeSave() ) + openFile( *recentFiles.at( id ) ); + } +} + +void TrWindow::addRecentlyOpenedFile( const TQString &fn, TQStringList &lst ) +{ + if ( lst.tqfind( fn ) != lst.end() ) + return; + if ( lst.count() >= 10 ) + lst.remove( lst.begin() ); + lst << fn; +} + +void TrWindow::toggleGuessing() +{ + me->toggleGuessing(); +} + +void TrWindow::focusSourceList() +{ + slv->setFocus(); +} + +void TrWindow::focusPhraseList() +{ + plv->setFocus(); +} + +void TrWindow::updateClosePhraseBook() +{ + if ( dirtyItem != -1 ) { + closePhraseBookp->removeItem( closePhraseBookp->idAt(dirtyItem) ); + dirtyItem = -1; + } +} + +void TrWindow::toggleStatistics() +{ + if ( toggleStats->isOn() ) { + if ( !stats ) { + stats = new Statistics( this, "linguist_stats" ); + connect( this, TQT_SIGNAL(statsChanged(int,int,int,int,int,int)), stats, + TQT_SLOT(updateStats(int,int,int,int,int,int)) ); + connect( stats, TQT_SIGNAL(closed()), toggleStats, TQT_SLOT(toggle()) ); + } + updateStatistics(); + stats->show(); + } else if ( stats ) { + stats->close(); + } +} + +void TrWindow::updateStatistics() +{ + TQListViewItem * ci = lv->firstChild(); + int trW = 0; + int trC = 0; + int trCS = 0; + while ( ci ) { + countStats( ci, ((ContextLVI *)ci)->firstMessageItem(), trW, trC, trCS ); + ci = ci->nextSibling(); + } + // ..and the items in the source list + countStats( 0, slv->firstChild(), trW, trC, trCS ); + emit statsChanged( srcWords, srcChars, srcCharsSpc, trW, trC, trCS ); +} + + +void TrWindow::countStats( TQListViewItem* ci, TQListViewItem* mi, int& trW, int& trC, int& trCS ) +{ + MessageLVI * m; + while ( mi ) { + m = (MessageLVI *) mi; + if ( m->finished() && !(m->message().type() == MetaTranslatorMessage::Obsolete) ) + doCharCounting( m->translation(), trW, trC, trCS ); + if ( ci ) + mi = ((ContextLVI *)ci)->nextMessageItem(); + else + mi = mi->nextSibling(); + } +} + +void TrWindow::doCharCounting( const TQString& text, int& trW, int& trC, int& trCS ) +{ + trCS += text.length(); + bool inWord = FALSE; + for ( int i = 0; i < (int) text.length(); i++ ) { + if ( text[i].isLetterOrNumber() || text[i] == TQChar('_') ) { + if ( !inWord ) { + trW++; + inWord = TRUE; + } + } else { + inWord = FALSE; + } + if ( !text[i].isSpace() ) + trC++; + } +} diff --git a/experimental/tqtinterface/qt4/tools/linguist/linguist/trwindow.h b/experimental/tqtinterface/qt4/tools/linguist/linguist/trwindow.h new file mode 100644 index 000000000..3e695345c --- /dev/null +++ b/experimental/tqtinterface/qt4/tools/linguist/linguist/trwindow.h @@ -0,0 +1,238 @@ +/********************************************************************** +** Copyright (C) 2000-2008 Trolltech ASA. All rights reserved. +** +** This file is part of TQt Linguist. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing requirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at sales@trolltech.com. +** +** Licensees holding valid TQt Commercial licenses may use this file in +** accordance with the TQt Commercial License Agreement provided with +** the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef TRWINDOW_H +#define TRWINDOW_H + +#include "phrase.h" + +#include <metatranslator.h> + +#include <tqmainwindow.h> +#include <tqptrlist.h> +#include <tqdict.h> +#include <tqprinter.h> +#include <tqstringlist.h> +#include <tqpixmap.h> +#include <tqlistview.h> + +class TQAction; +class TQDialog; +class TQLabel; +class TQListView; +class TQListViewItem; +class TQPrinter; + +class Action; +class FindDialog; +class MessageEditor; + +class PhraseLV; +class ContextLVI; +class Statistics; + +class TrWindow : public TQMainWindow +{ + Q_OBJECT + TQ_OBJECT +public: + static TQPixmap * pxOn; + static TQPixmap * pxOff; + static TQPixmap * pxObsolete; + static TQPixmap * pxDanger; + static const TQPixmap pageCurl(); + + TrWindow(); + ~TrWindow(); + + void openFile( const TQString& name ); + +protected: + void readConfig(); + void writeConfig(); + void closeEvent( TQCloseEvent * ); + +Q_SIGNALS: + void statsChanged( int w, int c, int cs, int w2, int c2, int cs2 ); + +private Q_SLOTS: + void doneAndNext(); + void prev(); + void next(); + void recentFileActivated( int ); + void setupRecentFilesMenu(); + void open(); + void save(); + void saveAs(); + void release(); + void print(); + void tqfind(); + void tqfindAgain(); + void tqreplace(); + void newPhraseBook(); + void openPhraseBook(); + void closePhraseBook( int id ); + void editPhraseBook( int id ); + void printPhraseBook( int id ); + void manual(); + void revertSorting(); + void about(); + void aboutTQt(); + + void setupPhrase(); + bool maybeSave(); + void updateCaption(); + void showNewScope( TQListViewItem *item ); + void showNewCurrent( TQListViewItem *item ); + void updateTranslation( const TQString& translation ); + void updateFinished( bool finished ); + void toggleFinished( TQListViewItem *item, const TQPoint& p, int column ); + void prevUnfinished(); + void nextUnfinished(); + void tqfindNext( const TQString& text, int where, bool matchCase ); + void revalidate(); + void toggleGuessing(); + void focusSourceList(); + void focusPhraseList(); + void updateClosePhraseBook(); + void toggleStatistics(); + void updateStatistics(); + +private: + typedef TQPtrList<PhraseBook> PBL; + typedef TQDict<PhraseBook> PBD; + + static TQString friendlyString( const TQString& str ); + + void addRecentlyOpenedFile( const TQString & fn, TQStringList & lst ); + void setupMenuBar(); + void setupToolBars(); + void setCurrentContextItem( TQListViewItem *item ); + void setCurrentMessageItem( TQListViewItem *item ); + TQString friendlyPhraseBookName( int k ); + bool openPhraseBook( const TQString& name ); + bool savePhraseBook( TQString& name, const PhraseBook& pb ); + void updateProgress(); + void updatePhraseDict(); + PhraseBook getPhrases( const TQString& source ); + bool danger( const TQString& source, const TQString& translation, + bool verbose = FALSE ); + + int itemToIndex( TQListView * view, TQListViewItem * item ); + TQListViewItem * indexToItem( TQListView * view, int index ); + bool searchItem( const TQString & searchWhat, TQListViewItem * j, + TQListViewItem * k ); + void countStats( TQListViewItem * ci, TQListViewItem * mi, int& trW, int& trC, int& trCS ); + void doCharCounting( const TQString& text, int& trW, int& trC, int& trCS ); + + TQListView * plv; + TQListView * lv; + TQListView * slv; + MessageEditor * me; + TQLabel * progress; + TQLabel * modified; + MetaTranslator tor; + bool dirty; + bool messageIsShown; + int numFinished; + int numNonobsolete; + int numMessages; + int dirtyItem; + TQStringList recentFiles; + TQString filename; + + PBD phraseDict; + PBL phraseBooks; + TQStringList phraseBookNames; + + TQPrinter printer; + + FindDialog *f; + FindDialog *h; + TQString tqfindText; + int tqfindWhere; + bool tqfindMatchCase; + int foundItem; + TQListViewItem *foundScope; + int foundWhere; + int foundOffset; + + TQPopupMenu * phrasep; + TQPopupMenu * closePhraseBookp; + TQPopupMenu * editPhraseBookp; + TQPopupMenu * printPhraseBookp; + TQPopupMenu * recentFilesMenu; + int closePhraseBookId; + int editPhraseBookId; + int printPhraseBookId; + Action *openAct; + Action *saveAct; + Action *saveAsAct; + Action *releaseAct; + Action *printAct; + Action *exitAct; + Action *undoAct; + Action *redoAct; + Action *cutAct; + Action *copyAct; + Action *pasteAct; + Action *selectAllAct; + Action *tqfindAct; + Action *tqfindAgainAct; + Action *tqreplaceAct; + Action *newPhraseBookAct; + Action *openPhraseBookAct; + Action *acceleratorsAct; + Action *endingPunctuationAct; + Action *phraseMatchesAct; + Action *revertSortingAct; + Action *aboutAct; + Action *aboutTQtAct; + Action *manualAct; + Action *whatsThisAct; + Action *beginFromSourceAct; + Action *prevAct; + Action *nextAct; + Action *prevUnfinishedAct; + Action *nextUnfinishedAct; + Action *doneAndNextAct; + TQAction *doneAndNextAlt; + Action *doGuessesAct; + Action *toggleStats; + Statistics * stats; + int srcWords; + int srcChars; + int srcCharsSpc; +}; + +#endif |