Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM Calendar Support
Commits
fdd95875
Commit
fdd95875
authored
Jan 26, 2021
by
Laurent Montel
😁
Browse files
run git clang-format
parent
c3ab99a7
Changes
65
Hide whitespace changes
Inline
Side-by-side
src/archivedialog.cpp
View file @
fdd95875
...
...
@@ -13,26 +13,26 @@
#include <Akonadi/Calendar/IncidenceChanger>
#include <QComboBox>
#include <KDateComboBox>
#include <KLineEdit>
#include <KLocalizedString>
#include <KMessageBox>
#include <QUrl>
#include <KUrlRequester>
#include <QComboBox>
#include <QHBoxLayout>
#include <QUrl>
#include <QSpinBox>
#include <QButtonGroup>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QFrame>
#include <QGroupBox>
#include <QLabel>
#include <QPushButton>
#include <QRadioButton>
#include <QSpinBox>
#include <QVBoxLayout>
#include <QWhatsThis>
#include <QDialogButtonBox>
#include <QPushButton>
using
namespace
CalendarSupport
;
...
...
@@ -58,56 +58,43 @@ ArchiveDialog::ArchiveDialog(const Akonadi::ETMCalendar::Ptr &cal, Akonadi::Inci
auto
topLayout
=
new
QVBoxLayout
(
topFrame
);
topLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
QLabel
*
descLabel
=
new
QLabel
(
topFrame
);
descLabel
->
setText
(
xi18nc
(
"@info:whatsthis"
,
"Archiving saves old items into the given file and "
"then deletes them in the current calendar. If the archive file "
"already exists they will be added. "
"(<link url=
\"
#
\"
>How to restore</link>)"
));
descLabel
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"In order to add an archive to your calendar, use the Merge Calendar "
"function. You can view an archive by opening it like you would any "
"other calendar. It is not saved in a special format, but as "
"vCalendar."
));
descLabel
->
setTextInteractionFlags
(
Qt
::
TextSelectableByMouse
|
Qt
::
TextSelectableByKeyboard
|
Qt
::
LinksAccessibleByMouse
|
Qt
::
LinksAccessibleByKeyboard
);
descLabel
->
setText
(
xi18nc
(
"@info:whatsthis"
,
"Archiving saves old items into the given file and "
"then deletes them in the current calendar. If the archive file "
"already exists they will be added. "
"(<link url=
\"
#
\"
>How to restore</link>)"
));
descLabel
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"In order to add an archive to your calendar, use the Merge Calendar "
"function. You can view an archive by opening it like you would any "
"other calendar. It is not saved in a special format, but as "
"vCalendar."
));
descLabel
->
setTextInteractionFlags
(
Qt
::
TextSelectableByMouse
|
Qt
::
TextSelectableByKeyboard
|
Qt
::
LinksAccessibleByMouse
|
Qt
::
LinksAccessibleByKeyboard
);
descLabel
->
setWordWrap
(
true
);
descLabel
->
setContextMenuPolicy
(
Qt
::
NoContextMenu
);
topLayout
->
addWidget
(
descLabel
);
connect
(
descLabel
,
&
QLabel
::
linkActivated
,
this
,
&
ArchiveDialog
::
showWhatsThis
);
auto
radioBG
=
new
QButtonGroup
(
this
);
connect
(
radioBG
,
QOverload
<
QAbstractButton
*>::
of
(
&
QButtonGroup
::
buttonClicked
),
this
,
&
ArchiveDialog
::
slotActionChanged
);
connect
(
radioBG
,
QOverload
<
QAbstractButton
*>::
of
(
&
QButtonGroup
::
buttonClicked
),
this
,
&
ArchiveDialog
::
slotActionChanged
);
auto
dateLayout
=
new
QHBoxLayout
();
dateLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
mArchiveOnceRB
=
new
QRadioButton
(
i18nc
(
"@option:radio"
,
"Archive now items older than:"
),
topFrame
);
mArchiveOnceRB
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Enable one time archiving or purging of older items"
));
mArchiveOnceRB
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"If you check this box, events and to-dos older than the specified age "
"will be archived or purged. The items will be archived unless the "
"
\"
Delete only
\"
option is enabled; else the items will be purged "
"and not saved."
));
mArchiveOnceRB
=
new
QRadioButton
(
i18nc
(
"@option:radio"
,
"Archive now items older than:"
),
topFrame
);
mArchiveOnceRB
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Enable one time archiving or purging of older items"
));
mArchiveOnceRB
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"If you check this box, events and to-dos older than the specified age "
"will be archived or purged. The items will be archived unless the "
"
\"
Delete only
\"
option is enabled; else the items will be purged "
"and not saved."
));
dateLayout
->
addWidget
(
mArchiveOnceRB
);
radioBG
->
addButton
(
mArchiveOnceRB
);
mDateEdit
=
new
KDateComboBox
(
topFrame
);
mDateEdit
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the one time archiving cut-off date"
));
mDateEdit
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"The date before which items should be archived. All older events "
"and to-dos will be saved and deleted, the newer (and events "
"exactly on that date) will be kept."
));
mDateEdit
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the one time archiving cut-off date"
));
mDateEdit
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"The date before which items should be archived. All older events "
"and to-dos will be saved and deleted, the newer (and events "
"exactly on that date) will be kept."
));
dateLayout
->
addWidget
(
mDateEdit
);
topLayout
->
addLayout
(
dateLayout
);
...
...
@@ -117,17 +104,12 @@ ArchiveDialog::ArchiveDialog(const Akonadi::ETMCalendar::Ptr &cal, Akonadi::Inci
auto
autoArchiveHBoxHBoxLayout
=
new
QHBoxLayout
(
autoArchiveHBox
);
autoArchiveHBoxHBoxLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
topLayout
->
addWidget
(
autoArchiveHBox
);
mAutoArchiveRB
=
new
QRadioButton
(
i18nc
(
"@option:radio"
,
"Automaticall&y archive items older than:"
),
autoArchiveHBox
);
mAutoArchiveRB
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Enable automatic archiving or purging of older items"
));
mAutoArchiveRB
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"If this feature is enabled, the application will regularly check if "
"events and to-dos have to be archived; this means you will not "
"need to use this dialog box again, except to change the settings."
));
mAutoArchiveRB
=
new
QRadioButton
(
i18nc
(
"@option:radio"
,
"Automaticall&y archive items older than:"
),
autoArchiveHBox
);
mAutoArchiveRB
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Enable automatic archiving or purging of older items"
));
mAutoArchiveRB
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"If this feature is enabled, the application will regularly check if "
"events and to-dos have to be archived; this means you will not "
"need to use this dialog box again, except to change the settings."
));
radioBG
->
addButton
(
mAutoArchiveRB
);
autoArchiveHBoxHBoxLayout
->
addWidget
(
mAutoArchiveRB
);
...
...
@@ -138,94 +120,70 @@ ArchiveDialog::ArchiveDialog(const Akonadi::ETMCalendar::Ptr &cal, Akonadi::Inci
mExpiryTimeNumInput
->
setEnabled
(
false
);
mExpiryTimeNumInput
->
setValue
(
7
);
mExpiryTimeNumInput
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the archival age in days, weeks or months"
));
mExpiryTimeNumInput
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"The age of the events and to-dos to archive. All older items "
"will be saved and deleted, the newer will be kept."
));
mExpiryTimeNumInput
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the archival age in days, weeks or months"
));
mExpiryTimeNumInput
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"The age of the events and to-dos to archive. All older items "
"will be saved and deleted, the newer will be kept."
));
mExpiryUnitsComboBox
=
new
QComboBox
(
autoArchiveHBox
);
autoArchiveHBoxHBoxLayout
->
addWidget
(
mExpiryUnitsComboBox
);
mExpiryUnitsComboBox
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the units for the automatic archive age"
));
mExpiryUnitsComboBox
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select the time units (days, weeks or months) for automatic archiving."
));
mExpiryUnitsComboBox
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the units for the automatic archive age"
));
mExpiryUnitsComboBox
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select the time units (days, weeks or months) for automatic archiving."
));
// Those items must match the "Expiry Unit" enum in the kcfg file!
mExpiryUnitsComboBox
->
addItem
(
i18nc
(
"@item:inlistbox expires in daily units"
,
"Day(s)"
));
mExpiryUnitsComboBox
->
addItem
(
i18nc
(
"@item:inlistbox expiration in weekly units"
,
"Week(s)"
));
mExpiryUnitsComboBox
->
addItem
(
i18nc
(
"@item:inlistbox expiration in monthly units"
,
"Month(s)"
));
mExpiryUnitsComboBox
->
addItem
(
i18nc
(
"@item:inlistbox expires in daily units"
,
"Day(s)"
));
mExpiryUnitsComboBox
->
addItem
(
i18nc
(
"@item:inlistbox expiration in weekly units"
,
"Week(s)"
));
mExpiryUnitsComboBox
->
addItem
(
i18nc
(
"@item:inlistbox expiration in monthly units"
,
"Month(s)"
));
mExpiryUnitsComboBox
->
setEnabled
(
false
);
auto
fileLayout
=
new
QHBoxLayout
();
fileLayout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
QLabel
*
l
=
new
QLabel
(
i18nc
(
"@label"
,
"Archive &file:"
),
topFrame
);
fileLayout
->
addWidget
(
l
);
mArchiveFile
=
new
KUrlRequester
(
QUrl
::
fromLocalFile
(
KCalPrefs
::
instance
()
->
mArchiveFile
),
topFrame
);
mArchiveFile
=
new
KUrlRequester
(
QUrl
::
fromLocalFile
(
KCalPrefs
::
instance
()
->
mArchiveFile
),
topFrame
);
mArchiveFile
->
setMode
(
KFile
::
File
);
mArchiveFile
->
setFilter
(
i18nc
(
"@label filter for KUrlRequester"
,
"*.ics|iCalendar Files"
));
mArchiveFile
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the location of the archive"
));
mArchiveFile
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"The path of the archive file. The events and to-dos will be appended "
"to the specified file, so any events that are already in the file "
"will not be modified or deleted. You can later load or merge the "
"file like any other calendar. It is not saved in a special "
"format, it uses the iCalendar format."
));
mArchiveFile
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Set the location of the archive"
));
mArchiveFile
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"The path of the archive file. The events and to-dos will be appended "
"to the specified file, so any events that are already in the file "
"will not be modified or deleted. You can later load or merge the "
"file like any other calendar. It is not saved in a special "
"format, it uses the iCalendar format."
));
l
->
setBuddy
(
mArchiveFile
->
lineEdit
());
fileLayout
->
addWidget
(
mArchiveFile
);
topLayout
->
addLayout
(
fileLayout
);
QGroupBox
*
typeBox
=
new
QGroupBox
(
i18nc
(
"@title:group"
,
"Type of Items to Archive"
));
typeBox
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Here you can select which items "
"should be archived. Events are archived if they "
"ended before the date given above; to-dos are archived if "
"they were finished before the date."
));
typeBox
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Here you can select which items "
"should be archived. Events are archived if they "
"ended before the date given above; to-dos are archived if "
"they were finished before the date."
));
topLayout
->
addWidget
(
typeBox
);
QBoxLayout
*
typeLayout
=
new
QVBoxLayout
(
typeBox
);
mEvents
=
new
QCheckBox
(
i18nc
(
"@option:check"
,
"Archive &Events"
));
mEvents
->
setToolTip
(
i18nc
(
"@option:check"
,
"Archive or purge events"
));
mEvents
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select this option to archive events if they ended before the date given above."
));
mEvents
->
setToolTip
(
i18nc
(
"@option:check"
,
"Archive or purge events"
));
mEvents
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select this option to archive events if they ended before the date given above."
));
typeLayout
->
addWidget
(
mEvents
);
mTodos
=
new
QCheckBox
(
i18nc
(
"@option:check"
,
"Archive Completed &To-dos"
));
mTodos
->
setToolTip
(
i18nc
(
"@option:check"
,
"Archive or purge completed to-dos"
));
mTodos
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select this option to archive to-dos if they were completed "
"before the date given above."
));
mTodos
->
setToolTip
(
i18nc
(
"@option:check"
,
"Archive or purge completed to-dos"
));
mTodos
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select this option to archive to-dos if they were completed "
"before the date given above."
));
typeLayout
->
addWidget
(
mTodos
);
mDeleteCb
=
new
QCheckBox
(
i18nc
(
"@option:check"
,
"&Delete only, do not save"
),
topFrame
);
mDeleteCb
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Purge the old items without saving them"
));
mDeleteCb
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select this option to delete old events and to-dos without saving "
"them. It is not possible to recover the events later."
));
mDeleteCb
->
setToolTip
(
i18nc
(
"@info:tooltip"
,
"Purge the old items without saving them"
));
mDeleteCb
->
setWhatsThis
(
i18nc
(
"@info:whatsthis"
,
"Select this option to delete old events and to-dos without saving "
"them. It is not possible to recover the events later."
));
topLayout
->
addWidget
(
mDeleteCb
);
connect
(
mDeleteCb
,
&
QCheckBox
::
toggled
,
mArchiveFile
,
&
KUrlRequester
::
setDisabled
);
connect
(
mDeleteCb
,
&
QCheckBox
::
toggled
,
this
,
&
ArchiveDialog
::
slotEnableUser1
);
connect
(
mArchiveFile
->
lineEdit
(),
&
QLineEdit
::
textChanged
,
this
,
&
ArchiveDialog
::
slotEnableUser1
);
connect
(
mArchiveFile
->
lineEdit
(),
&
QLineEdit
::
textChanged
,
this
,
&
ArchiveDialog
::
slotEnableUser1
);
// Load settings from KCalPrefs
mExpiryTimeNumInput
->
setValue
(
KCalPrefs
::
instance
()
->
mExpiryTime
);
...
...
@@ -254,8 +212,7 @@ ArchiveDialog::~ArchiveDialog()
void
ArchiveDialog
::
slotEnableUser1
()
{
const
bool
state
=
(
mDeleteCb
->
isChecked
()
||
!
mArchiveFile
->
lineEdit
()
->
text
().
trimmed
().
isEmpty
());
const
bool
state
=
(
mDeleteCb
->
isChecked
()
||
!
mArchiveFile
->
lineEdit
()
->
text
().
trimmed
().
isEmpty
());
mUser1Button
->
setEnabled
(
state
);
}
...
...
@@ -289,11 +246,10 @@ void ArchiveDialog::slotUser1()
}
// Force filename to be ending with vCalendar extension
QString
filename
=
destUrl
.
fileName
();
if
(
!
filename
.
endsWith
(
QLatin1String
(
".vcs"
))
&&
!
filename
.
endsWith
(
QLatin1String
(
".ics"
)))
{
if
(
!
filename
.
endsWith
(
QLatin1String
(
".vcs"
))
&&
!
filename
.
endsWith
(
QLatin1String
(
".ics"
)))
{
filename
.
append
(
QLatin1String
(
".ics"
));
destUrl
=
destUrl
.
adjusted
(
QUrl
::
RemoveFilename
);
destUrl
.
setPath
(
destUrl
.
path
()
+
filename
);
destUrl
.
setPath
(
destUrl
.
path
()
+
filename
);
}
KCalPrefs
::
instance
()
->
mArchiveFile
=
destUrl
.
url
();
...
...
@@ -318,7 +274,7 @@ void ArchiveDialog::slotEventsDeleted()
void
ArchiveDialog
::
showWhatsThis
()
{
QWidget
*
widget
=
qobject_cast
<
QWidget
*
>
(
sender
());
QWidget
*
widget
=
qobject_cast
<
QWidget
*>
(
sender
());
if
(
widget
&&
!
widget
->
whatsThis
().
isEmpty
())
{
QWhatsThis
::
showText
(
QCursor
::
pos
(),
widget
->
whatsThis
());
}
...
...
src/archivedialog.h
View file @
fdd95875
...
...
@@ -21,12 +21,14 @@ class QCheckBox;
class
QRadioButton
;
class
QPushButton
;
namespace
Akonadi
{
namespace
Akonadi
{
class
IncidenceChanger
;
class
ETMCalendar
;
}
namespace
CalendarSupport
{
namespace
CalendarSupport
{
class
CALENDARSUPPORT_EXPORT
ArchiveDialog
:
public
QDialog
{
Q_OBJECT
...
...
src/attachmenthandler.cpp
View file @
fdd95875
...
...
@@ -18,31 +18,32 @@
@author Allen Winter \<winter@kde.org\>
*/
#include "attachmenthandler.h"
#include "calendarsupport_debug.h"
#include "calendarsupport/utils.h"
#include "calendarsupport_debug.h"
#include <ItemFetchJob>
#include <KLocalizedString>
#include <KMessageBox>
#include <KIO/FileCopyJob>
#include <KIO/StatJob>
#include <KJobWidgets>
#include <KJob>
#include <KIO/JobUiDelegate>
#include <KIO/OpenUrlJob>
#include <KIO/StatJob>
#include <KJob>
#include <KJobWidgets>
#include <KLocalizedString>
#include <KMessageBox>
#include <QFileDialog>
#include <QTemporaryFile>
#include <QDesktopServices>
#include <QFile>
#include <Q
Pointer
>
#include <Q
FileDialog
>
#include <QMimeDatabase>
#include <QDesktopServices>
#include <QPointer>
#include <QTemporaryFile>
using
namespace
KCalendarCore
;
using
namespace
Akonadi
;
namespace
CalendarSupport
{
namespace
CalendarSupport
{
struct
ReceivedInfo
{
QString
uid
;
QString
attachmentName
;
...
...
@@ -60,7 +61,8 @@ public:
QPointer
<
QWidget
>
const
mParent
;
};
AttachmentHandler
::
AttachmentHandler
(
QWidget
*
parent
)
:
QObject
(
parent
)
AttachmentHandler
::
AttachmentHandler
(
QWidget
*
parent
)
:
QObject
(
parent
)
,
d
(
new
Private
(
parent
))
{
}
...
...
@@ -92,9 +94,7 @@ Attachment AttachmentHandler::find(const QString &attachmentName, const Incidenc
}
if
(
a
.
isEmpty
())
{
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"No attachment named
\"
%1
\"
found in the incidence."
,
attachmentName
));
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"No attachment named
\"
%1
\"
found in the incidence."
,
attachmentName
));
return
Attachment
();
}
...
...
@@ -105,8 +105,7 @@ Attachment AttachmentHandler::find(const QString &attachmentName, const Incidenc
if
(
!
job
->
exec
())
{
KMessageBox
::
sorry
(
d
->
mParent
,
i18n
(
"The attachment
\"
%1
\"
is a web link that is inaccessible from this computer. "
,
QUrl
::
fromPercentEncoding
(
a
.
uri
().
toLatin1
())));
i18n
(
"The attachment
\"
%1
\"
is a web link that is inaccessible from this computer. "
,
QUrl
::
fromPercentEncoding
(
a
.
uri
().
toLatin1
())));
return
Attachment
();
}
}
...
...
@@ -121,10 +120,9 @@ Attachment AttachmentHandler::find(const QString &attachmentName, const Schedule
Incidence
::
Ptr
incidence
=
message
->
event
().
dynamicCast
<
Incidence
>
();
if
(
!
incidence
)
{
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"The calendar invitation stored in this email message is broken in some way. "
"Unable to continue."
));
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"The calendar invitation stored in this email message is broken in some way. "
"Unable to continue."
));
return
Attachment
();
}
...
...
@@ -140,9 +138,7 @@ static QUrl tempFileForAttachment(const Attachment &attachment)
QMimeDatabase
db
;
QStringList
patterns
=
db
.
mimeTypeForName
(
attachment
.
mimeType
()).
globPatterns
();
if
(
!
patterns
.
empty
())
{
s_tempFile
=
new
QTemporaryFile
(
QDir
::
tempPath
()
+
QLatin1String
(
"/attachementview_XXXXXX"
)
+
patterns
.
first
().
remove
(
QLatin1Char
(
'*'
)));
s_tempFile
=
new
QTemporaryFile
(
QDir
::
tempPath
()
+
QLatin1String
(
"/attachementview_XXXXXX"
)
+
patterns
.
first
().
remove
(
QLatin1Char
(
'*'
)));
}
else
{
s_tempFile
=
new
QTemporaryFile
();
}
...
...
@@ -153,7 +149,7 @@ static QUrl tempFileForAttachment(const Attachment &attachment)
s_tempFile
->
close
();
QFile
tf
(
s_tempFile
->
fileName
());
if
(
tf
.
size
()
!=
attachment
.
size
())
{
//whoops. failed to write the entire attachment. return an invalid URL.
//
whoops. failed to write the entire attachment. return an invalid URL.
delete
s_tempFile
;
s_tempFile
=
nullptr
;
return
url
;
...
...
@@ -182,9 +178,7 @@ bool AttachmentHandler::view(const Attachment &attachment)
job
->
start
();
}
else
{
stat
=
false
;
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"Unable to create a temporary file for the attachment."
));
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"Unable to create a temporary file for the attachment."
));
}
delete
s_tempFile
;
s_tempFile
=
nullptr
;
...
...
@@ -217,9 +211,7 @@ bool AttachmentHandler::view(const QString &attachmentName, const ScheduleMessag
bool
AttachmentHandler
::
saveAs
(
const
Attachment
&
attachment
)
{
// get the saveas file name
const
QString
saveAsFile
=
QFileDialog
::
getSaveFileName
(
d
->
mParent
,
i18n
(
"Save Attachment"
),
attachment
.
label
());
const
QString
saveAsFile
=
QFileDialog
::
getSaveFileName
(
d
->
mParent
,
i18n
(
"Save Attachment"
),
attachment
.
label
());
if
(
saveAsFile
.
isEmpty
())
{
return
false
;
}
...
...
@@ -240,9 +232,7 @@ bool AttachmentHandler::saveAs(const Attachment &attachment)
}
}
else
{
stat
=
false
;
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"Unable to create a temporary file for the attachment."
));
KMessageBox
::
error
(
d
->
mParent
,
i18n
(
"Unable to create a temporary file for the attachment."
));
}
delete
s_tempFile
;
s_tempFile
=
nullptr
;
...
...
src/attachmenthandler.h
View file @
fdd95875
...
...
@@ -24,7 +24,8 @@ class KJob;
class
QWidget
;
namespace
CalendarSupport
{
namespace
CalendarSupport
{
/**
@brief
Provides methods to handle incidence attachments.
...
...
@@ -35,7 +36,6 @@ class AttachmentHandler : public QObject
{
Q_OBJECT
public:
/**
* Constructs an AttachmentHandler.
* @param parent is the parent widget for the dialogs used by this class.
...
...
src/autotests/noteeditdialogtest.cpp
View file @
fdd95875
...
...
@@ -7,8 +7,8 @@
#include "noteeditdialogtest.h"
#include "noteeditdialog.h"
#include <AkonadiCore/EntityTreeModel>
#include <Akonadi/Notes/NoteUtils>
#include <AkonadiCore/EntityTreeModel>
#include <AkonadiWidgets/CollectionComboBox>
#include <KPIMTextEdit/RichTextEditor>
...
...
@@ -38,10 +38,8 @@ NoteEditDialogTest::NoteEditDialogTest()
collection
.
setContentMimeTypes
(
QStringList
()
<<
Akonadi
::
NoteUtils
::
noteMimeType
());
QStandardItem
*
item
=
new
QStandardItem
(
collection
.
name
());
item
->
setData
(
QVariant
::
fromValue
(
collection
),
Akonadi
::
EntityTreeModel
::
CollectionRole
);
item
->
setData
(
QVariant
::
fromValue
(
collection
.
id
()),
Akonadi
::
EntityTreeModel
::
CollectionIdRole
);
item
->
setData
(
QVariant
::
fromValue
(
collection
),
Akonadi
::
EntityTreeModel
::
CollectionRole
);
item
->
setData
(
QVariant
::
fromValue
(
collection
.
id
()),
Akonadi
::
EntityTreeModel
::
CollectionIdRole
);
model
->
appendRow
(
item
);
}
...
...
@@ -53,8 +51,7 @@ void NoteEditDialogTest::shouldHaveDefaultValuesOnCreation()
NoteEditDialog
edit
;
QVERIFY
(
!
edit
.
note
());
auto
notetitle
=
edit
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"notetitle"
));
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
auto
ok
=
edit
.
findChild
<
QPushButton
*>
(
QStringLiteral
(
"save-button"
));
QVERIFY
(
notetitle
);
QCOMPARE
(
notetitle
->
text
(),
QString
());
...
...
@@ -113,8 +110,7 @@ void NoteEditDialogTest::shouldHaveFilledText()
edit
.
load
(
item
);
auto
notetitle
=
edit
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"notetitle"
));
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
QCOMPARE
(
notetitle
->
text
(),
title
);
QCOMPARE
(
notetext
->
toPlainText
(),
text
);
}
...
...
@@ -133,8 +129,7 @@ void NoteEditDialogTest::shouldHaveRichText()
item
.
setPayload
(
note
.
message
());
edit
.
load
(
item
);
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
QCOMPARE
(
notetext
->
toPlainText
(),
text
);
QVERIFY
(
notetext
->
editor
()
->
acceptRichText
());
}
...
...
@@ -142,8 +137,7 @@ void NoteEditDialogTest::shouldHaveRichText()
void
NoteEditDialogTest
::
shouldDefaultCollectionIsValid
()
{
NoteEditDialog
edit
;
auto
*
akonadicombobox
=
edit
.
findChild
<
Akonadi
::
CollectionComboBox
*>
(
QStringLiteral
(
"akonadicombobox"
));
auto
*
akonadicombobox
=
edit
.
findChild
<
Akonadi
::
CollectionComboBox
*>
(
QStringLiteral
(
"akonadicombobox"
));
QVERIFY
(
akonadicombobox
);
QVERIFY
(
akonadicombobox
->
currentCollection
().
isValid
());
}
...
...
@@ -151,8 +145,7 @@ void NoteEditDialogTest::shouldDefaultCollectionIsValid()
void
NoteEditDialogTest
::
shouldEmitCollectionChangedWhenCurrentCollectionWasChanged
()
{
NoteEditDialog
edit
;
auto
*
akonadicombobox
=
edit
.
findChild
<
Akonadi
::
CollectionComboBox
*>
(
QStringLiteral
(
"akonadicombobox"
));
auto
*
akonadicombobox
=
edit
.
findChild
<
Akonadi
::
CollectionComboBox
*>
(
QStringLiteral
(
"akonadicombobox"
));
akonadicombobox
->
setCurrentIndex
(
0
);
QCOMPARE
(
akonadicombobox
->
currentIndex
(),
0
);
QSignalSpy
spy
(
&
edit
,
&
NoteEditDialog
::
collectionChanged
);
...
...
@@ -164,8 +157,7 @@ void NoteEditDialogTest::shouldEmitCollectionChangedWhenCurrentCollectionWasChan
void
NoteEditDialogTest
::
shouldEmitCorrectCollection
()
{
NoteEditDialog
edit
;
auto
*
akonadicombobox
=
edit
.
findChild
<
Akonadi
::
CollectionComboBox
*>
(
QStringLiteral
(
"akonadicombobox"
));
auto
*
akonadicombobox
=
edit
.
findChild
<
Akonadi
::
CollectionComboBox
*>
(
QStringLiteral
(
"akonadicombobox"
));
Akonadi
::
NoteUtils
::
NoteMessageWrapper
note
;
QString
title
=
QStringLiteral
(
"title"
);
...
...
@@ -219,14 +211,13 @@ void NoteEditDialogTest::shouldNotEmitNoteWhenTextIsEmpty()
QSignalSpy
spy
(
&
edit
,
&
NoteEditDialog
::
createNote
);
auto
ok
=
edit
.
findChild
<
QPushButton
*>
(
QStringLiteral
(
"save-button"
));
//Need to set title to empty, 'cause NoteUtils uses default title: "New Note"
//
Need to set title to empty, 'cause NoteUtils uses default title: "New Note"
auto
notetitle
=
edit
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"notetitle"
));
notetitle
->
setText
(
QString
());
QTest
::
mouseClick
(
ok
,
Qt
::
LeftButton
);
QCOMPARE
(
spy
.
count
(),
0
);
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
notetext
->
editor
()
->
setText
(
QStringLiteral
(
"F"
));
QTest
::
mouseClick
(
ok
,
Qt
::
LeftButton
);
QCOMPARE
(
spy
.
count
(),
1
);
...
...
@@ -248,17 +239,14 @@ void NoteEditDialogTest::shouldNoteHasCorrectText()
QTest
::
mouseClick
(
ok
,
Qt
::
LeftButton
);
QCOMPARE
(
spy
.
count
(),
1
);
Akonadi
::
NoteUtils
::
NoteMessageWrapper
rNote
(
spy
.
at
(
0
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
Akonadi
::
NoteUtils
::
NoteMessageWrapper
rNote
(
spy
.
at
(
0
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
QCOMPARE
(
rNote
.
text
(),
text
);
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
auto
*
notetext
=
edit
.
findChild
<
KPIMTextEdit
::
RichTextEditorWidget
*>
(
QStringLiteral
(
"notetext"
));
QString
text2
=
QStringLiteral
(
"F"
);
notetext
->
editor
()
->
setText
(
text2
);
QTest
::
mouseClick
(
ok
,
Qt
::
LeftButton
);
QCOMPARE
(
spy
.
count
(),
2
);
Akonadi
::
NoteUtils
::
NoteMessageWrapper
r2Note
(
spy
.
at
(
1
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
Akonadi
::
NoteUtils
::
NoteMessageWrapper
r2Note
(
spy
.
at
(
1
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
QCOMPARE
(
r2Note
.
text
(),
text2
);
}
...
...
@@ -278,16 +266,14 @@ void NoteEditDialogTest::shouldNoteHasCorrectTitle()
QTest
::
mouseClick
(
ok
,
Qt
::
LeftButton
);
QCOMPARE
(
spy
.
count
(),
1
);
Akonadi
::
NoteUtils
::
NoteMessageWrapper
rNote
(
spy
.
at
(
0
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
Akonadi
::
NoteUtils
::
NoteMessageWrapper
rNote
(
spy
.
at
(
0
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
QCOMPARE
(
rNote
.
title
(),
text
);
auto
notetitle
=
edit
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"notetitle"
));
QString
text2
=
QStringLiteral
(
"F"
);
notetitle
->
setText
(
text2
);
QTest
::
mouseClick
(
ok
,
Qt
::
LeftButton
);
QCOMPARE
(
spy
.
count
(),
2
);
Akonadi
::
NoteUtils
::
NoteMessageWrapper
r2Note
(
spy
.
at
(
1
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
Akonadi
::
NoteUtils
::
NoteMessageWrapper
r2Note
(
spy
.
at
(
1
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());
QCOMPARE
(
r2Note
.
title
(),
text2
);
}
...
...
@@ -307,16 +293,13 @@ void NoteEditDialogTest::shouldNoteHasCorrectTextFormat()
QTest
::
mouseClick
(
ok
,
Qt
::
LeftButton
);
QCOMPARE
(
spy
.
count
(),
1
);
Akonadi
::
NoteUtils
::
NoteMessageWrapper
rNote
(
spy
.
at
(
0
).
at
(
0
).
value
<
Akonadi
::
Item
>
().
payload
<
KMime
::
Message
::
Ptr
>
());