obsolete_crap--
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 24 Oct 2007 00:54:08 +0000 (00:54 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 24 Oct 2007 00:54:08 +0000 (00:54 +0000)
Removed the old style.cpp/h (may that code never see the light of day again), and the
old Client::(dis)connect[To|From]LocalCore() functions from main.cpp - these won't be
needed anymore.

src/client/client.h
src/common/main.cpp
src/qtui/chatwidget.cpp
src/qtui/chatwidget.h
src/qtui/qtui.pri
src/qtui/style.cpp [deleted file]
src/qtui/style.h [deleted file]

index 7aeb548..ec9d8d6 100644 (file)
@@ -134,8 +134,6 @@ private:
   void init();
   
   void syncToCore(const QVariant &coreState);
-  QVariant connectToLocalCore(QString user, QString passwd);  // defined in main.cpp
-  void disconnectFromLocalCore();                             // defined in main.cpp
 
   static QPointer<Client> instanceptr;
   
index 7880e0c..fc5c0f7 100644 (file)
@@ -32,7 +32,6 @@
 #include <QApplication>
 #include "client.h"
 #include "qtui.h"
-#include "style.h"
 
 #elif defined BUILD_MONO
 #include <QApplication>
@@ -40,7 +39,6 @@
 #include "core.h"
 #include "coresession.h"
 #include "qtui.h"
-#include "style.h"
 
 #else
 #error "Something is wrong - you need to #define a build mode!"
@@ -95,7 +93,6 @@ int main(int argc, char **argv) {
   //Settings::init();
 
 #ifndef BUILD_CORE
-  Style::init();
   QtUi *gui = new QtUi();
   Client::init(gui);
   gui->init();
@@ -116,29 +113,3 @@ int main(int argc, char **argv) {
 
   return exitCode;
 }
-
-#ifdef BUILD_QTUI
-QVariant Client::connectToLocalCore(QString, QString) { return QVariant(); }
-void Client::disconnectFromLocalCore() {}
-
-#elif defined BUILD_MONO
-QVariant Client::connectToLocalCore(QString user, QString passwd) {
-  // TODO catch exceptions
-  /*
-  QVariant reply = Core::connectLocalClient(user, passwd);
-  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)));
-  return reply;
-  */
-  return QVariant();
-}
-
-void Client::disconnectFromLocalCore() {
-  /*
-  disconnect(Core::localSession(), 0, ClientProxy::instance(), 0);
-  disconnect(ClientProxy::instance(), 0, Core::localSession(), 0);
-  Core::disconnectLocalClient();
-  */
-}
-
-#endif
index 5a3ab40..68d63da 100644 (file)
@@ -19,9 +19,9 @@
  ***************************************************************************/
 
 #include "util.h"
-#include "style.h"
 #include "chatwidget.h"
 #include "chatline.h"
+#include "qtui.h"
 
 
 ChatWidget::ChatWidget(QWidget *parent) : QAbstractScrollArea(parent) {
@@ -233,10 +233,10 @@ void ChatWidget::setContents(QList<ChatLine *> list) {
 
 //!\brief Computes the different x position vars for given tsWidth and senderWidth.
 void ChatWidget::computePositions() {
-  senderX = tsWidth + Style::sepTsSender();
-  textX = senderX + senderWidth + Style::sepSenderText();
-  tsGrabPos = tsWidth + (int)Style::sepTsSender()/2;
-  senderGrabPos = senderX + senderWidth + (int)Style::sepSenderText()/2;
+  senderX = tsWidth + QtUi::style()->sepTsSender();
+  textX = senderX + senderWidth + QtUi::style()->sepSenderText();
+  tsGrabPos = tsWidth + (int)QtUi::style()->sepTsSender()/2;
+  senderGrabPos = senderX + senderWidth + (int)QtUi::style()->sepSenderText()/2;
   textWidth = viewport()->size().width() - textX;
 }
 
@@ -460,15 +460,15 @@ void ChatWidget::handleMouseMoveEvent(const QPoint &_pos) {
       break;
   }
   // Pass 2: Some mouse modes need work after being set...
-  if(mouseMode == DragTsSep && x < size().width() - Style::sepSenderText() - senderWidth - 10) {
+  if(mouseMode == DragTsSep && x < size().width() - QtUi::style()->sepSenderText() - senderWidth - 10) {
     // Drag first column separator
-    int foo = Style::sepTsSender()/2;
+    int foo = QtUi::style()->sepTsSender()/2;
     tsWidth = qMax(x, foo) - foo;
     computePositions();
     layout();
   } else if(mouseMode == DragTextSep && x < size().width() - 10) {
     // Drag second column separator
-    int foo = tsWidth + Style::sepTsSender() + Style::sepSenderText()/2;
+    int foo = tsWidth + QtUi::style()->sepTsSender() + QtUi::style()->sepSenderText()/2;
     senderWidth = qMax(x, foo) - foo;
     computePositions();
     layout();
index f15be23..8e2f0ae 100644 (file)
 #ifndef _CHATWIDGET_H_
 #define _CHATWIDGET_H_
 
-//#include "style.h"
-//#include "message.h"
-//#include "buffer.h"
-//#include <QtCore>
 #include <QtGui>
 
 class ChatLine;
index 49fa712..714a8c0 100644 (file)
@@ -3,10 +3,10 @@ QT_MOD = core gui network
 
 SRCS += bufferview.cpp bufferviewfilter.cpp bufferwidget.cpp channelwidgetinput.cpp chatline.cpp \
        chatwidget.cpp coreconnectdlg.cpp \
-       guisettings.cpp identities.cpp mainwin.cpp qtui.cpp qtuistyle.cpp serverlist.cpp settingsdlg.cpp style.cpp tabcompleter.cpp topicwidget.cpp
+       guisettings.cpp identities.cpp mainwin.cpp qtui.cpp qtuistyle.cpp serverlist.cpp settingsdlg.cpp tabcompleter.cpp topicwidget.cpp
 
 HDRS += bufferview.h bufferviewfilter.h bufferwidget.h channelwidgetinput.h chatline.h chatwidget.h coreconnectdlg.h \
-       guisettings.h identities.h mainwin.h qtui.h qtuistyle.h serverlist.h settingsdlg.h settingspage.h style.h tabcompleter.h topicwidget.h
+       guisettings.h identities.h mainwin.h qtui.h qtuistyle.h serverlist.h settingsdlg.h settingspage.h tabcompleter.h topicwidget.h
 
 
 FORMNAMES = identitiesdlg.ui identitieseditdlg.ui networkeditdlg.ui mainwin.ui nickeditdlg.ui serverlistdlg.ui \
diff --git a/src/qtui/style.cpp b/src/qtui/style.cpp
deleted file mode 100644 (file)
index 0181187..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel Team                             *
- *   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) any later version.                                   *
- *                                                                         *
- *   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 "style.h"
-
-void Style::init() {
-   // Colors (mIRC standard)
-  colors["00"] = QColor("white");
-  colors["01"] = QColor("black");
-  colors["02"] = QColor("navy");
-  colors["03"] = QColor("green");
-  colors["04"] = QColor("red");
-  colors["05"] = QColor("maroon");
-  colors["06"] = QColor("purple");
-  colors["07"] = QColor("orange");
-  colors["08"] = QColor("yellow");
-  colors["09"] = QColor("lime");
-  colors["10"] = QColor("teal");
-  colors["11"] = QColor("aqua");
-  colors["12"] = QColor("royalblue");
-  colors["13"] = QColor("fuchsia");
-  colors["14"] = QColor("grey");
-  colors["15"] = QColor("silver");
-
-  QTextCharFormat def;
-  def.setForeground(QBrush("black"));
-  def.setFont(QFont("Verdana",9));
-  formats["default"] = def;
-
-  // %B - 0x02 - bold
-  QTextCharFormat bold;
-  bold.setFontWeight(QFont::Bold);
-  formats["%B"] = bold;
-
-  // %O - 0x0f - plain
-  formats["%O"] = def;
-
-  // %R - 0x12 - reverse
-  // -- - 0x16 - reverse
-  // (no format)
-
-  // %S - 0x1d - italic
-  QTextCharFormat italic;
-  italic.setFontItalic(true);
-  formats["%S"] = italic;
-
-  // %U - 0x1f - underline
-  QTextCharFormat underline;
-  underline.setFontUnderline(true);
-  formats["%U"] = underline;
-
-  // %C - 0x03 - mIRC colors
-  for(uint i = 0; i < 16; i++) {
-    QString idx = QString("%1").arg(i, (int)2, (int)10, (QChar)'0');
-    QTextCharFormat fgf; fgf.setForeground(QBrush(colors[idx])); formats[QString("cf%1").arg(idx)] = fgf;
-    QTextCharFormat bgf; bgf.setBackground(QBrush(colors[idx])); formats[QString("cb%1").arg(idx)] = bgf;
-  }
-
-  // Internal formats - %D<char>
-  // %D0 - plain msg
-  QTextCharFormat plainMsg;
-  plainMsg.setForeground(QBrush("black"));
-  formats["%D0"] = plainMsg;
-  // %Dn - notice
-  QTextCharFormat notice;
-  notice.setForeground(QBrush("navy"));
-  formats["%Dn"] = notice;
-  // %Ds - server msg
-  QTextCharFormat server;
-  server.setForeground(QBrush("navy"));
-  formats["%Ds"] = server;
-  // %De - error msg
-  QTextCharFormat error;
-  error.setForeground(QBrush("red"));
-  formats["%De"] = error;
-  // %Dj - join
-  QTextCharFormat join;
-  join.setForeground(QBrush("green"));
-  formats["%Dj"] = join;
-  // %Dp - part
-  QTextCharFormat part;
-  part.setForeground(QBrush("indianred"));
-  formats["%Dp"] = part;
-  // %Dq - quit
-  QTextCharFormat quit;
-  quit.setForeground(QBrush("indianred"));
-  formats["%Dq"] = quit;
-  // %Dk - kick
-  QTextCharFormat kick;
-  kick.setForeground(QBrush("indianred"));
-  formats["%Dk"] = kick;
-  // %Dr - nick rename
-  QTextCharFormat nren;
-  nren.setForeground(QBrush("magenta"));
-  formats["%Dr"] = nren;
-  // %Dm - mode change
-  QTextCharFormat mode;
-  mode.setForeground(QBrush("steelblue"));
-  formats["%Dm"] = mode;
-  // %Da - ctcp action
-  QTextCharFormat action;
-  action.setFontItalic(true);
-  action.setForeground(QBrush("darkmagenta"));
-  formats["%Da"] = action;
-
-  // %DT - timestamp
-  QTextCharFormat ts;
-  ts.setForeground(QBrush("grey"));
-  formats["%DT"] = ts;
-  // %DS - sender
-  QTextCharFormat sender;
-  sender.setAnchor(true);
-  sender.setForeground(QBrush("navy"));
-  formats["%DS"] = sender;
-  // %DN - nickname
-  QTextCharFormat nick;
-  nick.setAnchor(true);
-  nick.setFontWeight(QFont::Bold);
-  formats["%DN"] = nick;
-  // %DH - hostmask
-  QTextCharFormat hostmask;
-  hostmask.setFontItalic(true);
-  formats["%DH"] = hostmask;
-  // %DC - channame
-  QTextCharFormat channel;
-  channel.setAnchor(true);
-  channel.setFontWeight(QFont::Bold);
-  formats["%DC"] = channel;
-  // %DM - modeflags
-  QTextCharFormat flags;
-  flags.setFontWeight(QFont::Bold);
-  formats["%DM"] = flags;
-  // %DU - clickable URL
-  QTextCharFormat url;
-  url.setFontUnderline(true);
-  url.setAnchor(true);
-  formats["%DU"] = url;
-}
-
-/** Returns a string stripped of format codes, and a list of FormatRange objects
- *  describing the formats of the string.
- * \param s string in internal format (% style format codes)
- */ 
-Style::StyledString Style::formattedToStyled(QString s) {
-  QHash<QString, int> toggles;
-  QString p;
-  StyledString sf;
-  QTextLayout::FormatRange rng;
-  rng.format = formats["default"]; rng.start = 0; rng.length = -1; sf.formats.append(rng);
-  toggles["default"] = sf.formats.count() - 1;
-  int i, j;
-  for(i = 0, j = 0; i < s.length(); i++) {
-    if(s[i] != '%') { p += s[i]; j++; continue; }
-    if(s[++i] == '%') { p += '%'; j++; continue; }
-    else if(s[i] == 'D' && s[i+1] == 'c') {  // color code
-      if(s[i+2] == '-') {  // color off
-        if(toggles.contains("fg")) {
-          sf.formats[toggles["fg"]].length = j - sf.formats[toggles["fg"]].start;
-          toggles.remove("fg");
-        }
-        if(toggles.contains("bg")) {
-          sf.formats[toggles["bg"]].length = j - sf.formats[toggles["bg"]].start;
-          toggles.remove("bg");
-        }
-        i += 2;
-      } else if(s[i+2] == 'f') { // foreground
-        if(toggles.contains("fg")) {
-          sf.formats[toggles["fg"]].length = j - sf.formats[toggles["fg"]].start;
-          toggles.remove("fg");
-        }
-        QTextLayout::FormatRange range;
-        range.format = formats[s.mid(i+1, 4)]; range.start = j; range.length = -1; sf.formats.append(range);
-        toggles["fg"] = sf.formats.count() - 1;
-        i += 4;
-      } else {  // background
-        Q_ASSERT(s[i+2] == 'b');
-        if(toggles.contains("bg")) {
-          sf.formats[toggles["bg"]].length = j - sf.formats[toggles["bg"]].start;
-          toggles.remove("bg");
-        }
-        QTextLayout::FormatRange range;
-        range.format = formats[s.mid(i+1, 4)]; range.start = j; range.length = -1; sf.formats.append(range);
-        toggles["bg"] = sf.formats.count() - 1;
-        i += 4;
-      }
-    } else if(s[i] == 'O') {
-      foreach(QString key, toggles.keys()) {
-        if(key == "default") continue;
-        sf.formats[toggles[key]].length = j - sf.formats[toggles[key]].start;
-        toggles.remove(key);
-      }
-
-    } else if(s[i] == 'R') {
-      // TODO implement reverse formatting
-
-    } else {
-      // all others are toggles
-      QString key = "%"; key += s[i];
-      if(s[i] == 'D') key += s[i+1];
-      if(formats.contains(key)) {
-        if(s[i] == 'D') i++;
-        if(toggles.contains(key)) {
-          sf.formats[toggles[key]].length = j - sf.formats[toggles[key]].start;
-          if(key == "%DU") {
-            // URL handling
-            // FIXME check for and handle format codes within URLs
-            QString u = s.mid(i - sf.formats[toggles[key]].length - 2, sf.formats[toggles[key]].length);
-            UrlInfo url;
-            url.start = sf.formats[toggles[key]].start;
-            url.end   = j;
-            url.url = QUrl(u);
-            sf.urls.append(url);
-          }
-          toggles.remove(key);
-        } else {
-          QTextLayout::FormatRange range;
-          range.format = formats[key]; range.start = j; range.length = -1;
-          sf.formats.append(range);
-          toggles[key] = sf.formats.count() -1;
-        }
-      } else {
-        // unknown format
-        p += '%'; p += s[i]; j+=2;
-      }
-    }
-  }
-  foreach(int idx, toggles.values()) {
-    sf.formats[idx].length = j - sf.formats[idx].start;
-  }
-  sf.text = p;
-  return sf;
-}
-
-QHash<QString, QTextCharFormat> Style::formats;
-QHash<QString, QColor> Style::colors;
-
diff --git a/src/qtui/style.h b/src/qtui/style.h
deleted file mode 100644 (file)
index 68b52da..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-07 by The Quassel Team                             *
- *   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) any later version.                                   *
- *                                                                         *
- *   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 _STYLE_H_
-#define _STYLE_H_
-
-#include <QtCore>
-#include <QTextCharFormat>
-#include <QTextLayout>
-
-class Style {
-
-  public:
-    static void init();
-
-    struct UrlInfo {
-      int start, end;
-      QUrl url;
-    };
-
-    struct StyledString {
-      QString text;
-      QList<QTextLayout::FormatRange> formats;
-      QList<UrlInfo> urls;
-    };
-
-    static StyledString formattedToStyled(QString);
-    static int sepTsSender() { return 10; }
-    static int sepSenderText() { return 10; }
-
-
-  private:
-    static QHash<QString, QTextCharFormat> formats;
-    static QHash<QString, QColor> colors;
-
-};
-
-#endif