Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KDE Pim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Unmaintained
KDE Pim
Commits
d25b5b8d
Commit
d25b5b8d
authored
Apr 07, 2015
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow to use kactioncollection here. Clean up code. Add unittest
parent
04f37a2d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
5 deletions
+112
-5
kmail/kmmainwidget.cpp
kmail/kmmainwidget.cpp
+1
-0
kmail/tag/tagselectdialog.cpp
kmail/tag/tagselectdialog.cpp
+22
-5
kmail/tag/tagselectdialog.h
kmail/tag/tagselectdialog.h
+6
-0
kmail/tests/CMakeLists.txt
kmail/tests/CMakeLists.txt
+3
-0
kmail/tests/tagselectdialogtest.cpp
kmail/tests/tagselectdialogtest.cpp
+47
-0
kmail/tests/tagselectdialogtest.h
kmail/tests/tagselectdialogtest.h
+33
-0
No files found.
kmail/kmmainwidget.cpp
View file @
d25b5b8d
...
...
@@ -1914,6 +1914,7 @@ void KMMainWidget::slotSelectMoreMessageTagList()
return
;
TagSelectDialog
dlg
(
this
,
selectedMessages
.
count
(),
selectedMessages
.
first
()
);
dlg
.
setActionCollection
(
QList
<
KActionCollection
*>
()
<<
actionCollection
());
if
(
dlg
.
exec
()
)
{
const
Akonadi
::
Tag
::
List
lst
=
dlg
.
selectedTag
();
if
(
!
lst
.
isEmpty
())
{
...
...
kmail/tag/tagselectdialog.cpp
View file @
d25b5b8d
...
...
@@ -61,32 +61,45 @@ TagSelectDialog::TagSelectDialog( QWidget * parent, int numberOfSelectedMessages
setMainWidget
(
mainWidget
);
mListTag
=
new
QListWidget
(
this
);
mListTag
->
setObjectName
(
QLatin1String
(
"listtag"
));
KListWidgetSearchLine
*
listWidgetSearchLine
=
new
KListWidgetSearchLine
(
this
,
mListTag
);
listWidgetSearchLine
->
setClickMessage
(
i18n
(
"Search tag"
));
listWidgetSearchLine
->
setClearButtonShown
(
true
);
listWidgetSearchLine
->
setTrapReturnKey
(
true
);
listWidgetSearchLine
->
setObjectName
(
QLatin1String
(
"searchline"
));
mainLayout
->
addWidget
(
listWidgetSearchLine
);
mainLayout
->
addWidget
(
mListTag
);
createTagList
();
connect
(
this
,
SIGNAL
(
user1Clicked
()),
SLOT
(
slotAddNewTag
()));
readConfig
();
}
TagSelectDialog
::~
TagSelectDialog
()
{
writeConfig
();
}
KConfigGroup
group
(
KMKernel
::
self
()
->
config
(),
"TagSelectDialog"
);
void
TagSelectDialog
::
readConfig
()
{
KConfigGroup
group
(
KGlobal
::
config
(),
"TagSelectDialog"
);
const
QSize
size
=
group
.
readEntry
(
"Size"
,
QSize
(
500
,
300
)
);
if
(
size
.
isValid
()
)
{
resize
(
size
);
}
}
TagSelectDialog
::~
TagSelectDialo
g
()
void
TagSelectDialog
::
writeConfi
g
()
{
KConfigGroup
group
(
K
MKernel
::
self
()
->
config
(),
"TagSelectDialog"
);
KConfigGroup
group
(
K
Global
::
config
(),
"TagSelectDialog"
);
group
.
writeEntry
(
"Size"
,
size
()
);
}
void
TagSelectDialog
::
slotAddNewTag
()
{
QPointer
<
MailCommon
::
AddTagDialog
>
dialog
=
new
MailCommon
::
AddTagDialog
(
QList
<
KActionCollection
*>
()
,
this
);
QPointer
<
MailCommon
::
AddTagDialog
>
dialog
=
new
MailCommon
::
AddTagDialog
(
mActionCollectionList
,
this
);
dialog
->
setTags
(
mTagList
);
if
(
dialog
->
exec
()
)
{
mListTag
->
clear
();
...
...
@@ -103,6 +116,11 @@ void TagSelectDialog::createTagList()
connect
(
fetchJob
,
SIGNAL
(
result
(
KJob
*
)),
this
,
SLOT
(
slotTagsFetched
(
KJob
*
)));
}
void
TagSelectDialog
::
setActionCollection
(
const
QList
<
KActionCollection
*>
&
actionCollectionList
)
{
mActionCollectionList
=
actionCollectionList
;
}
void
TagSelectDialog
::
slotTagsFetched
(
KJob
*
job
)
{
if
(
job
->
error
())
{
...
...
@@ -143,6 +161,5 @@ Akonadi::Tag::List TagSelectDialog::selectedTag() const
lst
.
append
(
Akonadi
::
Tag
::
fromUrl
(
item
->
data
(
UrlTag
).
toString
()
)
);
}
}
qDebug
()
<<
" lst"
<<
lst
;
return
lst
;
}
kmail/tag/tagselectdialog.h
View file @
d25b5b8d
...
...
@@ -35,6 +35,7 @@
#include "tag.h"
class
QListWidget
;
class
KActionCollection
;
class
TagSelectDialog
:
public
KDialog
{
Q_OBJECT
...
...
@@ -43,11 +44,15 @@ public:
~
TagSelectDialog
();
Akonadi
::
Tag
::
List
selectedTag
()
const
;
void
setActionCollection
(
const
QList
<
KActionCollection
*>
&
actionCollectionList
);
private
Q_SLOTS
:
void
slotAddNewTag
();
void
slotTagsFetched
(
KJob
*
);
private:
void
writeConfig
();
void
readConfig
();
void
createTagList
();
enum
ItemType
{
UrlTag
=
Qt
::
UserRole
+
1
...
...
@@ -56,6 +61,7 @@ private:
Akonadi
::
Item
mSelectedItem
;
QList
<
MailCommon
::
Tag
::
Ptr
>
mTagList
;
QList
<
KActionCollection
*>
mActionCollectionList
;
QListWidget
*
mListTag
;
};
...
...
kmail/tests/CMakeLists.txt
View file @
d25b5b8d
...
...
@@ -63,3 +63,6 @@ set( kmail_configureagentitemtest_source configureagentitemtest.cpp ../configure
kde4_add_unit_test
(
configureagentitemtest
${
kmail_configureagentitemtest_source
}
)
target_link_libraries
(
configureagentitemtest
${
QT_QTTEST_LIBRARY
}
${
KDE4_KDEUI_LIBS
}
)
add_akonadi_isolated_test_advanced
(
tagselectdialogtest.cpp
"../tag/tagselectdialog.cpp"
"
${
KDEPIMLIBS_AKONADI_LIBS
}
;kmailprivate;mailcommon"
)
kmail/tests/tagselectdialogtest.cpp
0 → 100644
View file @
d25b5b8d
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "tagselectdialogtest.h"
#include "tag/tagselectdialog.h"
#include <KListWidgetSearchLine>
#include <QListWidget>
#include <qtest_kde.h>
TagSelectDialogTest
::
TagSelectDialogTest
(
QObject
*
parent
)
:
QObject
(
parent
)
{
}
TagSelectDialogTest
::~
TagSelectDialogTest
()
{
}
void
TagSelectDialogTest
::
shouldHaveDefaultValue
()
{
TagSelectDialog
dlg
(
0
,
1
,
Akonadi
::
Item
());
QListWidget
*
listWidget
=
dlg
.
findChild
<
QListWidget
*>
(
QLatin1String
(
"listtag"
));
QVERIFY
(
listWidget
);
KListWidgetSearchLine
*
listWidgetSearchLine
=
dlg
.
findChild
<
KListWidgetSearchLine
*>
(
QLatin1String
(
"searchline"
));
QVERIFY
(
listWidgetSearchLine
);
QVERIFY
(
listWidgetSearchLine
->
isClearButtonShown
());
QVERIFY
(
listWidgetSearchLine
->
trapReturnKey
());
}
QTEST_KDEMAIN
(
TagSelectDialogTest
,
GUI
)
kmail/tests/tagselectdialogtest.h
0 → 100644
View file @
d25b5b8d
/*
Copyright (c) 2015 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TAGSELECTDIALOGTEST_H
#define TAGSELECTDIALOGTEST_H
#include <QObject>
class
TagSelectDialogTest
:
public
QObject
{
Q_OBJECT
public:
explicit
TagSelectDialogTest
(
QObject
*
parent
=
0
);
~
TagSelectDialogTest
();
private
Q_SLOTS
:
void
shouldHaveDefaultValue
();
};
#endif // TAGSELECTDIALOGTEST_H
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