From: Manuel Nickschas Date: Mon, 25 Jun 2007 18:21:09 +0000 (+0000) Subject: Finished the fusion of the different main_* files, so now we have only one #ifdef... X-Git-Tag: 0.1.0~191 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=6869909402a4dc807ee5261cc2a0999ac33053ee Finished the fusion of the different main_* files, so now we have only one #ifdef-ridden main.cpp. Thought it might be a good idea to enable gcc warnings (-Wall -Wextra -ansi), so I did. While fixing most of the resulting warnings, I also found a couple of bugs. So this was a Good Thing[tm], obviously. Don't even think of enabling -pedantic as well - this fails horribly somewhere in Qt. --- diff --git a/Quassel.kdevelop.filelist b/Quassel.kdevelop.filelist index 83a2e94b..2d5153c0 100644 --- a/Quassel.kdevelop.filelist +++ b/Quassel.kdevelop.filelist @@ -25,7 +25,6 @@ src/common/logger.cpp src/common/logger.h src/common/main_core.cpp src/common/main_gui.cpp -src/common/main_mono.cpp src/common/message.cpp src/common/message.h src/common/proxy_common.h @@ -103,3 +102,4 @@ src/qtgui/ui/settingsdlg.ui src/common/build_mono.cpp src/common/build_qtgui.cpp src/common/build_core.cpp +src/common/main.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d84f7dfe..9fc218e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -53,6 +53,7 @@ FIND_PACKAGE(Qt4 REQUIRED) SET(QT_USE_QTXML true) SET(QT_USE_QTSQL true) SET(QT_USE_QTNETWORK true) +SET(QT_USE_QTUITOOLS true) SET(QT_DONT_USE_QTGUI true) # This is added later if GUI is requested INCLUDE(${QT_USE_FILE}) @@ -69,6 +70,8 @@ ENDIF(BUILD_MONO AND NOT BUILD_CORE) QT4_ADD_RESOURCES(_RCCS ${quassel_RCCS}) +ADD_DEFINITIONS(-Wall -Wextra -ansi) # may not be portable! + SET(TARGET_LIST ) IF(BUILD_CORE) diff --git a/src/client/client.cpp b/src/client/client.cpp index 419a8a2a..8b954d39 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -256,12 +256,12 @@ void Client::recvMessage(const Message &msg) { b->appendMsg(msg); } -void Client::recvStatusMsg(QString net, QString msg) { +void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) { //recvMessage(net, Message::server("", QString("[STATUS] %1").arg(msg))); } -void Client::recvBacklogData(BufferId id, const QList &msgs, bool done) { +void Client::recvBacklogData(BufferId id, const QList &msgs, bool /*done*/) { Buffer *b = buffer(id); foreach(QVariant v, msgs) { Message msg = v.value(); diff --git a/src/common/build_mono.cpp b/src/common/build_mono.cpp index 626ad2b2..27f0efc1 100644 --- a/src/common/build_mono.cpp +++ b/src/common/build_mono.cpp @@ -19,4 +19,4 @@ ***************************************************************************/ #define BUILD_MONO -#include "main_mono.cpp" +#include "main.cpp" diff --git a/src/common/global.h b/src/common/global.h index 1f4eb688..49f97505 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -99,6 +99,7 @@ class Global : public QObject { struct Exception { Exception(QString msg = "Unknown Exception") : _msg(msg) {}; + virtual ~Exception() {}; // make gcc happy virtual inline QString msg() { return _msg; } protected: diff --git a/src/common/main_mono.cpp b/src/common/main.cpp similarity index 95% rename from src/common/main_mono.cpp rename to src/common/main.cpp index b77c2cd3..48760d2d 100644 --- a/src/common/main_mono.cpp +++ b/src/common/main.cpp @@ -64,32 +64,44 @@ int main(int argc, char **argv) { QCoreApplication::setOrganizationName("Quassel IRC Development Team"); Global::quasselDir = QDir::homePath() + "/.quassel"; - + Core::instance(); #ifdef BUILD_MONO QObject::connect(Core::localSession(), SIGNAL(proxySignal(CoreSignal, QVariant, QVariant, QVariant)), ClientProxy::instance(), SLOT(recv(CoreSignal, QVariant, QVariant, QVariant))); QObject::connect(ClientProxy::instance(), SIGNAL(send(ClientSignal, QVariant, QVariant, QVariant)), Core::localSession(), SLOT(processSignal(ClientSignal, QVariant, QVariant, QVariant))); #endif Settings::init(); - Style::init(); +#ifndef BUILD_CORE + Style::init(); MainWin *mainWin = new MainWin(); Client::init(mainWin); mainWin->init(); +#else + Core::instance(); // create and init the core object +#endif + int exitCode = app.exec(); + +#ifndef BUILD_CORE // the mainWin has to be deleted before the Core // if not Quassel will crash on exit under certain conditions since the gui // still wants to access clientdata delete mainWin; Client::destroy(); +#endif +#ifndef BUILD_QTGUI Core::destroy(); +#endif + return exitCode; } +#ifndef BUILD_CORE void Client::syncToCore() { //Q_ASSERT(Global::data("CoreReady").toBool()); coreBuffers = Core::localSession()->buffers(); // NOTE: We don't need to request server states, because in the monolithic version there can't be // any servers connected at this stage... } - +#endif diff --git a/src/common/message.h b/src/common/message.h index 8ce0cfef..8cfa23ad 100644 --- a/src/common/message.h +++ b/src/common/message.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005/06 by The Quassel Team * + * Copyright (C) 2005-07 by The Quassel IRC Development Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -31,13 +31,13 @@ struct Message { enum Flags { None = 0, Self = 1, PrivMsg = 2, Highlight = 4 }; uint msgId; - Type type; - quint8 flags; + BufferId buffer; QString target; - QString sender; QString text; + QString sender; + Type type; + quint8 flags; QDateTime timeStamp; - BufferId buffer; Message(QString _target, Type _type = Plain, QString _text = "", QString _sender = "", quint8 _flags = None) : target(_target), text(_text), sender(_sender), type(_type), flags(_flags) { timeStamp = QDateTime::currentDateTime().toUTC(); } @@ -46,23 +46,8 @@ struct Message { : buffer(_buffer), text(_text), sender(_sender), type(_type), flags(_flags) { timeStamp = QDateTime::currentDateTime().toUTC(); } Message(QDateTime _ts, BufferId _buffer = BufferId(), Type _type = Plain, QString _text = "", QString _sender = "", quint8 _flags = None) - : timeStamp(_ts), buffer(_buffer), text(_text), sender(_sender), type(_type), flags(_flags) {} - -/* - static Message plain(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message notice(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message action(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message nick(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message mode(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message join(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message part(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message quit(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message kick(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message kill(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message server(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message info(QString _target, QString _text, QString _sender = "", quint8 _flags = None); - static Message error(QString _target, QString _text, QString _sender = "", quint8 _flags = None); -*/ + : buffer(_buffer), text(_text), sender(_sender), type(_type), flags(_flags), timeStamp(_ts) {} + }; QDataStream &operator<<(QDataStream &out, const Message &msg); diff --git a/src/common/quasselui.h b/src/common/quasselui.h index 4209cdd9..1b8c7a0e 100644 --- a/src/common/quasselui.h +++ b/src/common/quasselui.h @@ -26,7 +26,7 @@ class AbstractUiMsg { public: - + virtual ~AbstractUiMsg() {}; virtual QString sender() const = 0; virtual QString text() const = 0; virtual MsgId msgId() const = 0; @@ -39,6 +39,7 @@ class AbstractUiMsg { class AbstractUi { public: + virtual ~AbstractUi() {}; virtual AbstractUiMsg *layoutMsg(const Message &) = 0; diff --git a/src/core/core.cpp b/src/core/core.cpp index a3dcd269..1df55da2 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -43,7 +43,7 @@ void Core::destroy() { } Core::Core() { - + qDebug() << "core"; } void Core::init() { diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index 6c4ef442..826748c7 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h @@ -63,6 +63,7 @@ Q_DECLARE_INTERFACE(CorePluginInterface, */ class SettingsInterface { public: + virtual ~SettingsInterface() {}; virtual QString category() = 0; virtual QString title() = 0; virtual QWidget *settingsWidget() = 0; diff --git a/src/qtgui/chatline.cpp b/src/qtgui/chatline.cpp index 5d828c1f..fd3c7104 100644 --- a/src/qtgui/chatline.cpp +++ b/src/qtgui/chatline.cpp @@ -223,6 +223,8 @@ int ChatLine::posToCursor(QPointF pos) { return line.start; } } + qWarning() << "Should we ever reach this point?"; + return 0; } void ChatLine::precomputeLine() { @@ -243,7 +245,7 @@ void ChatLine::precomputeLine() { for(int j = url.start; j < url.end; j++) charUrlIdx[j] = i; } if(!textFormat.count()) return; - int idx = 0; int cnt = 0; int w = 0; int h = 0; + int idx = 0; int cnt = 0; int w = 0; QFontMetrics metrics(textFormat[0].format.font()); Word wr; wr.start = -1; wr.trailing = -1; diff --git a/src/qtgui/chatwidget.cpp b/src/qtgui/chatwidget.cpp index d67eb9ef..ea6adf02 100644 --- a/src/qtgui/chatwidget.cpp +++ b/src/qtgui/chatwidget.cpp @@ -89,14 +89,15 @@ void ChatWidget::adjustScrollBar() { //} } -void ChatWidget::scrollBarValChanged(int val) { - return; +void ChatWidget::scrollBarValChanged(int /*val*/) { + /* if(val >= verticalScrollBar()->maximum()) bottomLine = -1; else { int bot = val + viewport()->height(); int line = yToLineIdx(bot); //bottomLine = line; } + */ } void ChatWidget::scrollBarAction(int action) { @@ -269,7 +270,6 @@ void ChatWidget::paintEvent(QPaintEvent *event) { void ChatWidget::layout() { // TODO fix scrollbars //int botLine = yToLineIdx(verticalScrollBar()->value() + - qreal y = 0; for(int i = 0; i < lines.count(); i++) { qreal h = lines[i]->layout(tsWidth, senderWidth, textWidth); ycoords[i+1] = h + ycoords[i]; @@ -281,7 +281,7 @@ void ChatWidget::layout() { } int ChatWidget::yToLineIdx(qreal y) { - if(y >= ycoords[ycoords.count()-1]) ycoords.count()-1; + if(y >= ycoords[ycoords.count()-1]) return ycoords.count()-1; if(ycoords.count() <= 1) return 0; int uidx = 0; int oidx = ycoords.count() - 1; @@ -314,11 +314,13 @@ void ChatWidget::mousePressEvent(QMouseEvent *event) { } mouseMode = Pressed; break; + default: + break; } } } -void ChatWidget::mouseDoubleClickEvent(QMouseEvent *event) { +void ChatWidget::mouseDoubleClickEvent(QMouseEvent * /*event*/) { @@ -386,7 +388,7 @@ void ChatWidget::handleMouseMoveEvent(const QPoint &_pos) { QPoint pos = _pos + QPoint(0, verticalScrollBar()->value()); int x = pos.x(); int y = pos.y(); - MousePos oldpos = mousePos; + //MousePos oldpos = mousePos; if(x >= tsGrabPos - 3 && x <= tsGrabPos + 3) mousePos = OverTsSep; else if(x >= senderGrabPos - 3 && x <= senderGrabPos + 3) mousePos = OverTextSep; else mousePos = None; @@ -450,6 +452,8 @@ void ChatWidget::handleMouseMoveEvent(const QPoint &_pos) { break; case DragTextSep: break; + default: + break; } // Pass 2: Some mouse modes need work after being set... if(mouseMode == DragTsSep && x < size().width() - Style::sepSenderText() - senderWidth - 10) { @@ -535,8 +539,3 @@ QString ChatWidget::selectionToString() { return lines[selectionLine]->text().mid(selectionStart, selectionEnd - selectionStart); } -/************************************************************************************/ - - -/******************************************************************************************************************/ - diff --git a/src/qtgui/mainwin.h b/src/qtgui/mainwin.h index 15852a82..123d5f45 100644 --- a/src/qtgui/mainwin.h +++ b/src/qtgui/mainwin.h @@ -48,7 +48,7 @@ class MainWin : public QMainWindow, public AbstractUi { public: MainWin(); - ~MainWin(); + virtual ~MainWin(); void init(); void registerBufferViewDock(BufferViewDock *); diff --git a/src/qtgui/serverlist.cpp b/src/qtgui/serverlist.cpp index e221c736..9b36fcc3 100644 --- a/src/qtgui/serverlist.cpp +++ b/src/qtgui/serverlist.cpp @@ -355,7 +355,7 @@ void NetworkEditDlg::on_editIdentities_clicked() { /***************************************************************************/ -ServerEditDlg::ServerEditDlg(QWidget *parent, VarMap server) { +ServerEditDlg::ServerEditDlg(QWidget *parent, VarMap server) : QDialog(parent) { ui.setupUi(this); if(!server.isEmpty()) {