1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
#include "expirypropertiesdialog.h"
#include "folderrequester.h"
#include "kmfolder.h"
#include "kmfoldertree.h"
#include <tqvariant.h>
#include <tqpushbutton.h>
#include <tqgroupbox.h>
#include <tqcheckbox.h>
#include <tqspinbox.h>
#include <tqlabel.h>
#include <tqradiobutton.h>
#include <tqbuttongroup.h>
#include <tqcombobox.h>
#include <tqlayout.h>
#include <tqtooltip.h>
#include <tqwhatsthis.h>
#include <klocale.h>
#include <kmessagebox.h>
using namespace KMail;
/*
* Constructs a ExpiryPropertiesDialog as a child of 'parent', with the
* name 'name'.
*
*/
ExpiryPropertiesDialog::ExpiryPropertiesDialog( KMFolderTree* tree, KMFolder* folder )
: KDialogBase( tree, "expiry_properties", false, i18n( "Mail Expiry Properties" ),
KDialogBase::Ok|KDialogBase::Cancel,
KDialogBase::Ok, true ),
mFolder( folder )
{
setWFlags( getWFlags() | WDestructiveClose );
TQWidget* privateLayoutWidget = new TQWidget( this, "globalVBox" );
setMainWidget( privateLayoutWidget );
privateLayoutWidget->setGeometry( TQRect( 10, 20, 270, 138 ) );
globalVBox = new TQVBoxLayout( privateLayoutWidget, 11, 6, "globalVBox");
globalVBox->setSpacing( 20 );
readHBox = new TQHBoxLayout( 0, 0, 6, "readHBox");
expireReadMailCB = new TQCheckBox( privateLayoutWidget, "expireReadMailCB" );
expireReadMailCB->setText( i18n( "Expire read mails after" ) );
connect( expireReadMailCB, TQT_SIGNAL( toggled( bool )),
this, TQT_SLOT( slotUpdateControls() ) );
readHBox->addWidget( expireReadMailCB );
expireReadMailSB = new TQSpinBox( privateLayoutWidget, "expireReadMailSB" );
expireReadMailSB->setMaxValue( 999999 );
expireReadMailSB->setValue( 30 );
readHBox->addWidget( expireReadMailSB );
labelDays = new TQLabel( privateLayoutWidget, "labelDays" );
labelDays->setText( i18n( "days" ) );
readHBox->addWidget( labelDays );
globalVBox->addLayout( readHBox );
unreadHBox = new TQHBoxLayout( 0, 0, 6, "unreadHBox");
expireUnreadMailCB = new TQCheckBox( privateLayoutWidget, "expireUnreadMailCB" );
expireUnreadMailCB->setText( i18n( "Expire unread mails after" ) );
connect( expireUnreadMailCB, TQT_SIGNAL( toggled( bool )),
this, TQT_SLOT( slotUpdateControls() ) );
unreadHBox->addWidget( expireUnreadMailCB );
expireUnreadMailSB = new TQSpinBox( privateLayoutWidget, "expireUnreadMailSB" );
expireUnreadMailSB->setMaxValue( 99999 );
expireUnreadMailSB->setValue( 30 );
unreadHBox->addWidget( expireUnreadMailSB );
labelDays2 = new TQLabel( privateLayoutWidget, "labelDays2" );
labelDays2->setText( i18n( "days" ) );
labelDays2->setAlignment( int( TQLabel::AlignTop ) );
unreadHBox->addWidget( labelDays2 );
globalVBox->addLayout( unreadHBox );
expiryActionHBox = new TQHBoxLayout( 0, 0, 6, "expiryActionHBox");
expiryActionLabel = new TQLabel( privateLayoutWidget, "expiryActionLabel" );
expiryActionLabel->setText( i18n( "Expiry action:" ) );
expiryActionLabel->setAlignment( int( TQLabel::AlignVCenter ) );
expiryActionHBox->addWidget( expiryActionLabel );
actionsHBox = new TQVBoxLayout( 0, 0, 6, "actionsHBox");
actionsGroup = new TQButtonGroup( this );
actionsGroup->hide(); // for mutual exclusion of the radio buttons
moveToHBox = new TQHBoxLayout( 0, 0, 6, "moveToHBox");
moveToRB = new TQRadioButton( privateLayoutWidget, "moveToRB" );
actionsGroup->insert( moveToRB );
connect( moveToRB, TQT_SIGNAL( toggled( bool ) ),
this, TQT_SLOT( slotUpdateControls() ) );
moveToRB->setText( i18n( "Move to:" ) );
moveToHBox->addWidget( moveToRB );
folderSelector = new KMail::FolderRequester( privateLayoutWidget, tree );
folderSelector->setMustBeReadWrite( true );
moveToHBox->addWidget( folderSelector );
actionsHBox->addLayout( moveToHBox );
deletePermanentlyRB = new TQRadioButton( privateLayoutWidget, "deletePermanentlyRB" );
actionsGroup->insert( deletePermanentlyRB );
deletePermanentlyRB->setText( i18n( "Delete permanently" ) );
actionsHBox->addWidget( deletePermanentlyRB );
expiryActionHBox->addLayout( actionsHBox );
globalVBox->addLayout( expiryActionHBox );
note = new TQLabel( privateLayoutWidget, "note" );
note->setText( i18n( "Note: Expiry action will be applied immediately after confirming settings." ) );
note->setAlignment( int( TQLabel::WordBreak | TQLabel::AlignVCenter ) );
globalVBox->addWidget( note );
// Load the values from the folder
bool expiryGloballyOn = mFolder->isAutoExpire();
int daysToExpireRead, daysToExpireUnread;
mFolder->daysToExpire( daysToExpireUnread, daysToExpireRead);
if ( expiryGloballyOn
&& mFolder->getReadExpireUnits() != expireNever
&& daysToExpireRead >= 0 ) {
expireReadMailCB->setChecked( true );
expireReadMailSB->setValue( daysToExpireRead );
}
if ( expiryGloballyOn
&& mFolder->getUnreadExpireUnits() != expireNever
&& daysToExpireUnread >= 0 ) {
expireUnreadMailCB->setChecked( true );
expireUnreadMailSB->setValue( daysToExpireUnread );
}
if ( mFolder->expireAction() == KMFolder::ExpireDelete )
deletePermanentlyRB->setChecked( true );
else
moveToRB->setChecked( true );
TQString destFolderID = mFolder->expireToFolderId();
if ( !destFolderID.isEmpty() ) {
KMFolder* destFolder = kmkernel->findFolderById( destFolderID );
if ( destFolder )
folderSelector->setFolder( destFolder );
}
slotUpdateControls();
resize( TQSize(295, 204).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
}
/*
* Destroys the object and frees any allocated resources
*/
ExpiryPropertiesDialog::~ExpiryPropertiesDialog()
{
// no need to delete child widgets, Qt does it all for us
}
void ExpiryPropertiesDialog::slotOk()
{
bool enableGlobally = expireReadMailCB->isChecked() || expireUnreadMailCB->isChecked();
KMFolder *expireToFolder = folderSelector->folder();
if ( enableGlobally && moveToRB->isChecked() && !expireToFolder ) {
KMessageBox::error(
this,
i18n( "Please select a folder to expire messages into." ),
i18n( "No Folder Selected" ) );
return;
}
if ( expireToFolder ) {
if ( expireToFolder->idString() == mFolder->idString() ) {
KMessageBox::error(
this,
i18n( "Please select a different folder than the current folder "
"to expire message into." ),
i18n( "Wrong Folder Selected" ) );
return;
} else {
mFolder->setExpireToFolderId( expireToFolder->idString() );
}
}
mFolder->setAutoExpire( enableGlobally );
// we always write out days now
mFolder->setReadExpireAge( expireReadMailSB->value() );
mFolder->setUnreadExpireAge( expireUnreadMailSB->value() );
mFolder->setReadExpireUnits( expireReadMailCB->isChecked()? expireDays : expireNever );
mFolder->setUnreadExpireUnits( expireUnreadMailCB->isChecked()? expireDays : expireNever );
if ( deletePermanentlyRB->isChecked() )
mFolder->setExpireAction( KMFolder::ExpireDelete );
else
mFolder->setExpireAction( KMFolder::ExpireMove );
// trigger immediate expiry if there is something to do
if ( enableGlobally )
mFolder->expireOldMessages( true /*immediate*/);
KDialogBase::slotOk();
}
void ExpiryPropertiesDialog::slotUpdateControls()
{
bool showExpiryActions = expireReadMailCB->isChecked() || expireUnreadMailCB->isChecked();
moveToRB->setEnabled( showExpiryActions );
folderSelector->setEnabled( showExpiryActions && moveToRB->isChecked() );
deletePermanentlyRB->setEnabled( showExpiryActions );
}
#include "expirypropertiesdialog.moc"
|