00001 #include <kdialog.h>
00002 #include <klocale.h>
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "regexptestdlgbase.h"
00013
00014 #include <qvariant.h>
00015 #include <kdialog.h>
00016 #include <qpushbutton.h>
00017 #include <qlabel.h>
00018 #include <qlineedit.h>
00019 #include <qbuttongroup.h>
00020 #include <qradiobutton.h>
00021 #include <qheader.h>
00022 #include <qlistview.h>
00023 #include <qlayout.h>
00024 #include <qtooltip.h>
00025 #include <qwhatsthis.h>
00026
00027
00028
00029
00030
00031
00032
00033
00034 RegexpTestDialogBase::RegexpTestDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl )
00035 : QDialog( parent, name, modal, fl )
00036 {
00037 if ( !name )
00038 setName( "regexp_test_dialog" );
00039 setSizeGripEnabled( FALSE );
00040 regexp_test_dialogLayout = new QGridLayout( this, 1, 1, KDialog::marginHint(), KDialog::spacingHint(), "regexp_test_dialogLayout");
00041
00042 pattern_label = new QLabel( this, "pattern_label" );
00043
00044 regexp_test_dialogLayout->addWidget( pattern_label, 0, 0 );
00045
00046 teststring_label = new QLabel( this, "teststring_label" );
00047
00048 regexp_test_dialogLayout->addWidget( teststring_label, 2, 0 );
00049
00050 teststring_edit = new QLineEdit( this, "teststring_edit" );
00051
00052 regexp_test_dialogLayout->addMultiCellWidget( teststring_edit, 2, 2, 1, 2 );
00053
00054 success_label = new QLabel( this, "success_label" );
00055 success_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, 0, 0, success_label->sizePolicy().hasHeightForWidth() ) );
00056
00057 regexp_test_dialogLayout->addMultiCellWidget( success_label, 3, 3, 1, 2 );
00058
00059 Layout4 = new QHBoxLayout( 0, 0, KDialog::spacingHint(), "Layout4");
00060
00061 insertbutton = new QPushButton( this, "insertbutton" );
00062 insertbutton->setDefault( TRUE );
00063 Layout4->addWidget( insertbutton );
00064 Horizontal_Spacing2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00065 Layout4->addItem( Horizontal_Spacing2 );
00066
00067 cancelbutton = new QPushButton( this, "cancelbutton" );
00068 cancelbutton->setAutoDefault( TRUE );
00069 Layout4->addWidget( cancelbutton );
00070
00071 regexp_test_dialogLayout->addMultiCellLayout( Layout4, 5, 5, 0, 2 );
00072
00073 pattern_edit = new QLineEdit( this, "pattern_edit" );
00074
00075 regexp_test_dialogLayout->addWidget( pattern_edit, 0, 1 );
00076
00077 flavor_group = new QButtonGroup( this, "flavor_group" );
00078 flavor_group->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)4, 0, 0, flavor_group->sizePolicy().hasHeightForWidth() ) );
00079 flavor_group->setColumnLayout(0, Qt::Vertical );
00080 flavor_group->layout()->setSpacing( KDialog::spacingHint() );
00081 flavor_group->layout()->setMargin( KDialog::marginHint() );
00082 flavor_groupLayout = new QVBoxLayout( flavor_group->layout() );
00083 flavor_groupLayout->setAlignment( Qt::AlignTop );
00084
00085 basicposix_button = new QRadioButton( flavor_group, "basicposix_button" );
00086 basicposix_button->setChecked( TRUE );
00087 flavor_groupLayout->addWidget( basicposix_button );
00088
00089 extendedposix_button = new QRadioButton( flavor_group, "extendedposix_button" );
00090 flavor_groupLayout->addWidget( extendedposix_button );
00091
00092 qregexp_button = new QRadioButton( flavor_group, "qregexp_button" );
00093 flavor_groupLayout->addWidget( qregexp_button );
00094
00095 qregexp_min_button = new QRadioButton( flavor_group, "qregexp_min_button" );
00096 flavor_groupLayout->addWidget( qregexp_min_button );
00097
00098 kregexp_button = new QRadioButton( flavor_group, "kregexp_button" );
00099 flavor_groupLayout->addWidget( kregexp_button );
00100
00101 regexp_test_dialogLayout->addMultiCellWidget( flavor_group, 1, 1, 0, 2 );
00102
00103 rxedit_button = new QPushButton( this, "rxedit_button" );
00104 rxedit_button->setAutoDefault( TRUE );
00105
00106 regexp_test_dialogLayout->addWidget( rxedit_button, 0, 2 );
00107
00108 layout2 = new QHBoxLayout( 0, 0, KDialog::spacingHint(), "layout2");
00109
00110 subgroups_label = new QLabel( this, "subgroups_label" );
00111 layout2->addWidget( subgroups_label );
00112
00113 subgroups_listview = new QListView( this, "subgroups_listview" );
00114 subgroups_listview->addColumn( tr2i18n( "Group" ) );
00115 subgroups_listview->addColumn( tr2i18n( "Value" ) );
00116 subgroups_listview->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)5, 0, 0, subgroups_listview->sizePolicy().hasHeightForWidth() ) );
00117 subgroups_listview->setAllColumnsShowFocus( TRUE );
00118 subgroups_listview->setResizeMode( QListView::AllColumns );
00119 layout2->addWidget( subgroups_listview );
00120
00121 regexp_test_dialogLayout->addMultiCellLayout( layout2, 4, 4, 0, 2 );
00122 languageChange();
00123 resize( QSize(541, 367).expandedTo(minimumSizeHint()) );
00124 clearWState( WState_Polished );
00125
00126
00127 connect( cancelbutton, SIGNAL( clicked() ), this, SLOT( reject() ) );
00128 connect( flavor_group, SIGNAL( clicked(int) ), this, SLOT( somethingChanged() ) );
00129 connect( pattern_edit, SIGNAL( textChanged(const QString&) ), this, SLOT( somethingChanged() ) );
00130 connect( teststring_edit, SIGNAL( textChanged(const QString&) ), this, SLOT( somethingChanged() ) );
00131 connect( insertbutton, SIGNAL( clicked() ), this, SLOT( insertQuoted() ) );
00132 connect( rxedit_button, SIGNAL( clicked() ), this, SLOT( showRegExpEditor() ) );
00133
00134
00135 setTabOrder( pattern_edit, rxedit_button );
00136 setTabOrder( rxedit_button, basicposix_button );
00137 setTabOrder( basicposix_button, teststring_edit );
00138 setTabOrder( teststring_edit, subgroups_listview );
00139 setTabOrder( subgroups_listview, insertbutton );
00140 setTabOrder( insertbutton, cancelbutton );
00141 setTabOrder( cancelbutton, extendedposix_button );
00142
00143
00144 pattern_label->setBuddy( pattern_edit );
00145 teststring_label->setBuddy( teststring_edit );
00146 }
00147
00148
00149
00150
00151 RegexpTestDialogBase::~RegexpTestDialogBase()
00152 {
00153
00154 }
00155
00156
00157
00158
00159
00160 void RegexpTestDialogBase::languageChange()
00161 {
00162 setCaption( tr2i18n( "Test Regular Expression" ) );
00163 pattern_label->setText( tr2i18n( "&Regular expression:" ) );
00164 teststring_label->setText( tr2i18n( "&Test string:" ) );
00165 QWhatsThis::add( teststring_edit, tr2i18n( "Enter a string which will be matched against the regular expression" ) );
00166 success_label->setText( QString::null );
00167 insertbutton->setText( tr2i18n( "&Insert Quoted" ) );
00168 QWhatsThis::add( insertbutton, tr2i18n( "Inserts the regular expression into the currently opened source code file. Escapes any special characters like backslash." ) );
00169 cancelbutton->setText( tr2i18n( "&Close" ) );
00170 QWhatsThis::add( cancelbutton, tr2i18n( "Closes the dialog" ) );
00171 QWhatsThis::add( pattern_edit, tr2i18n( "enter a regular expression, for example <tt>KD.*</tt>, which matches all strings beginning with \"KD\"" ) );
00172 flavor_group->setTitle( tr2i18n( "Regular Expression T&ype" ) );
00173 basicposix_button->setText( tr2i18n( "&Basic POSIX syntax (used by grep)" ) );
00174 QWhatsThis::add( basicposix_button, tr2i18n( "A description of this syntax can be found in the grep manpage" ) );
00175 extendedposix_button->setText( tr2i18n( "E&xtended POSIX syntax (used by egrep)" ) );
00176 QWhatsThis::add( extendedposix_button, tr2i18n( "A description of this syntax can be found in the grep manpage" ) );
00177 qregexp_button->setText( tr2i18n( "&QRegExp syntax" ) );
00178 QWhatsThis::add( qregexp_button, tr2i18n( "A description of this syntax can be found in the documentation of the QRegExp class" ) );
00179 qregexp_min_button->setText( tr2i18n( "QRegExp syntax (&minimal)" ) );
00180 QWhatsThis::add( qregexp_min_button, tr2i18n( "Matches a QRegExp non-greedy. Please read the QRegExp::setMinimal documentation for more details." ) );
00181 kregexp_button->setText( tr2i18n( "&KRegExp syntax" ) );
00182 QWhatsThis::add( kregexp_button, tr2i18n( "A description of this syntax can be found in the KDE API documentation." ) );
00183 rxedit_button->setText( tr2i18n( "&Edit..." ) );
00184 subgroups_label->setText( tr2i18n( "Matched subgroups:" ) );
00185 subgroups_listview->header()->setLabel( 0, tr2i18n( "Group" ) );
00186 subgroups_listview->header()->setLabel( 1, tr2i18n( "Value" ) );
00187 QWhatsThis::add( subgroups_listview, tr2i18n( "Shows which groups were matched. See the corresponding documentation for how groups are matched." ) );
00188 }
00189
00190 void RegexpTestDialogBase::insertQuoted()
00191 {
00192 qWarning( "RegexpTestDialogBase::insertQuoted(): Not implemented yet" );
00193 }
00194
00195 void RegexpTestDialogBase::somethingChanged()
00196 {
00197 qWarning( "RegexpTestDialogBase::somethingChanged(): Not implemented yet" );
00198 }
00199
00200 void RegexpTestDialogBase::showRegExpEditor()
00201 {
00202 qWarning( "RegexpTestDialogBase::showRegExpEditor(): Not implemented yet" );
00203 }
00204
00205 #include "regexptestdlgbase.moc"