From: Marcus Eggenberger Date: Thu, 5 Feb 2009 14:23:40 +0000 (+0100) Subject: Fixes #410 - away log (you'll find it in the views menu) X-Git-Tag: 0.4.0~133 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=453ccab6ade4a21c7aa3c331af893c91468250a4 Fixes #410 - away log (you'll find it in the views menu) --- diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 2fad8d65..ee333cee 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -960,6 +960,15 @@ MsgId NetworkModel::lastSeenMarkerMsgId(BufferId bufferId) const { return _bufferItemCache[bufferId]->lastSeenMarkerMsgId(); } +MsgId NetworkModel::lastSeenMsgId(const BufferId &bufferId) { + BufferItem *bufferItem = findBufferItem(bufferId); + if(!bufferItem) { + qDebug() << "NetworkModel::lastSeenMsgId(): buffer is unknown:" << bufferId; + return MsgId(); + } + return bufferItem->lastSeenMsgId(); +} + void NetworkModel::setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId) { BufferItem *bufferItem = findBufferItem(bufferId); if(!bufferItem) { diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index 868de0bd..f763a21c 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -323,6 +323,7 @@ public: public slots: void bufferUpdated(BufferInfo bufferInfo); void removeBuffer(BufferId bufferId); + MsgId lastSeenMsgId(const BufferId &bufferId); void setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId); void setBufferActivity(const BufferId &bufferId, BufferInfo::ActivityLevel activity); void clearBufferActivity(const BufferId &bufferId); diff --git a/src/core/core.cpp b/src/core/core.cpp index aa1b7d48..4e7632fc 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -158,10 +158,21 @@ void Core::init() { } Core::~Core() { + _server.close(); + _v6server.close(); foreach(QTcpSocket *socket, blocksizes.keys()) { socket->disconnectFromHost(); // disconnect non authed clients } - qDeleteAll(sessions); + + + foreach(SessionThread *session, sessions) { + session->stopSession(); + session->wait(); + delete session; + qDebug() << "next"; + } + +// qDeleteAll(sessions); qDeleteAll(_storageBackends); } diff --git a/src/core/corenetwork.cpp b/src/core/corenetwork.cpp index a40b5464..f0561838 100644 --- a/src/core/corenetwork.cpp +++ b/src/core/corenetwork.cpp @@ -82,6 +82,8 @@ CoreNetwork::CoreNetwork(const NetworkId &networkid, CoreSession *session) CoreNetwork::~CoreNetwork() { if(connectionState() != Disconnected && connectionState() != Network::Reconnecting) disconnectFromIrc(false); // clean up, but this does not count as requested disconnect! + else + socket.close(); disconnect(&socket, 0, this, 0); // this keeps the socket from triggering events during clean up delete _ircServerHandler; delete _userInputHandler; diff --git a/src/core/sessionthread.cpp b/src/core/sessionthread.cpp index 35caf13b..c29d1ff7 100644 --- a/src/core/sessionthread.cpp +++ b/src/core/sessionthread.cpp @@ -36,9 +36,12 @@ SessionThread::SessionThread(UserId uid, bool restoreState, QObject *parent) } SessionThread::~SessionThread() { - // shut down thread gracefully - quit(); - wait(); + if(_session) { + _session->setParent(0); + _session->moveToThread(thread()); + _session->deleteLater(); + _session = 0; + } } CoreSession *SessionThread::session() { @@ -103,5 +106,13 @@ void SessionThread::run() { emit initialized(); exec(); delete _session; + _session = 0; } +void SessionThread::stopSession() { + if(_session) { + connect(_session, SIGNAL(destroyed()), this, SLOT(quit())); + _session->deleteLater(); + _session = 0; + } +} diff --git a/src/core/sessionthread.h b/src/core/sessionthread.h index 810e8583..f9280f05 100644 --- a/src/core/sessionthread.h +++ b/src/core/sessionthread.h @@ -44,6 +44,7 @@ public: public slots: void addClient(QObject *peer); + void stopSession(); private slots: void setSessionInitialized(); diff --git a/src/qtui/CMakeLists.txt b/src/qtui/CMakeLists.txt index 2e0d3cf1..ca17c3a5 100644 --- a/src/qtui/CMakeLists.txt +++ b/src/qtui/CMakeLists.txt @@ -7,6 +7,8 @@ include(${QT_USE_FILE}) set(SOURCES aboutdlg.cpp + awaylogfilter.cpp + awaylogview.cpp bufferwidget.cpp channellistdlg.cpp chatitem.cpp @@ -50,6 +52,8 @@ set(SOURCES set(MOC_HDRS aboutdlg.h + awaylogfilter.h + awaylogview.h bufferwidget.h channellistdlg.h chatitem.h diff --git a/src/qtui/awaylogfilter.cpp b/src/qtui/awaylogfilter.cpp new file mode 100644 index 00000000..09964a46 --- /dev/null +++ b/src/qtui/awaylogfilter.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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 "awaylogfilter.h" + +AwayLogFilter::AwayLogFilter(MessageModel *model, QObject *parent) + : ChatMonitorFilter(model, parent) +{ +} + +bool AwayLogFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { + Q_UNUSED(sourceParent) + + QModelIndex source_index = sourceModel()->index(sourceRow, 0); + + Message::Flags flags = (Message::Flags)source_index.data(MessageModel::FlagsRole).toInt(); + if(!(flags & Message::Backlog && flags & Message::Highlight)) + return false; + + BufferId bufferId = source_index.data(MessageModel::BufferIdRole).value(); + if(!bufferId.isValid()) { + return false; + } + + if(Client::networkModel()->lastSeenMsgId(bufferId) >= source_index.data(MessageModel::MsgIdRole).value()) + return false; + + return true; +} diff --git a/src/qtui/awaylogfilter.h b/src/qtui/awaylogfilter.h new file mode 100644 index 00000000..bb80011e --- /dev/null +++ b/src/qtui/awaylogfilter.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 AWAYLOGFILTER_H +#define AWAYLOGFILTER_H + +#include "chatmonitorfilter.h" + +class AwayLogFilter : public ChatMonitorFilter { + Q_OBJECT + +public: + AwayLogFilter(MessageModel *model, QObject *parent = 0); + + virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + virtual QString idString() const { return "AwayLog"; } +}; + +#endif //AWAYLOGFILTER_H diff --git a/src/qtui/awaylogview.cpp b/src/qtui/awaylogview.cpp new file mode 100644 index 00000000..cb26792a --- /dev/null +++ b/src/qtui/awaylogview.cpp @@ -0,0 +1,53 @@ +/*************************************************************************** + * 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 "awaylogview.h" + +#include +#include + +#include "awaylogfilter.h" +#include "chatlinemodel.h" +#include "chatscene.h" + +AwayLogView::AwayLogView(AwayLogFilter *filter, QWidget *parent) + : ChatMonitorView(filter, parent) +{ +} + +void AwayLogView::addActionsToMenu(QMenu *menu, const QPointF &pos) { + ChatView::addActionsToMenu(menu, pos); + if(!menu->isEmpty()) + menu->addSeparator(); + + if(scene()->columnByScenePos(pos) == ChatLineModel::SenderColumn) { + menu->addSeparator(); + + QAction *showNetworkAction = menu->addAction(tr("Show Network Name"), this, SLOT(showFieldsChanged(bool))); + showNetworkAction->setCheckable(true); + showNetworkAction->setChecked(filter()->showFields() & ChatMonitorFilter::NetworkField); + showNetworkAction->setData(ChatMonitorFilter::NetworkField); + + QAction *showBufferAction = menu->addAction(tr("Show Buffer Name"), this, SLOT(showFieldsChanged(bool))); + showBufferAction->setCheckable(true); + showBufferAction->setChecked(filter()->showFields() & ChatMonitorFilter::BufferField); + showBufferAction->setData(ChatMonitorFilter::BufferField); + } +} diff --git a/src/qtui/awaylogview.h b/src/qtui/awaylogview.h new file mode 100644 index 00000000..542d8ead --- /dev/null +++ b/src/qtui/awaylogview.h @@ -0,0 +1,36 @@ +/*************************************************************************** + * 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 AWAYLOGVIEW_H +#define AWAYLOGVIEW_H + +#include "chatmonitorview.h" + +class AwayLogFilter; + +class AwayLogView : public ChatMonitorView { + Q_OBJECT + +public: + AwayLogView(AwayLogFilter *filter, QWidget *parent = 0); + virtual void addActionsToMenu(QMenu *menu, const QPointF &pos); +}; + +#endif //AWAYLOGVIEW_H diff --git a/src/qtui/chatmonitorview.h b/src/qtui/chatmonitorview.h index 06f1f151..f238f7b3 100644 --- a/src/qtui/chatmonitorview.h +++ b/src/qtui/chatmonitorview.h @@ -39,6 +39,9 @@ private slots: void showFieldsChanged(bool checked); void showSettingsPage(); +protected: + inline ChatMonitorFilter *filter() const { return _filter; } + private: ChatMonitorFilter *_filter; }; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 10aedfa9..555ac5d4 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -29,6 +29,8 @@ #endif #include "aboutdlg.h" +#include "awaylogfilter.h" +#include "awaylogview.h" #include "action.h" #include "actioncollection.h" #include "buffermodel.h" @@ -100,7 +102,8 @@ MainWin::MainWin(QWidget *parent) sslLabel(new QLabel()), msgProcessorStatusWidget(new MsgProcessorStatusWidget()), _titleSetter(this), - _trayIcon(new QSystemTrayIcon(this)) + _trayIcon(new QSystemTrayIcon(this)), + _awayLog(0) { QtUiSettings uiSettings; QString style = uiSettings.value("Style", QString()).toString(); @@ -222,7 +225,9 @@ void MainWin::setupActions() { connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockDockPositions_toggled(bool))); coll->addAction("ToggleSearchBar", new Action(SmallIcon("edit-find"), tr("Show &Search Bar"), coll, - 0, 0, tr("Ctrl+F")))->setCheckable(true); + 0, 0, tr("Ctrl+F")))->setCheckable(true); + coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll, + this, SLOT(showAwayLog()))); coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll, 0, 0))->setCheckable(true); @@ -270,6 +275,7 @@ void MainWin::setupMenus() { _bufferViewsMenu->addAction(coll->action("ConfigureBufferViews")); _viewMenu->addSeparator(); _viewMenu->addAction(coll->action("ToggleSearchBar")); + _viewMenu->addAction(coll->action("ShowAwayLog")); _viewMenu->addAction(coll->action("ToggleStatusBar")); _viewMenu->addSeparator(); _viewMenu->addAction(coll->action("LockDockPositions")); @@ -652,6 +658,21 @@ void MainWin::showCoreInfoDlg() { CoreInfoDlg(this).exec(); } +void MainWin::showAwayLog() { + if(_awayLog) + return; + AwayLogFilter *filter = new AwayLogFilter(Client::messageModel()); + _awayLog = new AwayLogView(filter, 0); + filter->setParent(_awayLog); + connect(_awayLog, SIGNAL(destroyed()), this, SLOT(awayLogDestroyed())); + _awayLog->setAttribute(Qt::WA_DeleteOnClose); + _awayLog->show(); +} + +void MainWin::awayLogDestroyed() { + _awayLog = 0; +} + void MainWin::showSettingsDlg() { SettingsDlg *dlg = new SettingsDlg(); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 682b37b7..a4f6496a 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -92,6 +92,7 @@ class MainWin private slots: void addBufferView(int bufferViewConfigId); + void awayLogDestroyed(); void removeBufferView(int bufferViewConfigId); void messagesInserted(const QModelIndex &parent, int start, int end); void showAboutDlg(); @@ -99,6 +100,7 @@ class MainWin void startInternalCore(); void showCoreConnectionDlg(bool autoConnect = false); void showCoreInfoDlg(); + void showAwayLog(); void showSettingsDlg(); void showNotificationsDlg(); #ifdef HAVE_KDE @@ -162,6 +164,7 @@ class MainWin QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu; + QWidget *_awayLog; friend class QtUi; };