00001 #include <kdialog.h>
00002 #include <klocale.h>
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "replacedlg.h"
00013
00014 #include <qvariant.h>
00015 #include <kdialog.h>
00016 #include <qpushbutton.h>
00017 #include <qgroupbox.h>
00018 #include <qcheckbox.h>
00019 #include <qbuttongroup.h>
00020 #include <qradiobutton.h>
00021 #include <kcombobox.h>
00022 #include <kurlrequester.h>
00023 #include <qlabel.h>
00024 #include <qlayout.h>
00025 #include <qtooltip.h>
00026 #include <qwhatsthis.h>
00027
00028
00029
00030
00031
00032
00033
00034
00035 ReplaceDlg::ReplaceDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
00036 : QDialog( parent, name, modal, fl )
00037 {
00038 if ( !name )
00039 setName( "ReplaceDlg" );
00040 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth() ) );
00041 setMaximumSize( QSize( 32767, 32767 ) );
00042 ReplaceDlgLayout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "ReplaceDlgLayout");
00043
00044 groupBox2 = new QGroupBox( this, "groupBox2" );
00045 groupBox2->setColumnLayout(0, Qt::Vertical );
00046 groupBox2->layout()->setSpacing( KDialog::spacingHint() );
00047 groupBox2->layout()->setMargin( KDialog::marginHint() );
00048 groupBox2Layout = new QVBoxLayout( groupBox2->layout() );
00049 groupBox2Layout->setAlignment( Qt::AlignTop );
00050
00051 case_box = new QCheckBox( groupBox2, "case_box" );
00052 case_box->setChecked( TRUE );
00053 groupBox2Layout->addWidget( case_box );
00054
00055 buttonGroup2 = new QButtonGroup( groupBox2, "buttonGroup2" );
00056 buttonGroup2->setFrameShape( QButtonGroup::NoFrame );
00057 buttonGroup2->setColumnLayout(0, Qt::Vertical );
00058 buttonGroup2->layout()->setSpacing( KDialog::spacingHint() );
00059 buttonGroup2->layout()->setMargin( 0 );
00060 buttonGroup2Layout = new QVBoxLayout( buttonGroup2->layout() );
00061 buttonGroup2Layout->setAlignment( Qt::AlignTop );
00062
00063 strings_all_radio = new QRadioButton( buttonGroup2, "strings_all_radio" );
00064 strings_all_radio->setChecked( TRUE );
00065 buttonGroup2Layout->addWidget( strings_all_radio );
00066
00067 strings_wholewords_radio = new QRadioButton( buttonGroup2, "strings_wholewords_radio" );
00068 buttonGroup2Layout->addWidget( strings_wholewords_radio );
00069
00070 layout3 = new QHBoxLayout( 0, 0, KDialog::spacingHint(), "layout3");
00071
00072 strings_regexp_radio = new QRadioButton( buttonGroup2, "strings_regexp_radio" );
00073 layout3->addWidget( strings_regexp_radio );
00074
00075 regexp_button = new QPushButton( buttonGroup2, "regexp_button" );
00076 regexp_button->setEnabled( FALSE );
00077 layout3->addWidget( regexp_button );
00078 buttonGroup2Layout->addLayout( layout3 );
00079 groupBox2Layout->addWidget( buttonGroup2 );
00080
00081 regexp_combo = new KHistoryCombo( groupBox2, "regexp_combo" );
00082 regexp_combo->setEnabled( FALSE );
00083 groupBox2Layout->addWidget( regexp_combo );
00084
00085 ReplaceDlgLayout->addWidget( groupBox2, 1, 0 );
00086
00087 buttonGroup1 = new QButtonGroup( this, "buttonGroup1" );
00088 buttonGroup1->setColumnLayout(0, Qt::Vertical );
00089 buttonGroup1->layout()->setSpacing( KDialog::spacingHint() );
00090 buttonGroup1->layout()->setMargin( KDialog::marginHint() );
00091 buttonGroup1Layout = new QVBoxLayout( buttonGroup1->layout() );
00092 buttonGroup1Layout->setAlignment( Qt::AlignTop );
00093
00094 files_all_radio = new QRadioButton( buttonGroup1, "files_all_radio" );
00095 files_all_radio->setChecked( TRUE );
00096 buttonGroup1Layout->addWidget( files_all_radio );
00097
00098 files_open_radio = new QRadioButton( buttonGroup1, "files_open_radio" );
00099 buttonGroup1Layout->addWidget( files_open_radio );
00100
00101 files_path_radio = new QRadioButton( buttonGroup1, "files_path_radio" );
00102 buttonGroup1Layout->addWidget( files_path_radio );
00103
00104 path_urlreq = new KURLRequester( buttonGroup1, "path_urlreq" );
00105 path_urlreq->setEnabled( FALSE );
00106 buttonGroup1Layout->addWidget( path_urlreq );
00107
00108 ReplaceDlgLayout->addWidget( buttonGroup1, 2, 0 );
00109
00110 layout4 = new QHBoxLayout( 0, 0, KDialog::spacingHint(), "layout4");
00111
00112 expression_varning_label = new QLabel( this, "expression_varning_label" );
00113 QFont expression_varning_label_font( expression_varning_label->font() );
00114 expression_varning_label_font.setBold( TRUE );
00115 expression_varning_label->setFont( expression_varning_label_font );
00116 layout4->addWidget( expression_varning_label );
00117 spacer1 = new QSpacerItem( 40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00118 layout4->addItem( spacer1 );
00119
00120 find_button = new QPushButton( this, "find_button" );
00121 find_button->setDefault( TRUE );
00122 layout4->addWidget( find_button );
00123
00124 cancel_button = new QPushButton( this, "cancel_button" );
00125 layout4->addWidget( cancel_button );
00126
00127 ReplaceDlgLayout->addLayout( layout4, 3, 0 );
00128
00129 groupBox1 = new QGroupBox( this, "groupBox1" );
00130 groupBox1->setColumnLayout(0, Qt::Vertical );
00131 groupBox1->layout()->setSpacing( KDialog::spacingHint() );
00132 groupBox1->layout()->setMargin( KDialog::marginHint() );
00133 groupBox1Layout = new QGridLayout( groupBox1->layout() );
00134 groupBox1Layout->setAlignment( Qt::AlignTop );
00135
00136 textLabel1 = new QLabel( groupBox1, "textLabel1" );
00137
00138 groupBox1Layout->addWidget( textLabel1, 0, 0 );
00139
00140 find_combo = new KHistoryCombo( groupBox1, "find_combo" );
00141
00142 groupBox1Layout->addWidget( find_combo, 1, 0 );
00143
00144 textLabel2 = new QLabel( groupBox1, "textLabel2" );
00145
00146 groupBox1Layout->addWidget( textLabel2, 2, 0 );
00147
00148 replacement_combo = new KHistoryCombo( groupBox1, "replacement_combo" );
00149
00150 groupBox1Layout->addWidget( replacement_combo, 3, 0 );
00151
00152 ReplaceDlgLayout->addWidget( groupBox1, 0, 0 );
00153 languageChange();
00154 resize( QSize(428, 487).expandedTo(minimumSizeHint()) );
00155 clearWState( WState_Polished );
00156
00157
00158 connect( cancel_button, SIGNAL( clicked() ), this, SLOT( reject() ) );
00159 connect( find_button, SIGNAL( clicked() ), this, SLOT( accept() ) );
00160 connect( strings_regexp_radio, SIGNAL( toggled(bool) ), regexp_button, SLOT( setEnabled(bool) ) );
00161 connect( files_path_radio, SIGNAL( toggled(bool) ), path_urlreq, SLOT( setEnabled(bool) ) );
00162 connect( strings_regexp_radio, SIGNAL( toggled(bool) ), find_combo, SLOT( setDisabled(bool) ) );
00163 connect( strings_regexp_radio, SIGNAL( toggled(bool) ), regexp_combo, SLOT( setEnabled(bool) ) );
00164
00165
00166 setTabOrder( find_combo, replacement_combo );
00167 setTabOrder( replacement_combo, case_box );
00168 setTabOrder( case_box, strings_all_radio );
00169 setTabOrder( strings_all_radio, strings_regexp_radio );
00170 setTabOrder( strings_regexp_radio, regexp_button );
00171 setTabOrder( regexp_button, regexp_combo );
00172 setTabOrder( regexp_combo, files_all_radio );
00173 setTabOrder( files_all_radio, path_urlreq );
00174 setTabOrder( path_urlreq, find_button );
00175 setTabOrder( find_button, cancel_button );
00176 setTabOrder( cancel_button, strings_wholewords_radio );
00177 setTabOrder( strings_wholewords_radio, files_path_radio );
00178
00179
00180 textLabel1->setBuddy( find_combo );
00181 textLabel2->setBuddy( replacement_combo );
00182 }
00183
00184
00185
00186
00187 ReplaceDlg::~ReplaceDlg()
00188 {
00189
00190 }
00191
00192
00193
00194
00195
00196 void ReplaceDlg::languageChange()
00197 {
00198 setCaption( tr2i18n( "Project Wide String Replacement" ) );
00199 groupBox2->setTitle( tr2i18n( "Options" ) );
00200 case_box->setText( tr2i18n( "C&ase sensitive" ) );
00201 buttonGroup2->setTitle( QString::null );
00202 strings_all_radio->setText( tr2i18n( "All s&ubstrings" ) );
00203 strings_wholewords_radio->setText( tr2i18n( "&Whole words only" ) );
00204 strings_regexp_radio->setText( tr2i18n( "Regular e&xpression:" ) );
00205 QToolTip::add( strings_regexp_radio, tr2i18n( "Use regexp to specify target" ) );
00206 regexp_button->setText( tr2i18n( "&Edit" ) );
00207 QToolTip::add( regexp_button, tr2i18n( "Opens the regexp editor. Only enabled if installed." ) );
00208 QToolTip::add( regexp_combo, tr2i18n( "Enter the regexp here" ) );
00209 buttonGroup1->setTitle( tr2i18n( "Target Files in Project" ) );
00210 files_all_radio->setText( tr2i18n( "A&ll files" ) );
00211 QToolTip::add( files_all_radio, tr2i18n( "All files in the project will be considered." ) );
00212 files_open_radio->setText( tr2i18n( "&Open files only" ) );
00213 QToolTip::add( files_open_radio, tr2i18n( "Only open project files will be considered." ) );
00214 files_path_radio->setText( tr2i18n( "Files under &path:" ) );
00215 QToolTip::add( files_path_radio, tr2i18n( "Only project files in this dir and its subdirs will be considered." ) );
00216 expression_varning_label->setText( tr2i18n( "Expression is invalid." ) );
00217 find_button->setText( tr2i18n( "&Find && Replace" ) );
00218 QToolTip::add( find_button, tr2i18n( "Start looking for possible replacement targets." ) );
00219 cancel_button->setText( tr2i18n( "&Cancel" ) );
00220 groupBox1->setTitle( tr2i18n( "Strings" ) );
00221 textLabel1->setText( tr2i18n( "&Text to find:" ) );
00222 QToolTip::add( find_combo, tr2i18n( "Target string" ) );
00223 textLabel2->setText( tr2i18n( "&Replacement text:" ) );
00224 QToolTip::add( replacement_combo, tr2i18n( "The replacement string" ) );
00225 }
00226
00227 #include "replacedlg.moc"