messagemodel.cpp
mappedselectionmodel.cpp
networkmodel.cpp
+ quasselui.cpp
selectionmodelsynchronizer.cpp
treemodel.cpp)
#include "client.h"
-AbstractMessageProcessor::AbstractMessageProcessor(QObject *parent) : QObject(parent) {
-
-
-
+AbstractMessageProcessor::AbstractMessageProcessor(QObject *parent)
+ : QObject(parent)
+{
}
-void AbstractMessageProcessor::postProcess(Message &msg) {
- Client::buffer(msg.bufferInfo())->updateActivityLevel(msg);
-}
+// void AbstractMessageProcessor::postProcess(Message &msg) {
+// Client::buffer(msg.bufferInfo())->updateActivityLevel(msg);
+// }
#ifndef ABSTRACTMESSAGEPROCESSOR_H_
#define ABSTRACTMESSAGEPROCESSOR_H_
+#include "client.h"
#include "message.h"
+#include "networkmodel.h"
class AbstractMessageProcessor : public QObject {
Q_OBJECT
void progressUpdated(int value, int maximum);
protected:
- void postProcess(Message &msg);
+ inline void postProcess(Message &msg) { Client::networkModel()->updateBufferActivity(msg); }
};
Buffer::Buffer(BufferInfo bufferid, QObject *parent)
: QObject(parent),
- _bufferInfo(bufferid),
- _isVisible(false),
- _activityLevel(NoActivity)
+ _bufferInfo(bufferid)
{
-
}
BufferInfo Buffer::bufferInfo() const {
return _bufferInfo;
}
-void Buffer::setVisible(bool visible) {
- _isVisible = visible;
- setActivityLevel(NoActivity);
- if(_lastRcvdMsg.msgId() > 0) setLastSeenMsg(_lastRcvdMsg.msgId());
-}
-
-void Buffer::setLastSeenMsg(const MsgId &msgId) {
- const MsgId oldLastSeen = lastSeenMsg();
- if(!oldLastSeen.isValid() || (msgId.isValid() && msgId > oldLastSeen)) {
- _lastSeenMsg = msgId;
- Client::setBufferLastSeenMsg(bufferInfo().bufferId(), msgId);
- setActivityLevel(NoActivity);
- }
-}
-
-void Buffer::setActivityLevel(ActivityLevel level) {
- _activityLevel = level;
- if(bufferInfo().bufferId() > 0) {
- Client::networkModel()->setBufferActivity(bufferInfo(), level);
- }
-}
-
-void Buffer::updateActivityLevel(const Message &msg) {
- // FIXME dirty hack to allow the lastSeen stuff to continue to work
- // will be made much nicer once Buffer dies, I hope...
- if(msg.msgId() > _lastRcvdMsg.msgId()) _lastRcvdMsg = msg;
-
- if(isVisible())
- return;
-
- if(msg.flags() & Message::Self) // don't update activity for our own messages
- return;
-
- if(lastSeenMsg().isValid() && lastSeenMsg() >= msg.msgId())
- return;
-
- ActivityLevel level = activityLevel() | OtherActivity;
- if(msg.type() & (Message::Plain | Message::Notice | Message::Action))
- level |= NewMessage;
-
- if(msg.flags() & Message::Highlight)
- level |= Highlight;
-
- if(level != activityLevel())
- setActivityLevel(level);
-}
Buffer(BufferInfo, QObject *parent = 0);
BufferInfo bufferInfo() const;
- inline bool isVisible() const { return _isVisible; }
- inline MsgId lastSeenMsg() const { return _lastSeenMsg; }
- inline ActivityLevel activityLevel() const { return _activityLevel; }
-
-public slots:
- void setVisible(bool visible);
- void setLastSeenMsg(const MsgId &msgId);
- void setActivityLevel(ActivityLevel level);
- void updateActivityLevel(const Message &msg);
private:
BufferInfo _bufferInfo;
- bool _isVisible;
- MsgId _lastSeenMsg;
- Message _lastRcvdMsg;
- ActivityLevel _activityLevel;
-
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)
view->setSelectionModel(mappedSelectionModel);
}
-QModelIndex BufferModel::currentIndex() {
- return standardSelectionModel()->currentIndex();
-}
-
void BufferModel::setCurrentIndex(const QModelIndex &newCurrent) {
_selectionModelSynchronizer.selectionModel()->setCurrentIndex(newCurrent, QItemSelectionModel::Current);
_selectionModelSynchronizer.selectionModel()->select(newCurrent, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
void synchronizeSelectionModel(MappedSelectionModel *selectionModel);
void synchronizeView(QAbstractItemView *view);
- QModelIndex currentIndex();
+ inline QModelIndex currentIndex() { return standardSelectionModel()->currentIndex(); }
void setCurrentIndex(const QModelIndex &newCurrent);
private slots:
_connectedToCore(false),
_syncedToCore(false)
{
- _monitorBuffer = new Buffer(BufferInfo(), this);
_signalProxy->synchronize(_ircListHelper);
connect(_backlogManager, SIGNAL(backlog(BufferId, const QVariantList &)),
// create buffersyncer
Q_ASSERT(!_bufferSyncer);
_bufferSyncer = new BufferSyncer(this);
- connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), this, SLOT(updateLastSeenMsg(BufferId, MsgId)));
+ connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), _networkModel, SLOT(setLastSeenMsgId(BufferId, MsgId)));
connect(bufferSyncer(), SIGNAL(bufferRemoved(BufferId)), this, SLOT(bufferRemoved(BufferId)));
connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
signalProxy()->synchronize(bufferSyncer());
//qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
}
-void Client::updateLastSeenMsg(BufferId id, const MsgId &msgId) {
- Buffer *b = buffer(id);
- if(!b) {
- qWarning() << "Client::updateLastSeen(): Unknown buffer" << id;
- return;
- }
- b->setLastSeenMsg(msgId);
-}
-
void Client::setBufferLastSeenMsg(BufferId id, const MsgId &msgId) {
if(!bufferSyncer())
return;
static QList<Buffer *> buffers();
static Buffer *buffer(BufferId bufferUid);
static Buffer *buffer(BufferInfo);
- static inline Buffer *monitorBuffer() { return instance()->_monitorBuffer; }
static QList<NetworkId> networkIds();
static const Network * network(NetworkId);
void recvStatusMsg(QString network, QString message);
void receiveBacklog(BufferId bufferId, const QVariantList &msgs);
void updateBufferInfo(BufferInfo);
- void updateLastSeenMsg(BufferId id, const MsgId &msgId);
void bufferDestroyed();
void networkDestroyed();
QHash<NetworkId, Network *> _networks;
QHash<IdentityId, Identity *> _identities;
- Buffer *_monitorBuffer;
-
static AccountId _currentCoreAccount;
friend class ClientSyncer;
#include <QAbstractItemView>
#include "bufferinfo.h"
+#include "buffermodel.h"
#include "client.h"
#include "signalproxy.h"
#include "network.h"
}
}
-void BufferItem::updateActivityLevel(Buffer::ActivityLevel level) {
- Buffer::ActivityLevel oldActivity = _activity;
- _activity |= level;
- if(oldActivity != _activity)
+//void BufferItem::updateActivityLevel(Buffer::ActivityLevel level) {
+void BufferItem::updateActivityLevel(const Message &msg) {
+ if(isCurrentBuffer())
+ return;
+
+ if(msg.flags() & Message::Self) // don't update activity for our own messages
+ return;
+
+ if(lastSeenMsgId() >= msg.msgId())
+ return;
+
+ Buffer::ActivityLevel oldLevel = activityLevel();
+
+ _activity |= Buffer::OtherActivity;
+ if(msg.type() & (Message::Plain | Message::Notice | Message::Action))
+ _activity |= Buffer::NewMessage;
+
+ if(msg.flags() & Message::Highlight)
+ _activity |= Buffer::Highlight;
+
+ if(oldLevel != _activity)
emit dataChanged();
}
emit dataChanged(0);
}
+bool BufferItem::isCurrentBuffer() const {
+ return _bufferInfo.bufferId() == Client::bufferModel()->currentIndex().data(NetworkModel::BufferIdRole).value<BufferId>();
+}
+
QString BufferItem::toolTip(int column) const {
Q_UNUSED(column);
return tr("<p> %1 - %2 </p>").arg(bufferInfo().bufferId().toInt()).arg(bufferName());
}
-/*
-void BufferItem::setLastMsgInsert(QDateTime msgDate) {
- if(msgDate.isValid() && msgDate > _lastMsgInsert)
- _lastMsgInsert = msgDate;
-}
-*/
-/*
-// FIXME emit dataChanged()
-bool BufferItem::setLastSeen() {
- if(_lastSeen > _lastMsgInsert)
- return false;
-
- _lastSeen = _lastMsgInsert;
- BufferSettings(bufferInfo().bufferId()).setLastSeen(_lastSeen);
- return true;
-}
-
-QDateTime BufferItem::lastSeen() {
- return _lastSeen;
-}
-*/
-
/*****************************************
* StatusBufferItem
*****************************************/
return index.data(NetworkModel::ItemTypeRole) == NetworkModel::BufferItemType;
}
-/*
-Buffer *NetworkModel::getBufferByIndex(const QModelIndex &index) const {
- BufferItem *item = static_cast<BufferItem *>(index.internalPointer());
- return Client::instance()->buffer(item->id());
-}
-*/
-
int NetworkModel::networkRow(NetworkId networkId) {
NetworkItem *netItem = 0;
for(int i = 0; i < rootItem->childCount(); i++) {
return indexByItem(_bufferItemCache[bufferId]);
}
-BufferItem *NetworkModel::findBufferItem(const BufferInfo &bufferInfo) {
- NetworkItem *netItem = findNetworkItem(bufferInfo.networkId());
- if(!netItem)
- return 0;
-
- BufferItem *bufferItem = netItem->findBufferItem(bufferInfo);
- return bufferItem;
-}
-
BufferItem *NetworkModel::findBufferItem(BufferId bufferId) {
- NetworkItem *netItem;
- BufferItem *bufferItem;
-
- for(int i = 0; i < rootItem->childCount(); i++) {
- netItem = qobject_cast<NetworkItem *>(rootItem->child(i));
- if((bufferItem = netItem->findBufferItem(bufferId)))
- return bufferItem;
- }
- return 0;
+ if(_bufferItemCache.contains(bufferId))
+ return _bufferItemCache[bufferId];
+ else
+ return 0;
}
BufferItem *NetworkModel::bufferItem(const BufferInfo &bufferInfo) {
+ if(_bufferItemCache.contains(bufferInfo.bufferId()))
+ return _bufferItemCache[bufferInfo.bufferId()];
+
NetworkItem *netItem = networkItem(bufferInfo.networkId());
return netItem->bufferItem(bufferInfo);
}
}
void NetworkModel::removeBuffer(BufferId bufferId) {
+ BufferItem *buffItem = findBufferItem(bufferId);
+ if(!buffItem)
+ return;
+
+ buffItem->parent()->removeChild(buffItem);
+}
+
+void NetworkModel::setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId) {
BufferItem *bufferItem = findBufferItem(bufferId);
- if(bufferItem)
- bufferItem->parent()->removeChild(bufferItem);
+ if(!bufferItem) {
+ qDebug() << "NetworkModel::setLastSeenMsgId(): buffer is unknown:" << bufferId;
+ return;
+ }
+ bufferItem->setLastSeenMsgId(msgId);
}
-/*
void NetworkModel::updateBufferActivity(const Message &msg) {
- BufferItem *buff = bufferItem(msg.bufferInfo());
- Q_ASSERT(buff);
-
- buff->setLastMsgInsert(msg.timestamp());
-
- if(buff->lastSeen() >= msg.timestamp())
+ BufferItem *bufferItem = findBufferItem(msg.bufferInfo());
+ if(!bufferItem) {
+ qDebug() << "NetworkModel::updateBufferActivity(): buffer is unknown:" << msg.bufferInfo();
return;
-
- BufferItem::ActivityLevel level = BufferItem::OtherActivity;
- if(msg.type() == Message::Plain || msg.type() == Message::Notice)
- level |= BufferItem::NewMessage;
-
- if(msg.flags() & Message::Highlight)
- level |= BufferItem::Highlight;
-
- bufferItem(msg.bufferInfo())->updateActivity(level);
+ }
+ bufferItem->updateActivityLevel(msg);
}
-*/
-void NetworkModel::setBufferActivity(const BufferInfo &info, Buffer::ActivityLevel level) {
- BufferItem *buff = bufferItem(info);
- Q_ASSERT(buff);
-
- buff->setActivityLevel(level);
+void NetworkModel::setBufferActivity(const BufferId &bufferId, Buffer::ActivityLevel level) {
+ BufferItem *bufferItem = findBufferItem(bufferId);
+ if(!bufferItem) {
+ qDebug() << "NetworkModel::setBufferActivity(): buffer is unknown:" << bufferId;
+ return;
+ }
+ bufferItem->setActivityLevel(level);
}
const Network *NetworkModel::networkByIndex(const QModelIndex &index) const {
return Client::network(networkId);
}
-
-
void NetworkModel::checkForRemovedBuffers(const QModelIndex &parent, int start, int end) {
if(parent.data(ItemTypeRole) != NetworkItemType)
return;
virtual inline bool isActive() const { return qobject_cast<NetworkItem *>(parent())->isActive(); }
+ inline const MsgId &lastSeenMsgId() const { return _lastSeenMsgId; }
+ inline void setLastSeenMsgId(const MsgId &msgId) { _lastSeenMsgId = msgId; }
inline Buffer::ActivityLevel activityLevel() const { return _activity; }
void setActivityLevel(Buffer::ActivityLevel level);
- void updateActivityLevel(Buffer::ActivityLevel level);
-
- void setLastMsgInsert(QDateTime msgDate);
- bool setLastSeen();
- QDateTime lastSeen();
+ //void updateActivityLevel(Buffer::ActivityLevel level);
+ void updateActivityLevel(const Message &msg);
+ bool isCurrentBuffer() const;
virtual QString toolTip(int column) const;
public slots:
private:
BufferInfo _bufferInfo;
Buffer::ActivityLevel _activity;
+ MsgId _lastSeenMsgId;
};
/*****************************************
Buffer::ActivityLevel bufferActivity(const BufferInfo &buffer) const;
QString bufferName(BufferId bufferId);
+ MsgId lastSeenMsgId(BufferId BufferId);
NetworkId networkId(BufferId bufferId);
QString networkName(BufferId bufferId);
BufferInfo::Type bufferType(BufferId bufferId);
public slots:
void bufferUpdated(BufferInfo bufferInfo);
void removeBuffer(BufferId bufferId);
- void setBufferActivity(const BufferInfo &buffer, Buffer::ActivityLevel activity);
+ void setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId);
+ void setBufferActivity(const BufferId &bufferId, Buffer::ActivityLevel activity);
+ void updateBufferActivity(const Message &msg);
void networkRemoved(const NetworkId &networkId);
private slots:
int networkRow(NetworkId networkId);
NetworkItem *findNetworkItem(NetworkId networkId);
NetworkItem *networkItem(NetworkId networkId);
- BufferItem *findBufferItem(const BufferInfo &bufferInfo);
+ inline BufferItem *findBufferItem(const BufferInfo &bufferInfo) { return findBufferItem(bufferInfo.bufferId()); }
BufferItem *findBufferItem(BufferId bufferId);
BufferItem *bufferItem(const BufferInfo &bufferInfo);
--- /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 "quasselui.h"
+
+bool AbstractUi::_visible = false;
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef _QUASSELUI_H_
-#define _QUASSELUI_H_
+#ifndef QUASSELUI_H
+#define QUASSELUI_H
#include <QObject>
#include "message.h"
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; }
+
protected slots:
virtual void connectedToCore() {}
virtual void disconnectedFromCore() {}
void connectToCore(const QVariantMap &connInfo);
void disconnectFromCore();
+private:
+ static bool _visible;
};
#endif
ui.setupUi(this);
}
-BufferWidget::~BufferWidget() {
-
-}
-
AbstractChatView *BufferWidget::createChatView(BufferId id) {
ChatView *chatView;
chatView = new ChatView(Client::buffer(id), this);
public:
BufferWidget(QWidget *parent);
- virtual ~BufferWidget();
protected:
virtual AbstractChatView *createChatView(BufferId);
#include <QtGui>
#include "bufferinfo.h"
+#include "buffersyncer.h"
+#include "client.h"
#include "chatitem.h"
#include "chatline.h"
+#include "messagemodel.h"
#include "qtui.h"
ChatLine::ChatLine(int row, QAbstractItemModel *model, QGraphicsItem *parent)
}
void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+// const QAbstractItemModel *model_ = model();
+// if(model_ && row() > 0) {
+// MsgId msgId = model_->data(model_->index(row() - 1, 0), MessageModel::MsgIdRole).value<MsgId>();
+// BufferId bufferId = model_->data(model_->index(row() - 1, 0), MessageModel::BufferIdRole).value<BufferId>();
+// qDebug() << msgId;
+// }
if(_selection & Highlighted) {
painter->fillRect(boundingRect(), QBrush(QtUi::style()->highlightColor()));
}
inline int row() { return _row; }
inline void setRow(int row) { _row = row; }
+ inline const QAbstractItemModel *model() const { return chatScene() ? chatScene()->model() : 0; }
+ inline ChatScene *chatScene() const { return qobject_cast<ChatScene *>(scene()); }
inline qreal width() const { return _width; }
inline qreal height() const { return _height; }
ChatItem &item(ChatLineModel::ColumnType);
#include <QGraphicsSceneMouseEvent>
#include <QPersistentModelIndex>
-#include "buffer.h"
#include "chatitem.h"
#include "chatline.h"
#include "chatlinemodelitem.h"
#include "types.h"
class AbstractUiMsg;
-class Buffer;
class BufferId;
class ChatItem;
class ChatLine;
scene()->setIsFetchingBacklog(vbar->value() == vbar->minimum());
}
}
+
+MsgId ChatView::lastMsgId() const {
+ if(!scene())
+ return MsgId();
+
+ QAbstractItemModel *model = scene()->model();
+ if(!model || model->rowCount() == 0)
+ return MsgId();
+
+
+ return model->data(model->index(model->rowCount() - 1, 0), MessageModel::MsgIdRole).value<MsgId>();
+}
ChatView(MessageFilter *, QWidget *parent = 0);
ChatView(Buffer *, QWidget *parent = 0);
+ virtual MsgId lastMsgId() const;
inline ChatScene *scene() const { return _scene; }
public slots:
class Buffer;
class BufferViewConfig;
class MsgProcessorStatusWidget;
-class QtUi;
class Message;
class NickListWidget;
class MainWin : public QMainWindow {
Q_OBJECT
- public:
- MainWin(QWidget *parent = 0);
- virtual ~MainWin();
+public:
+ MainWin(QWidget *parent = 0);
+ virtual ~MainWin();
- void init();
- void addBufferView(BufferViewConfig *config = 0);
+ void init();
+ void addBufferView(BufferViewConfig *config = 0);
- void displayTrayIconMessage(const QString &title, const QString &message);
+ void displayTrayIconMessage(const QString &title, const QString &message);
#ifdef HAVE_DBUS
- void sendDesktopNotification(const QString &title, const QString &message);
+ void sendDesktopNotification(const QString &title, const QString &message);
#endif
- virtual bool event(QEvent *event);
-
- public slots:
- void setTrayIconActivity(bool active = false);
-
- protected:
- void closeEvent(QCloseEvent *event);
- virtual void changeEvent(QEvent *event);
-
- protected slots:
- void connectedToCore();
- void setConnectedState();
- void updateLagIndicator(int lag);
- void securedConnection();
- void disconnectedFromCore();
- void setDisconnectedState();
- void systrayActivated( QSystemTrayIcon::ActivationReason );
-
- private slots:
- void addBufferView(int bufferViewConfigId);
- void removeBufferView(int bufferViewConfigId);
- void messagesInserted(const QModelIndex &parent, int start, int end);
- void showChannelList(NetworkId netId = NetworkId());
- void showCoreInfoDlg();
- void showSettingsDlg();
- void on_actionEditNetworks_triggered();
- void on_actionManageViews_triggered();
- void on_actionLockDockPositions_toggled(bool lock);
- void showAboutDlg();
- void on_actionDebugNetworkModel_triggered(bool);
-
- void showCoreConnectionDlg(bool autoConnect = false);
-
- void clientNetworkCreated(NetworkId);
- void clientNetworkRemoved(NetworkId);
- void clientNetworkUpdated();
- void connectOrDisconnectFromNet();
-
- void makeTrayIconBlink();
- void saveStatusBarStatus(bool enabled);
-
- void loadLayout();
- void saveLayout();
-
+ virtual bool event(QEvent *event);
+
+public slots:
+ void setTrayIconActivity(bool active = false);
+
+protected:
+ void closeEvent(QCloseEvent *event);
+ virtual void changeEvent(QEvent *event);
+
+protected slots:
+ void connectedToCore();
+ void setConnectedState();
+ void updateLagIndicator(int lag);
+ void securedConnection();
+ void disconnectedFromCore();
+ void setDisconnectedState();
+ void systrayActivated( QSystemTrayIcon::ActivationReason );
+
+private slots:
+ void addBufferView(int bufferViewConfigId);
+ void removeBufferView(int bufferViewConfigId);
+ void messagesInserted(const QModelIndex &parent, int start, int end);
+ void showChannelList(NetworkId netId = NetworkId());
+ void showCoreInfoDlg();
+ void showSettingsDlg();
+ void on_actionEditNetworks_triggered();
+ void on_actionManageViews_triggered();
+ void on_actionLockDockPositions_toggled(bool lock);
+ void showAboutDlg();
+ void on_actionDebugNetworkModel_triggered(bool);
+
+ void showCoreConnectionDlg(bool autoConnect = false);
+
+ void clientNetworkCreated(NetworkId);
+ void clientNetworkRemoved(NetworkId);
+ void clientNetworkUpdated();
+ void connectOrDisconnectFromNet();
+
+ void makeTrayIconBlink();
+ void saveStatusBarStatus(bool enabled);
+
+ void loadLayout();
+ void saveLayout();
+
#ifdef HAVE_DBUS
- void desktopNotificationClosed(uint id, uint reason);
- void desktopNotificationInvoked(uint id, const QString & action);
+ void desktopNotificationClosed(uint id, uint reason);
+ void desktopNotificationInvoked(uint id, const QString & action);
#endif
-
- signals:
- void connectToCore(const QVariantMap &connInfo);
- void disconnectFromCore();
- void requestBacklog(BufferInfo, QVariant, QVariant);
-
- private:
- Ui::MainWin ui;
-
- QMenu *systrayMenu;
- QLabel *coreLagLabel;
- QLabel *sslLabel;
- MsgProcessorStatusWidget *msgProcessorStatusWidget;
-
- TitleSetter _titleSetter;
-
- void setupMenus();
- void setupViews();
- void setupNickWidget();
- void setupChatMonitor();
- void setupInputWidget();
- void setupTopicWidget();
- void setupStatusBar();
- void setupSystray();
-
- void toggleVisibility();
-
- void enableMenus();
-
- QSystemTrayIcon *systray;
- QIcon activeTrayIcon;
- QIcon onlineTrayIcon;
- QIcon offlineTrayIcon;
- bool trayIconActive;
- QTimer *timer;
-
- BufferId currentBuffer;
- QString currentProfile;
-
- QList<QDockWidget *> _netViews;
- NickListWidget *nickListWidget;
-
+
+signals:
+ void connectToCore(const QVariantMap &connInfo);
+ void disconnectFromCore();
+ void requestBacklog(BufferInfo, QVariant, QVariant);
+
+private:
+ Ui::MainWin ui;
+
+ QMenu *systrayMenu;
+ QLabel *coreLagLabel;
+ QLabel *sslLabel;
+ MsgProcessorStatusWidget *msgProcessorStatusWidget;
+
+ TitleSetter _titleSetter;
+
+ void setupMenus();
+ void setupViews();
+ void setupNickWidget();
+ void setupChatMonitor();
+ void setupInputWidget();
+ void setupTopicWidget();
+ void setupStatusBar();
+ void setupSystray();
+
+ void toggleVisibility();
+
+ void enableMenus();
+
+ QSystemTrayIcon *systray;
+ QIcon activeTrayIcon;
+ QIcon onlineTrayIcon;
+ QIcon offlineTrayIcon;
+ bool trayIconActive;
+ QTimer *timer;
+
+ BufferId currentBuffer;
+ QString currentProfile;
+
+ QList<QDockWidget *> _netViews;
+ NickListWidget *nickListWidget;
+
#ifdef HAVE_DBUS
- org::freedesktop::Notifications *desktopNotifications;
- quint32 notificationId;
+ org::freedesktop::Notifications *desktopNotifications;
+ quint32 notificationId;
#endif
-
- friend class QtUi;
+
+ friend class QtUi;
};
#endif
***************************************************************************/
#include "abstractbuffercontainer.h"
-#include "buffer.h"
#include "client.h"
#include "networkmodel.h"
AbstractBufferContainer::~AbstractBufferContainer() {
}
-
void AbstractBufferContainer::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
Q_ASSERT(model());
if(!parent.isValid()) {
}
void AbstractBufferContainer::removeBuffer(BufferId bufferId) {
- if(Client::buffer(bufferId)) Client::buffer(bufferId)->setVisible(false);
if(!_chatViews.contains(bufferId))
return;
}
void AbstractBufferContainer::setCurrentBuffer(BufferId bufferId) {
- AbstractChatView *chatView = 0;
- Buffer *prevBuffer = Client::buffer(currentBuffer());
- if(prevBuffer) prevBuffer->setVisible(false);
+ BufferId prevBufferId = currentBuffer();
+ if(prevBufferId.isValid() && _chatViews.contains(prevBufferId)) {
+ Client::setBufferLastSeenMsg(prevBufferId, _chatViews[prevBufferId]->lastMsgId());
+ }
- Buffer *buf;
- if(!bufferId.isValid() || !(buf = Client::buffer(bufferId))) {
- if(bufferId.isValid())
- qWarning() << "AbstractBufferContainer::setBuffer(BufferId): Can't show unknown Buffer:" << bufferId;
+ if(!bufferId.isValid()) {
+ qWarning() << "AbstractBufferContainer::setBuffer(BufferId): invalid BufferId:" << bufferId;
_currentBuffer = 0;
showChatView(0);
return;
}
- if(_chatViews.contains(bufferId)) {
- chatView = _chatViews[bufferId];
- } else {
- chatView = createChatView(bufferId);
- _chatViews[bufferId] = chatView;
- }
+
+ if(!_chatViews.contains(bufferId))
+ _chatViews[bufferId] = createChatView(bufferId);
+
_currentBuffer = bufferId;
showChatView(bufferId);
- buf->setVisible(true);
+ Client::networkModel()->setBufferActivity(bufferId, Buffer::NoActivity);
+ Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
setFocus();
}
public:
virtual ~AbstractChatView() {};
-
+ virtual MsgId lastMsgId() const = 0;
};
#endif