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
PIM EventViews
Commits
25b7024b
Commit
25b7024b
authored
Sep 24, 2021
by
Glen Ditchfield
🐛
Committed by
Glen Ditchfield
Sep 28, 2021
Browse files
Add a Completed Date column to the To-Do List view
CCBUG: 374774
parent
f4a9b72b
Pipeline
#83349
passed with stage
in 8 minutes and 41 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/todo/todomodel.cpp
View file @
25b7024b
...
...
@@ -262,6 +262,8 @@ QVariant TodoModel::data(const QModelIndex &index, int role) const
return
todo
->
hasStartDate
()
?
QLocale
().
toString
(
todo
->
dtStart
().
toLocalTime
().
date
(),
QLocale
::
ShortFormat
)
:
QVariant
(
QString
());
case
DueDateColumn
:
return
todo
->
hasDueDate
()
?
QLocale
().
toString
(
todo
->
dtDue
().
toLocalTime
().
date
(),
QLocale
::
ShortFormat
)
:
QVariant
(
QString
());
case
CompletedDateColumn
:
return
todo
->
hasCompletedDate
()
?
QLocale
().
toString
(
todo
->
completed
().
toLocalTime
().
date
(),
QLocale
::
ShortFormat
)
:
QVariant
(
QString
());
case
CategoriesColumn
:
{
QString
categories
=
todo
->
categories
().
join
(
i18nc
(
"delimiter for joining category/tag names"
,
","
));
return
QVariant
(
categories
);
...
...
@@ -288,6 +290,8 @@ QVariant TodoModel::data(const QModelIndex &index, int role) const
return
QVariant
(
todo
->
dtStart
().
date
());
case
DueDateColumn
:
return
QVariant
(
todo
->
dtDue
().
date
());
case
CompletedDateColumn
:
return
QVariant
(
todo
->
completed
().
date
());
case
CategoriesColumn
:
return
QVariant
(
todo
->
categories
());
case
DescriptionColumn
:
...
...
@@ -582,6 +586,8 @@ QVariant TodoModel::headerData(int column, Qt::Orientation orientation, int role
return
QVariant
(
i18n
(
"Start Date"
));
case
DueDateColumn
:
return
QVariant
(
i18n
(
"Due Date"
));
case
CompletedDateColumn
:
return
QVariant
(
i18nc
(
"@title:column date completed"
,
"Completed"
));
case
CategoriesColumn
:
return
QVariant
(
i18n
(
"Tags"
));
case
DescriptionColumn
:
...
...
src/todo/todomodel.h
View file @
25b7024b
...
...
@@ -36,6 +36,7 @@ public:
CategoriesColumn
,
DescriptionColumn
,
CalendarColumn
,
CompletedDateColumn
,
ColumnCount
// Just for iteration/column count purposes. Always keep at the end of enum.
};
...
...
src/todo/todoview.cpp
View file @
25b7024b
...
...
@@ -522,6 +522,7 @@ void TodoView::restoreLayout(KConfig *config, const QString &group, bool minimal
mView
->
hideColumn
(
TodoModel
::
RecurColumn
);
mView
->
hideColumn
(
TodoModel
::
DescriptionColumn
);
mView
->
hideColumn
(
TodoModel
::
CalendarColumn
);
mView
->
hideColumn
(
TodoModel
::
CompletedDateColumn
);
if
(
minimalDefaults
)
{
mView
->
hideColumn
(
TodoModel
::
PriorityColumn
);
...
...
@@ -1096,6 +1097,7 @@ void TodoView::resizeColumns()
mView
->
resizeColumnToContents
(
TodoModel
::
StartDateColumn
);
mView
->
resizeColumnToContents
(
TodoModel
::
DueDateColumn
);
mView
->
resizeColumnToContents
(
TodoModel
::
CompletedDateColumn
);
mView
->
resizeColumnToContents
(
TodoModel
::
PriorityColumn
);
mView
->
resizeColumnToContents
(
TodoModel
::
CalendarColumn
);
mView
->
resizeColumnToContents
(
TodoModel
::
RecurColumn
);
...
...
src/todo/todoviewsortfilterproxymodel.cpp
View file @
25b7024b
...
...
@@ -91,6 +91,8 @@ bool TodoViewSortFilterProxyModel::lessThan(const QModelIndex &left, const QMode
}
}
else
if
(
right
.
column
()
==
TodoModel
::
StartDateColumn
)
{
return
compareStartDates
(
left
,
right
)
==
-
1
;
}
else
if
(
right
.
column
()
==
TodoModel
::
CompletedDateColumn
)
{
return
compareCompletedDates
(
left
,
right
)
==
-
1
;
}
else
if
(
right
.
column
()
==
TodoModel
::
PriorityColumn
)
{
const
int
comparison
=
comparePriorities
(
left
,
right
);
...
...
@@ -190,6 +192,38 @@ int TodoViewSortFilterProxyModel::compareStartDates(const QModelIndex &left, con
}
}
int
TodoViewSortFilterProxyModel
::
compareCompletedDates
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
Q_ASSERT
(
left
.
column
()
==
TodoModel
::
CompletedDateColumn
);
Q_ASSERT
(
right
.
column
()
==
TodoModel
::
CompletedDateColumn
);
const
auto
leftTodo
=
left
.
data
(
TodoModel
::
TodoPtrRole
).
value
<
KCalendarCore
::
Todo
::
Ptr
>
();
const
auto
rightTodo
=
right
.
data
(
TodoModel
::
TodoPtrRole
).
value
<
KCalendarCore
::
Todo
::
Ptr
>
();
if
(
!
leftTodo
||
!
rightTodo
)
{
return
0
;
}
const
bool
leftIsEmpty
=
!
leftTodo
->
hasCompletedDate
();
const
bool
rightIsEmpty
=
!
rightTodo
->
hasCompletedDate
();
if
(
leftIsEmpty
!=
rightIsEmpty
)
{
// One of them doesn't have a completed date.
// For sorting, no date is considered a very big date.
return
rightIsEmpty
?
-
1
:
1
;
}
else
if
(
!
leftIsEmpty
)
{
// Both have completed dates.
const
auto
leftDateTime
=
leftTodo
->
completed
();
const
auto
rightDateTime
=
rightTodo
->
completed
();
if
(
leftDateTime
==
rightDateTime
)
{
return
0
;
}
else
{
return
leftDateTime
<
rightDateTime
?
-
1
:
1
;
}
}
else
{
// Neither has a completed date.
return
0
;
}
}
void
TodoViewSortFilterProxyModel
::
setCategoryFilter
(
const
QStringList
&
categories
)
{
mCategories
=
categories
;
...
...
src/todo/todoviewsortfilterproxymodel.h
View file @
25b7024b
...
...
@@ -43,6 +43,7 @@ public Q_SLOTS:
private:
int
compareStartDates
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
int
compareDueDates
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
int
compareCompletedDates
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
int
comparePriorities
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
int
compareCompletion
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
QStringList
mCategories
;
...
...
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