kmail

chiasmuskeyselector.cpp

Go to the documentation of this file.
00001 #include "chiasmuskeyselector.h"
00002 
00003 #include <klineedit.h>
00004 #include <klistbox.h>
00005 #include <klocale.h>
00006 
00007 #include <qlayout.h>
00008 #include <qlabel.h>
00009 
00010 ChiasmusKeySelector::ChiasmusKeySelector( QWidget* parent, const QString& caption,
00011                                           const QStringList& keys, const QString& currentKey,
00012                                           const QString& lastOptions )
00013   : KDialogBase( parent, "chiasmusKeySelector", true, caption, Ok|Cancel, Ok, true )
00014 {
00015   QWidget *page = makeMainWidget();
00016 
00017   QVBoxLayout *layout = new QVBoxLayout(page, KDialog::spacingHint());
00018 
00019   mLabel = new QLabel( i18n( "Please select the Chiasmus key file to use:" ), page );
00020   layout->addWidget( mLabel );
00021 
00022   mListBox = new KListBox( page );
00023   mListBox->insertStringList( keys );
00024   const int current = keys.findIndex( currentKey );
00025   mListBox->setSelected( QMAX( 0, current ), true );
00026   mListBox->ensureCurrentVisible();
00027   layout->addWidget( mListBox, 1 );
00028 
00029   QLabel* optionLabel = new QLabel( i18n( "Additional arguments for chiasmus:" ), page );
00030   layout->addWidget( optionLabel );
00031 
00032   mOptions = new KLineEdit( lastOptions, page );
00033   optionLabel->setBuddy( mOptions );
00034   layout->addWidget( mOptions );
00035 
00036   layout->addStretch();
00037 
00038   connect( mListBox, SIGNAL( doubleClicked( QListBoxItem * ) ), this, SLOT( slotOk() ) );
00039   connect( mListBox, SIGNAL( returnPressed( QListBoxItem * ) ), this, SLOT( slotOk() ) );
00040 
00041   mListBox->setFocus();
00042 }
00043 
00044 QString ChiasmusKeySelector::key() const
00045 {
00046   return mListBox->currentText();
00047 }
00048 
00049 QString ChiasmusKeySelector::options() const
00050 {
00051   return mOptions->text();
00052 }
00053 
00054 
00055 #include "chiasmuskeyselector.moc"