From b4e2743faa869d0fe80e1e3505ff81d247c5d2c3 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 28 Jun 2019 01:31:19 +0800 Subject: [PATCH] [feature] refine HistoryWindow design --- fu.pro | 1 + fu.qrc | 5 + icons/check-square.svg | 1 + icons/file.svg | 1 + icons/trash.svg | 1 + icons/x-square.svg | 1 + icons/x.svg | 1 + src/application.h | 1 + src/components/previewbox.cpp | 16 +- src/components/previewbox.h | 4 +- src/components/thumbnaillabel.cpp | 2 +- src/core/clipservice.cpp | 90 ++++++++++- src/core/clipservice.h | 3 + src/core/outputformatservice.cpp | 2 +- src/core/serverservice.cpp | 8 +- src/core/tagservice.cpp | 24 ++- src/core/tagservice.h | 2 + src/core/uploadservice.cpp | 1 - src/core/utils.h | 32 ++++ src/historywindow.cpp | 88 +++++++---- src/historywindow.h | 5 +- src/historywindow.ui | 239 ++++++++++++++++++++++-------- src/main.cpp | 2 +- src/models/clip.h | 1 + src/models/record.h | 12 -- 25 files changed, 410 insertions(+), 133 deletions(-) create mode 100644 icons/check-square.svg create mode 100644 icons/file.svg create mode 100644 icons/trash.svg create mode 100644 icons/x-square.svg create mode 100644 icons/x.svg create mode 100644 src/core/utils.h diff --git a/fu.pro b/fu.pro index 5d51df7..f9aadea 100644 --- a/fu.pro +++ b/fu.pro @@ -77,6 +77,7 @@ HEADERS += \ src/core/tagservice.h \ src/core/uploadservice.h \ src/core/uploadthread.h \ + src/core/utils.h \ src/historywindow.h \ src/application.h \ src/models/clip.h \ diff --git a/fu.qrc b/fu.qrc index 3238f30..8cfdecb 100644 --- a/fu.qrc +++ b/fu.qrc @@ -4,5 +4,10 @@ icons/icon-180.png icons/unknown-icon.png icons/icon-uploading-32.png + icons/x.svg + icons/check-square.svg + icons/trash.svg + icons/x-square.svg + icons/file.svg diff --git a/icons/check-square.svg b/icons/check-square.svg new file mode 100644 index 0000000..72ab7a8 --- /dev/null +++ b/icons/check-square.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/file.svg b/icons/file.svg new file mode 100644 index 0000000..378519a --- /dev/null +++ b/icons/file.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/trash.svg b/icons/trash.svg new file mode 100644 index 0000000..55650bd --- /dev/null +++ b/icons/trash.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/x-square.svg b/icons/x-square.svg new file mode 100644 index 0000000..7677c38 --- /dev/null +++ b/icons/x-square.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/x.svg b/icons/x.svg new file mode 100644 index 0000000..7d5875c --- /dev/null +++ b/icons/x.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/application.h b/src/application.h index e442bbc..d5ada29 100644 --- a/src/application.h +++ b/src/application.h @@ -1,6 +1,7 @@ #ifndef APPLICATION_H #define APPLICATION_H +#include "core/utils.h" #include "components/errormessage.h" #include "upgradedialog.h" #include "aboutdialog.h" diff --git a/src/components/previewbox.cpp b/src/components/previewbox.cpp index d9d8d22..83ce22f 100644 --- a/src/components/previewbox.cpp +++ b/src/components/previewbox.cpp @@ -25,12 +25,12 @@ PreviewBox::PreviewBox(QWidget *parent) previewImg = new ThumbnailLabel(this); boxLayout->addWidget(previewImg); - uploadedTo = new QLabel(this); - uploadedTo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - uploadedTo->setMaximumHeight(25); - uploadedTo->setText(tr("Uploaded to: ") + "haha"); - uploadedTo->setAlignment(Qt::AlignHCenter); - boxLayout->addWidget(uploadedTo); + name = new QLabel(this); + name->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + name->setMaximumHeight(25); + name->setText(tr("Uploaded to: ") + "haha"); + name->setAlignment(Qt::AlignHCenter); + boxLayout->addWidget(name); tagsFrame = nullptr; @@ -53,9 +53,9 @@ void PreviewBox::setImage(const QPixmap &thumbnail) previewImg->setPixmap(thumbnail); } -void PreviewBox::setUploadedTo(const QString &serverName) +void PreviewBox::setName(const QString &n) { - uploadedTo->setText(serverName); + name->setText(n); } void PreviewBox::setTags(const QStringList &tags) diff --git a/src/components/previewbox.h b/src/components/previewbox.h index 8604f40..0d6ff8c 100644 --- a/src/components/previewbox.h +++ b/src/components/previewbox.h @@ -15,14 +15,14 @@ class PreviewBox : public QFrame //~PreviewBox(); void setImage(const QPixmap &thumbnail); - void setUploadedTo(const QString &serverName); + void setName(const QString &name); void setTags(const QStringList &tags); bool isSelected(); protected: void mousePressEvent(QMouseEvent *evt) override; QLabel *previewImg; - QLabel *uploadedTo; + QLabel *name; QFrame *tagsFrame; bool selected; }; diff --git a/src/components/thumbnaillabel.cpp b/src/components/thumbnaillabel.cpp index b3ab882..6445875 100644 --- a/src/components/thumbnaillabel.cpp +++ b/src/components/thumbnaillabel.cpp @@ -10,7 +10,7 @@ ThumbnailLabel::ThumbnailLabel(QWidget *parent) setMaximumSize(THUMB_WIDTH, THUMB_HEIGHT); setAlignment(Qt::AlignCenter); - setStyleSheet("background: white"); + //setStyleSheet("background: white"); setPixmap(ClipService::unkownFileIcon()); } diff --git a/src/core/clipservice.cpp b/src/core/clipservice.cpp index af6e41f..542bd62 100644 --- a/src/core/clipservice.cpp +++ b/src/core/clipservice.cpp @@ -3,6 +3,19 @@ #include +Clip convertResultToClip(QSqlQuery &result) { + Clip clip; + auto rec = result.record(); + clip.id = result.value(rec.indexOf("id")).toUInt(); + clip.name = result.value(rec.indexOf("name")).toString(); + clip.isImage = result.value(rec.indexOf("isImage")).toBool(); + clip.isFile = result.value(rec.indexOf("isFile")).toBool(); + clip.rawPngThumb = result.value(rec.indexOf("preview")).toByteArray(); + clip.description = result.value(rec.indexOf("description")).toString(); + clip.createdAt = result.value(rec.indexOf("createdAt")).toDateTime(); + return clip; +} + ClipService::ClipService(SqlStore &store) : _store(store) { @@ -52,6 +65,64 @@ void ClipService::setClipboard(const QString &text) QApplication::clipboard()->setText(text); } +QList ClipService::search(QMap &filter) +{ + QList clips; + + QStringList sql, where; + sql.append("SELECT clips.* FROM clips"); + + + if (filter.contains("dateFrom")) { + where.append(QString("DATETIME(clips.createdAt) > DATETIME('%1')").arg(dateToISO(filter["dateFrom"].toDate()))); + } + if (filter.contains("dateTo")) { + where.append(QString("DATETIME(clips.createdAt) <= DATETIME('%1')").arg(dateToISO(filter["dateTo"].toDate().addDays(1)))); + } + if (filter.contains("serverIds")) { + auto serverIds = qvariant_cast>(filter["serverIds"]); + sql.append("LEFT JOIN uploads ON clips.id=uploads.clipId"); + where.append(QString("uploads.serverId IN (%1)").arg(join(serverIds))); + } + if (filter.contains("tags")) { + auto tags = qvariant_cast(filter["tags"]); + auto tagIds = APP->tagService()->mapToIds(tags); + sql.append("LEFT JOIN clips_tags ON clips.id=clips_tags.clipId"); + where.append(QString("clips_tags.tagId IN (%1)").arg(join(tagIds))); + } + + if (!where.empty()) { + sql.append("WHERE"); + sql.append(where.join(" AND ")); + } + + sql.append("ORDER BY id DESC"); + auto sqlText = sql.join(" "); + + qDebug() << sqlText; + + auto result = _store.exec(sqlText); + while (result.next()) { + clips.append(convertResultToClip(result)); + } + + for (auto &clip : clips) { + auto tagsResult = _store.exec(QString("SELECT tags.name FROM tags LEFT JOIN clips_tags ON (tags.id=clips_tags.tagId) WHERE clips_tags.clipId=%1").arg(clip.id)); + while (tagsResult.next()) { + clip.tags.append(tagsResult.value(0).toString()); + } + } + + return clips; +} + +QList>> ClipService::searchAndGroup(QMap &filter) +{ + auto clips = search(filter); + auto datedClips = groupByCreationDate(clips); + return datedClips; +} + QPixmap ClipService::thumbnailize(const QPixmap &origin) { return origin.scaled(THUMB_WIDTH, THUMB_HEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -59,7 +130,24 @@ QPixmap ClipService::thumbnailize(const QPixmap &origin) const QPixmap &ClipService::unkownFileIcon() { - const static QPixmap unknownImg(":icons/unknown-icon.png"); + const static QPixmap unknownImg(":icons/file.svg"); return unknownImg; } +QList>> ClipService::groupByCreationDate(QList &clips) +{ + QList>> datedClips; + for (auto &clip : clips) { + QDate date = clip.createdAt.date(); + if (datedClips.empty() || datedClips.last().first != date) { + //if (!datedClips.contains(date)) { + QPair> pair; + QList clips; + pair.first = date; + pair.second = clips; + datedClips.append(pair); + } + datedClips.last().second.append(clip); + } + return datedClips; +} diff --git a/src/core/clipservice.h b/src/core/clipservice.h index 768c79e..1b4ba49 100644 --- a/src/core/clipservice.h +++ b/src/core/clipservice.h @@ -13,8 +13,11 @@ class ClipService QList getAllFromClipboard(); void setClipboard(const QString &text); + QList search(QMap &filter); + QList>> searchAndGroup(QMap &filter); static QPixmap thumbnailize(const QPixmap &origin); const static QPixmap &unkownFileIcon(); + static QList>> groupByCreationDate(QList &clips); }; #endif // CLIPSERVICE_H diff --git a/src/core/outputformatservice.cpp b/src/core/outputformatservice.cpp index a24928a..73955db 100644 --- a/src/core/outputformatservice.cpp +++ b/src/core/outputformatservice.cpp @@ -1,7 +1,7 @@ #include "error.h" #include "outputformatservice.h" -OutputFormat convertResultToOutputFormat(QSqlQuery result) { +OutputFormat convertResultToOutputFormat(QSqlQuery &result) { OutputFormat outputFormat; auto rec = result.record(); outputFormat.id = result.value(rec.indexOf("id")).toUInt(); diff --git a/src/core/serverservice.cpp b/src/core/serverservice.cpp index 12d70e3..ca43062 100644 --- a/src/core/serverservice.cpp +++ b/src/core/serverservice.cpp @@ -1,6 +1,6 @@ -#include "../application.h" -#include "error.h" #include "serverservice.h" +#include "error.h" +#include "../application.h" #include "../protocols/localstorageprotocol.h" #include "../protocols/ftpprotocol.h" @@ -9,7 +9,7 @@ QString toJson(QVariantMap &settings) return QJsonDocument::fromVariant(settings).toJson(QJsonDocument::Compact); } -Server convertResultToServer(QSqlQuery result) { +Server convertResultToServer(QSqlQuery &result) { Server server; auto rec = result.record(); server.id = result.value(rec.indexOf("id")).toUInt(); @@ -74,7 +74,7 @@ void ServerService::append(Server &server) query.bindValue(":name", server.name); query.bindValue(":protocol", server.protocol); query.bindValue(":settings", toJson(server.settings)); - query.bindValue(":createdAt", QDateTime::currentDateTime().toString(Qt::ISODate)); + query.bindValue(":createdAt", datetimeToISO()); auto result = _store.exec(); server.id = result.lastInsertId().toUInt(); diff --git a/src/core/tagservice.cpp b/src/core/tagservice.cpp index 0b16065..7eda343 100644 --- a/src/core/tagservice.cpp +++ b/src/core/tagservice.cpp @@ -1,7 +1,7 @@ #include "tagservice.h" -Tag convertResultToTag(QSqlQuery result) { +Tag convertResultToTag(QSqlQuery &result) { Tag tag; auto rec = result.record(); tag.id = result.value(rec.indexOf("id")).toUInt(); @@ -62,9 +62,8 @@ void TagService::remove(uint id) query.exec(); } -uint TagService::findOrAppend(const QString &name) +uint TagService::find(const QString &name) { - qDebug() << "find or append " << name; auto query = _store.prepare("SELECT id FROM tags WHERE name=:name"); query.bindValue(":name", name); @@ -73,5 +72,22 @@ uint TagService::findOrAppend(const QString &name) qDebug() << "tag found: " << result.value(0); return result.value(0).toUInt(); } - return append(name); + return 0; +} + +uint TagService::findOrAppend(const QString &name) +{ + auto tagId = find(name); + return tagId || append(name); +} + +QList TagService::mapToIds(const QStringList &tags) +{ + QList tagIds; + for (auto &tag : tags) { + auto tagId = this->find(tag); + if (tagId) + tagIds.append(tagId); + } + return tagIds; } diff --git a/src/core/tagservice.h b/src/core/tagservice.h index a0ce995..3558b64 100644 --- a/src/core/tagservice.h +++ b/src/core/tagservice.h @@ -16,7 +16,9 @@ class TagService uint append(const QString &name); void update(uint id, const QString &name); void remove(uint id); + uint find(const QString &name); uint findOrAppend(const QString &name); + QList mapToIds(const QStringList &tags); }; #endif // TAGSERVICE_H diff --git a/src/core/uploadservice.cpp b/src/core/uploadservice.cpp index bc923cc..086cf2a 100644 --- a/src/core/uploadservice.cpp +++ b/src/core/uploadservice.cpp @@ -25,7 +25,6 @@ void UploadService::upload(QList &clips, const QStringList &tags, const QS tagIds.append(APP->tagService()->findOrAppend(tag)); } - int i = 0; for (auto &clip : clips) { clip.description = desc; auto query = _store.prepare("INSERT INTO clips (name, isImage, isFile, preview, description, createdAt)" diff --git a/src/core/utils.h b/src/core/utils.h new file mode 100644 index 0000000..4725406 --- /dev/null +++ b/src/core/utils.h @@ -0,0 +1,32 @@ +#ifndef UTILS_H +#define UTILS_H + +#include + +inline QString datetimeToISO(const QDateTime &dt = QDateTime::currentDateTime()) { + QDateTime dt2(dt); + dt2.setOffsetFromUtc(dt.offsetFromUtc()); + return dt2.toString(Qt::ISODate); +} + +inline QDateTime dateToDateTime(const QDate &date = QDate::currentDate()) { + QTime time(0,0,0); + QDateTime datetime(date, time); + return datetime; +} + +inline QString dateToISO(const QDate &date = QDate::currentDate()) { + return datetimeToISO(dateToDateTime(date)); +} + +template +inline QString join(const QList list, const QString &sep = ", ") { + QStringList tmp; + for (auto &item : list) { + qDebug() << item; + tmp.append(QString("%1").arg(item)); + } + return tmp.join(sep); +} + +#endif // UTILS_H diff --git a/src/historywindow.cpp b/src/historywindow.cpp index 3a7e90c..372a374 100644 --- a/src/historywindow.cpp +++ b/src/historywindow.cpp @@ -1,40 +1,38 @@ #include "historywindow.h" #include "ui_historywindow.h" -#include "models/record.h" #include "components/flowlayout.h" #include "components/previewbox.h" #include "components/tagbutton.h" +#include "application.h" #include #include +#include HistoryWindow::HistoryWindow() : QMainWindow(), ui(new Ui::HistoryWindow) { - ; ui->setupUi(this); + ui->dteFrom->setDate(QDate::currentDate().addMonths(-1)); + ui->dteTo->setDate(QDate::currentDate()); - // mock records - QList records; - const static QPixmap thumbnail = QPixmap("D:/Nextcloud/kleshwong/wallpapers/6fVBDMW-dark-minimalist-wallpaper.jpg").scaled(160, 160, Qt::KeepAspectRatio); - for (int i = 0; i < 100; i++) - { - - Record record; - record.setUploadedTo("imgur.com"); - record.setThumbnail(thumbnail); - record.setTags({"Mr.Robot", "Hello", "World"}); - QDateTime createdAt = QDateTime::currentDateTime().addDays(-QRandomGenerator::global()->bounded(0, 5)); - record.setCreatedAt(createdAt); - records.append(record); + for (auto &server : APP->serverService()->getAll()) { + auto serverCtrl = new QCheckBox(ui->sclServers); + serverCtrl->setText(server.name); + serverCtrl->setProperty("serverId", server.id); + ui->sclServers->layout()->addWidget(serverCtrl); } - updateRecords(records); - // set up context menu - connect(ui->sclRecords, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showRecordsContextMenu(const QPoint &))); + reload(); + + auto test = new QAction(this); + test->setText("test"); + addAction(test); + connect(ui->btnApply, SIGNAL(clicked()), this, SLOT(reload())); + connect(ui->sclClips, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showClipsContextMenu(const QPoint &))); } HistoryWindow::~HistoryWindow() @@ -43,45 +41,71 @@ HistoryWindow::~HistoryWindow() } -void HistoryWindow::updateRecords(const QList &records) +void HistoryWindow::reload() { - QLayout *recordsLayout = ui->sclRecords->layout(); + QMap filter; + if (ui->grpByDate->isChecked()) { + filter["dateFrom"] = ui->dteFrom->date(); + filter["dateTo"] = ui->dteTo->date(); + } + if (ui->grpByServers->isChecked()) { + QList serverIds; + for (auto &serverCtrl : ui->sclServers->findChildren()) { + if (serverCtrl->isChecked()) { + auto serverId = serverCtrl->property("serverId").toUInt(); + serverIds.append(serverId); + } + } + filter["serverIds"] = QVariant::fromValue(serverIds); + } + + if (ui->grpTags->isChecked()) { + filter["tags"] = ui->tgeTags->tags(); + } + + if (ui->grpByImage->isChecked()) { + filter["image"] = ui->tnlImage->pixmap(); + } + + QLayout *layout = ui->sclClips->layout(); // clean up old widgets QLayoutItem *item; - while ((item = recordsLayout->takeAt(0)) != nullptr) { + while ((item = layout->takeAt(0)) != nullptr) { delete item->widget(); delete item; } // rebuild new widgets - QMap> dateRecordsMap = Record::groupByCreationDate(records); - for (const QDate &date : dateRecordsMap.keys()) { + auto datedClips = APP->clipService()->searchAndGroup(filter); + for (const auto &pair : datedClips) { + auto date = pair.first; QLabel *dateLabel = new QLabel(this); dateLabel->setText(date.toString("yyyy-MM-dd")); dateLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); dateLabel->setStyleSheet("font-size: 24px; font: bold; border-bottom: 1px solid black;"); dateLabel->setMargin(10); - recordsLayout->addWidget(dateLabel); + layout->addWidget(dateLabel); QFrame *groupedFrame = new QFrame(this); FlowLayout *groupedLayout = new FlowLayout(groupedFrame); groupedLayout->setMargin(0); groupedFrame->setLayout(groupedLayout); - for (const Record &record : dateRecordsMap[date]) { + for (auto &clip: pair.second) { PreviewBox *box = new PreviewBox(this); - box->setUploadedTo(record.getUploadedTo()); - box->setImage(record.getThumbnail()); - box->setTags(record.getTags()); + QPixmap thumbnail; + thumbnail.loadFromData(clip.rawPngThumb, "PNG"); + box->setImage(thumbnail); + box->setTags(clip.tags); + box->setName(clip.name); groupedLayout->addWidget(box); } - recordsLayout->addWidget(groupedFrame); + layout->addWidget(groupedFrame); } } -void HistoryWindow::showRecordsContextMenu(const QPoint &pos) +void HistoryWindow::showClipsContextMenu(const QPoint &pos) { - qDebug() <<"hello"; QMenu contextMenu(this); QAction copyUrlAction(tr("Copy as ") + "Plain Url", this); contextMenu.addAction(©UrlAction); @@ -113,5 +137,5 @@ void HistoryWindow::showRecordsContextMenu(const QPoint &pos) QAction unselectAllAction(tr("&Unselect All"), this); contextMenu.addAction(&unselectAllAction); - contextMenu.exec(ui->sclRecords->mapToGlobal(pos)); + contextMenu.exec(ui->sclClips->mapToGlobal(pos)); } diff --git a/src/historywindow.h b/src/historywindow.h index 212bfd8..bf42914 100644 --- a/src/historywindow.h +++ b/src/historywindow.h @@ -1,7 +1,6 @@ #ifndef HISTORYWINDOW_H #define HISTORYWINDOW_H -#include "models/record.h" #include #include @@ -25,10 +24,10 @@ class HistoryWindow : public QMainWindow private: Ui::HistoryWindow *ui; - void updateRecords(const QList &records); private slots: - void showRecordsContextMenu(const QPoint &pos); + void reload(); + void showClipsContextMenu(const QPoint &pos); }; #endif // HISTORYWINDOW_H diff --git a/src/historywindow.ui b/src/historywindow.ui index bf43e7e..1969e17 100644 --- a/src/historywindow.ui +++ b/src/historywindow.ui @@ -31,10 +31,16 @@ - 280 + 220 0 + + + 200 + 16777215 + + QFrame::StyledPanel @@ -50,10 +56,16 @@ - + By Date + + true + + + true + @@ -63,7 +75,7 @@ - + @@ -73,13 +85,13 @@ - + - + 16777215 @@ -89,36 +101,28 @@ By Servers + + true + + + false + - + true - + 0 0 - 238 + 178 116 - - - - CheckBox - - - - - - - CheckBox - - - @@ -144,9 +148,15 @@ By Tags + + true + + + false + - + QFrame::StyledPanel @@ -159,32 +169,74 @@ - + By Image - + + true + + + false + + + + + + + + + 0 + 0 + + + + + 160 + 160 + + + + + + + + + - + - No Image Selected + Paste + + + + Qt::Vertical + + + + 20 + 40 + + + + - + Apply - + Clear @@ -198,7 +250,80 @@ - + + + + + + 0 + 0 + + + + Delete + + + + :/icons/x.svg:/icons/x.svg + + + + + + + + 0 + 0 + + + + Clearn All + + + + :/icons/trash.svg:/icons/trash.svg + + + + + + + Select All + + + + :/icons/check-square.svg:/icons/check-square.svg + + + + + + + Unselect All + + + + :/icons/x-square.svg:/icons/x-square.svg + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::DefaultContextMenu @@ -211,13 +336,13 @@ true - + 0 0 - 972 - 725 + 1032 + 746 @@ -230,39 +355,25 @@ - - - - - - Previous Page - - - - - - - Page: 1 - - - Qt::AlignCenter - - - - - - - Next Page - - - - - - + + + + :/icons/x.svg:/icons/x.svg + + + Delete + + + Delete selected clips + + + Del + + @@ -278,6 +389,8 @@
src/components/thumbnaillabel.h
- + + + diff --git a/src/main.cpp b/src/main.cpp index 46d0445..f9dc815 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -37,6 +37,6 @@ int main(int argc, char *argv[]) if (!app.prepare(parser.value(dbPathOption))) return -1; - app.showUploadDialog(); + app.showHistoryWindow(); return app.exec(); } diff --git a/src/models/clip.h b/src/models/clip.h index c1ba75d..2e0b7fd 100644 --- a/src/models/clip.h +++ b/src/models/clip.h @@ -14,6 +14,7 @@ struct Clip QString name; QString description; QDateTime createdAt; + QStringList tags; }; #endif // CLIP_H diff --git a/src/models/record.h b/src/models/record.h index 9d3d6af..6238ca3 100644 --- a/src/models/record.h +++ b/src/models/record.h @@ -34,18 +34,6 @@ class Record void setThumbnail(QPixmap value) { thumbnail = value; } QPixmap getThumbnail() const { return thumbnail; } - static QMap> groupByCreationDate(QList records) { - QMap> dateRecordsMap; - for (const Record &record : records) { - QDate date = record.createdAt.date(); - if (!dateRecordsMap.contains(date)) { - QList dateRecords; - dateRecordsMap.insert(date, dateRecords); - } - dateRecordsMap[date].append(record); - } - return dateRecordsMap; - } }; #endif // RECORD_H