This is the first step of cleaning up MainWin. I intend to move most stuff out of that
old crufty class, mainly into QtUi or other modules.
#include "quasselui.h"
+AbstractUi * AbstractUi::_instance = 0;
bool AbstractUi::_visible = false;
+
+AbstractUi::AbstractUi() {
+ Q_ASSERT(!_instance);
+ _instance = this;
+}
Q_OBJECT
public:
+ AbstractUi();
+ virtual ~AbstractUi() {};
virtual void init() {}; // called after the client is initialized
virtual MessageModel *createMessageModel(QObject *parent) = 0;
virtual AbstractMessageProcessor *createMessageProcessor(QObject *parent) = 0;
- inline static bool isVisible() { return _visible; }
- inline static void setVisible(bool visible) { _visible = visible; }
+ inline static bool isVisible() { return _visible; }
+ inline static void setVisible(bool visible) { _visible = visible; }
protected slots:
virtual void connectedToCore() {}
void connectToCore(const QVariantMap &connInfo);
void disconnectFromCore();
-private:
- static bool _visible;
+ private:
+ static AbstractUi *_instance;
+ static bool _visible;
};
#endif
#include "qtui.h"
-#include <QDebug>
-
#include "actioncollection.h"
#include "chatlinemodel.h"
#include "mainwin.h"
+#include "abstractnotificationbackend.h"
#include "qtuimessageprocessor.h"
#include "qtuistyle.h"
+#include "types.h"
#include "uisettings.h"
#include "util.h"
ActionCollection *QtUi::_actionCollection = 0;
+QSet<AbstractNotificationBackend *> QtUi::_notificationBackends;
QtUiStyle *QtUi::_style = 0;
-QtUi::QtUi() : AbstractUi()
-{
+QtUi::QtUi() : AbstractUi() {
if(_style != 0) {
qWarning() << "QtUi has been instantiated again!";
return;
}
QtUi::~QtUi() {
+ unregisterAllNotificationBackends();
delete _style;
delete mainWin;
}
void QtUi::disconnectedFromCore() {
mainWin->disconnectedFromCore();
}
+
+void QtUi::registerNotificationBackend(AbstractNotificationBackend *backend) {
+ if(!_notificationBackends.contains(backend)) {
+ _notificationBackends.insert(backend);
+ }
+}
+
+void QtUi::unregisterNotificationBackend(AbstractNotificationBackend *backend) {
+ _notificationBackends.remove(backend);
+}
+
+void QtUi::unregisterAllNotificationBackends() {
+ _notificationBackends.clear();
+}
+
+void QtUi::notify(BufferId id, const QString &sender, const QString &text) {
+ foreach(AbstractNotificationBackend *backend, _notificationBackends)
+ backend->notify(id, sender, text);
+}
#include "quasselui.h"
+class AbstractNotificationBackend;
class ActionCollection;
class MainWin;
class MessageModel;
*/
inline static ActionCollection *actionCollection();
+ static void registerNotificationBackend(AbstractNotificationBackend *);
+ static void unregisterNotificationBackend(AbstractNotificationBackend *);
+ static void unregisterAllNotificationBackends();
+ static void notify(BufferId bufId, const QString &sender, const QString &text);
+
public slots:
void init();
MainWin *mainWin;
static ActionCollection *_actionCollection;
static QtUiStyle *_style;
+ static QSet<AbstractNotificationBackend *> _notificationBackends;
};
ActionCollection *QtUi::actionCollection() { return _actionCollection; }
set(SOURCES
abstractbuffercontainer.cpp
abstractitemview.cpp
+ abstractnotificationbackend.cpp
action.cpp
actioncollection.cpp
bufferview.cpp
set(MOC_HDRS
abstractbuffercontainer.h
abstractitemview.h
+ abstractnotificationbackend.h
action.h
actioncollection.h
bufferview.h
--- /dev/null
+/***************************************************************************
+* Copyright (C) 2005-08 by the Quassel Project *
+* devel@quassel-irc.org *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) version 3. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#include "abstractnotificationbackend.h"
+
--- /dev/null
+/***************************************************************************
+* Copyright (C) 2005-08 by the Quassel Project *
+* devel@quassel-irc.org *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) version 3. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+#ifndef ABSTRACTNOTIFICATIONBACKEND_H_
+#define ABSTRACTNOTIFICATIONBACKEND_H_
+
+#include <QObject>
+#include <QString>
+
+#include "bufferinfo.h"
+
+class SettingsPage;
+
+class AbstractNotificationBackend : public QObject {
+ Q_OBJECT
+
+ public:
+ //AbstractNotificationBackend(QObject *parent);
+ //virtual ~AbstractNotificationBackend();
+
+ virtual void notify(BufferId bufId, const QString &sender, const QString &text) = 0;
+ virtual SettingsPage *configWidget() const = 0;
+
+};
+
+#endif