00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "senderlistdialog.h"
00019 #include <qlistview.h>
00020
00021 SenderListDialog::SenderListDialog(QWidget *parent, ListType type, QStringList list, int blackListAction )
00022 : KDialog( parent )
00023 {
00024
00025 this->type = type;
00026 this->list = list;
00027 this->blacklistAction = blackListAction;
00028
00029
00030 config = KGlobal::config();
00031
00032
00033 if( type == White )
00034 setCaption( "Whitelist" );
00035 else
00036 setCaption( "Blacklist" );
00037
00038
00039
00040
00041
00042 QWidget* wdgMain = new QWidget( this );
00043 setMainWidget( wdgMain );
00044 QVBoxLayout* layMain = new QVBoxLayout( wdgMain );
00045
00046
00047 editFrame = new KEditListBox( wdgMain, "editFrame", true, KEditListBox::Add | KEditListBox::Remove );
00048 editFrame->setTitle( i18nc( "@title:window dialog to edit the black- or whitelist", "List" ) );
00049 if( type == White )
00050 editFrame->listView()->setToolTip( i18nc( "@info/rich", "A mail whose sender is listed here will pass the filter.<nl/>A mail will be accepted, if its From line incloses a list entry.<nl/>E.g. a line of<nl/>"Ulrich Weigelt" <ulrich.weigelt@gmx.de> is accepted by the entries<nl/>Ulrich Weigelt<nl/>ulrich.weigelt@gmx.de<nl/>"Ulrich Weigelt" <ulrich.weigelt@gmx.de>" ) );
00051 else
00052 editFrame->listView()->setToolTip( i18nc( "@info:tooltip", "A mail whose sender is listed here will be hold up by the filter.<nl/>A mail will be stopped, if its From line incloses a list entry.<nl/>E.g. a line of<nl/>"Ulrich Weigelt" <ulrich.weigelt@gmx.de> is filtered by the entries<nl/>Ulrich Weigelt<nl/>ulrich.weigelt@gmx.de<nl/>"Ulrich Weigelt" <ulrich.weigelt@gmx.de>" ) );
00053
00054 layMain->addWidget( editFrame );
00055
00056 connect( editFrame->addButton(), SIGNAL( clicked() ), this, SLOT( slotSort() ) );
00057 connect( editFrame->lineEdit(), SIGNAL( returnPressed( const QString & ) ), this, SLOT( slotSort() ) );
00058
00059
00060 if( type == Black )
00061 {
00062 QGroupBox* gboxAction = new QGroupBox( i18nc( "@title:group action to execute if a blacklisted mail comes in", "Action" ), wdgMain );
00063 QHBoxLayout* layAction = new QHBoxLayout();
00064 gboxAction->setLayout( layAction );
00065 layMain->addWidget( gboxAction );
00066
00067 grpAction = new QButtonGroup( NULL );
00068 btnDelete = new QRadioButton( i18nc( "@option:radio delete a blacklisted mail", "Delete"), gboxAction );
00069 btnMark = new QRadioButton( i18nc( "@option:radio mark a blacklisted mail", "Mark" ), gboxAction );
00070
00071 grpAction->addButton( btnDelete, ID_BUTTON_FILTER_SENDERLIST_DELETE );
00072 grpAction->addButton( btnMark, ID_BUTTON_FILTER_SENDERLIST_MARK );
00073
00074 btnDelete->setToolTip( i18nc( "@info:tooltip", "The mails will be deleted." ) );
00075 btnMark->setToolTip( i18nc( "@info:tooltip", "The mails will be marked." ) );
00076
00077 layAction->addWidget( btnDelete );
00078 layAction->addWidget( btnMark );
00079
00080
00081 switch( DEFAULT_FILTER_BLACKLIST_ACTION )
00082 {
00083 case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE : btnDelete->setChecked( true ); break;
00084 case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK : btnMark->setChecked( true ); break;
00085 default : btnDelete->setChecked( true ); break;
00086 }
00087 }
00088
00089 setGeometry( 50, 50, (int)( this->width() / 2 ), this->height() );
00090
00091
00092 fillDialog();
00093 }
00094
00095
00096 SenderListDialog::~SenderListDialog()
00097 {
00098 }
00099
00100 void SenderListDialog::slotSort( )
00101 {
00102 editFrame->listView()->model()->sort( 0 );
00103 }
00104
00105 void SenderListDialog::slotButtonClicked( int button )
00106 {
00107 if( button == KDialog::Ok )
00108 {
00109
00110 list = editFrame->items();
00111 if( type == Black ) {
00112 int action = grpAction->checkedId();
00113 if( action != ID_BUTTON_FILTER_SENDERLIST_DELETE && action != ID_BUTTON_FILTER_SENDERLIST_MARK )
00114 action = DEFAULT_FILTER_BLACKLIST_ACTION;
00115
00116 switch( action )
00117 {
00118 case ID_BUTTON_FILTER_SENDERLIST_DELETE : blacklistAction = CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE; break;
00119 case ID_BUTTON_FILTER_SENDERLIST_MARK : blacklistAction = CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK; break;
00120 default : blacklistAction = DEFAULT_FILTER_BLACKLIST_ACTION; break;
00121 }
00122
00123 } else {
00124 blacklistAction = DEFAULT_FILTER_BLACKLIST_ACTION;
00125 }
00126
00127
00128 }
00129
00130
00131 KDialog::slotButtonClicked( button );
00132
00133 }
00134
00135 void SenderListDialog::fillDialog( )
00136 {
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 editFrame->setItems( list );
00160 if( type == Black )
00161 {
00162 switch( blacklistAction )
00163 {
00164 case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_DELETE : btnDelete->setChecked( true ); break;
00165 case CONFIG_VALUE_FILTER_BLACKLIST_ACTION_MARK : btnMark->setChecked( true ); break;
00166 default : btnDelete->setChecked( true ); break;
00167 }
00168 }
00169
00170 }
00171
00172 int SenderListDialog::getBlacklistAction() const
00173 {
00174 return blacklistAction;
00175 }
00176
00177 QStringList SenderListDialog::getList() const
00178 {
00179 return list;
00180 }
00181
00182
00183
00184 #include "senderlistdialog.moc"