Finished the fusion of the different main_* files, so now we have only one #ifdef...
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 25 Jun 2007 18:21:09 +0000 (18:21 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 25 Jun 2007 18:21:09 +0000 (18:21 +0000)
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.

14 files changed:
Quassel.kdevelop.filelist
src/CMakeLists.txt
src/client/client.cpp
src/common/build_mono.cpp
src/common/global.h
src/common/main.cpp [moved from src/common/main_mono.cpp with 95% similarity]
src/common/message.h
src/common/quasselui.h
src/core/core.cpp
src/plugins/plugin.h
src/qtgui/chatline.cpp
src/qtgui/chatwidget.cpp
src/qtgui/mainwin.h
src/qtgui/serverlist.cpp

index 83a2e94..2d5153c 100644 (file)
@@ -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
index d84f7df..9fc218e 100644 (file)
@@ -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)
index 419a8a2..8b954d3 100644 (file)
@@ -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<QVariant> &msgs, bool done) {
+void Client::recvBacklogData(BufferId id, const QList<QVariant> &msgs, bool /*done*/) {
   Buffer *b = buffer(id);
   foreach(QVariant v, msgs) {
     Message msg = v.value<Message>();
index 626ad2b..27f0efc 100644 (file)
@@ -19,4 +19,4 @@
  ***************************************************************************/
 
 #define BUILD_MONO
-#include "main_mono.cpp"
+#include "main.cpp"
index 1f4eb68..49f9750 100644 (file)
@@ -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:
similarity index 95%
rename from src/common/main_mono.cpp
rename to src/common/main.cpp
index b77c2cd..48760d2 100644 (file)
@@ -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
index 8ce0cfe..8cfa23a 100644 (file)
@@ -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);
index 4209cdd..1b8c7a0 100644 (file)
@@ -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;
 
 
index a3dcd26..1df55da 100644 (file)
@@ -43,7 +43,7 @@ void Core::destroy() {
 }
 
 Core::Core() {
-
+  qDebug() << "core";
 }
 
 void Core::init() {
index 6c4ef44..826748c 100644 (file)
@@ -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;
index 5d828c1..fd3c710 100644 (file)
@@ -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;
index d67eb9e..ea6adf0 100644 (file)
@@ -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);
 }
 
-/************************************************************************************/
-
-
-/******************************************************************************************************************/
-
index 15852a8..123d5f4 100644 (file)
@@ -48,7 +48,7 @@ class MainWin : public QMainWindow, public AbstractUi {
 
   public:
     MainWin();
-    ~MainWin();
+    virtual ~MainWin();
 
     void init();
     void registerBufferViewDock(BufferViewDock *);
index e221c73..9b36fcc 100644 (file)
@@ -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()) {