knode
knfilterdialog.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <QLabel>
00016 #include <QCheckBox>
00017
00018 #include <QVBoxLayout>
00019 #include <QGridLayout>
00020 #include <QGroupBox>
00021
00022 #include <klocale.h>
00023 #include <kmessagebox.h>
00024 #include <klineedit.h>
00025
00026 #include "knglobals.h"
00027 #include "knfiltermanager.h"
00028 #include "knfilterconfigwidget.h"
00029 #include "knarticlefilter.h"
00030 #include "utilities.h"
00031 #include "knfilterdialog.h"
00032
00033
00034 KNFilterDialog::KNFilterDialog( KNArticleFilter *f, QWidget *parent )
00035 : KDialog( parent ),
00036 fltr(f)
00037 {
00038 if ( f->id() == -1 )
00039 setCaption( i18n("New Filter") );
00040 else
00041 setCaption( i18n("Properties of %1", f->name()) );
00042 setButtons( Ok|Cancel|Help );
00043 setDefaultButton( Ok );
00044
00045 QFrame* page = new QFrame( this );
00046 setMainWidget( page );
00047
00048 QGroupBox *gb = new QGroupBox( page );
00049 fname=new KLineEdit(gb);
00050 QLabel *l1=new QLabel(i18n("Na&me:"),gb);
00051 l1->setBuddy(fname);
00052 apon=new QComboBox(gb);
00053 apon->addItem(i18n("Single Articles"));
00054 apon->addItem(i18n("Whole Threads"));
00055 QLabel *l2=new QLabel(i18n("Apply o&n:"),gb);
00056 l2->setBuddy(apon);
00057 enabled=new QCheckBox(i18n("Sho&w in menu"), gb);
00058
00059 fw=new KNFilterConfigWidget(page);
00060
00061 QGridLayout *gbL=new QGridLayout(gb);
00062 gbL->setSpacing(5);
00063 gbL->setMargin(8);
00064 gbL->addWidget(l1, 0,0);
00065 gbL->addWidget(fname, 0,1, 1,3);
00066 gbL->addWidget(enabled, 1,0);
00067 gbL->addWidget(l2, 1,2);
00068 gbL->addWidget(apon, 1,3);
00069 gbL->setColumnStretch(1,1);
00070
00071 QVBoxLayout *topL=new QVBoxLayout(page);
00072 topL->setSpacing(5);
00073 topL->setMargin(0);
00074
00075 topL->addWidget(gb);
00076 topL->addWidget(fw,1);
00077
00078 enabled->setChecked(f->isEnabled());
00079 apon->setCurrentIndex((int) f->applyOn());
00080 fname->setText(f->translatedName());
00081
00082 fw->status->setFilter(f->status);
00083 fw->lines->setFilter(f->lines);
00084 fw->age->setFilter(f->age);
00085 fw->score->setFilter(f->score);
00086 fw->subject->setFilter(f->subject);
00087 fw->from->setFilter(f->from);
00088 fw->messageId->setFilter(f->messageId);
00089 fw->references->setFilter(f->references);
00090
00091 setFixedHeight(sizeHint().height());
00092 KNHelper::restoreWindowSize("filterDLG", this, sizeHint());
00093
00094 setHelp("anc-using-filters");
00095 connect( fname, SIGNAL( textChanged ( const QString & )), this, SLOT( slotTextChanged( const QString & )));
00096 connect( this, SIGNAL(okClicked()),this,SLOT(slotOk()));
00097 slotTextChanged( fname->text() );
00098 }
00099
00100
00101
00102 KNFilterDialog::~KNFilterDialog()
00103 {
00104 KNHelper::saveWindowSize("filterDLG", size());
00105 }
00106
00107 void KNFilterDialog::slotTextChanged( const QString &_text )
00108 {
00109 enableButtonOk( !_text.isEmpty() );
00110 }
00111
00112 void KNFilterDialog::slotOk()
00113 {
00114 if (fname->text().isEmpty())
00115 KMessageBox::sorry(this, i18n("Please provide a name for this filter."));
00116 else
00117 if (!knGlobals.filterManager()->newNameIsOK(fltr,fname->text()))
00118 KMessageBox::sorry(this, i18n("A filter with this name exists already.\nPlease choose a different name."));
00119 else {
00120 fltr->setTranslatedName(fname->text());
00121 fltr->setEnabled(enabled->isChecked());
00122 fltr->status=fw->status->filter();
00123 fltr->score=fw->score->filter();
00124 fltr->age=fw->age->filter();
00125 fltr->lines=fw->lines->filter();
00126 fltr->subject=fw->subject->filter();
00127 fltr->from=fw->from->filter();
00128 fltr->messageId=fw->messageId->filter();
00129 fltr->references=fw->references->filter();
00130 fltr->setApplyOn(apon->currentIndex());
00131
00132 accept();
00133 }
00134 }
00135
00136
00137
00138
00139
00140 #include "knfilterdialog.moc"