Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Unmaintained
KDE Pim
Commits
e5ed9bdb
Commit
e5ed9bdb
authored
Jul 09, 2014
by
Daniel Vrátil
🤖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AkonadiConsole: Fix sorting items by date in Browser tab
BUG: 250091 FIXED-IN: 4.14.0
parent
9102b4b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
1 deletion
+67
-1
akonadiconsole/akonadibrowsermodel.cpp
akonadiconsole/akonadibrowsermodel.cpp
+45
-0
akonadiconsole/akonadibrowsermodel.h
akonadiconsole/akonadibrowsermodel.h
+16
-0
akonadiconsole/browserwidget.cpp
akonadiconsole/browserwidget.cpp
+6
-1
No files found.
akonadiconsole/akonadibrowsermodel.cpp
View file @
e5ed9bdb
...
...
@@ -311,3 +311,48 @@ void AkonadiBrowserModel::setItemDisplayMode( AkonadiBrowserModel::ItemDisplayMo
}
emit
layoutChanged
();
}
AkonadiBrowserSortModel
::
AkonadiBrowserSortModel
(
AkonadiBrowserModel
*
model
,
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
,
mBrowserModel
(
model
)
{
}
AkonadiBrowserSortModel
::~
AkonadiBrowserSortModel
()
{
}
bool
AkonadiBrowserSortModel
::
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
if
(
mBrowserModel
->
itemDisplayMode
()
==
AkonadiBrowserModel
::
CalendarMode
)
{
if
(
left
.
column
()
==
1
||
left
.
column
()
==
2
)
{
const
Item
leftItem
=
left
.
data
(
EntityTreeModel
::
ItemRole
).
value
<
Item
>
();
const
Item
rightItem
=
right
.
data
(
EntityTreeModel
::
ItemRole
).
value
<
Item
>
();
if
(
!
leftItem
.
hasPayload
<
IncidencePtr
>
()
||
!
rightItem
.
hasPayload
<
IncidencePtr
>
()
)
{
return
false
;
}
const
IncidencePtr
leftInc
=
leftItem
.
payload
<
IncidencePtr
>
();
const
IncidencePtr
rightInc
=
rightItem
.
payload
<
IncidencePtr
>
();
if
(
left
.
column
()
==
1
)
{
return
leftInc
->
dtStart
()
<
rightInc
->
dtStart
();
}
else
if
(
left
.
column
()
==
2
)
{
return
leftInc
->
dateTime
(
KCalCore
::
IncidenceBase
::
RoleEnd
)
<
rightInc
->
dateTime
(
KCalCore
::
IncidenceBase
::
RoleEnd
);
}
}
}
else
if
(
mBrowserModel
->
itemDisplayMode
()
==
AkonadiBrowserModel
::
MailMode
)
{
if
(
left
.
column
()
==
2
)
{
const
Item
leftItem
=
left
.
data
(
EntityTreeModel
::
ItemRole
).
value
<
Item
>
();
const
Item
rightItem
=
right
.
data
(
EntityTreeModel
::
ItemRole
).
value
<
Item
>
();
if
(
!
leftItem
.
hasPayload
<
MessagePtr
>
()
||
!
rightItem
.
hasPayload
<
MessagePtr
>
()
)
{
return
false
;
}
const
MessagePtr
leftMail
=
leftItem
.
payload
<
MessagePtr
>
();
const
MessagePtr
rightMail
=
rightItem
.
payload
<
MessagePtr
>
();
return
leftMail
->
date
(
false
)
->
dateTime
()
<
rightMail
->
date
(
false
)
->
dateTime
();
}
}
return
QSortFilterProxyModel
::
lessThan
(
left
,
right
);
}
akonadiconsole/akonadibrowsermodel.h
View file @
e5ed9bdb
...
...
@@ -23,6 +23,8 @@
#include <akonadi/entitytreemodel.h>
#include <akonadi/changerecorder.h>
#include <QSortFilterProxyModel>
using
namespace
Akonadi
;
class
AkonadiBrowserModel
:
public
EntityTreeModel
...
...
@@ -60,7 +62,21 @@ private:
State
*
m_calendarState
;
ItemDisplayMode
m_itemDisplayMode
;
};
class
AkonadiBrowserSortModel
:
public
QSortFilterProxyModel
{
Q_OBJECT
public:
explicit
AkonadiBrowserSortModel
(
AkonadiBrowserModel
*
browserModel
,
QObject
*
parent
=
0
);
~
AkonadiBrowserSortModel
();
protected:
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
private:
AkonadiBrowserModel
*
mBrowserModel
;
};
#endif
akonadiconsole/browserwidget.cpp
View file @
e5ed9bdb
...
...
@@ -156,10 +156,15 @@ BrowserWidget::BrowserWidget(KXmlGuiWindow *xmlGuiWindow, QWidget * parent) :
itemFilter
->
addMimeTypeExclusionFilter
(
Collection
::
mimeType
()
);
itemFilter
->
setHeaderGroup
(
EntityTreeModel
::
ItemListHeaders
);
AkonadiBrowserSortModel
*
sortModel
=
new
AkonadiBrowserSortModel
(
mBrowserModel
,
this
);
sortModel
->
setDynamicSortFilter
(
true
);
sortModel
->
setSourceModel
(
itemFilter
);
const
KConfigGroup
group
=
KGlobal
::
config
()
->
group
(
"FavoriteCollectionsModel"
);
FavoriteCollectionsModel
*
favoritesModel
=
new
FavoriteCollectionsModel
(
mBrowserModel
,
group
,
this
);
favoritesView
->
setModel
(
favoritesModel
);
QSplitter
*
splitter3
=
new
QSplitter
(
Qt
::
Vertical
,
this
);
splitter3
->
setObjectName
(
"itemSplitter"
);
splitter
->
addWidget
(
splitter3
);
...
...
@@ -175,7 +180,7 @@ BrowserWidget::BrowserWidget(KXmlGuiWindow *xmlGuiWindow, QWidget * parent) :
QTimer
::
singleShot
(
0
,
this
,
SLOT
(
modelChanged
())
);
itemUi
.
itemView
->
setXmlGuiClient
(
xmlGuiWindow
);
itemUi
.
itemView
->
setModel
(
itemFilter
);
itemUi
.
itemView
->
setModel
(
sortModel
);
itemUi
.
itemView
->
setSelectionMode
(
QAbstractItemView
::
ExtendedSelection
);
connect
(
itemUi
.
itemView
,
SIGNAL
(
activated
(
QModelIndex
)),
SLOT
(
itemActivated
(
QModelIndex
))
);
connect
(
itemUi
.
itemView
,
SIGNAL
(
clicked
(
QModelIndex
)),
SLOT
(
itemActivated
(
QModelIndex
))
);
...
...
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