mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 10:13:42 +00:00
Tags are now visible on each task
This commit is contained in:
parent
bae67e6851
commit
839109b77b
6 changed files with 54 additions and 2 deletions
|
@ -38,6 +38,7 @@ qt_add_qml_module(mirai
|
||||||
src/qml/TaskItem.qml
|
src/qml/TaskItem.qml
|
||||||
src/qml/forms/TaskForm.qml
|
src/qml/forms/TaskForm.qml
|
||||||
src/qml/components/TabSelector.qml
|
src/qml/components/TabSelector.qml
|
||||||
|
src/qml/components/Tag.qml
|
||||||
src/qml/styles/MiraiColorPalette.qml
|
src/qml/styles/MiraiColorPalette.qml
|
||||||
src/qml/styles/CatppuccinFrappe.qml
|
src/qml/styles/CatppuccinFrappe.qml
|
||||||
src/qml/views/ListView.qml
|
src/qml/views/ListView.qml
|
||||||
|
|
|
@ -123,9 +123,14 @@ void Backend::rebuildQMLTasksList() {
|
||||||
lastDate = task.date;
|
lastDate = task.date;
|
||||||
shouldShowDate = true;
|
shouldShowDate = true;
|
||||||
}
|
}
|
||||||
|
QList<QString> qStringTags;
|
||||||
|
for (auto& tag : task.getTags()) {
|
||||||
|
qStringTags.push_back(QString::fromStdString(tag));
|
||||||
|
}
|
||||||
QMLTasks.push_back({
|
QMLTasks.push_back({
|
||||||
.taskItem = &task,
|
.taskItem = &task,
|
||||||
.shouldShowDate = shouldShowDate
|
.shouldShowDate = shouldShowDate,
|
||||||
|
.tags = qStringTags
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,10 @@ QString QMLTaskItem::getDate() {
|
||||||
return QString::fromStdString(taskItem->getDate());
|
return QString::fromStdString(taskItem->getDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QString> QMLTaskItem::getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
|
||||||
bool QMLTaskItem::getShouldShowDate() {
|
bool QMLTaskItem::getShouldShowDate() {
|
||||||
return shouldShowDate;
|
return shouldShowDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ struct QMLTaskItem {
|
||||||
Q_PROPERTY(QString text READ getText)
|
Q_PROPERTY(QString text READ getText)
|
||||||
Q_PROPERTY(QString state READ getState)
|
Q_PROPERTY(QString state READ getState)
|
||||||
Q_PROPERTY(QString date READ getDate)
|
Q_PROPERTY(QString date READ getDate)
|
||||||
|
Q_PROPERTY(QList<QString> tags READ getTags)
|
||||||
Q_PROPERTY(bool shouldShowDate READ getShouldShowDate)
|
Q_PROPERTY(bool shouldShowDate READ getShouldShowDate)
|
||||||
QML_VALUE_TYPE(taskItem)
|
QML_VALUE_TYPE(taskItem)
|
||||||
|
|
||||||
|
@ -30,10 +31,12 @@ public:
|
||||||
QString getRawFormat();
|
QString getRawFormat();
|
||||||
QString getState();
|
QString getState();
|
||||||
QString getDate();
|
QString getDate();
|
||||||
|
QList<QString> getTags();
|
||||||
bool getShouldShowDate();
|
bool getShouldShowDate();
|
||||||
|
|
||||||
mirai::TaskItem* taskItem;
|
mirai::TaskItem* taskItem;
|
||||||
bool shouldShowDate = false;
|
bool shouldShowDate = false;
|
||||||
|
QList<QString> tags;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Window
|
import QtQuick.Window
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import QtQuick.Controls
|
|
||||||
import Mirai
|
import Mirai
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
|
@ -24,4 +23,16 @@ RowLayout {
|
||||||
backend.updateTodo(index, modelData.state === 'DONE' ? "TODO" : "DONE", modelData.text, modelData.date)
|
backend.updateTodo(index, modelData.state === 'DONE' ? "TODO" : "DONE", modelData.text, modelData.date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: task.tags
|
||||||
|
Tag {
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
text: modelData
|
||||||
|
backgroundColor: colorPalette.selected.fieldBackground
|
||||||
|
textColor: colorPalette.selected.palette.sapphire
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
28
src/qml/components/Tag.qml
Normal file
28
src/qml/components/Tag.qml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Mirai. Copyright (C) 2024 Vyn
|
||||||
|
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
||||||
|
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Window
|
||||||
|
import Mirai
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: control
|
||||||
|
property string text
|
||||||
|
property string backgroundColor
|
||||||
|
property string textColor
|
||||||
|
color: backgroundColor
|
||||||
|
implicitWidth: childrenRect.width
|
||||||
|
implicitHeight: childrenRect.height
|
||||||
|
radius: 8
|
||||||
|
|
||||||
|
AppText {
|
||||||
|
color: control.textColor
|
||||||
|
padding: 2
|
||||||
|
leftPadding: 6
|
||||||
|
rightPadding: 6
|
||||||
|
text: control.text
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue