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
Akonadi Console
Commits
33f7c2e8
Commit
33f7c2e8
authored
May 02, 2021
by
Laurent Montel
😁
Browse files
Modernize code
parent
d1ff850d
Pipeline
#60424
passed with stage
in 5 minutes and 33 seconds
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
autotests/jobtrackersearchwidgettest.cpp
View file @
33f7c2e8
...
...
@@ -25,7 +25,7 @@ JobTrackerSearchWidgetTest::~JobTrackerSearchWidgetTest()
void
JobTrackerSearchWidgetTest
::
shouldHaveDefaultValue
()
{
JobTrackerSearchWidget
w
;
auto
*
mainLayout
=
w
.
findChild
<
QHBoxLayout
*>
(
QStringLiteral
(
"mainlayout"
));
auto
mainLayout
=
w
.
findChild
<
QHBoxLayout
*>
(
QStringLiteral
(
"mainlayout"
));
QVERIFY
(
mainLayout
);
int
top
=
-
1
;
int
bottom
=
-
1
;
...
...
@@ -37,17 +37,17 @@ void JobTrackerSearchWidgetTest::shouldHaveDefaultValue()
QCOMPARE
(
left
,
0
);
QCOMPARE
(
right
,
0
);
auto
*
mSearchLineEdit
=
w
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"searchline"
));
auto
mSearchLineEdit
=
w
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"searchline"
));
QVERIFY
(
mSearchLineEdit
);
QVERIFY
(
mSearchLineEdit
->
isClearButtonEnabled
());
QVERIFY
(
mSearchLineEdit
->
text
().
isEmpty
());
auto
*
mSelectColumn
=
w
.
findChild
<
QComboBox
*>
(
QStringLiteral
(
"selectcolumn"
));
auto
mSelectColumn
=
w
.
findChild
<
QComboBox
*>
(
QStringLiteral
(
"selectcolumn"
));
QVERIFY
(
mSelectColumn
);
QCOMPARE
(
mSelectColumn
->
count
(),
8
);
QCOMPARE
(
mSelectColumn
->
currentIndex
(),
0
);
auto
*
mSelectOnlyError
=
w
.
findChild
<
QCheckBox
*>
(
QStringLiteral
(
"selectonlyerror"
));
auto
mSelectOnlyError
=
w
.
findChild
<
QCheckBox
*>
(
QStringLiteral
(
"selectonlyerror"
));
QVERIFY
(
mSelectOnlyError
);
QVERIFY
(
!
mSelectOnlyError
->
text
().
isEmpty
());
QCOMPARE
(
mSelectOnlyError
->
checkState
(),
Qt
::
Unchecked
);
...
...
@@ -57,7 +57,7 @@ void JobTrackerSearchWidgetTest::shouldEmitSignal()
{
JobTrackerSearchWidget
w
;
QSignalSpy
searchWidgetSignal
(
&
w
,
&
JobTrackerSearchWidget
::
searchTextChanged
);
auto
*
mSearchLineEdit
=
w
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"searchline"
));
auto
mSearchLineEdit
=
w
.
findChild
<
QLineEdit
*>
(
QStringLiteral
(
"searchline"
));
const
QString
foo
=
QStringLiteral
(
"foo"
);
mSearchLineEdit
->
setText
(
foo
);
QCOMPARE
(
searchWidgetSignal
.
count
(),
1
);
...
...
@@ -71,7 +71,7 @@ void JobTrackerSearchWidgetTest::shouldEmitColumnChanged()
{
JobTrackerSearchWidget
w
;
QSignalSpy
columnChangedSignal
(
&
w
,
&
JobTrackerSearchWidget
::
columnChanged
);
auto
*
mSelectColumn
=
w
.
findChild
<
QComboBox
*>
(
QStringLiteral
(
"selectcolumn"
));
auto
mSelectColumn
=
w
.
findChild
<
QComboBox
*>
(
QStringLiteral
(
"selectcolumn"
));
mSelectColumn
->
setCurrentIndex
(
2
);
QCOMPARE
(
columnChangedSignal
.
count
(),
1
);
}
...
...
@@ -80,7 +80,7 @@ void JobTrackerSearchWidgetTest::shouldEmitSelectOnlyErrorChanged()
{
JobTrackerSearchWidget
w
;
QSignalSpy
selectOnlyErrorChangedSignal
(
&
w
,
&
JobTrackerSearchWidget
::
selectOnlyErrorChanged
);
auto
*
mSelectOnlyError
=
w
.
findChild
<
QCheckBox
*>
(
QStringLiteral
(
"selectonlyerror"
));
auto
mSelectOnlyError
=
w
.
findChild
<
QCheckBox
*>
(
QStringLiteral
(
"selectonlyerror"
));
mSelectOnlyError
->
setChecked
(
true
);
QCOMPARE
(
selectOnlyErrorChangedSignal
.
count
(),
1
);
}
...
...
src/akonadibrowsermodel.cpp
View file @
33f7c2e8
...
...
@@ -86,7 +86,7 @@ public:
if
(
!
item
.
hasPayload
<
KMime
::
Message
::
Ptr
>
())
{
return
QVariant
();
}
const
KMime
::
Message
::
Ptr
mail
=
item
.
payload
<
KMime
::
Message
::
Ptr
>
();
const
auto
mail
=
item
.
payload
<
KMime
::
Message
::
Ptr
>
();
// NOTE: remember to update AkonadiBrowserSortModel::lessThan if you insert/move columns
switch
(
column
)
{
...
...
@@ -138,7 +138,7 @@ public:
}
if
(
item
.
hasPayload
<
KContacts
::
Addressee
>
())
{
const
KContacts
::
Addressee
addr
=
item
.
payload
<
KContacts
::
Addressee
>
();
const
auto
addr
=
item
.
payload
<
KContacts
::
Addressee
>
();
switch
(
column
)
{
case
0
:
...
...
@@ -153,7 +153,7 @@ public:
if
(
item
.
hasPayload
<
KContacts
::
ContactGroup
>
())
{
switch
(
column
)
{
case
0
:
const
KContacts
::
ContactGroup
group
=
item
.
payload
<
KContacts
::
ContactGroup
>
();
const
auto
group
=
item
.
payload
<
KContacts
::
ContactGroup
>
();
return
group
.
name
();
}
return
QVariant
();
...
...
@@ -185,7 +185,7 @@ public:
if
(
!
item
.
hasPayload
<
IncidencePtr
>
())
{
return
QVariant
();
}
const
IncidencePtr
incidence
=
item
.
payload
<
IncidencePtr
>
();
const
auto
incidence
=
item
.
payload
<
IncidencePtr
>
();
// NOTE: remember to update AkonadiBrowserSortModel::lessThan if you insert/move columns
switch
(
column
)
{
case
0
:
...
...
@@ -348,8 +348,8 @@ bool AkonadiBrowserSortModel::lessThan(const QModelIndex &left, const QModelInde
if
(
!
leftItem
.
hasPayload
<
IncidencePtr
>
()
||
!
rightItem
.
hasPayload
<
IncidencePtr
>
())
{
return
false
;
}
const
IncidencePtr
leftInc
=
leftItem
.
payload
<
IncidencePtr
>
();
const
IncidencePtr
rightInc
=
rightItem
.
payload
<
IncidencePtr
>
();
const
auto
leftInc
=
leftItem
.
payload
<
IncidencePtr
>
();
const
auto
rightInc
=
rightItem
.
payload
<
IncidencePtr
>
();
if
(
left
.
column
()
==
1
)
{
return
leftInc
->
dtStart
()
<
rightInc
->
dtStart
();
...
...
@@ -364,8 +364,8 @@ bool AkonadiBrowserSortModel::lessThan(const QModelIndex &left, const QModelInde
if
(
!
leftItem
.
hasPayload
<
KMime
::
Message
::
Ptr
>
()
||
!
rightItem
.
hasPayload
<
KMime
::
Message
::
Ptr
>
())
{
return
false
;
}
const
KMime
::
Message
::
Ptr
leftMail
=
leftItem
.
payload
<
KMime
::
Message
::
Ptr
>
();
const
KMime
::
Message
::
Ptr
rightMail
=
rightItem
.
payload
<
KMime
::
Message
::
Ptr
>
();
const
auto
leftMail
=
leftItem
.
payload
<
KMime
::
Message
::
Ptr
>
();
const
auto
rightMail
=
rightItem
.
payload
<
KMime
::
Message
::
Ptr
>
();
const
KMime
::
Headers
::
Date
*
ldate
=
leftMail
->
date
(
false
);
const
KMime
::
Headers
::
Date
*
rdate
=
rightMail
->
date
(
false
);
if
(
ldate
&&
rdate
)
{
...
...
src/browserwidget.cpp
View file @
33f7c2e8
...
...
@@ -116,7 +116,7 @@ BrowserWidget::BrowserWidget(KXmlGuiWindow *xmlGuiWindow, QWidget *parent)
connect
(
mTagView
,
&
QTreeView
::
customContextMenuRequested
,
this
,
&
BrowserWidget
::
tagViewContextMenuRequested
);
connect
(
mTagView
,
&
QTreeView
::
doubleClicked
,
this
,
&
BrowserWidget
::
tagViewDoubleClicked
);
Session
*
session
=
new
Session
((
"AkonadiConsole Browser Widget"
),
this
);
auto
session
=
new
Session
((
"AkonadiConsole Browser Widget"
),
this
);
// monitor collection changes
mBrowserMonitor
=
new
ChangeRecorder
(
this
);
...
...
@@ -384,7 +384,7 @@ void BrowserWidget::setItem(const Akonadi::Item &item)
mAttrModel
=
new
QStandardItemModel
();
QStringList
labels
{
QStringLiteral
(
"Attribute"
),
QStringLiteral
(
"Value"
)};
mAttrModel
->
setHorizontalHeaderLabels
(
labels
);
for
(
const
auto
*
attr
:
list
)
{
for
(
const
auto
attr
:
list
)
{
auto
type
=
new
QStandardItem
(
QString
::
fromLatin1
(
attr
->
type
()));
type
->
setEditable
(
false
);
mAttrModel
->
appendRow
({
type
,
new
QStandardItem
(
QString
::
fromLatin1
(
attr
->
serialized
()))});
...
...
@@ -619,7 +619,7 @@ void BrowserWidget::addTagRequested()
void
BrowserWidget
::
addSubTagRequested
()
{
auto
action
=
qobject_cast
<
QAction
*>
(
sender
());
const
Akonadi
::
Tag
parentTag
=
action
->
parent
()
->
property
(
"Tag"
).
value
<
Akonadi
::
Tag
>
();
const
auto
parentTag
=
action
->
parent
()
->
property
(
"Tag"
).
value
<
Akonadi
::
Tag
>
();
Akonadi
::
Tag
tag
;
tag
.
setParent
(
parentTag
);
...
...
@@ -633,7 +633,7 @@ void BrowserWidget::addSubTagRequested()
void
BrowserWidget
::
editTagRequested
()
{
auto
action
=
qobject_cast
<
QAction
*>
(
sender
());
const
Akonadi
::
Tag
tag
=
action
->
parent
()
->
property
(
"Tag"
).
value
<
Akonadi
::
Tag
>
();
const
auto
tag
=
action
->
parent
()
->
property
(
"Tag"
).
value
<
Akonadi
::
Tag
>
();
auto
dlg
=
new
TagPropertiesDialog
(
tag
,
this
);
connect
(
dlg
,
&
TagPropertiesDialog
::
accepted
,
this
,
&
BrowserWidget
::
modifyTag
);
connect
(
dlg
,
&
TagPropertiesDialog
::
rejected
,
dlg
,
&
TagPropertiesDialog
::
deleteLater
);
...
...
@@ -647,7 +647,7 @@ void BrowserWidget::tagViewDoubleClicked(const QModelIndex &index)
return
;
}
const
Akonadi
::
Tag
tag
=
mTagModel
->
data
(
index
,
TagModel
::
TagRole
).
value
<
Akonadi
::
Tag
>
();
const
auto
tag
=
mTagModel
->
data
(
index
,
TagModel
::
TagRole
).
value
<
Akonadi
::
Tag
>
();
Q_ASSERT
(
tag
.
isValid
());
auto
dlg
=
new
TagPropertiesDialog
(
tag
,
this
);
...
...
@@ -670,7 +670,7 @@ void BrowserWidget::removeTagRequested()
}
auto
action
=
qobject_cast
<
QAction
*>
(
sender
());
const
Akonadi
::
Tag
tag
=
action
->
parent
()
->
property
(
"Tag"
).
value
<
Akonadi
::
Tag
>
();
const
auto
tag
=
action
->
parent
()
->
property
(
"Tag"
).
value
<
Akonadi
::
Tag
>
();
new
Akonadi
::
TagDeleteJob
(
tag
,
this
);
}
...
...
src/connectionpage.cpp
View file @
33f7c2e8
...
...
@@ -53,8 +53,7 @@ ConnectionPage::ConnectionPage(const QString &identifier, QWidget *parent)
layout
->
addWidget
(
mDataView
);
org
::
freedesktop
::
Akonadi
::
TracerNotification
*
iface
=
new
org
::
freedesktop
::
Akonadi
::
TracerNotification
(
QString
(),
QStringLiteral
(
"/tracing/notifications"
),
QDBusConnection
::
sessionBus
(),
this
);
auto
iface
=
new
org
::
freedesktop
::
Akonadi
::
TracerNotification
(
QString
(),
QStringLiteral
(
"/tracing/notifications"
),
QDBusConnection
::
sessionBus
(),
this
);
connect
(
iface
,
&
OrgFreedesktopAkonadiTracerNotificationInterface
::
connectionDataInput
,
this
,
&
ConnectionPage
::
connectionDataInput
);
connect
(
iface
,
&
OrgFreedesktopAkonadiTracerNotificationInterface
::
connectionDataOutput
,
this
,
&
ConnectionPage
::
connectionDataOutput
);
...
...
src/debugwidget.cpp
View file @
33f7c2e8
...
...
@@ -35,7 +35,7 @@ DebugWidget::DebugWidget(QWidget *parent)
service
+=
QLatin1Char
(
'.'
)
+
Akonadi
::
ServerManager
::
instanceIdentifier
();
}
mDebugInterface
=
new
DebugInterface
(
service
,
QStringLiteral
(
"/debug"
),
QDBusConnection
::
sessionBus
(),
this
);
QCheckBox
*
cb
=
new
QCheckBox
(
QStringLiteral
(
"Enable debugger"
),
this
);
auto
cb
=
new
QCheckBox
(
QStringLiteral
(
"Enable debugger"
),
this
);
cb
->
setChecked
(
mDebugInterface
->
isValid
()
&&
mDebugInterface
->
tracer
().
value
()
==
QLatin1String
(
"dbus"
));
connect
(
cb
,
&
QCheckBox
::
toggled
,
this
,
&
DebugWidget
::
enableDebugger
);
layout
->
addWidget
(
cb
);
...
...
@@ -50,8 +50,7 @@ DebugWidget::DebugWidget(QWidget *parent)
mGeneralView
=
new
KTextEdit
(
splitter
);
mGeneralView
->
setReadOnly
(
true
);
org
::
freedesktop
::
Akonadi
::
TracerNotification
*
iface
=
new
org
::
freedesktop
::
Akonadi
::
TracerNotification
(
QString
(),
QStringLiteral
(
"/tracing/notifications"
),
QDBusConnection
::
sessionBus
(),
this
);
auto
iface
=
new
org
::
freedesktop
::
Akonadi
::
TracerNotification
(
QString
(),
QStringLiteral
(
"/tracing/notifications"
),
QDBusConnection
::
sessionBus
(),
this
);
connect
(
iface
,
&
org
::
freedesktop
::
Akonadi
::
TracerNotification
::
signalEmitted
,
this
,
&
DebugWidget
::
signalEmitted
);
connect
(
iface
,
&
org
::
freedesktop
::
Akonadi
::
TracerNotification
::
warningEmitted
,
this
,
&
DebugWidget
::
warningEmitted
);
...
...
@@ -60,11 +59,11 @@ DebugWidget::DebugWidget(QWidget *parent)
auto
buttonLayout
=
new
QHBoxLayout
;
layout
->
addLayout
(
buttonLayout
);
QPushButton
*
clearGeneralButton
=
new
QPushButton
(
QStringLiteral
(
"Clear Information View"
),
this
);
QPushButton
*
clearFilteredButton
=
new
QPushButton
(
QStringLiteral
(
"Clear Filtered Messages"
),
this
);
QPushButton
*
clearAllButton
=
new
QPushButton
(
QStringLiteral
(
"Clear All Messages"
),
this
);
QPushButton
*
saveRichtextButton
=
new
QPushButton
(
QStringLiteral
(
"Save Filtered Messages ..."
),
this
);
QPushButton
*
saveRichtextEverythingButton
=
new
QPushButton
(
QStringLiteral
(
"Save All Messages ..."
),
this
);
auto
clearGeneralButton
=
new
QPushButton
(
QStringLiteral
(
"Clear Information View"
),
this
);
auto
clearFilteredButton
=
new
QPushButton
(
QStringLiteral
(
"Clear Filtered Messages"
),
this
);
auto
clearAllButton
=
new
QPushButton
(
QStringLiteral
(
"Clear All Messages"
),
this
);
auto
saveRichtextButton
=
new
QPushButton
(
QStringLiteral
(
"Save Filtered Messages ..."
),
this
);
auto
saveRichtextEverythingButton
=
new
QPushButton
(
QStringLiteral
(
"Save All Messages ..."
),
this
);
buttonLayout
->
addWidget
(
clearFilteredButton
);
buttonLayout
->
addWidget
(
clearAllButton
);
...
...
src/jobtrackerwidget.cpp
View file @
33f7c2e8
...
...
@@ -68,7 +68,7 @@ JobTrackerWidget::JobTrackerWidget(const char *name, QWidget *parent, const QStr
d
->
model
->
setEnabled
(
false
);
// since it can be slow, default to off
auto
layout2
=
new
QHBoxLayout
;
QPushButton
*
button
=
new
QPushButton
(
QStringLiteral
(
"Save to file..."
),
this
);
auto
button
=
new
QPushButton
(
QStringLiteral
(
"Save to file..."
),
this
);
connect
(
button
,
&
QAbstractButton
::
clicked
,
this
,
&
JobTrackerWidget
::
slotSaveToFile
);
layout2
->
addWidget
(
button
);
layout2
->
addStretch
(
1
);
...
...
src/searchwidget.cpp
View file @
33f7c2e8
...
...
@@ -201,7 +201,7 @@ void SearchWidget::fetchItem(const QModelIndex &index)
return
;
}
Akonadi
::
ItemFetchJob
*
fetchJob
=
new
Akonadi
::
ItemFetchJob
(
Akonadi
::
Item
(
docId
));
auto
fetchJob
=
new
Akonadi
::
ItemFetchJob
(
Akonadi
::
Item
(
docId
));
fetchJob
->
fetchScope
().
fetchFullPayload
();
connect
(
fetchJob
,
&
Akonadi
::
ItemFetchJob
::
result
,
this
,
&
SearchWidget
::
itemFetched
);
}
...
...
src/tagpropertiesdialog.cpp
View file @
33f7c2e8
...
...
@@ -110,7 +110,7 @@ void TagPropertiesDialog::setupUi()
if
(
query
.
exec
())
{
while
(
query
.
next
())
{
QList
<
QStandardItem
*>
items
;
QStandardItem
*
item
=
new
QStandardItem
(
query
.
value
(
0
).
toString
());
auto
item
=
new
QStandardItem
(
query
.
value
(
0
).
toString
());
item
->
setEditable
(
false
);
items
<<
item
;
item
=
new
QStandardItem
(
query
.
value
(
1
).
toString
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment