2 #include "expirypropertiesdialog.h"
3 #include "folderrequester.h"
5 #include "kmfoldertree.h"
8 #include <tqpushbutton.h>
9 #include <tqgroupbox.h>
10 #include <tqcheckbox.h>
11 #include <tqspinbox.h>
13 #include <tqradiobutton.h>
14 #include <tqbuttongroup.h>
15 #include <tqcombobox.h>
17 #include <tqtooltip.h>
18 #include <tqwhatsthis.h>
20 #include <tdelocale.h>
21 #include <tdemessagebox.h>
23 using namespace KMail;
30 ExpiryPropertiesDialog::ExpiryPropertiesDialog( KMFolderTree* tree,
KMFolder* folder )
31 : KDialogBase( tree,
"expiry_properties", false, i18n(
"Mail Expiry Properties" ),
32 KDialogBase::
Ok|KDialogBase::Cancel,
33 KDialogBase::
Ok, true ),
36 setWFlags( getWFlags() | WDestructiveClose );
37 TQWidget* privateLayoutWidget =
new TQWidget(
this,
"globalVBox" );
38 setMainWidget( privateLayoutWidget );
39 privateLayoutWidget->setGeometry( TQRect( 10, 20, 270, 138 ) );
40 globalVBox =
new TQVBoxLayout( privateLayoutWidget, 11, 6,
"globalVBox");
41 globalVBox->setSpacing( 20 );
43 readHBox =
new TQHBoxLayout( 0, 0, 6,
"readHBox");
45 expireReadMailCB =
new TQCheckBox( privateLayoutWidget,
"expireReadMailCB" );
46 expireReadMailCB->setText( i18n(
"Expire read mails after" ) );
47 connect( expireReadMailCB, TQ_SIGNAL( toggled(
bool )),
48 this, TQ_SLOT( slotUpdateControls() ) );
49 readHBox->addWidget( expireReadMailCB );
51 expireReadMailSB =
new TQSpinBox( privateLayoutWidget,
"expireReadMailSB" );
52 expireReadMailSB->setMaxValue( 999999 );
53 expireReadMailSB->setValue( 30 );
54 readHBox->addWidget( expireReadMailSB );
56 labelDays =
new TQLabel( privateLayoutWidget,
"labelDays" );
57 labelDays->setText( i18n(
"days" ) );
58 readHBox->addWidget( labelDays );
59 globalVBox->addLayout( readHBox );
61 unreadHBox =
new TQHBoxLayout( 0, 0, 6,
"unreadHBox");
63 expireUnreadMailCB =
new TQCheckBox( privateLayoutWidget,
"expireUnreadMailCB" );
64 expireUnreadMailCB->setText( i18n(
"Expire unread mails after" ) );
65 connect( expireUnreadMailCB, TQ_SIGNAL( toggled(
bool )),
66 this, TQ_SLOT( slotUpdateControls() ) );
67 unreadHBox->addWidget( expireUnreadMailCB );
69 expireUnreadMailSB =
new TQSpinBox( privateLayoutWidget,
"expireUnreadMailSB" );
70 expireUnreadMailSB->setMaxValue( 99999 );
71 expireUnreadMailSB->setValue( 30 );
72 unreadHBox->addWidget( expireUnreadMailSB );
74 labelDays2 =
new TQLabel( privateLayoutWidget,
"labelDays2" );
75 labelDays2->setText( i18n(
"days" ) );
76 labelDays2->setAlignment(
int( TQLabel::AlignTop ) );
77 unreadHBox->addWidget( labelDays2 );
78 globalVBox->addLayout( unreadHBox );
80 expiryActionHBox =
new TQHBoxLayout( 0, 0, 6,
"expiryActionHBox");
82 expiryActionLabel =
new TQLabel( privateLayoutWidget,
"expiryActionLabel" );
83 expiryActionLabel->setText( i18n(
"Expiry action:" ) );
84 expiryActionLabel->setAlignment(
int( TQLabel::AlignVCenter ) );
85 expiryActionHBox->addWidget( expiryActionLabel );
87 actionsHBox =
new TQVBoxLayout( 0, 0, 6,
"actionsHBox");
88 actionsGroup =
new TQButtonGroup(
this );
91 moveToHBox =
new TQHBoxLayout( 0, 0, 6,
"moveToHBox");
93 moveToRB =
new TQRadioButton( privateLayoutWidget,
"moveToRB" );
94 actionsGroup->insert( moveToRB );
95 connect( moveToRB, TQ_SIGNAL( toggled(
bool ) ),
96 this, TQ_SLOT( slotUpdateControls() ) );
97 moveToRB->setText( i18n(
"Move to:" ) );
98 moveToHBox->addWidget( moveToRB );
101 folderSelector->setMustBeReadWrite(
true );
102 moveToHBox->addWidget( folderSelector );
103 actionsHBox->addLayout( moveToHBox );
105 deletePermanentlyRB =
new TQRadioButton( privateLayoutWidget,
"deletePermanentlyRB" );
106 actionsGroup->insert( deletePermanentlyRB );
107 deletePermanentlyRB->setText( i18n(
"Delete permanently" ) );
108 actionsHBox->addWidget( deletePermanentlyRB );
109 expiryActionHBox->addLayout( actionsHBox );
110 globalVBox->addLayout( expiryActionHBox );
112 note =
new TQLabel( privateLayoutWidget,
"note" );
113 note->setText( i18n(
"Note: Expiry action will be applied immediately after confirming settings." ) );
114 note->setAlignment(
int( TQLabel::WordBreak | TQLabel::AlignVCenter ) );
115 globalVBox->addWidget( note );
118 bool expiryGloballyOn = mFolder->isAutoExpire();
119 int daysToExpireRead, daysToExpireUnread;
120 mFolder->daysToExpire( daysToExpireUnread, daysToExpireRead);
122 if ( expiryGloballyOn
123 && mFolder->getReadExpireUnits() != expireNever
124 && daysToExpireRead >= 0 ) {
125 expireReadMailCB->setChecked(
true );
126 expireReadMailSB->setValue( daysToExpireRead );
128 if ( expiryGloballyOn
129 && mFolder->getUnreadExpireUnits() != expireNever
130 && daysToExpireUnread >= 0 ) {
131 expireUnreadMailCB->setChecked(
true );
132 expireUnreadMailSB->setValue( daysToExpireUnread );
135 if ( mFolder->expireAction() == KMFolder::ExpireDelete )
136 deletePermanentlyRB->setChecked(
true );
138 moveToRB->setChecked(
true );
140 TQString destFolderID = mFolder->expireToFolderId();
141 if ( !destFolderID.isEmpty() ) {
142 KMFolder* destFolder = kmkernel->findFolderById( destFolderID );
144 folderSelector->setFolder( destFolder );
146 slotUpdateControls();
147 resize( TQSize(295, 204).expandedTo(minimumSizeHint()) );
148 clearWState( WState_Polished );
154 ExpiryPropertiesDialog::~ExpiryPropertiesDialog()
159 void ExpiryPropertiesDialog::slotOk()
161 bool enableGlobally = expireReadMailCB->isChecked() || expireUnreadMailCB->isChecked();
163 KMFolder *expireToFolder = folderSelector->folder();
164 if ( enableGlobally && moveToRB->isChecked() && !expireToFolder ) {
167 i18n(
"Please select a folder to expire messages into." ),
168 i18n(
"No Folder Selected" ) );
172 if ( expireToFolder ) {
173 if ( expireToFolder->
idString() == mFolder->idString() ) {
176 i18n(
"Please select a different folder than the current folder "
177 "to expire message into." ),
178 i18n(
"Wrong Folder Selected" ) );
181 mFolder->setExpireToFolderId( expireToFolder->
idString() );
185 mFolder->setAutoExpire( enableGlobally );
187 mFolder->setReadExpireAge( expireReadMailSB->value() );
188 mFolder->setUnreadExpireAge( expireUnreadMailSB->value() );
189 mFolder->setReadExpireUnits( expireReadMailCB->isChecked()? expireDays : expireNever );
190 mFolder->setUnreadExpireUnits( expireUnreadMailCB->isChecked()? expireDays : expireNever );
192 if ( deletePermanentlyRB->isChecked() )
193 mFolder->setExpireAction( KMFolder::ExpireDelete );
195 mFolder->setExpireAction( KMFolder::ExpireMove );
198 if ( enableGlobally )
199 mFolder->expireOldMessages(
true );
200 KDialogBase::slotOk();
203 void ExpiryPropertiesDialog::slotUpdateControls()
205 bool showExpiryActions = expireReadMailCB->isChecked() || expireUnreadMailCB->isChecked();
206 moveToRB->setEnabled( showExpiryActions );
207 folderSelector->setEnabled( showExpiryActions && moveToRB->isChecked() );
208 deletePermanentlyRB->setEnabled( showExpiryActions );
212 #include "expirypropertiesdialog.moc"
TQString idString() const
Returns a string that can be used to identify this folder.
A widget that contains a KLineEdit which shows the current folder and a button that fires a KMFolderS...
@ Ok
The user rights/ACL have been fetched from the server sucessfully.