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
e8960ad9
Commit
e8960ad9
authored
Jan 26, 2021
by
Laurent Montel
😁
Browse files
run git clang-format
parent
d1998f19
Changes
60
Hide whitespace changes
Inline
Side-by-side
autotests/jobtrackermodeltest.cpp
View file @
e8960ad9
...
...
@@ -9,9 +9,9 @@
#include "jobtracker.h"
#include "jobtrackermodel.h"
//#include "modeltest.h"
#include <akonadi/private/instance_p.h>
#include <QSignalSpy>
#include <QTest>
#include <akonadi/private/instance_p.h>
static
QString
rowSpyToText
(
const
QSignalSpy
&
spy
)
{
...
...
@@ -54,12 +54,11 @@ void JobTrackerModelTest::shouldDisplayOneJob()
{
// GIVEN
JobTrackerModel
model
(
"jobtracker"
);
//ModelTest modelTest(&model);
//
ModelTest modelTest(&model);
const
QString
jobName
(
QStringLiteral
(
"job1"
));
QSignalSpy
rowATBISpy
(
&
model
,
&
QAbstractItemModel
::
rowsAboutToBeInserted
);
QSignalSpy
rowInsertedSpy
(
&
model
,
&
QAbstractItemModel
::
rowsInserted
);
connect
(
&
model
,
&
QAbstractItemModel
::
rowsAboutToBeInserted
,
this
,
[
&
](
const
QModelIndex
&
parent
)
{
connect
(
&
model
,
&
QAbstractItemModel
::
rowsAboutToBeInserted
,
this
,
[
&
](
const
QModelIndex
&
parent
)
{
// rowsAboutToBeInserted is supposed to be emitted before the insert
if
(
!
parent
.
isValid
())
{
QCOMPARE
(
model
.
rowCount
(),
0
);
...
...
@@ -67,8 +66,7 @@ void JobTrackerModelTest::shouldDisplayOneJob()
QCOMPARE
(
model
.
rowCount
(
parent
),
0
);
}
});
connect
(
&
model
,
&
QAbstractItemModel
::
rowsInserted
,
this
,
[
&
](
const
QModelIndex
&
parent
)
{
connect
(
&
model
,
&
QAbstractItemModel
::
rowsInserted
,
this
,
[
&
](
const
QModelIndex
&
parent
)
{
if
(
!
parent
.
isValid
())
{
QCOMPARE
(
model
.
rowCount
(),
1
);
QVERIFY
(
model
.
index
(
0
,
0
).
isValid
());
...
...
autotests/jobtrackersearchwidgettest.cpp
View file @
e8960ad9
...
...
@@ -6,12 +6,12 @@
#include "jobtrackersearchwidgettest.h"
#include "jobtrackersearchwidget.h"
#include <QTest>
#include <QCheckBox>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QSignalSpy>
#include <QComboBox>
#include <QCheckBox>
#include <QTest>
JobTrackerSearchWidgetTest
::
JobTrackerSearchWidgetTest
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
autotests/jobtrackertest.cpp
View file @
e8960ad9
...
...
@@ -7,13 +7,13 @@
#include "jobtrackertest.h"
#include "jobtracker.h"
#include <akonadi/private/instance_p.h>
#include <QSignalSpy>
#include <QTest>
#include <akonadi/private/instance_p.h>
static
QString
intPairListToString
(
const
QVariant
&
var
)
{
const
auto
arg
=
var
.
value
<
QList
<
QPair
<
int
,
int
>
>
>
();
const
auto
arg
=
var
.
value
<
QList
<
QPair
<
int
,
int
>
>
>
();
QString
ret
;
for
(
const
auto
&
pair
:
arg
)
{
if
(
!
ret
.
isEmpty
())
{
...
...
@@ -38,7 +38,7 @@ void JobTrackerTest::initTestCase()
// Don't interfere with a running akonadiconsole
Akonadi
::
Instance
::
setIdentifier
(
QStringLiteral
(
"jobtrackertest"
));
qRegisterMetaType
<
QList
<
QPair
<
int
,
int
>
>
>
();
qRegisterMetaType
<
QList
<
QPair
<
int
,
int
>
>
>
();
}
void
JobTrackerTest
::
shouldBeEmpty
()
...
...
src/agentconfigdialog.cpp
View file @
e8960ad9
...
...
@@ -6,9 +6,9 @@
#include "agentconfigdialog.h"
#include "agentconfigmodel.h"
#include <KGuiItem>
#include <QDialogButtonBox>
#include <QPushButton>
#include <KGuiItem>
#include <QVBoxLayout>
AgentConfigDialog
::
AgentConfigDialog
(
QWidget
*
parent
)
...
...
src/agentconfigmodel.cpp
View file @
e8960ad9
...
...
@@ -6,11 +6,12 @@
#include "agentconfigmodel.h"
#include "akonadiconsole_debug.h"
#include <QDBusInterface>
#include <QMetaMethod>
#include "akonadiconsole_debug.h"
AgentConfigModel
::
AgentConfigModel
(
QObject
*
parent
)
:
QAbstractTableModel
(
parent
)
AgentConfigModel
::
AgentConfigModel
(
QObject
*
parent
)
:
QAbstractTableModel
(
parent
)
,
m_interface
(
nullptr
)
{
}
...
...
@@ -25,9 +26,7 @@ void AgentConfigModel::setAgentInstance(const Akonadi::AgentInstance &instance)
beginResetModel
();
m_settings
.
clear
();
m_interface
=
new
QDBusInterface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
instance
.
identifier
()),
QStringLiteral
(
"/Settings"
));
m_interface
=
new
QDBusInterface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
instance
.
identifier
()),
QStringLiteral
(
"/Settings"
));
if
(
!
m_interface
->
isValid
())
{
qCritical
()
<<
"Unable to obtain KConfigXT D-Bus interface of agent"
<<
instance
.
identifier
();
delete
m_interface
;
...
...
@@ -43,17 +42,17 @@ void AgentConfigModel::reload()
m_settings
.
clear
();
for
(
int
i
=
0
;
i
<
m_interface
->
metaObject
()
->
methodCount
();
++
i
)
{
const
QMetaMethod
method
=
m_interface
->
metaObject
()
->
method
(
i
);
if
(
QByteArray
(
method
.
typeName
()).
isEmpty
())
{
// returns void
if
(
QByteArray
(
method
.
typeName
()).
isEmpty
())
{
// returns void
continue
;
}
const
QByteArray
signature
(
method
.
methodSignature
());
if
(
signature
.
isEmpty
())
{
continue
;
}
if
(
signature
.
startsWith
(
"set"
)
||
!
signature
.
contains
(
"()"
))
{
// setter or takes parameters // krazy:exclude=strings
if
(
signature
.
startsWith
(
"set"
)
||
!
signature
.
contains
(
"()"
))
{
// setter or takes parameters // krazy:exclude=strings
continue
;
}
if
(
signature
.
startsWith
(
"Introspect"
))
{
// D-Bus stuff // krazy:exclude=strings
if
(
signature
.
startsWith
(
"Introspect"
))
{
// D-Bus stuff // krazy:exclude=strings
continue
;
}
const
QString
methodName
=
QString
::
fromLatin1
(
signature
.
left
(
signature
.
indexOf
(
'('
)));
...
...
src/agentconfigmodel.h
View file @
e8960ad9
...
...
@@ -34,7 +34,7 @@ public Q_SLOTS:
void
writeConfig
();
private:
QVector
<
QPair
<
QString
,
QVariant
>
>
m_settings
;
QVector
<
QPair
<
QString
,
QVariant
>>
m_settings
;
QDBusInterface
*
m_interface
=
nullptr
;
};
...
...
src/agentwidget.cpp
View file @
e8960ad9
...
...
@@ -10,31 +10,31 @@
#include "agentconfigdialog.h"
#include "akonadiconsole_debug.h"
#include <AkonadiWidgets/agenttypedialog.h>
#include <AkonadiWidgets/agentinstancewidget.h>
#include <AkonadiCore/agentmanager.h>
#include <AkonadiCore/AgentFilterProxyModel>
#include <AkonadiCore/agentinstancecreatejob.h>
#include <Akonadi
Widgets/controlgui
.h>
#include <Akonadi
Core/agentmanager
.h>
#include <AkonadiWidgets/AgentConfigurationDialog>
#include <AkonadiWidgets/agentinstancewidget.h>
#include <AkonadiWidgets/agenttypedialog.h>
#include <AkonadiWidgets/controlgui.h>
#include <KLocalizedString>
#include <KMessageBox>
#include <KStandardGuiItem>
#include <QIcon>
#include <QPointer>
#include <QMenu>
#include <QPushButton>
#include <KGuiItem>
#include <QDBusInterface>
#include <QDBusMessage>
#include <QDBusReply>
#include <QDialogButtonBox>
#include <QMenu>
#include <QMetaMethod>
#include <QPlainTextEdit>
#include <QPointer>
#include <QPushButton>
#include <QResizeEvent>
#include <KGuiItem>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QPlainTextEdit>
class
TextDialog
:
public
QDialog
{
...
...
@@ -120,7 +120,7 @@ AgentWidget::AgentWidget(QWidget *parent)
ui
.
abortButton
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"dialog-cancel"
)));
connect
(
ui
.
abortButton
,
&
QPushButton
::
clicked
,
this
,
&
AgentWidget
::
abortAgent
);
ui
.
restartButton
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"system-reboot"
)));
//FIXME: Is using system-reboot icon here a good idea?
ui
.
restartButton
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"system-reboot"
)));
//
FIXME: Is using system-reboot icon here a good idea?
connect
(
ui
.
restartButton
,
&
QPushButton
::
clicked
,
this
,
&
AgentWidget
::
restartAgent
);
ui
.
instanceWidget
->
agentFilterProxyModel
()
->
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
...
...
@@ -194,15 +194,14 @@ void AgentWidget::removeAgent()
{
const
AgentInstance
::
List
list
=
ui
.
instanceWidget
->
selectedAgentInstances
();
if
(
!
list
.
isEmpty
())
{
if
(
KMessageBox
::
questionYesNo
(
this
,
i18np
(
"Do you really want to delete the selected agent instance?"
,
"Do you really want to delete these %1 agent instances?"
,
list
.
size
()),
list
.
size
()
==
1
?
QStringLiteral
(
"Agent Deletion"
)
:
QStringLiteral
(
"Multiple Agent Deletion"
),
KStandardGuiItem
::
del
(),
KStandardGuiItem
::
cancel
(),
QString
(),
KMessageBox
::
Dangerous
)
if
(
KMessageBox
::
questionYesNo
(
this
,
i18np
(
"Do you really want to delete the selected agent instance?"
,
"Do you really want to delete these %1 agent instances?"
,
list
.
size
()),
list
.
size
()
==
1
?
QStringLiteral
(
"Agent Deletion"
)
:
QStringLiteral
(
"Multiple Agent Deletion"
),
KStandardGuiItem
::
del
(),
KStandardGuiItem
::
cancel
(),
QString
(),
KMessageBox
::
Dangerous
)
==
KMessageBox
::
Yes
)
{
for
(
const
AgentInstance
&
agent
:
list
)
{
AgentManager
::
self
()
->
removeInstance
(
agent
);
...
...
@@ -257,8 +256,7 @@ void AgentWidget::showTaskList()
return
;
}
QDBusInterface
iface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
agent
.
identifier
()),
QStringLiteral
(
"/Debug"
),
QString
());
QDBusInterface
iface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
agent
.
identifier
()),
QStringLiteral
(
"/Debug"
),
QString
());
QDBusReply
<
QString
>
reply
=
iface
.
call
(
QStringLiteral
(
"dumpToString"
));
QString
txt
;
...
...
@@ -282,8 +280,7 @@ void AgentWidget::showChangeNotifications()
return
;
}
QDBusInterface
iface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
agent
.
identifier
()),
QStringLiteral
(
"/Debug"
),
QString
());
QDBusInterface
iface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
agent
.
identifier
()),
QStringLiteral
(
"/Debug"
),
QString
());
QDBusReply
<
QString
>
reply
=
iface
.
call
(
QStringLiteral
(
"dumpNotificationListToString"
));
QString
txt
;
...
...
@@ -352,15 +349,13 @@ void AgentWidget::cloneAgent(KJob *job)
Q_ASSERT
(
cloneTarget
.
isValid
());
Q_ASSERT
(
mCloneSource
.
isValid
());
QDBusInterface
sourceIface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
mCloneSource
.
identifier
()),
QStringLiteral
(
"/Settings"
));
QDBusInterface
sourceIface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
mCloneSource
.
identifier
()),
QStringLiteral
(
"/Settings"
));
if
(
!
sourceIface
.
isValid
())
{
qCritical
()
<<
"Unable to obtain KConfigXT D-Bus interface of source agent"
<<
mCloneSource
.
identifier
();
return
;
}
QDBusInterface
targetIface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
cloneTarget
.
identifier
()),
QStringLiteral
(
"/Settings"
));
QDBusInterface
targetIface
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.%1"
).
arg
(
cloneTarget
.
identifier
()),
QStringLiteral
(
"/Settings"
));
if
(
!
targetIface
.
isValid
())
{
qCritical
()
<<
"Unable to obtain KConfigXT D-Bus interface of target agent"
<<
cloneTarget
.
identifier
();
return
;
...
...
@@ -372,17 +367,17 @@ void AgentWidget::cloneAgent(KJob *job)
// corresponding setter in the target interface
for
(
int
i
=
0
;
i
<
sourceIface
.
metaObject
()
->
methodCount
();
++
i
)
{
const
QMetaMethod
method
=
sourceIface
.
metaObject
()
->
method
(
i
);
if
(
QByteArray
(
method
.
typeName
()).
isEmpty
())
{
// returns void
if
(
QByteArray
(
method
.
typeName
()).
isEmpty
())
{
// returns void
continue
;
}
const
QByteArray
signature
(
method
.
methodSignature
());
if
(
signature
.
isEmpty
())
{
continue
;
}
if
(
signature
.
startsWith
(
"set"
)
||
!
signature
.
contains
(
"()"
))
{
// setter or takes parameters // krazy:exclude=strings
if
(
signature
.
startsWith
(
"set"
)
||
!
signature
.
contains
(
"()"
))
{
// setter or takes parameters // krazy:exclude=strings
continue
;
}
if
(
signature
.
startsWith
(
"Introspect"
))
{
// D-Bus stuff // krazy:exclude=strings
if
(
signature
.
startsWith
(
"Introspect"
))
{
// D-Bus stuff // krazy:exclude=strings
continue
;
}
const
QString
methodName
=
QLatin1String
(
signature
.
left
(
signature
.
indexOf
(
'('
)));
...
...
@@ -413,25 +408,19 @@ void AgentWidget::currentChanged()
QString
agentStatus
;
switch
(
instance
.
status
())
{
case
AgentInstance
::
Idle
:
agentStatus
=
i18nc
(
"agent is in an idle state"
,
"Idle"
);
agentStatus
=
i18nc
(
"agent is in an idle state"
,
"Idle"
);
break
;
case
AgentInstance
::
Running
:
agentStatus
=
i18nc
(
"agent is running"
,
"Running (%1%)"
,
instance
.
progress
());
agentStatus
=
i18nc
(
"agent is running"
,
"Running (%1%)"
,
instance
.
progress
());
break
;
case
AgentInstance
::
Broken
:
agentStatus
=
i18nc
(
"agent is broken somehow"
,
"Broken"
);
agentStatus
=
i18nc
(
"agent is broken somehow"
,
"Broken"
);
break
;
case
AgentInstance
::
NotConfigured
:
agentStatus
=
i18nc
(
"agent is not yet configured"
,
"Not Configured"
);
agentStatus
=
i18nc
(
"agent is not yet configured"
,
"Not Configured"
);
break
;
}
ui
.
statusLabel
->
setText
(
i18nc
(
"Two statuses, for example
\"
Online, Running (66%)
\"
or
\"
Offline, Broken
\"
"
,
"%1, %2"
,
onlineStatus
,
agentStatus
));
ui
.
statusLabel
->
setText
(
i18nc
(
"Two statuses, for example
\"
Online, Running (66%)
\"
or
\"
Offline, Broken
\"
"
,
"%1, %2"
,
onlineStatus
,
agentStatus
));
ui
.
statusMessageLabel
->
setText
(
instance
.
statusMessage
());
ui
.
capabilitiesLabel
->
setText
(
instance
.
type
().
capabilities
().
join
(
QLatin1String
(
", "
)));
ui
.
mimeTypeLabel
->
setText
(
instance
.
type
().
mimeTypes
().
join
(
QLatin1String
(
", "
)));
...
...
@@ -452,7 +441,10 @@ void AgentWidget::showContextMenu(const QPoint &pos)
menu
.
addSeparator
();
menu
.
addMenu
(
mSyncMenu
);
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"dialog-cancel"
)),
QStringLiteral
(
"Abort Activity"
),
this
,
&
AgentWidget
::
abortAgent
);
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"system-reboot"
)),
QStringLiteral
(
"Restart Agent"
),
this
,
&
AgentWidget
::
restartAgent
);
//FIXME: Is using system-reboot icon here a good idea?
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"system-reboot"
)),
QStringLiteral
(
"Restart Agent"
),
this
,
&
AgentWidget
::
restartAgent
);
// FIXME: Is using system-reboot icon here a good idea?
menu
.
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"network-disconnect"
)),
QStringLiteral
(
"Toggle Online/Offline"
),
this
,
&
AgentWidget
::
toggleOnline
);
menu
.
addAction
(
QStringLiteral
(
"Show task list"
),
this
,
&
AgentWidget
::
showTaskList
);
menu
.
addAction
(
QStringLiteral
(
"Show change-notification log"
),
this
,
&
AgentWidget
::
showChangeNotifications
);
...
...
src/akonadibrowsermodel.cpp
View file @
e8960ad9
...
...
@@ -11,8 +11,8 @@
#include <kcontacts/addressee.h>
#include <kcontacts/contactgroup.h>
#include <KCalendarCore/Incidence>
#include <KCalendarCore/Event>
#include <KCalendarCore/Incidence>
using
IncidencePtr
=
QSharedPointer
<
KCalendarCore
::
Incidence
>
;
...
...
@@ -42,12 +42,7 @@ public:
{
}
enum
Columns
{
IdColumn
=
0
,
RemoteIdColumn
=
1
,
GIDColumn
=
2
,
MimeTypeColumn
=
3
};
enum
Columns
{
IdColumn
=
0
,
RemoteIdColumn
=
1
,
GIDColumn
=
2
,
MimeTypeColumn
=
3
};
QVariant
entityData
(
const
Item
&
item
,
int
column
,
int
role
)
const
override
{
...
...
@@ -173,7 +168,8 @@ public:
CalendarState
()
{
m_collectionHeaders
<<
QStringLiteral
(
"Collection"
);
m_itemHeaders
<<
QStringLiteral
(
"UID"
)
<<
QStringLiteral
(
"Summary"
)
<<
QStringLiteral
(
"DateTime start"
)
<<
QStringLiteral
(
"DateTime End"
)
<<
QStringLiteral
(
"Type"
);
m_itemHeaders
<<
QStringLiteral
(
"UID"
)
<<
QStringLiteral
(
"Summary"
)
<<
QStringLiteral
(
"DateTime start"
)
<<
QStringLiteral
(
"DateTime End"
)
<<
QStringLiteral
(
"Type"
);
}
virtual
~
CalendarState
()
...
...
@@ -314,7 +310,7 @@ void AkonadiBrowserModel::setItemDisplayMode(AkonadiBrowserModel::ItemDisplayMod
}
const
int
newColumnCount
=
qMax
(
newState
->
m_collectionHeaders
.
count
(),
newState
->
m_itemHeaders
.
count
());
//qCDebug(AKONADICONSOLE_LOG) << "column count changed from" << oldColumnCount << "to" << newColumnCount;
//
qCDebug(AKONADICONSOLE_LOG) << "column count changed from" << oldColumnCount << "to" << newColumnCount;
if
(
newColumnCount
>
oldColumnCount
)
{
beginInsertColumns
(
QModelIndex
(),
oldColumnCount
,
newColumnCount
-
1
);
m_currentState
=
newState
;
...
...
src/akonadibrowsermodel.h
View file @
e8960ad9
...
...
@@ -7,8 +7,8 @@
#ifndef AKONADIBROWSERMODEL_H
#define AKONADIBROWSERMODEL_H
#include <AkonadiCore/entitytreemodel.h>
#include <AkonadiCore/changerecorder.h>
#include <AkonadiCore/entitytreemodel.h>
#include <QSortFilterProxyModel>
...
...
@@ -21,12 +21,7 @@ public:
explicit
AkonadiBrowserModel
(
ChangeRecorder
*
monitor
,
QObject
*
parent
=
nullptr
);
~
AkonadiBrowserModel
();
enum
ItemDisplayMode
{
GenericMode
,
MailMode
,
ContactsMode
,
CalendarMode
};
enum
ItemDisplayMode
{
GenericMode
,
MailMode
,
ContactsMode
,
CalendarMode
};
void
setItemDisplayMode
(
ItemDisplayMode
itemDisplayMode
);
ItemDisplayMode
itemDisplayMode
()
const
;
...
...
src/browserwidget.cpp
View file @
e8960ad9
...
...
@@ -6,69 +6,69 @@
#include "browserwidget.h"
#include "akonadibrowsermodel.h"
#include "collectionaclpage.h"
#include "collectionattributespage.h"
#include "collectioninternalspage.h"
#include "co
llectionaclpag
e.h"
#include "co
nfig-akonadiconsol
e.h"
#include "dbaccess.h"
#include "akonadibrowsermodel.h"
#include "tagpropertiesdialog.h"
#include "config-akonadiconsole.h"
#include <AkonadiCore/TagFetchScope>
#include <AkonadiCore/attributefactory.h>
#include <AkonadiCore/changerecorder.h>
#include <Akonadi
Widgets/controlgui
.h>
#include <Akonadi
Core/collectionfilterproxymodel
.h>
#include <AkonadiCore/entitymimetypefiltermodel.h>
#include <AkonadiCore/favoritecollectionsmodel.h>
#include <AkonadiCore/itemfetchjob.h>
#include <AkonadiCore/itemfetchscope.h>
#include <AkonadiCore/itemmodifyjob.h>
#include <AkonadiCore/job.h>
#include <AkonadiCore/collectionfilterproxymodel.h>
#include <AkonadiWidgets/collectionpropertiesdialog.h>
#include <AkonadiCore/selectionproxymodel.h>
#include <AkonadiCore/session.h>
#include <AkonadiWidgets/standardactionmanager.h>
#include <AkonadiWidgets/entitylistview.h>
#include <AkonadiWidgets/entitytreeview.h>
#include <AkonadiCore/favoritecollectionsmodel.h>
#include <AkonadiCore/tagmodel.h>
#include <AkonadiCore/statisticsproxymodel.h>
#include <AkonadiCore/tagdeletejob.h>
#include <AkonadiCore/TagFetchScope>
#include <AkonadiCore/tagmodel.h>
#include <AkonadiWidgets/collectionpropertiesdialog.h>
#include <AkonadiWidgets/controlgui.h>
#include <AkonadiWidgets/entitylistview.h>
#include <AkonadiWidgets/entitytreeview.h>
#include <AkonadiWidgets/standardactionmanager.h>
#include <AkonadiXml/XmlWriteJob>
#include <KViewStateMaintainer>
#include <akonadi/private/compressionstream_p.h>
#include <KCalendarCore/ICalFormat>
#include <KCalendarCore/Incidence>
#include <kcontacts/addressee.h>
#include <kcontacts/contactgroup.h>
#include <KCalendarCore/Incidence>
#include <KCalendarCore/ICalFormat>
#include "akonadiconsole_debug.h"
#include <AkonadiCore/tagcreatejob.h>
#include <AkonadiCore/tagmodifyjob.h>
#include <KActionCollection>
#include <KConfig>
#include <KConfigGroup>
#include <KMessageBox>
#include <KXmlGuiWindow>
#include <KToggleAction>
#include <KActionCollection>
#include <AkonadiCore/tagmodifyjob.h>
#include <AkonadiCore/tagcreatejob.h>
#include <KXmlGuiWindow>
#include <QSplitter>
#include <QVBoxLayout>
#include <QStandardItemModel>
#include <QSqlQuery>
#include <QTimer>
#include <KSharedConfig>
#include <Q
Menu
>
#include <Q
Buffer
>
#include <QFileDialog>
#include <QMenu>
#include <QSplitter>
#include <QSqlError>
#include <QBuffer>
#include <QSqlQuery>
#include <QStandardItemModel>
#include <QTimer>
#include <QVBoxLayout>
#ifdef ENABLE_CONTENTVIEWS
#include <Akonadi/Contact/ContactGroupViewer>
#include <Akonadi/Contact/ContactViewer>
#include <CalendarSupport/IncidenceViewer>
#include <MessageViewer/Viewer>
#include <Akonadi/Contact/ContactViewer>
#include <Akonadi/Contact/ContactGroupViewer>
#endif
using
namespace
Akonadi
;
...
...
@@ -98,7 +98,7 @@ BrowserWidget::BrowserWidget(KXmlGuiWindow *xmlGuiWindow, QWidget *parent)
splitter2
->
addWidget
(
mCollectionView
);
auto
*
favoritesView
=
new
EntityListView
(
xmlGuiWindow
,
this
);
//favoritesView->setViewMode( QListView::IconMode );
//
favoritesView->setViewMode( QListView::IconMode );
splitter2
->
addWidget
(
favoritesView
);
splitter
->
addWidget
(
splitter2
);
...
...
@@ -135,7 +135,7 @@ BrowserWidget::BrowserWidget(KXmlGuiWindow *xmlGuiWindow, QWidget *parent)
mBrowserModel
->
setShowSystemEntities
(
true
);
mBrowserModel
->
setListFilter
(
CollectionFetchScope
::
Display
);
// new ModelTest( mBrowserModel );
// new ModelTest( mBrowserModel );
auto
*
collectionFilter
=
new
EntityMimeTypeFilterModel
(
this
);
collectionFilter
->
setSourceModel
(
mBrowserModel
);
...
...
@@ -271,7 +271,7 @@ void BrowserWidget::clear()
void
BrowserWidget
::
currentChanged
(
const
QModelIndex
&
index
)
{
const
Item
item
=
index
.
sibling
(
index
.
row
(),
0
).
data
(
EntityTreeModel
::
ItemRole
).
value
<
Item
>
();
const
Item
item
=
index
.
sibling
(
index
.
row
(),
0
).
data
(
EntityTreeModel
::
ItemRole
).
value
<
Item
>
();
if
(
!
item
.
isValid
())
{
clear
();
return
;
...
...
@@ -318,13 +318,12 @@ void BrowserWidget::setItem(const Akonadi::Item &item)
}
else
if
(
item
.
hasPayload
<
KCalendarCore
::
Incidence
::
Ptr
>
())
{
mIncidenceView
->
setItem
(
item
);
contentUi
.
stack
->
setCurrentWidget
(
mIncidenceView
->
parentWidget
());
}
else
if
(
item
.
mimeType
()
==
QLatin1String
(
"message/rfc822"
)
||
item
.
mimeType
()
==
QLatin1String
(
"message/news"
))
{
}
else
if
(
item
.
mimeType
()
==
QLatin1String
(
"message/rfc822"
)
||
item
.
mimeType
()
==
QLatin1String
(
"message/news"
))
{
mMailView
->
setMessageItem
(
item
,
MimeTreeParser
::
Force
);
contentUi
.
stack
->
setCurrentWidget
(
mMailView
->
parentWidget
());
}
else
#endif
if
(
item
.
hasPayload
<
QPixmap
>
())
{
if
(
item
.
hasPayload
<
QPixmap
>
())
{
contentUi
.
imageView
->
setPixmap
(
item
.
payload
<
QPixmap
>
());
contentUi
.
stack
->
setCurrentWidget
(
contentUi
.
imageViewPage
);
}
else
{
...
...
@@ -394,14 +393,14 @@ void BrowserWidget::setItem(const Akonadi::Item &item)
connect
(
mAttrModel
,
&
QStandardItemModel
::
itemChanged
,
this
,
&
BrowserWidget
::
contentViewChanged
);
if
(
mMonitor
)
{
mMonitor
->
deleteLater
();
// might be the one calling us
mMonitor
->
deleteLater
();
// might be the one calling us
}
mMonitor
=
new
Monitor
(
this
);
mMonitor
->
setObjectName
(
QStringLiteral
(
"itemMonitor"
));
mMonitor
->
setItemMonitored
(
item
);
mMonitor
->
itemFetchScope
().
fetchFullPayload
();
mMonitor
->
itemFetchScope
().
fetchAllAttributes
();
qRegisterMetaType
<
QSet
<
QByteArray
>
>
();
qRegisterMetaType
<
QSet
<
QByteArray
>>
();
connect
(
mMonitor
,
&
Akonadi
::
Monitor
::
itemChanged
,
this
,
&
BrowserWidget
::
setItem
,
Qt
::
QueuedConnection
);
contentUi
.
saveButton
->
setEnabled
(
false
);
}
...
...
@@ -543,12 +542,15 @@ void BrowserWidget::clearCache()
query
.
next
();
const
int
emptyRidCount
=
query
.
value
(
0
).
toInt
();
if
(
emptyRidCount
>
0
)
{
if
(
KMessageBox
::
warningContinueCancel
(
this
,
QStringLiteral
(
"The collection '%1' contains %2 items without Remote ID. "
"Those items were likely never uploaded to the destination server, "
"so clearing this collection means that those <b>data will be lost</b>. "
"Are you sure you want to proceed?"
).
arg
(
coll
.
id
()).
arg
(
emptyRidCount
),
QStringLiteral
(
"POSSIBLE DATA LOSS!"
))
==
KMessageBox
::
Cancel
)
{
if
(
KMessageBox
::
warningContinueCancel
(
this
,
QStringLiteral
(
"The collection '%1' contains %2 items without Remote ID. "
"Those items were likely never uploaded to the destination server, "
"so clearing this collection means that those <b>data will be lost</b>. "
"Are you sure you want to proceed?"
)
.
arg
(
coll
.
id
())
.
arg
(
emptyRidCount
),
QStringLiteral
(
"POSSIBLE DATA LOSS!"
))
==
KMessageBox
::
Cancel
)
{
return
;
}
}
...
...
@@ -590,8 +592,16 @@ void BrowserWidget::tagViewContextMenuRequested(const QPoint &pos)
menu
->
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"list-add"
)),
QStringLiteral
(
"&Add tag..."
),
this
,
&
BrowserWidget
::
addTagRequested
);
if
(
index
.
isValid
())
{
menu
->
addAction
(
QStringLiteral
(
"Add &subtag..."
),
this
,
&
BrowserWidget
::
addSubTagRequested
);
menu
->
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"document-edit"
)),
QStringLiteral
(
"&Edit tag..."
),
this
,
&
BrowserWidget
::
editTagRequested
,
QKeySequence
(
Qt
::
Key_Return
));
menu
->
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)),
QStringLiteral
(
"&Delete tag..."
),
this
,
&
BrowserWidget
::
removeTagRequested
,
QKeySequence
::
Delete
);
menu
->
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"document-edit"
)),
QStringLiteral
(
"&Edit tag..."
),
this
,
&
BrowserWidget
::
editTagRequested
,
QKeySequence
(
Qt
::
Key_Return
));
menu
->
addAction
(
QIcon
::
fromTheme
(
QStringLiteral
(
"edit-delete"
)),
QStringLiteral
(
"&Delete tag..."
),
this
,
&
BrowserWidget
::
removeTagRequested
,
QKeySequence
::
Delete
);
menu
->
setProperty
(
"Tag"
,
index
.
data
(
TagModel
::
TagRole
));
}
...
...
@@ -648,9 +658,14 @@ void BrowserWidget::tagViewDoubleClicked(const QModelIndex &index)
void
BrowserWidget
::
removeTagRequested
()
{
if
(
KMessageBox
::
questionYesNo
(
this
,
QStringLiteral
(
"Do you really want to remove selected tag?"
),
QStringLiteral
(
"Delete tag?"
),
KStandardGuiItem
::
del
(),
KStandardGuiItem
::
cancel
(),
QString
(),
KMessageBox
::
Dangerous
)
==
KMessageBox
::
No
)
{
if
(
KMessageBox
::
questionYesNo
(
this
,
QStringLiteral
(
"Do you really want to remove selected tag?"
),
QStringLiteral
(
"Delete tag?"
),
KStandardGuiItem
::
del
(),
KStandardGuiItem
::
cancel
(),
QString
(),
KMessageBox
::
Dangerous
)
==
KMessageBox
::
No
)
{
return
;
}
...
...
src/browserwidget.h
View file @
e8960ad9
...
...
@@ -7,8 +7,8 @@
#ifndef AKONADICONSOLE_BROWSERWIDGET_H
#define AKONADICONSOLE_BROWSERWIDGET_H
#include <ui_browserwidget_itemview.h>
#include <ui_browserwidget_contentview.h>
#include <ui_browserwidget_itemview.h>
#include <AkonadiCore/collection.h>
#include <AkonadiCore/item.h>
...
...
@@ -27,7 +27,8 @@ class AkonadiBrowserModel;
template
<
typename
T
>
class
KViewStateMaintainer
;
namespace
Akonadi
{
namespace
Akonadi
{
class
ChangeRecorder
;