diff --git a/src/controllers/notifications/NotificationController.cpp b/src/controllers/notifications/NotificationController.cpp index 984363f0f..e9778a10e 100644 --- a/src/controllers/notifications/NotificationController.cpp +++ b/src/controllers/notifications/NotificationController.cpp @@ -1,4 +1,4 @@ -#include "NotificationController.hpp" +#include "controllers/notifications/NotificationController.hpp" #include "Application.hpp" #include "controllers/notifications/NotificationModel.hpp" @@ -33,23 +33,47 @@ void NotificationController::updateChannelNotification( bool NotificationController::isChannelNotified(const QString &channelName) { + for (std::vector::size_type i = 0; + i != notificationVector.getVector().size(); i++) { + if (notificationVector.getVector()[i] == channelName) { + return true; + } + } + return false; + /* const auto &vector = notificationSetting_.getValue(); return std::find(vector.begin(), vector.end(), channelName) != vector.end(); + */ } void NotificationController::addChannelNotification(const QString &channelName) { + notificationVector.appendItem(channelName); + /* auto vector = notificationSetting_.getValue(); vector.push_back(channelName); notificationSetting_.setValue(vector); + */ } void NotificationController::removeChannelNotification( const QString &channelName) { + for (std::vector::size_type i = 0; + i != notificationVector.getVector().size(); i++) { + if (notificationVector.getVector()[i] == channelName) { + notificationVector.removeItem(i); + i--; + } + } + + // notificationVector.removeItem(std::find( + // notificationVector.begin(), notificationVector.end(), channelName)); + /* auto vector = notificationSetting_.getValue(); vector.erase(std::find(vector.begin(), vector.end(), channelName)); notificationSetting_.setValue(vector); + */ } NotificationModel *NotificationController::createModel(QObject *parent) diff --git a/src/controllers/notifications/NotificationModel.cpp b/src/controllers/notifications/NotificationModel.cpp index 8049f62b1..e8ecbc064 100644 --- a/src/controllers/notifications/NotificationModel.cpp +++ b/src/controllers/notifications/NotificationModel.cpp @@ -23,4 +23,5 @@ void NotificationModel::getRowFromItem(const QString &item, { setStringItem(row[0], item); } + } // namespace chatterino diff --git a/src/widgets/settingspages/NotificationPage.cpp b/src/widgets/settingspages/NotificationPage.cpp index 5da0a8296..77ba20d01 100644 --- a/src/widgets/settingspages/NotificationPage.cpp +++ b/src/widgets/settingspages/NotificationPage.cpp @@ -1,8 +1,9 @@ #include "NotificationPage.hpp" #include "Application.hpp" +#include "controllers/notifications/NotificationController.hpp" +#include "controllers/notifications/NotificationModel.hpp" #include "singletons/Settings.hpp" -#include "src/controllers/notifications/NotificationController.hpp" #include "util/LayoutCreator.hpp" #include "widgets/helper/EditableModelView.hpp" @@ -57,7 +58,8 @@ NotificationPage::NotificationPage() }); view->addButtonPressed.connect([] { - getApp()->notifications->addChannelNotification("channel"); + getApp()->notifications->notificationVector.appendItem( + "channel"); }); } }