30 #include <Akonadi/Calendar/IncidenceChanger>
33 #include <KDateComboBox>
34 #include <KFileDialog>
36 #include <KLocalizedString>
37 #include <KMessageBox>
40 #include <KUrlRequester>
43 #include <QButtonGroup>
48 #include <QHBoxLayout>
51 #include <QRadioButton>
52 #include <QVBoxLayout>
55 using namespace CalendarSupport;
58 Akonadi::IncidenceChanger *changer,
62 setCaption( i18nc(
"@title:window",
"Archive/Delete Past Events and To-dos" ) );
63 setButtons( User1|Cancel );
64 setDefaultButton( User1 );
66 showButtonSeparator(
true );
67 setButtonText( User1, i18nc(
"@action:button",
"&Archive" ) );
72 setMainWidget( topFrame );
75 #ifndef KDEPIM_MOBILE_UI
78 i18nc(
"@info:whatsthis",
79 "Archiving saves old items into the given file and "
80 "then deletes them in the current calendar. If the archive file "
81 "already exists they will be added. "
82 "(<link url=\"#\">How to restore</link>)" ) );
84 i18nc(
"@info:whatsthis",
85 "In order to add an archive to your calendar, use the Merge Calendar "
86 "function. You can view an archive by opening it like you would any "
87 "other calendar. It is not saved in a special format, but as "
90 Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard |
91 Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard );
95 connect( descLabel, SIGNAL(linkActivated(
QString)), SLOT(showWhatsThis()) );
103 mArchiveOnceRB =
new QRadioButton( i18nc(
"@option:radio",
104 "Archive now items older than:" ),
107 i18nc(
"@info:tooltip",
108 "Enable one time archiving or purging of older items" ) );
110 i18nc(
"@info:whatsthis",
111 "If you check this box, events and to-dos older than the specified age "
112 "will be archived or purged. The items will be archived unless the "
113 "\"Delete only\" option is enabled; else the items will be purged "
114 "and not saved." ) );
118 mDateEdit =
new KDateComboBox( topFrame );
119 mDateEdit->setToolTip(
120 i18nc(
"@info:tooltip",
121 "Set the one time archiving cut-off date" ) );
122 mDateEdit->setWhatsThis(
123 i18nc(
"@info:whatsthis",
124 "The date before which items should be archived. All older events "
125 "and to-dos will be saved and deleted, the newer (and events "
126 "exactly on that date) will be kept." ) );
132 KHBox *autoArchiveHBox =
new KHBox( topFrame );
134 mAutoArchiveRB =
new QRadioButton( i18nc(
"@option:radio",
135 "Automaticall&y archive items older than:" ),
138 i18nc(
"@info:tooltip",
139 "Enable automatic archiving or purging of older items" ) );
141 i18nc(
"@info:whatsthis",
142 "If this feature is enabled, the application will regularly check if "
143 "events and to-dos have to be archived; this means you will not "
144 "need to use this dialog box again, except to change the settings." ) );
147 mExpiryTimeNumInput =
new KIntNumInput( autoArchiveHBox );
148 mExpiryTimeNumInput->setRange( 1, 500, 1 );
149 mExpiryTimeNumInput->setSliderEnabled(
false );
150 mExpiryTimeNumInput->setEnabled(
false );
151 mExpiryTimeNumInput->setValue( 7 );
152 mExpiryTimeNumInput->setToolTip(
153 i18nc(
"@info:tooltip",
154 "Set the archival age in days, weeks or months" ) );
155 mExpiryTimeNumInput->setWhatsThis(
156 i18nc(
"@info:whatsthis",
157 "The age of the events and to-dos to archive. All older items "
158 "will be saved and deleted, the newer will be kept." ) );
160 mExpiryUnitsComboBox =
new KComboBox( autoArchiveHBox );
161 mExpiryUnitsComboBox->setToolTip(
162 i18nc(
"@info:tooltip",
163 "Set the units for the automatic archive age" ) );
164 mExpiryUnitsComboBox->setWhatsThis(
165 i18nc(
"@info:whatsthis",
166 "Select the time units (days, weeks or months) for automatic archiving." ) );
168 mExpiryUnitsComboBox->addItem(
169 i18nc(
"@item:inlistbox expires in daily units",
"Day(s)" ) );
170 mExpiryUnitsComboBox->addItem(
171 i18nc(
"@item:inlistbox expiration in weekly units",
"Week(s)" ) );
172 mExpiryUnitsComboBox->addItem(
173 i18nc(
"@item:inlistbox expiration in monthly units",
"Month(s)" ) );
174 mExpiryUnitsComboBox->setEnabled(
false );
179 QLabel *l =
new QLabel( i18nc(
"@label",
"Archive &file:" ), topFrame );
182 mArchiveFile->setMode( KFile::File );
183 mArchiveFile->setFilter( i18nc(
"@label filter for KUrlRequester",
"*.ics|iCalendar Files" ) );
184 mArchiveFile->setToolTip(
185 i18nc(
"@info:tooltip",
186 "Set the location of the archive" ) );
187 mArchiveFile->setWhatsThis(
188 i18nc(
"@info:whatsthis",
189 "The path of the archive file. The events and to-dos will be appended "
190 "to the specified file, so any events that are already in the file "
191 "will not be modified or deleted. You can later load or merge the "
192 "file like any other calendar. It is not saved in a special "
193 "format, it uses the iCalendar format." ) );
194 mArchiveFile->fileDialog()->setOperationMode( KFileDialog::Saving );
195 l->
setBuddy( mArchiveFile->lineEdit() );
199 #ifndef KDEPIM_MOBILE_UI
200 QGroupBox *typeBox =
new QGroupBox( i18nc(
"@title:group",
"Type of Items to Archive" ) );
202 i18nc(
"@info:whatsthis",
203 "Here you can select which items "
204 "should be archived. Events are archived if they "
205 "ended before the date given above; to-dos are archived if "
206 "they were finished before the date." ) );
215 mEvents =
new QCheckBox( i18nc(
"@option:check",
"Archive &Events" ) );
217 i18nc(
"@option:check",
"Archive or purge events" ) );
219 i18nc(
"@info:whatsthis",
220 "Select this option to archive events if they ended before the date given above." ) );
223 mTodos =
new QCheckBox( i18nc(
"@option:check",
"Archive Completed &To-dos" ) );
225 i18nc(
"@option:check",
"Archive or purge completed to-dos" ) );
227 i18nc(
"@info:whatsthis",
228 "Select this option to archive to-dos if they were completed "
229 "before the date given above." ) );
232 mDeleteCb =
new QCheckBox( i18nc(
"@option:check",
"&Delete only, do not save" ), topFrame );
234 i18nc(
"@info:tooltip",
235 "Purge the old items without saving them" ) );
237 i18nc(
"@info:whatsthis",
238 "Select this option to delete old events and to-dos without saving "
239 "them. It is not possible to recover the events later." ) );
241 connect( mDeleteCb, SIGNAL(toggled(
bool)), mArchiveFile, SLOT(setDisabled(
bool)) );
242 connect( mDeleteCb, SIGNAL(toggled(
bool)),
this, SLOT(
slotEnableUser1()) );
243 connect( mArchiveFile->lineEdit(), SIGNAL(textChanged(
QString)),
264 connect(
this, SIGNAL(user1Clicked()),
this, SLOT(
slotUser1()) );
273 const bool state = ( mDeleteCb->
isChecked() || !mArchiveFile->lineEdit()->text().trimmed().isEmpty() );
274 enableButton( KDialog::User1, state );
279 mDateEdit->setEnabled( mArchiveOnceRB->
isChecked() );
280 mExpiryTimeNumInput->setEnabled( mAutoArchiveRB->
isChecked() );
281 mExpiryUnitsComboBox->setEnabled( mAutoArchiveRB->
isChecked() );
300 KUrl destUrl( mArchiveFile->url() );
301 if ( !destUrl.isValid() ) {
302 KMessageBox::sorry(
this, i18nc(
"@info",
"The archive file name is not valid." ) );
306 QString filename = destUrl.fileName();
310 destUrl.setFileName( filename );
316 archiver.
runAuto( mCalendar, mChanger,
this,
true );
320 archiver.
runOnce( mCalendar, mChanger, mDateEdit->date(), this );
333 void ArchiveDialog::showWhatsThis()
336 if ( widget && !widget->
whatsThis().isEmpty() ) {
void showText(const QPoint &pos, const QString &text, QWidget *w)
QString & append(QChar ch)
void runAuto(const Akonadi::ETMCalendar::Ptr &calendar, Akonadi::IncidenceChanger *changer, QWidget *widget, bool withGUI)
Delete or archive events.
ArchiveDialog(const Akonadi::ETMCalendar::Ptr &calendar, Akonadi::IncidenceChanger *changer, QWidget *parent=0)
void setBuddy(QWidget *buddy)
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
void setText(const QString &)
This class handles expiring and archiving of events.
void setMargin(int margin)
static KCalPrefs * instance()
Get instance of KCalPrefs.
void setTextInteractionFlags(QFlags< Qt::TextInteractionFlag > flags)
void autoArchivingSettingsModified()
void runOnce(const Akonadi::ETMCalendar::Ptr &calendar, Akonadi::IncidenceChanger *changer, const QDate &limitDate, QWidget *widget)
Delete or archive events once.
void setWordWrap(bool on)
void setSpacing(int spacing)
void addLayout(QLayout *layout, int stretch)