From 5c6d2f36b5d52aa38517509f06e2c3d7f41503e8 Mon Sep 17 00:00:00 2001 From: apa420 Date: Thu, 9 Aug 2018 15:41:32 +0200 Subject: [PATCH] WIP notification settings, doesn't actually work --- .../notifications/NotificationModel.cpp | 26 +++++++++++++++++ .../notifications/NotificationModel.hpp | 28 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/controllers/notifications/NotificationModel.cpp create mode 100644 src/controllers/notifications/NotificationModel.hpp diff --git a/src/controllers/notifications/NotificationModel.cpp b/src/controllers/notifications/NotificationModel.cpp new file mode 100644 index 000000000..8049f62b1 --- /dev/null +++ b/src/controllers/notifications/NotificationModel.cpp @@ -0,0 +1,26 @@ +#include "NotificationModel.hpp" + +#include "Application.hpp" +#include "singletons/Settings.hpp" +#include "util/StandardItemHelper.hpp" + +namespace chatterino { + +NotificationModel::NotificationModel(QObject *parent) + : SignalVectorModel(1, parent) +{ +} + +// turn a vector item into a model row +QString NotificationModel::getItemFromRow(std::vector &row, + const QString &original) +{ + return QString(row[0]->data().toString()); +} + +void NotificationModel::getRowFromItem(const QString &item, + std::vector &row) +{ + setStringItem(row[0], item); +} +} // namespace chatterino diff --git a/src/controllers/notifications/NotificationModel.hpp b/src/controllers/notifications/NotificationModel.hpp new file mode 100644 index 000000000..83d14ba08 --- /dev/null +++ b/src/controllers/notifications/NotificationModel.hpp @@ -0,0 +1,28 @@ +#pragma once + +#include + +#include "common/SignalVectorModel.hpp" +#include "controllers/notifications/NotificationController.hpp" + +namespace chatterino { + +class NotificationController; + +class NotificationModel : public SignalVectorModel +{ + explicit NotificationModel(QObject *parent); + +protected: + // turn a vector item into a model row + virtual QString getItemFromRow(std::vector &row, + const QString &original) override; + + // turns a row in the model into a vector item + virtual void getRowFromItem(const QString &item, + std::vector &row) override; + + friend class NotificationController; +}; + +} // namespace chatterino