Expected for color, add filter model
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
greaterThan(QT_MAJOR_VERSION, 5): QT += widgets
|
||||
|
||||
CONFIG += c++17
|
||||
|
||||
win32:VERSION = 0.1.1.0 # major.minor.patch.build
|
||||
else:VERSION = 0.1.1 # major.minor.patch
|
||||
win32:VERSION = 0.2.0.0 # major.minor.patch.build
|
||||
else:VERSION = 0.2.0 # major.minor.patch
|
||||
|
||||
DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\"
|
||||
DEFINES += APP_NAME=\"\\\"TaskBoard\\\"\"
|
||||
@@ -74,6 +74,7 @@ SOURCES += \
|
||||
src/frames/mainwindow.cpp \
|
||||
src/frames/namedialog.cpp \
|
||||
src/frames/prefdialog.cpp \
|
||||
src/models/filter.cpp \
|
||||
src/models/priority.cpp \
|
||||
src/models/status.cpp \
|
||||
src/models/task.cpp \
|
||||
@@ -86,6 +87,7 @@ HEADERS += \
|
||||
src/frames/mainwindow.h \
|
||||
src/frames/namedialog.h \
|
||||
src/frames/prefdialog.h \
|
||||
src/models/filter.h \
|
||||
src/models/priority.h \
|
||||
src/models/status.h \
|
||||
src/models/task.h \
|
||||
|
||||
@@ -265,19 +265,19 @@ void MainWindow::init()
|
||||
QVector<Priority> MainWindow::defaultPriorities()
|
||||
{
|
||||
QVector<Priority> res;
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "None", QColor("#d9d9d9")));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Low", QColor("#309db0")));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor("#b08e30")));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor("#b04330")));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "None", QColor(217, 217, 217)));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Low", QColor(48, 157, 176)));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "Medium", QColor(176, 142, 48)));
|
||||
res.append(Priority(QUuid::createUuid().toString(QUuid::WithoutBraces), "High", QColor(176, 67, 48)));
|
||||
return res;
|
||||
}
|
||||
|
||||
QVector<Status> MainWindow::defaultStatus()
|
||||
{
|
||||
QVector<Status> res;
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor("#8f8f8f")));
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Working on", QColor("#5f30b0")));
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Completed", QColor("#30b049")));
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "To Do", QColor(143, 143, 143)));
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Working on", QColor(95, 48, 176)));
|
||||
res.append(Status(QUuid::createUuid().toString(QUuid::WithoutBraces), "Completed", QColor(48, 176, 73)));
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -362,6 +362,21 @@ void MainWindow::updateTaskRow(QTreeWidgetItem *item, Task t)
|
||||
item->setToolTip(0, t.getDescription());
|
||||
item->setText(3, t.getExpectedFor().toString());
|
||||
|
||||
if (t.getExpectedFor() < QDate::currentDate())
|
||||
{
|
||||
QBrush fgColor = item->foreground(3);
|
||||
fgColor.setColor(QColor(176, 67, 48));
|
||||
fgColor.setStyle(Qt::BrushStyle::SolidPattern);
|
||||
item->setForeground(3, fgColor);
|
||||
}
|
||||
else if (t.getExpectedFor() == QDate::currentDate())
|
||||
{
|
||||
QBrush fgColor = item->foreground(3);
|
||||
fgColor.setColor(QColor(176, 142, 48));
|
||||
fgColor.setStyle(Qt::BrushStyle::SolidPattern);
|
||||
item->setForeground(3, fgColor);
|
||||
}
|
||||
|
||||
if (!t.getStatusUUID().isEmpty())
|
||||
{
|
||||
item->setText(1, getStatusLabel(t.getStatusUUID()));
|
||||
|
||||
@@ -2,18 +2,24 @@
|
||||
|
||||
#define NAME_KEY "name"
|
||||
#define TASKS_KEY "tasks"
|
||||
#define UUID_KEY "uuid"
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonValue>
|
||||
#include <QUuid>
|
||||
|
||||
Board::Board(QString name)
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = uuid.toString(QUuid::WithoutBraces);
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
Board::Board(QJsonObject obj)
|
||||
{
|
||||
this->name = obj[NAME_KEY].toString();
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
QJsonArray jsonTasks = obj[TASKS_KEY].toArray();
|
||||
for (QJsonValue value : jsonTasks) {
|
||||
Task *t = new Task(value.toObject());
|
||||
@@ -30,6 +36,11 @@ Board::~Board()
|
||||
}
|
||||
}
|
||||
|
||||
const QString Board::getUuid()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
const QString Board::getName()
|
||||
{
|
||||
return name;
|
||||
|
||||
@@ -14,6 +14,7 @@ public:
|
||||
Board(QJsonObject);
|
||||
~Board();
|
||||
|
||||
const QString getUuid();
|
||||
const QString getName();
|
||||
void setName(const QString name);
|
||||
void add(Task);
|
||||
@@ -25,6 +26,7 @@ public:
|
||||
|
||||
private:
|
||||
QVector<Task*> tasks;
|
||||
QString uuid;
|
||||
QString name;
|
||||
|
||||
};
|
||||
|
||||
161
src/models/filter.cpp
Normal file
161
src/models/filter.cpp
Normal file
@@ -0,0 +1,161 @@
|
||||
#include "filter.h"
|
||||
|
||||
#define NAME_KEY "name"
|
||||
#define DATE_KEY "date"
|
||||
#define BOARDS_KEY "boards"
|
||||
#define STATUS_KEY "status"
|
||||
#define PRIORITY_KEY "priority"
|
||||
|
||||
filter::filter(QString name, uint8 expectedForComparator, QVector<QString> boards, QVector<QString> status, QVector<QString> priorities)
|
||||
{
|
||||
this->name = name;
|
||||
this->expectedForComparator = expectedForComparator;
|
||||
this->boards = boards;
|
||||
this->status = status;
|
||||
this->priorities = priorities;
|
||||
}
|
||||
|
||||
filter::filter(QJsonObject obj)
|
||||
{
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
this->expectedForComparator = obj[DATE_KEY].toInt();
|
||||
QJsonArray b = obj[BOARDS_KEY].toArray();
|
||||
QJsonArray s = obj[STATUS_KEY].toArray();
|
||||
QJsonArray p = obj[PRIORITY_KEY].toArray();
|
||||
foreach (QJsonValue value, b)
|
||||
{
|
||||
if (value.isString())
|
||||
{
|
||||
boards.append(value.toString());
|
||||
}
|
||||
}
|
||||
foreach (QJsonValue value, s)
|
||||
{
|
||||
if (value.isString())
|
||||
{
|
||||
status.append(value.toString());
|
||||
}
|
||||
}
|
||||
foreach (QJsonValue value, p)
|
||||
{
|
||||
if (value.isString())
|
||||
{
|
||||
priorities.append(value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVector<Task *> filter::get(QVector<Board *> allBoards)
|
||||
{
|
||||
QDate now = QDate::currentDate();
|
||||
QVector<Board*> selectedBoards;
|
||||
if (this->boards.count() > 0)
|
||||
{
|
||||
for (Board *b : allBoards)
|
||||
{
|
||||
foreach (QString boardUuid, this->boards)
|
||||
{
|
||||
if (b->getUuid() == boardUuid)
|
||||
{
|
||||
selectedBoards.append(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedBoards = allBoards;
|
||||
}
|
||||
|
||||
bool fstatus, fpriority, fdate;
|
||||
QVector<Task*> result;
|
||||
for (Board *b : selectedBoards)
|
||||
{
|
||||
for (Task *t : b->getTasks())
|
||||
{
|
||||
fstatus = filterStatus(t);
|
||||
fpriority = filterPriority(t);
|
||||
fdate = filterDate(t, now);
|
||||
if (fstatus && fpriority && fdate)
|
||||
{
|
||||
result.append(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool filter::filterStatus(Task *t)
|
||||
{
|
||||
if (status.count() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool result = false;
|
||||
foreach (QString s, status)
|
||||
{
|
||||
if (t->getStatusUUID() == s)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool filter::filterPriority(Task *t)
|
||||
{
|
||||
if (priorities.count() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool result = false;
|
||||
foreach (QString p, priorities)
|
||||
{
|
||||
if (t->getPriorityUUID() == p)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool filter::filterDate(Task *t, QDate now)
|
||||
{
|
||||
switch (expectedForComparator) {
|
||||
case 0:
|
||||
return true;
|
||||
case 1:
|
||||
return t->getExpectedFor() < now;
|
||||
case 2:
|
||||
return t->getExpectedFor() == now;
|
||||
case 3:
|
||||
return t->getExpectedFor() > now;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const QJsonObject filter::toJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
obj[name] = name;
|
||||
obj[DATE_KEY] = expectedForComparator;
|
||||
QJsonArray b;
|
||||
foreach (QString uuid, boards)
|
||||
{
|
||||
b.append(uuid);
|
||||
}
|
||||
QJsonArray s;
|
||||
foreach (QString uuid, status)
|
||||
{
|
||||
s.append(uuid);
|
||||
}
|
||||
QJsonArray p;
|
||||
foreach (QString uuid, priorities)
|
||||
{
|
||||
p.append(uuid);
|
||||
}
|
||||
obj[BOARDS_KEY] = b;
|
||||
obj[STATUS_KEY] = s;
|
||||
obj[PRIORITY_KEY] = p;
|
||||
return obj;
|
||||
}
|
||||
33
src/models/filter.h
Normal file
33
src/models/filter.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef FILTER_H
|
||||
#define FILTER_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "task.h"
|
||||
#include "board.h"
|
||||
|
||||
class filter
|
||||
{
|
||||
private:
|
||||
QString name;
|
||||
// 0 none, 1 lower, 2 equal, 3 upper
|
||||
uint8_t expectedForComparator;
|
||||
// if empty => all
|
||||
QVector<QString> boards;
|
||||
QVector<QString> status;
|
||||
QVector<QString> priorities;
|
||||
public:
|
||||
filter(QString name, uint8 expectedForComparator,QVector<QString> boards,QVector<QString> status,QVector<QString> priorities);
|
||||
filter(QJsonObject obj);
|
||||
|
||||
QVector<Task*> get(QVector<Board*>);
|
||||
|
||||
bool filterStatus(Task *t);
|
||||
bool filterPriority(Task *t);
|
||||
bool filterDate(Task *t, QDate now);
|
||||
const QJsonObject toJson();
|
||||
};
|
||||
|
||||
#endif // FILTER_H
|
||||
@@ -4,6 +4,8 @@
|
||||
#define NAME_KEY "name"
|
||||
#define COLOR_KEY "color"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
Priority::Priority(QString uuid, QString name, QColor color)
|
||||
{
|
||||
this->uuid = uuid;
|
||||
@@ -13,9 +15,10 @@ Priority::Priority(QString uuid, QString name, QColor color)
|
||||
|
||||
Priority::Priority(QJsonObject obj)
|
||||
{
|
||||
this->uuid = obj[UUID_KEY].toString();
|
||||
this->name = obj[NAME_KEY].toString();
|
||||
this->color = QColor(obj[COLOR_KEY].toString());
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
this->color = QColor(obj[COLOR_KEY].toString("#ffffff"));
|
||||
}
|
||||
|
||||
const QString Priority::getName()
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#define NAME_KEY "name"
|
||||
#define COLOR_KEY "color"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
Status::Status(QString uuid, QString name, QColor color)
|
||||
{
|
||||
this->uuid = uuid;
|
||||
@@ -13,9 +15,10 @@ Status::Status(QString uuid, QString name, QColor color)
|
||||
|
||||
Status::Status(QJsonObject obj)
|
||||
{
|
||||
this->uuid = obj[UUID_KEY].toString();
|
||||
this->name = obj[NAME_KEY].toString();
|
||||
this->color = QColor(obj[COLOR_KEY].toString());
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->name = obj[NAME_KEY].toString("!Missing name!");
|
||||
this->color = QColor(obj[COLOR_KEY].toString("#ffffff"));
|
||||
}
|
||||
|
||||
const QString Status::getName()
|
||||
|
||||
@@ -5,9 +5,14 @@
|
||||
#define EXPECTEDFOR_KEY "expected_for"
|
||||
#define PRIORITY_KEY "priority"
|
||||
#define STATUS_KEY "status"
|
||||
#define UUID_KEY "uuid"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
Task::Task(QString title, QString description, QDate expectedFor, QString priorityUUID, QString statusUUID)
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = uuid.toString(QUuid::WithoutBraces);
|
||||
this->title = title;
|
||||
this->description = description;
|
||||
this->expectedFor = expectedFor;
|
||||
@@ -17,6 +22,8 @@ Task::Task(QString title, QString description, QDate expectedFor, QString priori
|
||||
|
||||
Task::Task(QJsonObject obj)
|
||||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
this->uuid = obj[UUID_KEY].toString(uuid.toString(QUuid::WithoutBraces));
|
||||
this->title = obj[TITLE_KEY].toString();
|
||||
this->description = obj[DESCRIPTION_KEY].toString();
|
||||
this->expectedFor = QDate::fromString(obj[EXPECTEDFOR_KEY].toString(), Qt::DateFormat::ISODate);
|
||||
@@ -24,6 +31,11 @@ Task::Task(QJsonObject obj)
|
||||
this->statusUUID = obj[STATUS_KEY].toString();
|
||||
}
|
||||
|
||||
const QString Task::getUuid()
|
||||
{
|
||||
return this->uuid;
|
||||
}
|
||||
|
||||
const QString Task::getTitle()
|
||||
{
|
||||
return this->title;
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
Task(QString title, QString description, QDate expectedFor, QString priorityUUID, QString statusUUID);
|
||||
Task(QJsonObject);
|
||||
|
||||
const QString getUuid();
|
||||
const QString getTitle();
|
||||
const QString getDescription();
|
||||
const QDate getExpectedFor();
|
||||
@@ -21,6 +22,7 @@ public:
|
||||
void update(Task);
|
||||
|
||||
private:
|
||||
QString uuid;
|
||||
QString title;
|
||||
QString description;
|
||||
QDate expectedFor;
|
||||
|
||||
Reference in New Issue
Block a user