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
KMail
Commits
e3d0f6eb
Commit
e3d0f6eb
authored
Nov 15, 2021
by
Laurent Montel
😁
Browse files
Add collectionswitchertreeview widget
parent
d054f857
Pipeline
#97738
passed with stage
in 13 minutes and 56 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/CMakeLists.txt
View file @
e3d0f6eb
...
...
@@ -305,7 +305,8 @@ target_sources(kmailprivate PRIVATE
manageshowcollectionproperties.h
kmmigrateapplication.h
historyswitchfolder/historyswitchfoldermanager.h
historyswitchfolder/collectionswitchertreeview.cpp
historyswitchfolder/collectionswitchertreeview.h
)
qt_add_dbus_adaptor
(
kmailprivate_LIB_SRCS
...
...
@@ -521,6 +522,7 @@ if(BUILD_TESTING)
add_subdirectory
(
sieveimapinterface/tests/
)
add_subdirectory
(
undosend/autotests/
)
add_subdirectory
(
job/autotests/
)
add_subdirectory
(
historyswitchfolder/autotests/
)
endif
()
########### install files ###############
install
(
TARGETS kmailprivate
${
KDE_INSTALL_TARGETS_DEFAULT_ARGS
}
LIBRARY NAMELINK_SKIP
)
...
...
src/historyswitchfolder/autotests/CMakeLists.txt
0 → 100644
View file @
e3d0f6eb
macro
(
add_kmail_historyswitchfolder_unittest _source
)
get_filename_component
(
_name
${
_source
}
NAME_WE
)
ecm_add_test
(
${
_source
}
TEST_NAME
${
_name
}
LINK_LIBRARIES kmailprivate Qt::Test Qt::Widgets
)
endmacro
()
add_kmail_historyswitchfolder_unittest
(
collectionswitchertreeviewtest.cpp
)
src/historyswitchfolder/autotests/collectionswitchertreeviewtest.cpp
0 → 100644
View file @
e3d0f6eb
/*
This file is part of KMail, the KDE mail client.
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-only
*/
#include
"collectionswitchertreeviewtest.h"
#include
"historyswitchfolder/collectionswitchertreeview.h"
#include
<QTest>
QTEST_MAIN
(
CollectionSwitcherTreeViewTest
)
CollectionSwitcherTreeViewTest
::
CollectionSwitcherTreeViewTest
(
QObject
*
parent
)
:
QObject
{
parent
}
{
}
void
CollectionSwitcherTreeViewTest
::
shouldHaveDefaultValues
()
{
CollectionSwitcherTreeView
w
(
nullptr
);
QVERIFY
(
!
w
.
rootIsDecorated
());
QCOMPARE
(
w
.
selectionBehavior
(),
QAbstractItemView
::
SelectRows
);
QCOMPARE
(
w
.
selectionMode
(),
QAbstractItemView
::
SingleSelection
);
QCOMPARE
(
w
.
textElideMode
(),
Qt
::
ElideMiddle
);
QCOMPARE
(
w
.
horizontalScrollBarPolicy
(),
Qt
::
ScrollBarAlwaysOff
);
QVERIFY
(
w
.
isHeaderHidden
());
QCOMPARE
(
w
.
windowFlags
(),
Qt
::
Popup
|
Qt
::
FramelessWindowHint
);
}
src/historyswitchfolder/autotests/collectionswitchertreeviewtest.h
0 → 100644
View file @
e3d0f6eb
/*
This file is part of KMail, the KDE mail client.
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-only
*/
#pragma once
#include
<QObject>
class
CollectionSwitcherTreeViewTest
:
public
QObject
{
Q_OBJECT
public:
explicit
CollectionSwitcherTreeViewTest
(
QObject
*
parent
=
nullptr
);
~
CollectionSwitcherTreeViewTest
()
override
=
default
;
private
Q_SLOTS
:
void
shouldHaveDefaultValues
();
};
src/historyswitchfolder/collectionswitchertreeview.cpp
0 → 100644
View file @
e3d0f6eb
/*
This file is part of KMail, the KDE mail client.
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-only
*/
#include
"collectionswitchertreeview.h"
#include
<QKeyEvent>
CollectionSwitcherTreeView
::
CollectionSwitcherTreeView
(
QWidget
*
parent
)
:
QTreeView
(
parent
)
{
setWindowFlags
(
Qt
::
Popup
|
Qt
::
FramelessWindowHint
);
setSelectionBehavior
(
QAbstractItemView
::
SelectRows
);
setSelectionMode
(
QAbstractItemView
::
SingleSelection
);
setTextElideMode
(
Qt
::
ElideMiddle
);
setHorizontalScrollBarPolicy
(
Qt
::
ScrollBarAlwaysOff
);
setHeaderHidden
(
true
);
setRootIsDecorated
(
false
);
}
CollectionSwitcherTreeView
::~
CollectionSwitcherTreeView
()
{
}
int
CollectionSwitcherTreeView
::
sizeHintWidth
()
const
{
return
sizeHintForColumn
(
0
)
+
sizeHintForColumn
(
1
);
}
void
CollectionSwitcherTreeView
::
resizeColumnsToContents
()
{
resizeColumnToContents
(
0
);
resizeColumnToContents
(
1
);
}
void
CollectionSwitcherTreeView
::
keyReleaseEvent
(
QKeyEvent
*
event
)
{
if
(
event
->
key
()
==
Qt
::
Key_Control
)
{
Q_EMIT
collectionSelected
(
selectionModel
()
->
currentIndex
());
event
->
accept
();
hide
();
}
else
{
QTreeView
::
keyReleaseEvent
(
event
);
}
}
void
CollectionSwitcherTreeView
::
keyPressEvent
(
QKeyEvent
*
event
)
{
if
(
event
->
key
()
==
Qt
::
Key_Escape
)
{
event
->
accept
();
hide
();
}
else
{
QTreeView
::
keyPressEvent
(
event
);
}
}
void
CollectionSwitcherTreeView
::
showEvent
(
QShowEvent
*
event
)
{
resizeColumnsToContents
();
QTreeView
::
showEvent
(
event
);
}
src/historyswitchfolder/collectionswitchertreeview.h
0 → 100644
View file @
e3d0f6eb
/*
This file is part of KMail, the KDE mail client.
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-only
*/
#pragma once
#include
"kmail_private_export.h"
#include
<QTreeView>
class
KMAILTESTS_TESTS_EXPORT
CollectionSwitcherTreeView
:
public
QTreeView
{
Q_OBJECT
public:
explicit
CollectionSwitcherTreeView
(
QWidget
*
parent
=
nullptr
);
~
CollectionSwitcherTreeView
()
override
;
Q_REQUIRED_RESULT
int
sizeHintWidth
()
const
;
void
resizeColumnsToContents
();
Q_SIGNALS:
void
collectionSelected
(
const
QModelIndex
&
index
);
protected:
void
keyPressEvent
(
QKeyEvent
*
event
)
override
;
void
showEvent
(
QShowEvent
*
event
)
override
;
void
keyReleaseEvent
(
QKeyEvent
*
event
)
override
;
};
Write
Preview
Supports
Markdown
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