From dfbd0465f2a58eee4771472afd261869e5e5c400 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 10 Jun 2008 00:42:59 +0200 Subject: [PATCH] Removing SPUTDEV, obsolete code and #ifdefs from sources --- src/client/client.cpp | 112 +--------------------------------- src/common/message.cpp | 123 -------------------------------------- src/common/message.h | 13 ---- src/qtui/bufferwidget.cpp | 5 -- src/qtui/mainwin.cpp | 10 ++-- src/qtui/qtui.cpp | 17 +----- src/qtui/qtuistyle.cpp | 6 +- src/uisupport/uistyle.h | 5 -- 8 files changed, 11 insertions(+), 280 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index e936be5d..e532df8a 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -32,9 +32,7 @@ #include "ircchannel.h" #include "ircuser.h" #include "message.h" -#ifdef SPUTDEV -# include "messagemodel.h" -#endif +#include "messagemodel.h" #include "network.h" #include "networkmodel.h" #include "quasselui.h" @@ -95,12 +93,11 @@ void Client::init() { connect(this, SIGNAL(bufferUpdated(BufferInfo)), _networkModel, SLOT(bufferUpdated(BufferInfo))); connect(this, SIGNAL(networkRemoved(NetworkId)), - _networkModel, SLOT(networkRemoved(NetworkId))); + _networkModel, SLOT(networkRemoved(NetworkId))); _bufferModel = new BufferModel(_networkModel); -#ifdef SPUTDEV _messageModel = mainUi->createMessageModel(this); -#endif + SignalProxy *p = signalProxy(); p->attachSlot(SIGNAL(displayMsg(const Message &)), this, SLOT(recvMessage(const Message &))); @@ -440,87 +437,15 @@ void Client::networkDestroyed() { } } -#ifndef SPUTDEV -void Client::recvMessage(const Message &message) { - Message msg = message; - Buffer *b; - - checkForHighlight(msg); - - // FIXME clean up code! (dup) - - // TODO: make redirected messages show up in the correct buffer! - - if(msg.flags() & Message::Redirected) { - BufferSettings bufferSettings; - bool inStatus = bufferSettings.value("UserMessagesInStatusBuffer", QVariant(true)).toBool(); - bool inQuery = bufferSettings.value("UserMessagesInQueryBuffer", QVariant(false)).toBool(); - bool inCurrent = bufferSettings.value("UserMessagesInCurrentBuffer", QVariant(false)).toBool(); - - if(inStatus) { - b = statusBuffer(msg.bufferInfo().networkId()); - if(b) { - b->appendMsg(msg); - } else if(!inQuery && !inCurrent) { // make sure the message get's shown somewhere - b = buffer(msg.bufferInfo()); - b->appendMsg(msg); - } - } - - if(inQuery) { - b = buffer(msg.bufferInfo().bufferId()); - if(b) { - b->appendMsg(msg); - } else if(!inStatus && !inCurrent) { // make sure the message get's shown somewhere - b = statusBuffer(msg.bufferInfo().networkId()); - if(!b) b = buffer(msg.bufferInfo()); // seems like we have to create the buffer anyways... - b->appendMsg(msg); - } - } - - if(inCurrent) { - BufferId currentId = bufferModel()->currentIndex().data(NetworkModel::BufferIdRole).value(); - b = buffer(currentId); - if(b && currentId != msg.bufferInfo().bufferId() && !inQuery) { - b->appendMsg(msg); - } else if(!inStatus && !inQuery) { // make sure the message get's shown somewhere - b = statusBuffer(msg.bufferInfo().networkId()); - if(!b) b = buffer(msg.bufferInfo()); // seems like we have to create the buffer anyways... - b->appendMsg(msg); - } - } - } else { - // the regular case: we can deliver where it was supposed to go - b = buffer(msg.bufferInfo()); - b->appendMsg(msg); - } - //bufferModel()->updateBufferActivity(msg); - - if(msg.type() == Message::Plain || msg.type() == Message::Notice || msg.type() == Message::Action) { - const Network *net = network(msg.bufferInfo().networkId()); - QString networkName = net != 0 - ? net->networkName() + ":" - : QString(); - QString sender = networkName + msg.bufferInfo().bufferName() + ":" + msg.sender(); - Message mmsg = Message(msg.timestamp(), msg.bufferInfo(), msg.type(), msg.contents(), sender, msg.flags()); - monitorBuffer()->appendMsg(mmsg); - } - emit messageReceived(msg); -} -#else - void Client::recvMessage(const Message &msg) { //checkForHighlight(msg); _messageModel->insertMessage(msg); } -#endif /* SPUTDEV */ - void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) { //recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg))); } -#ifdef SPUTDEV void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) { //checkForHighlight(msg); foreach(QVariant v, msgs) { @@ -528,37 +453,6 @@ void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) { } } -#else - -void Client::receiveBacklog(BufferId bufferId, const QVariantList &msgs) { - Buffer *buffer_ = buffer(bufferId); - if(!buffer_) { - qWarning() << "Client::receiveBacklog(): received Backlog for unknown Buffer:" << bufferId; - return; - } - - if(msgs.isEmpty()) - return; // no work to be done... - - QVariantList::const_iterator msgIter = msgs.constBegin(); - QVariantList::const_iterator msgIterEnd = msgs.constEnd(); - Message msg; - while(msgIter != msgIterEnd) { - msg = (*msgIter).value(); - checkForHighlight(msg); - buffer_->prependMsg(msg); - msgIter++; - } - - if(!layoutQueue.contains(buffer_)) - layoutQueue.append(buffer_); - - if(!layoutTimer->isActive()) { - layoutTimer->start(); - } -} -#endif /* SPUTDEV */ - void Client::layoutMsg() { if(layoutQueue.isEmpty()) { layoutTimer->stop(); diff --git a/src/common/message.cpp b/src/common/message.cpp index 2ce40f81..124a291a 100644 --- a/src/common/message.cpp +++ b/src/common/message.cpp @@ -48,129 +48,6 @@ void Message::setFlags(Flags flags) { _flags = flags; } -#ifndef SPUTDEV -QString Message::mircToInternal(QString mirc) { - mirc.replace('%', "%%"); // escape % just to be sure - mirc.replace('\x02', "%B"); - mirc.replace('\x0f', "%O"); - mirc.replace('\x12', "%R"); - mirc.replace('\x16', "%R"); - mirc.replace('\x1d', "%S"); - mirc.replace('\x1f', "%U"); - - // Now we bring the color codes (\x03) in a sane format that can be parsed more easily later. - // %Dcfxx is foreground, %Dcbxx is background color, where xx is a 2 digit dec number denoting the color code. - // %Dc- turns color off. - // Note: We use the "mirc standard" as described in . - // This means that we don't accept something like \x03,5 (even though others, like WeeChat, do). - int pos = 0; - for(;;) { - pos = mirc.indexOf('\x03', pos); - if(pos < 0) break; // no more mirc color codes - QString ins, num; - int l = mirc.length(); - int i = pos + 1; - // check for fg color - if(i < l && mirc[i].isDigit()) { - num = mirc[i++]; - if(i < l && mirc[i].isDigit()) num.append(mirc[i++]); - else num.prepend('0'); - ins = QString("%Dcf%1").arg(num); - - if(i+1 < l && mirc[i] == ',' && mirc[i+1].isDigit()) { - i++; - num = mirc[i++]; - if(i < l && mirc[i].isDigit()) num.append(mirc[i++]); - else num.prepend('0'); - ins += QString("%Dcb%1").arg(num); - } - } else { - ins = "%Dc-"; - } - mirc.replace(pos, i-pos, ins); - } - return mirc; -} - -void Message::format() { - if(!_formattedText.isNull()) - return; // already done - - QString user = userFromMask(sender()); - QString host = hostFromMask(sender()); - QString nick = nickFromMask(sender()); - QString txt = mircToInternal(contents()); - QString bufferName = bufferInfo().bufferName(); - - _formattedTimestamp = tr("%DT[%1]").arg(timestamp().toLocalTime().toString("hh:mm:ss")); - - QString s, t; - switch(type()) { - case Message::Plain: - s = tr("%DS<%1>").arg(nick); t = tr("%D0%1").arg(txt); break; - case Message::Notice: - s = tr("%Dn[%1]").arg(nick); t = tr("%Dn%1").arg(txt); break; - case Message::Server: - s = tr("%Ds*"); t = tr("%Ds%1").arg(txt); break; - case Message::Error: - s = tr("%De*"); t = tr("%De%1").arg(txt); break; - case Message::Join: - s = tr("%Dj-->"); t = tr("%Dj%DN%1%DN %DH(%2@%3)%DH has joined %DC%4%DC").arg(nick, user, host, bufferName); break; - case Message::Part: - s = tr("%Dp<--"); t = tr("%Dp%DN%1%DN %DH(%2@%3)%DH has left %DC%4%DC").arg(nick, user, host, bufferName); - if(!txt.isEmpty()) t = QString("%1 (%2)").arg(t).arg(txt); - break; - case Message::Quit: - s = tr("%Dq<--"); t = tr("%Dq%DN%DU%1%DU%DN %DH(%2@%3)%DH has quit").arg(nick, user, host); - if(!txt.isEmpty()) t = QString("%1 (%2)").arg(t).arg(txt); - break; - case Message::Kick: - { s = tr("%Dk<-*"); - QString victim = txt.section(" ", 0, 0); - //if(victim == ui.ownNick->currentText()) victim = tr("you"); - QString kickmsg = txt.section(" ", 1); - t = tr("%Dk%DN%1%DN has kicked %DN%2%DN from %DC%3%DC").arg(nick).arg(victim).arg(bufferName); - if(!kickmsg.isEmpty()) t = QString("%1 (%2)").arg(t).arg(kickmsg); - } - break; - case Message::Nick: - s = tr("%Dr<->"); - if(nick == contents()) t = tr("%DrYou are now known as %DN%1%DN").arg(txt); - else t = tr("%Dr%DN%1%DN is now known as %DN%2%DN").arg(nick, txt); - break; - case Message::Mode: - s = tr("%Dm***"); - if(nick.isEmpty()) t = tr("%DmUser mode: %DM%1%DM").arg(contents()); - else t = tr("%DmMode %DM%1%DM by %DN%2%DN").arg(txt, nick); - break; - case Message::Action: - s = tr("%Da-*-"); - t = tr("%Da%DN%1%DN %2").arg(nick).arg(txt); - break; - default: - s = tr("%De%1").arg(sender()); - t = tr("%De[%1]").arg(txt); - } - _formattedSender = s; - _formattedText = t; -} - -QString Message::formattedTimestamp() { - format(); - return _formattedTimestamp; -} - -QString Message::formattedSender() { - format(); - return _formattedSender; -} - -QString Message::formattedText() { - format(); - return _formattedText; -} -#endif /* SPUTDEV */ - QDataStream &operator<<(QDataStream &out, const Message &msg) { out << msg.msgId() << (quint32)msg.timestamp().toTime_t() << (quint32)msg.type() << (quint8)msg.flags() << msg.bufferInfo() << msg.sender().toUtf8() << msg.contents().toUtf8(); diff --git a/src/common/message.h b/src/common/message.h index 797e28b7..a4c4ab6a 100644 --- a/src/common/message.h +++ b/src/common/message.h @@ -72,19 +72,6 @@ public: inline QDateTime timestamp() const { return _timestamp; } void setFlags(Flags flags); - -#ifndef SPUTDEV - QString formattedTimestamp(); - QString formattedSender(); - QString formattedText(); - - //static QString formattedToHtml(const QString &); - - /** Convert mIRC control codes to our own */ - static QString mircToInternal(QString); - - void format(); -#endif private: QDateTime _timestamp; diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index bc10ca54..d6dcfa25 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -20,7 +20,6 @@ #include "bufferwidget.h" #include "chatview.h" -#include "chatwidget.h" #include "settings.h" #include "client.h" @@ -36,11 +35,7 @@ BufferWidget::~BufferWidget() { AbstractChatView *BufferWidget::createChatView(BufferId id) { QWidget *chatView; -#ifdef SPUTDEV chatView = new ChatView(Client::buffer(id), this); -#else - chatView = new ChatWidget(id, this); -#endif _chatViews[id] = chatView; ui.stackedWidget->addWidget(chatView); chatView->setFocusProxy(this); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 4d599e26..1515dd47 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -20,7 +20,6 @@ #include "mainwin.h" #include "aboutdlg.h" -#include "chatwidget.h" #include "bufferview.h" #include "bufferviewconfig.h" #include "bufferviewfilter.h" @@ -286,7 +285,7 @@ void MainWin::setupNickWidget() { } void MainWin::setupChatMonitor() { -#ifndef SPUTDEV +/* VerticalDock *dock = new VerticalDock(tr("Chat Monitor"), this); dock->setObjectName("ChatMonitorDock"); @@ -305,7 +304,7 @@ void MainWin::setupChatMonitor() { addDockWidget(Qt::TopDockWidgetArea, dock, Qt::Vertical); ui.menuViews->addAction(dock->toggleViewAction()); -#endif /* SPUTDEV */ +*/ } void MainWin::setupInputWidget() { @@ -600,18 +599,19 @@ void MainWin::receiveMessage(const Message &msg) { UiSettings uiSettings; -#ifndef SPUTDEV bool displayBubble = uiSettings.value("NotificationBubble", QVariant(true)).toBool(); bool displayDesktop = uiSettings.value("NotificationDesktop", QVariant(true)).toBool(); if(displayBubble || displayDesktop) { +/* // FIXME port + if(uiSettings.value("DisplayPopupMessages", QVariant(true)).toBool()) { // FIXME don't invoke style engine for this! QString text = QtUi::style()->styleString(Message::mircToInternal(msg.contents())).plainText; if(displayBubble) displayTrayIconMessage(title, text); # ifdef HAVE_DBUS if(displayDesktop) sendDesktopNotification(title, text); # endif + */ } -#endif if(uiSettings.value("AnimateTrayIcon", QVariant(true)).toBool()) { QApplication::alert(this); setTrayIconActivity(true); diff --git a/src/qtui/qtui.cpp b/src/qtui/qtui.cpp index e58777e6..a6e7ddf4 100644 --- a/src/qtui/qtui.cpp +++ b/src/qtui/qtui.cpp @@ -20,11 +20,7 @@ #include "qtui.h" -#ifdef SPUTDEV -# include "chatlinemodel.h" -#else -# include "chatline-old.h" -#endif +#include "chatlinemodel.h" #include "mainwin.h" QtUiStyle *QtUi::_style; @@ -53,20 +49,11 @@ QtUiStyle *QtUi::style() { } MessageModel *QtUi::createMessageModel(QObject *parent) { -#ifndef SPUTDEV - Q_UNUSED(parent) - return 0; -#else return new ChatLineModel(parent); -#endif } AbstractUiMsg *QtUi::layoutMsg(const Message &msg) { -#ifndef SPUTDEV - return new ChatLineOld(msg); -#else - return 0; -#endif + return 0; // FIXME obsolete? } void QtUi::connectedToCore() { diff --git a/src/qtui/qtuistyle.cpp b/src/qtui/qtuistyle.cpp index 78255dca..8c9f5dc0 100644 --- a/src/qtui/qtuistyle.cpp +++ b/src/qtui/qtuistyle.cpp @@ -20,11 +20,7 @@ #include "qtuistyle.h" -#ifndef SPUTDEV -QtUiStyle::QtUiStyle() : UiStyle("QtUiStyle") { -#else -QtUiStyle::QtUiStyle() : UiStyle("QtUiStyleNew") { -#endif +QtUiStyle::QtUiStyle() : UiStyle("QtUiStyleNew") { // FIXME QtUiStyleNew naming // We need to just set our internal formats; everything else is done by the base class... // Internal message formats diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index 426b398e..b3e1a965 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -21,10 +21,6 @@ #ifndef _UISTYLE_H_ #define _UISTYLE_H_ -#ifndef SPUTDEV -# include "old-uistyle.h" -#else - #include #include #include @@ -161,5 +157,4 @@ QDataStream &operator>>(QDataStream &in, UiStyle::FormatList &formatList); Q_DECLARE_METATYPE(UiStyle::FormatList); -#endif // SPUTDEV #endif -- 2.20.1