Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Kalendar
Commits
a1da1e8d
Commit
a1da1e8d
authored
Jun 03, 2022
by
Carl Schwan
🚴
Committed by
Claudio Cambra
Aug 04, 2022
Browse files
Add folder title in mail list page
Signed-off-by:
Carl Schwan
<
carl@carlschwan.eu
>
parent
ee8cfabb
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/mail/mailmanager.cpp
View file @
a1da1e8d
...
...
@@ -57,6 +57,24 @@ MailManager::MailManager(QObject *parent)
// Setup selection model
m_collectionSelectionModel
=
new
QItemSelectionModel
(
m_foldersModel
);
connect
(
m_collectionSelectionModel
,
&
QItemSelectionModel
::
selectionChanged
,
this
,
[
this
](
const
QItemSelection
&
selected
,
const
QItemSelection
&
deselected
)
{
Q_UNUSED
(
deselected
)
const
auto
indexes
=
selected
.
indexes
();
if
(
indexes
.
count
())
{
QString
name
;
QModelIndex
index
=
indexes
[
0
];
while
(
index
.
isValid
())
{
if
(
name
.
isEmpty
())
{
name
=
index
.
data
(
Qt
::
DisplayRole
).
toString
();
}
else
{
name
=
index
.
data
(
Qt
::
DisplayRole
).
toString
()
+
QLatin1String
(
" / "
)
+
name
;
}
index
=
index
.
parent
();
}
m_selectedFolderName
=
name
;
Q_EMIT
selectedFolderNameChanged
();
}
});
auto
selectionModel
=
new
SelectionProxyModel
(
m_collectionSelectionModel
,
this
);
selectionModel
->
setSourceModel
(
treeModel
);
selectionModel
->
setFilterBehavior
(
KSelectionProxyModel
::
ChildrenOfExactSelection
);
...
...
@@ -102,7 +120,6 @@ MailModel *MailManager::folderModel() const
void
MailManager
::
loadMailCollection
(
const
QModelIndex
&
modelIndex
)
{
if
(
!
modelIndex
.
isValid
())
{
qDebug
()
<<
"hello"
;
return
;
}
...
...
@@ -123,3 +140,8 @@ Akonadi::Session *MailManager::session() const
{
return
m_session
;
}
QString
MailManager
::
selectedFolderName
()
const
{
return
m_selectedFolderName
;
}
src/mail/mailmanager.h
View file @
a1da1e8d
...
...
@@ -21,6 +21,7 @@ class MailManager : public QObject
Q_PROPERTY
(
bool
loading
READ
loading
NOTIFY
loadingChanged
)
Q_PROPERTY
(
Akonadi
::
CollectionFilterProxyModel
*
foldersModel
READ
foldersModel
CONSTANT
)
Q_PROPERTY
(
MailModel
*
folderModel
READ
folderModel
NOTIFY
folderModelChanged
)
Q_PROPERTY
(
QString
selectedFolderName
READ
selectedFolderName
NOTIFY
selectedFolderNameChanged
)
public:
MailManager
(
QObject
*
parent
=
nullptr
);
...
...
@@ -30,12 +31,14 @@ public:
Akonadi
::
CollectionFilterProxyModel
*
foldersModel
()
const
;
MailModel
*
folderModel
()
const
;
Akonadi
::
Session
*
session
()
const
;
QString
selectedFolderName
()
const
;
Q_INVOKABLE
void
loadMailCollection
(
const
QModelIndex
&
index
);
Q_SIGNALS:
void
loadingChanged
();
void
folderModelChanged
();
void
selectedFolderNameChanged
();
private:
bool
m_loading
;
...
...
@@ -45,5 +48,6 @@ private:
//folders
QItemSelectionModel
*
m_collectionSelectionModel
;
MailModel
*
m_folderModel
;
QString
m_selectedFolderName
;
};
src/mail/mailmodel.cpp
View file @
a1da1e8d
...
...
@@ -22,14 +22,16 @@ MailModel::MailModel(QObject *parent)
QHash
<
int
,
QByteArray
>
MailModel
::
roleNames
()
const
{
return
{{
TitleRole
,
QByteArrayLiteral
(
"title"
)},
{
DateRole
,
QByteArrayLiteral
(
"date"
)},
{
DateTimeRole
,
QByteArrayLiteral
(
"datetime"
)},
{
SenderRole
,
QByteArrayLiteral
(
"sender"
)},
{
UnreadRole
,
QByteArrayLiteral
(
"unread"
)},
{
FavoriteRole
,
QByteArrayLiteral
(
"favorite"
)},
{
TextColorRole
,
QByteArrayLiteral
(
"textColor"
)},
{
BackgroundColorRole
,
QByteArrayLiteral
(
"backgroudColor"
)}};
return
{
{
TitleRole
,
QByteArrayLiteral
(
"title"
)},
{
DateRole
,
QByteArrayLiteral
(
"date"
)},
{
DateTimeRole
,
QByteArrayLiteral
(
"datetime"
)},
{
SenderRole
,
QByteArrayLiteral
(
"sender"
)},
{
UnreadRole
,
QByteArrayLiteral
(
"unread"
)},
{
FavoriteRole
,
QByteArrayLiteral
(
"favorite"
)},
{
TextColorRole
,
QByteArrayLiteral
(
"textColor"
)},
{
BackgroundColorRole
,
QByteArrayLiteral
(
"backgroudColor"
)},
};
}
QVariant
MailModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
...
...
src/mail/mailmodel.h
View file @
a1da1e8d
...
...
@@ -14,8 +14,6 @@ class MailModel : public QIdentityProxyModel
{
Q_OBJECT
// Q_PROPERTY(ViewerHelper *viewerHelper READ viewerHelper WRITE setViewerHelper NOTIFY viewerHelperChanged)
public:
enum
AnimalRoles
{
TitleRole
=
Qt
::
UserRole
+
1
,
...
...
@@ -29,18 +27,9 @@ public:
FavoriteRole
,
};
// ViewerHelper *viewerHelper() const;
// void setViewerHelper(ViewerHelper *viewerHelper);
explicit
MailModel
(
QObject
*
parent
=
nullptr
);
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
virtual
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
Q_INVOKABLE
void
loadItem
(
int
row
);
///Q_SIGNALS:
/// void viewerHelperChanged();
///
///private:
/// ViewerHelper *m_viewerHelper = nullptr;
};
src/mail/qml/FolderView.qml
View file @
a1da1e8d
...
...
@@ -11,6 +11,7 @@ import org.kde.kitemmodels 1.0 as KItemModels
Kirigami.ScrollablePage
{
id
:
folderView
property
var
mailViewer
:
null
;
title
:
MailManager
.
selectedFolderName
ListView
{
id
:
mails
model
:
MailManager
.
folderModel
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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