diff options
Diffstat (limited to 'tqtinterface/qt4/tools/linguist/linguist/finddialog.cpp')
-rw-r--r-- | tqtinterface/qt4/tools/linguist/linguist/finddialog.cpp | 183 |
1 files changed, 183 insertions, 0 deletions
diff --git a/tqtinterface/qt4/tools/linguist/linguist/finddialog.cpp b/tqtinterface/qt4/tools/linguist/linguist/finddialog.cpp new file mode 100644 index 0000000..6dc876c --- /dev/null +++ b/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 ); +} |