23 #include <KFileDialog>
24 #include <KListWidgetSearchLine>
25 #include <KPushButton>
27 #include <QListWidget>
28 #include <QVBoxLayout>
31 using namespace MailCommon;
36 setObjectName( QLatin1String(
"filterselection") );
38 setCaption( i18n(
"Select Filters" ) );
39 setButtons( Ok | Cancel );
40 setDefaultButton( Ok );
41 showButtonSeparator(
true );
43 QVBoxLayout *
const top =
new QVBoxLayout( mainWidget() );
45 filtersListWidget =
new QListWidget();
46 KListWidgetSearchLine *searchLine =
new KListWidgetSearchLine(
this, filtersListWidget );
47 searchLine->setClickMessage(
48 i18nc(
"@info/plain Displayed grayed-out inside the textbox, verb to search",
51 top->addWidget( searchLine );
52 top->addWidget( filtersListWidget );
53 filtersListWidget->setAlternatingRowColors(
true );
54 filtersListWidget->setSortingEnabled(
false );
55 filtersListWidget->setSelectionMode( QAbstractItemView::NoSelection );
57 QHBoxLayout *
const buttonLayout =
new QHBoxLayout();
58 top->addLayout( buttonLayout );
59 selectAllButton =
new KPushButton( i18n(
"Select All" ) );
60 buttonLayout->addWidget( selectAllButton );
61 unselectAllButton =
new KPushButton( i18n(
"Unselect All" ) );
62 buttonLayout->addWidget( unselectAllButton );
77 qDeleteAll(originalFilters);
81 void FilterSelectionDialog::writeConfig()
83 KConfigGroup group( KGlobal::config(),
"FilterSelectionDialog" );
84 group.writeEntry(
"Size", size() );
87 void FilterSelectionDialog::readConfig()
89 KConfigGroup group( KGlobal::config(),
"FilterSelectionDialog" );
90 const QSize sizeDialog = group.readEntry(
"Size", QSize(300, 350) );
91 if ( sizeDialog.isValid() ) {
98 if ( filters.isEmpty() ) {
99 enableButtonOk(
false );
103 originalFilters = filters;
104 filtersListWidget->clear();
106 foreach (
const MailFilter *filter, filters ) {
108 item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
109 item->setCheckState( Qt::Checked );
117 const int filterCount = filtersListWidget->count();
118 for (
int i = 0; i < filterCount; ++i ) {
120 if ( item->checkState() == Qt::Checked ) {
121 filters << originalFilters[ i ];
123 delete originalFilters[ i ];
132 const int filterCount = filtersListWidget->count();
133 for (
int i = 0; i < filterCount; ++i ) {
135 item->setCheckState( Qt::Unchecked );
141 const int filterCount = filtersListWidget->count();
142 for (
int i = 0; i < filterCount; ++i ) {
144 item->setCheckState( Qt::Checked );
148 #include "filterselectiondialog.moc"
virtual ~FilterSelectionDialog()
void slotSelectAllButton()
FilterSelectionDialog(QWidget *parent=0)
void setFilters(const QList< MailFilter * > &filters)
void slotUnselectAllButton()
QString name() const
Equivalent to ()->name().
QList< MailFilter * > selectedFilters() const