Step 2: Remove obsolete files
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 9 Jun 2008 22:28:11 +0000 (00:28 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 2 Aug 2008 13:17:09 +0000 (15:17 +0200)
src/qtui/chatline-old.cpp [deleted file]
src/qtui/chatline-old.h [deleted file]
src/qtui/chatwidget.cpp [deleted file]
src/qtui/chatwidget.h [deleted file]
src/uisupport/old-uistyle.cpp [deleted file]
src/uisupport/old-uistyle.h [deleted file]

diff --git a/src/qtui/chatline-old.cpp b/src/qtui/chatline-old.cpp
deleted file mode 100644 (file)
index 3b0dae5..0000000
+++ /dev/null
@@ -1,385 +0,0 @@
-/***************************************************************************
- *   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 "chatline-old.h"
-#include "client.h"
-#include "network.h"
-#include "qtui.h"
-
-#include "qtuisettings.h"
-
-//! Construct a ChatLineOld object from a message.
-/**
- * \param m   The message to be layouted and rendered
- */
-QColor ChatLineOld::_highlightColor;
-ChatLineOld::ChatLineOld(const Message &m) {
-  hght = 0;
-  msg = m;
-  selectionMode = None;
-  isHighlight = false;
-  formatMsg(msg);
-
-  if(!_highlightColor.isValid()) {
-    QtUiSettings s("QtUi/Colors");
-    _highlightColor = s.value("highlightColor", QVariant(QColor("lightcoral"))).value<QColor>();
-  }
-}
-
-ChatLineOld::~ChatLineOld() {
-}
-
-void ChatLineOld::formatMsg(Message msg) {
-  isHighlight = msg.flags() & Message::Highlight;
-  QTextOption tsOption, senderOption, textOption;
-  styledTimeStamp = QtUi::style()->styleString(msg.formattedTimestamp());
-  styledSender = QtUi::style()->styleString(msg.formattedSender());
-  styledContents = QtUi::style()->styleString(msg.formattedText());
-  precomputeLine();
-}
-
-QList<ChatLineOld::FormatRange> ChatLineOld::calcFormatRanges(const UiStyle::StyledText &fs) {
-  QTextLayout::FormatRange additional;
-  additional.start = additional.length = 0;
-  return calcFormatRanges(fs, additional);
-}
-
-// This function is almost obsolete, since with the new style engine, we already get a list of formats...
-// We don't know yet if we keep this implementation of ChatLineOld, so I won't bother making this actually nice.
-QList<ChatLineOld::FormatRange> ChatLineOld::calcFormatRanges(const UiStyle::StyledText &_fs,
-     const QTextLayout::FormatRange &additional) {
-  UiStyle::StyledText fs = _fs;
-  QList<FormatRange> ranges;
-
-  if(additional.length > 0) {
-    for(int i = 0; i < fs.formatList.count(); i++) {
-      int oldend = fs.formatList[i].start + fs.formatList[i].length - 1;
-      int addend = additional.start + additional.length - 1;
-      if(oldend < additional.start) continue;
-      fs.formatList[i].length = additional.start - fs.formatList[i].start;
-      QTextLayout::FormatRange addfmtrng = fs.formatList[i];
-      addfmtrng.format.merge(additional.format);
-      addfmtrng.start = additional.start;
-      addfmtrng.length = qMin(oldend, addend) - additional.start + 1;
-      fs.formatList.insert(++i, addfmtrng);
-      if(addend == oldend) break;
-      if(addend < oldend) {
-        QTextLayout::FormatRange restfmtrng = fs.formatList[i-1];
-        restfmtrng.start = addend + 1;
-        restfmtrng.length = oldend - addend;
-        fs.formatList.insert(++i, restfmtrng);
-        break;
-      }
-    }
-  }
-
-  foreach(QTextLayout::FormatRange f, fs.formatList) {
-    if(f.length <= 0) continue;
-    FormatRange range;
-    range.start = f.start;
-    range.length = f.length;
-    range.format = f.format;
-    QFontMetrics metrics(range.format.font());
-    range.height = metrics.lineSpacing();
-    ranges.append(range);
-  }
-  return ranges;
-}
-
-void ChatLineOld::setSelection(SelectionMode mode, int start, int end) {
-  selectionMode = mode;
-  //tsFormat.clear(); senderFormat.clear(); textFormat.clear();
-  QPalette pal = QApplication::palette();
-  QTextLayout::FormatRange tsSel, senderSel, textSel;
-  switch (mode) {
-    case None:
-      tsFormat = calcFormatRanges(styledTimeStamp);
-      senderFormat = calcFormatRanges(styledSender);
-      textFormat = calcFormatRanges(styledContents);
-      break;
-    case Partial:
-      selectionStart = qMin(start, end); selectionEnd = qMax(start, end);
-      textSel.format.setForeground(pal.brush(QPalette::HighlightedText));
-      textSel.format.setBackground(pal.brush(QPalette::Highlight));
-      textSel.start = selectionStart;
-      textSel.length = selectionEnd - selectionStart;
-      textFormat = calcFormatRanges(styledContents, textSel);
-      break;
-    case Full:
-      tsSel.format.setForeground(pal.brush(QPalette::HighlightedText));
-      tsSel.format.setBackground(pal.brush(QPalette::Highlight));
-      tsSel.start = 0; tsSel.length = styledTimeStamp.plainText.length();
-      tsFormat = calcFormatRanges(styledTimeStamp, tsSel);
-      senderSel.format.setForeground(pal.brush(QPalette::HighlightedText));
-      senderSel.format.setBackground(pal.brush(QPalette::Highlight));
-      senderSel.start = 0; senderSel.length = styledSender.plainText.length();
-      senderFormat = calcFormatRanges(styledSender, senderSel);
-      textSel.format.setForeground(pal.brush(QPalette::HighlightedText));
-      textSel.format.setBackground(pal.brush(QPalette::Highlight));
-      textSel.start = 0; textSel.length = styledContents.plainText.length();
-      textFormat = calcFormatRanges(styledContents, textSel);
-      break;
-  }
-}
-
-MsgId ChatLineOld::msgId() const {
-  return msg.msgId();
-}
-
-BufferInfo ChatLineOld::bufferInfo() const {
-  return msg.bufferInfo();
-}
-
-QDateTime ChatLineOld::timestamp() const {
-  return msg.timestamp();
-}
-
-QString ChatLineOld::sender() const {
-  return styledSender.plainText;
-}
-
-QString ChatLineOld::text() const {
-  return styledContents.plainText;
-}
-
-bool ChatLineOld::isUrl(int c) const {
-  if(c < 0 || c >= charUrlIdx.count()) return false;;
-  return charUrlIdx[c] >= 0;
-}
-
-QUrl ChatLineOld::getUrl(int c) const {
-  if(c < 0 || c >= charUrlIdx.count()) return QUrl();
-  int i = charUrlIdx[c];
-  if(i >= 0) return styledContents.urls[i].url;
-  else return QUrl();
-}
-
-//!\brief Return the cursor position for the given coordinate pos.
-/**
- * \param pos The position relative to the ChatLineOld
- * \return The cursor position, [or -3 for invalid,] or -2 for timestamp, or -1 for sender
- */
-int ChatLineOld::posToCursor(QPointF pos) {
-  if(pos.x() < tsWidth + (int)QtUi::style()->sepTsSender()/2) return -2;
-  qreal textStart = tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText();
-  if(pos.x() < textStart) return -1;
-  int x = (int)(pos.x() - textStart);
-  for(int l = lineLayouts.count() - 1; l >=0; l--) {
-    LineLayout line = lineLayouts[l];
-    if(pos.y() >= line.y) {
-      int offset = charPos[line.start]; x += offset;
-      for(int i = line.start + line.length - 1; i >= line.start; i--) {
-        if((charPos[i] + charPos[i+1])/2 <= x) return i+1; // FIXME: Optimize this!
-      }
-      return line.start;
-    }
-  }
-  return 0;
-}
-
-void ChatLineOld::precomputeLine() {
-  tsFormat = calcFormatRanges(styledTimeStamp);
-  senderFormat = calcFormatRanges(styledSender);
-  textFormat = calcFormatRanges(styledContents);
-
-  minHeight = 0;
-  foreach(FormatRange fr, tsFormat) minHeight = qMax(minHeight, fr.height);
-  foreach(FormatRange fr, senderFormat) minHeight = qMax(minHeight, fr.height);
-
-  words.clear();
-  charPos.resize(styledContents.plainText.length() + 1);
-  charHeights.resize(styledContents.plainText.length());
-  charUrlIdx.fill(-1, styledContents.plainText.length());
-  for(int i = 0; i < styledContents.urls.count(); i++) {
-    QtUiStyle::UrlInfo url = styledContents.urls[i];
-    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;
-  QFontMetrics metrics(textFormat[0].format.font());
-  Word wr;
-  wr.start = -1; wr.trailing = -1;
-  for(int i = 0; i < styledContents.plainText.length(); ) {
-    charPos[i] = w; charHeights[i] = textFormat[idx].height;
-    w += metrics.charWidth(styledContents.plainText, i);
-    if(!styledContents.plainText[i].isSpace()) {
-      if(wr.trailing >= 0) {
-        // new word after space
-        words.append(wr);
-        wr.start = -1;
-      }
-      if(wr.start < 0) {
-        wr.start = i; wr.length = 1; wr.trailing = -1; wr.height = textFormat[idx].height;
-      } else {
-        wr.length++; wr.height = qMax(wr.height, textFormat[idx].height);
-      }
-    } else {
-      if(wr.start < 0) {
-        wr.start = i; wr.length = 0; wr.trailing = 1; wr.height = 0;
-      } else {
-        wr.trailing++;
-      }
-    }
-    if(++i < styledContents.plainText.length() && ++cnt >= textFormat[idx].length) {
-      cnt = 0; idx++;
-      Q_ASSERT(idx < textFormat.count());
-      metrics = QFontMetrics(textFormat[idx].format.font());
-    }
-  }
-  charPos[styledContents.plainText.length()] = w;
-  if(wr.start >= 0) words.append(wr);
-}
-
-qreal ChatLineOld::layout(qreal tsw, qreal senderw, qreal textw) {
-  tsWidth = tsw; senderWidth = senderw; textWidth = textw;
-  if(textw <= 0) return minHeight;
-  lineLayouts.clear(); LineLayout line;
-  int h = 0;
-  int offset = 0; int numWords = 0;
-  line.y = 0;
-  line.start = 0;
-  line.height = minHeight;  // first line needs room for ts and sender
-  for(uint i = 0; i < (uint)words.count(); i++) {
-    int lastpos = charPos[words[i].start + words[i].length]; // We use charPos[lastchar + 1], 'coz last char needs to fit
-    if(lastpos - offset <= textw) {
-      line.height = qMax(line.height, words[i].height);
-      line.length = words[i].start + words[i].length - line.start;
-      numWords++;
-    } else {
-      // we need to wrap!
-      if(numWords > 0) {
-        // ok, we had some words before, so store the layout and start a new line
-        h += line.height;
-        line.length = words[i-1].start + words[i-1].length - line.start;
-        lineLayouts.append(line);
-        line.y += line.height;
-        line.start = words[i].start;
-        line.height = words[i].height;
-        offset = charPos[words[i].start];
-      }
-      numWords = 1;
-      // check if the word fits into the current line
-      if(lastpos - offset <= textw) {
-        line.length = words[i].length;
-      } else {
-        // we need to break a word in the middle
-        int border = (int)textw + offset; // save some additions
-        line.start = words[i].start;
-        line.length = 1;
-        line.height = charHeights[line.start];
-        int j = line.start + 1;
-        for(int l = 1; l < words[i].length; j++, l++) {
-          if(charPos[j+1] < border) {
-            line.length++;
-            line.height = qMax(line.height, charHeights[j]);
-            continue;
-          } else {
-            h += line.height;
-            lineLayouts.append(line);
-            line.y += line.height;
-            line.start = j;
-            line.height = charHeights[j];
-            line.length = 1;
-            offset = charPos[j];
-            border = (int)textw + offset;
-          }
-        }
-      }
-    }
-  }
-  h += line.height;
-  if(numWords > 0) {
-    lineLayouts.append(line);
-  }
-  hght = h;
-  return hght;
-}
-
-//!\brief Draw ChatLineOld on the given QPainter at the given position.
-void ChatLineOld::draw(QPainter *p, const QPointF &pos) {
-  QPalette pal = QApplication::palette();
-
-  if(selectionMode == Full) {
-    p->setPen(Qt::NoPen);
-    p->setBrush(pal.brush(QPalette::Highlight));
-    p->drawRect(QRectF(pos, QSizeF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText() + textWidth, height())));
-  } else {
-    if(isHighlight) {
-      p->setPen(Qt::NoPen);
-      p->setBrush(_highlightColor /*pal.brush(QPalette::AlternateBase) */);
-      p->drawRect(QRectF(pos, QSizeF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText() + textWidth, height())));
-    }
-    if(selectionMode == Partial) {
-
-    }
-  } /*
-  p->setClipRect(QRectF(pos, QSizeF(tsWidth, height())));
-  tsLayout.draw(p, pos, tsFormat);
-  p->setClipRect(QRectF(pos + QPointF(tsWidth + Style::sepTsSender(), 0), QSizeF(senderWidth, height())));
-  senderLayout.draw(p, pos + QPointF(tsWidth + Style::sepTsSender(), 0), senderFormat);
-  p->setClipping(false);
-  textLayout.draw(p, pos + QPointF(tsWidth + Style::sepTsSender() + senderWidth + Style::sepSenderText(), 0), textFormat);
-    */
-  //p->setClipRect(QRectF(pos, QSizeF(tsWidth, 15)));
-  //p->drawRect(QRectF(pos, QSizeF(tsWidth, minHeight)));
-  p->setBackgroundMode(Qt::OpaqueMode);
-  QPointF tp = pos;
-  QRectF rect(pos, QSizeF(tsWidth, minHeight));
-  QRectF brect;
-  foreach(FormatRange fr, tsFormat) {
-    p->setFont(fr.format.font());
-    p->setPen(QPen(fr.format.foreground(), 0)); p->setBackground(fr.format.background());
-    p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, styledTimeStamp.plainText.mid(fr.start, fr.length), &brect);
-    rect.setLeft(brect.right());
-  }
-  rect = QRectF(pos + QPointF(tsWidth + QtUi::style()->sepTsSender(), 0), QSizeF(senderWidth, minHeight));
-  for(int i = senderFormat.count() - 1; i >= 0; i--) {
-    FormatRange fr = senderFormat[i];
-    p->setFont(fr.format.font()); p->setPen(QPen(fr.format.foreground(), 0)); p->setBackground(fr.format.background());
-    p->drawText(rect, Qt::AlignRight|Qt::TextSingleLine, styledSender.plainText.mid(fr.start, fr.length), &brect);
-    rect.setRight(brect.left());
-  }
-  QPointF tpos = pos + QPointF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText(), 0);
-  qreal h = 0; int l = 0;
-  if(lineLayouts.count() == 0) return; // how can this happen?
-  rect = QRectF(tpos + QPointF(0, h), QSizeF(textWidth, lineLayouts[l].height));
-  int offset = 0;
-  foreach(FormatRange fr, textFormat) {
-    if(l >= lineLayouts.count()) break;
-    p->setFont(fr.format.font()); p->setPen(QPen(fr.format.foreground(), 0)); p->setBackground(fr.format.background());
-    int start, end, frend, llend;
-    do {
-      frend = fr.start + fr.length;
-      if(frend <= lineLayouts[l].start) break;
-      llend = lineLayouts[l].start + lineLayouts[l].length;
-      start = qMax(fr.start, lineLayouts[l].start); end = qMin(frend, llend);
-      rect.setLeft(tpos.x() + charPos[start] - offset);
-      p->drawText(rect, Qt::AlignLeft|Qt::TextSingleLine, styledContents.plainText.mid(start, end - start), &brect);
-      if(llend <= end) {
-        h += lineLayouts[l].height;
-        l++;
-        if(l < lineLayouts.count()) {
-          rect = QRectF(tpos + QPointF(0, h), QSizeF(textWidth, lineLayouts[l].height));
-          offset = charPos[lineLayouts[l].start];
-        }
-      }
-    } while(end < frend && l < lineLayouts.count());
-  }
-}
diff --git a/src/qtui/chatline-old.h b/src/qtui/chatline-old.h
deleted file mode 100644 (file)
index b2b9445..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/***************************************************************************
- *   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 _CHATLINE_OLD_H_
-#define _CHATLINE_OLD_H_
-
-#include <QtGui>
-
-#include "util.h"
-#include "uistyle.h"
-#include "quasselui.h"
-
-//FIXME: chatline doku
-//!\brief Containing the layout and providing the rendering of a single message.
-/** A ChatLineOld takes a Message object,
- * formats it (by turning the various message types into a human-readable form and afterwards pumping it through
- * our Style engine), and stores it as a number of QTextLayouts representing the three fields of a chat line
- * (timestamp, sender and text). These layouts already include any rendering information such as font,
- * color, or selected characters. By calling layout(), they can be quickly layouted to fit a given set of field widths.
- * Afterwards, they can quickly be painted whenever necessary.
- *
- * By separating the complex and slow task of interpreting and formatting Message objects (which happens exactly once
- * per message) from the actual layouting and painting, we gain a lot of speed compared to the standard Qt rendering
- * functions.
- */
-class ChatLineOld : public QObject, public AbstractUiMsg {
-  Q_OBJECT
-
-  public:
-    ChatLineOld(const Message &message);
-    virtual ~ChatLineOld();
-
-    qreal layout(qreal tsWidth, qreal nickWidth, qreal textWidth);
-    qreal height() const { return hght; }
-    int posToCursor(QPointF pos);
-    void draw(QPainter *p, const QPointF &pos);
-
-    enum SelectionMode { None, Partial, Full };
-    void setSelection(SelectionMode, int start = 0, int end = 0);
-
-    QDateTime timestamp() const;
-    QString sender() const;
-    QString text() const;
-    MsgId msgId() const;
-    BufferInfo bufferInfo() const;
-
-    bool isUrl(int pos) const;
-    QUrl getUrl(int pos) const;
-
-  public slots:
-
-  private:
-    qreal hght;
-    Message msg;
-    qreal tsWidth, senderWidth, textWidth;
-    UiStyle::StyledText styledTimeStamp, styledSender, styledContents;
-
-    struct FormatRange {
-      int start;
-      int length;
-      int height;
-      QTextCharFormat format;
-    };
-    struct Word {
-      int start;
-      int length;
-      int trailing;
-      int height;
-    };
-    struct LineLayout {
-      int y;
-      int height;
-      int start;
-      int length;
-    };
-    QVector<int> charPos;
-    QVector<int> charWidths;
-    QVector<int> charHeights;
-    QVector<int> charUrlIdx;
-    QList<FormatRange> tsFormat, senderFormat, textFormat;
-    QList<Word> words;
-    QList<LineLayout> lineLayouts;
-    int minHeight;
-
-    bool isHighlight;
-    SelectionMode selectionMode;
-    int selectionStart, selectionEnd;
-    void formatMsg(Message);
-    void precomputeLine();
-    QList<FormatRange> calcFormatRanges(const UiStyle::StyledText &);
-    QList<FormatRange> calcFormatRanges(const UiStyle::StyledText &, const QTextLayout::FormatRange &additional);
-
-    static QColor _highlightColor;
-};
-
-#endif
diff --git a/src/qtui/chatwidget.cpp b/src/qtui/chatwidget.cpp
deleted file mode 100644 (file)
index cf897b6..0000000
+++ /dev/null
@@ -1,638 +0,0 @@
-/***************************************************************************
- *   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 "util.h"
-#include "chatwidget.h"
-#include "chatline-old.h"
-#include "qtui.h"
-#include "uisettings.h"
-#include "client.h"
-#include "buffer.h"
-#include "clientbacklogmanager.h"
-
-ChatWidget::ChatWidget(BufferId bufid, QWidget *parent) : QAbstractScrollArea(parent), AbstractChatView(),
-    lastBacklogOffset(0),
-    lastBacklogSize(0)
-{
-  //setAutoFillBackground(false);
-  //QPalette palette;
-  //palette.setColor(backgroundRole(), QColor(0, 0, 0, 50));
-  //setPalette(palette);
-  scrollTimer = new QTimer(this);
-  scrollTimer->setSingleShot(false);
-  scrollTimer->setInterval(100);
-  // setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-  setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-  setMinimumSize(QSize(20,20));
-  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-  bottomLine = -1;
-  height = 0;
-  ycoords.append(0);
-  pointerPosition = QPoint(0,0);
-  connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(scrollBarAction(int)));
-  connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrollBarValChanged(int)));
-
-  init(bufid);
-}
-
-void ChatWidget::init(BufferId id) {
-  bufferId = id;
-  setBackgroundRole(QPalette::Base);
-  setFont(QFont("Fixed"));
-  UiSettings s;
-  QVariant tsDef = s.value("DefaultTimestampColumnWidth", 90);
-  QVariant senderDef = s.value("DefaultSenderColumnWidth", 100);
-  tsWidth = s.value(QString("%1/TimestampColumnWidth").arg(bufferId.toInt()), tsDef).toInt();
-  senderWidth = s.value(QString("%1/SenderColumnWidth").arg(bufferId.toInt()), senderDef).toInt();
-  computePositions();
-  adjustScrollBar();
-  verticalScrollBar()->setValue(verticalScrollBar()->maximum());
-  //verticalScrollBar()->setPageStep(viewport()->height());
-  //verticalScrollBar()->setSingleStep(20);
-  //verticalScrollBar()->setMinimum(0);
-  //verticalScrollBar()->setMaximum((int)height - verticalScrollBar()->pageStep());
-
-  // setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-  setMouseTracking(true);
-  mouseMode = Normal;
-  selectionMode = NoSelection;
-  connect(scrollTimer, SIGNAL(timeout()), this, SLOT(handleScrollTimer()));
-
-  if(bufferId.isValid())
-    connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(viewportChanged(int)));
-}
-
-ChatWidget::~ChatWidget() {
-  //qDebug() << "destroying chatwidget" << bufferName;
-  //foreach(ChatLineOld *l, lines) {
-  //  delete l;
-  //}
-  UiSettings s;
-  s.setValue("DefaultTimestampColumnWidth", tsWidth);  // FIXME stupid dirty quicky
-  s.setValue("DefaultSenderColumnWidth", senderWidth);
-  s.setValue(QString("%1/TimestampColumnWidth").arg(bufferId.toInt()), tsWidth);
-  s.setValue(QString("%1/SenderColumnWidth").arg(bufferId.toInt()), senderWidth);
-}
-
-QSize ChatWidget::minimumSizeHint() const {
-  return QSize(20, 20);
-}
-
-QSize ChatWidget::sizeHint() const {
-  return QSize(400, 100);
-}
-
-// QSize ChatWidget::sizeHint() const {
-//   //qDebug() << size();
-//   return size();
-// }
-
-void ChatWidget::adjustScrollBar() {
-  verticalScrollBar()->setPageStep(viewport()->height());
-  verticalScrollBar()->setSingleStep(20);
-  verticalScrollBar()->setMinimum(0);
-  verticalScrollBar()->setMaximum((int)height - verticalScrollBar()->pageStep());
-  //qDebug() << height << viewport()->height() << verticalScrollBar()->pageStep();
-  //if(bottomLine < 0) {
-  //  verticalScrollBar()->setValue(verticalScrollBar()->maximum());
-  //} else {
-    //int bot = verticalScrollBar()->value() + viewport()->height(); //qDebug() << bottomLine;
-    //verticalScrollBar()->setValue(qMax(0, (int)ycoords[bottomLine+1] - viewport()->height()));
-  //}
-}
-
-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) {
-  switch(action) {
-    case QScrollBar::SliderSingleStepAdd:
-      // More elaborate. But what with loooong lines?
-      // verticalScrollBar()->setValue((int)ycoords[yToLineIdx(verticalScrollBar()->value() + viewport()->height()) + 1] - viewport()->height());
-      break;
-    case QScrollBar::SliderSingleStepSub:
-      //verticalScrollBar()->setValue((int)ycoords[yToLineIdx(verticalScrollBar()->value())]);
-      break;
-
-  }
-
-}
-
-void ChatWidget::handleScrollTimer() {
-  if(mouseMode == MarkText || mouseMode == MarkLines) {
-    if(pointerPosition.y() > viewport()->height()) {
-      verticalScrollBar()->setValue(verticalScrollBar()->value() + pointerPosition.y() - viewport()->height());
-      handleMouseMoveEvent(QPoint(pointerPosition.x(), viewport()->height()));
-    } else if(pointerPosition.y() < 0) {
-      verticalScrollBar()->setValue(verticalScrollBar()->value() + pointerPosition.y());
-      handleMouseMoveEvent(QPoint(pointerPosition.x(), 0));
-    }
-  }
-}
-
-void ChatWidget::ensureVisible(int line) {
-  int top = verticalScrollBar()->value();
-  int bot = top + viewport()->height();
-  if(ycoords[line+1] > bot) {
-    verticalScrollBar()->setValue(qMax(0, (int)ycoords[line+1] - viewport()->height()));
-  } else if(ycoords[line] < top) {
-    verticalScrollBar()->setValue((int)ycoords[line]);
-  }
-
-}
-
-void ChatWidget::clear() {
-  //contents->clear();
-}
-
-void ChatWidget::prependMsg(AbstractUiMsg *msg) {
-  ChatLineOld *line = dynamic_cast<ChatLineOld*>(msg);
-  Q_ASSERT(line);
-  prependChatLine(line);
-}
-
-void ChatWidget::prependChatLine(ChatLineOld *line) {
-  qreal h = line->layout(tsWidth, senderWidth, textWidth);
-  for(int i = 1; i < ycoords.count(); i++) ycoords[i] += h;
-  ycoords.insert(1, h);
-  lines.prepend(line);
-  height += h;
-  // Fix all variables containing line numbers
-  dragStartLine ++;
-  curLine ++;
-  selectionStart ++; selectionEnd ++;
-  adjustScrollBar();
-  verticalScrollBar()->setValue(verticalScrollBar()->value() + (int)h);
-  viewport()->update();
-}
-
-void ChatWidget::prependChatLines(QList<ChatLineOld *> clist) {
-  QList<qreal> tmpy; tmpy.append(0);
-  qreal h = 0;
-  foreach(ChatLineOld *l, clist) {
-    h += l->layout(tsWidth, senderWidth, textWidth);
-    tmpy.append(h);
-  }
-  ycoords.removeFirst();
-  for(int i = 0; i < ycoords.count(); i++) ycoords[i] += h;
-  ycoords = tmpy + ycoords;
-  lines = clist + lines;
-  height += h;
-  // Fix all variables containing line numbers
-  int i = clist.count();
-  dragStartLine += i;
-  curLine += i;
-  selectionStart += i; selectionEnd += i; //? selectionEnd += i;
-  //if(bottomLine >= 0) bottomLine += i;
-  adjustScrollBar();
-  //verticalScrollBar()->setPageStep(viewport()->height());
-  //verticalScrollBar()->setSingleStep(20);
-  //verticalScrollBar()->setMaximum((int)height - verticalScrollBar()->pageStep());
-  verticalScrollBar()->setValue(verticalScrollBar()->value() + (int)h);
-  viewport()->update();
-}
-
-void ChatWidget::appendMsg(AbstractUiMsg *msg) {
-  ChatLineOld *line = dynamic_cast<ChatLineOld*>(msg);
-  Q_ASSERT(line);
-  appendChatLine(line);
-}
-
-void ChatWidget::appendChatLine(ChatLineOld *line) {
-  qreal h = line->layout(tsWidth, senderWidth, textWidth);
-  ycoords.append(h + ycoords[ycoords.count() - 1]);
-  height += h;
-  bool flg = (verticalScrollBar()->value() == verticalScrollBar()->maximum());
-  adjustScrollBar();
-  if(flg) verticalScrollBar()->setValue(verticalScrollBar()->maximum());
-  lines.append(line);
-  viewport()->update();
-}
-
-
-void ChatWidget::appendChatLines(QList<ChatLineOld *> list) {
-  foreach(ChatLineOld *line, list) {
-    qreal h = line->layout(tsWidth, senderWidth, textWidth);
-    ycoords.append(h + ycoords[ycoords.count() - 1]);
-    height += h;
-    lines.append(line);
-  }
-  bool flg = (verticalScrollBar()->value() == verticalScrollBar()->maximum());
-  adjustScrollBar();
-  if(flg) verticalScrollBar()->setValue(verticalScrollBar()->maximum());
-  viewport()->update();
-}
-
-void ChatWidget::setContents(const QList<AbstractUiMsg *> &list) {
-  ycoords.clear();
-  ycoords.append(0);
-  height = 0;
-  lines.clear();
-  QList<ChatLineOld *> cl;
-  foreach(AbstractUiMsg *msg, list) cl << dynamic_cast<ChatLineOld *>(msg);
-  appendChatLines(cl);
-}
-
-//!\brief Computes the different x position vars for given tsWidth and senderWidth.
-void ChatWidget::computePositions() {
-  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;
-}
-
-void ChatWidget::resizeEvent(QResizeEvent *event) {
-  //qDebug() << bufferName << isVisible() << event->size() << event->oldSize();
-  /*if(event->oldSize().isValid())*/
-  //contents->setWidth(event->size().width());
-  //setAlignment(Qt::AlignBottom);
-  if(event->size() != event->oldSize()) {
-    computePositions();
-    layout();
-  }
-  //adjustScrollBar();
-  //qDebug() << viewport()->size() << viewport()->height();
-  //QAbstractScrollArea::resizeEvent(event);
-  //qDebug() << viewport()->size() << viewport()->geometry();
-}
-
-void ChatWidget::paintEvent(QPaintEvent *event) {
-  QPainter painter(viewport());
-
-  //qDebug() <<  verticalScrollBar()->value();
-  painter.translate(0, -verticalScrollBar()->value());
-  int top = event->rect().top() + verticalScrollBar()->value();
-  int bot = top + event->rect().height();
-  int idx = yToLineIdx(top);
-  if(idx < 0) return;
-  for(int i = idx; i < lines.count() ; i++) {
-    lines[i]->draw(&painter, QPointF(0, ycoords[i]));
-    if(ycoords[i+1] > bot) return;
-  }
-}
-
-//!\brief Layout the widget.
-void ChatWidget::layout() {
-  // TODO fix scrollbars
-  //int botLine = yToLineIdx(verticalScrollBar()->value() + 
-  for(int i = 0; i < lines.count(); i++) {
-    qreal h = lines[i]->layout(tsWidth, senderWidth, textWidth);
-    ycoords[i+1] = h + ycoords[i];
-  }
-  height = ycoords[ycoords.count()-1];
-  adjustScrollBar();
-  verticalScrollBar()->setValue(verticalScrollBar()->maximum());
-  viewport()->update();
-}
-
-int ChatWidget::yToLineIdx(qreal y) {
-  if(y >= ycoords[ycoords.count()-1]) return ycoords.count()-2;
-  if(ycoords.count() <= 1) return 0;
-  int uidx = 0;
-  int oidx = ycoords.count() - 1;
-  int idx;
-  while(1) {
-    if(uidx == oidx - 1) return uidx;
-    idx = (uidx + oidx) / 2;
-    if(ycoords[idx] > y) oidx = idx;
-    else uidx = idx;
-  }
-}
-
-void ChatWidget::mousePressEvent(QMouseEvent *event) {
-  if(lines.isEmpty()) return;
-  QPoint pos = event->pos() + QPoint(0, verticalScrollBar()->value());
-  if(event->button() == Qt::LeftButton) {
-    dragStartPos = pos;
-    dragStartMode = Normal;
-    switch(mouseMode) {
-      case Normal:
-        if(mousePos == OverTsSep) {
-          dragStartMode = DragTsSep;
-          setCursor(Qt::ClosedHandCursor);
-        } else if(mousePos == OverTextSep) {
-          dragStartMode = DragTextSep;
-          setCursor(Qt::ClosedHandCursor);
-        } else {
-          dragStartLine = yToLineIdx(pos.y());
-          dragStartCursor = lines[dragStartLine]->posToCursor(QPointF(pos.x(), pos.y()-ycoords[dragStartLine]));
-        }
-        mouseMode = Pressed;
-        break;
-      default:
-        break;
-    }
-  }
-}
-
-void ChatWidget::mouseDoubleClickEvent(QMouseEvent *event) {
-  // dirty and fast hack to make http:// urls klickable
-  if(lines.isEmpty())
-    return;
-
-  QPoint pos = event->pos() + QPoint(0, verticalScrollBar()->value());
-  int x = pos.x();
-  int y = pos.y();
-  int l = yToLineIdx(y);
-  if(lines.count() <= l)
-    return;
-
-  ChatLineOld *line = lines[l];
-  QString text = line->text();
-  int cursorAt = qMax(0, line->posToCursor(QPointF(x, y - ycoords[l])) - 1);
-
-  int start = 0;
-  if(cursorAt > 0) {
-    for(int i = cursorAt; i > 0; i--) {
-      if(text[i] == ' ') {
-       start = i + 1;
-       break;
-      }
-    }
-  }
-
-  int end = text.indexOf(" ", start);
-  int len = -1;
-  if(end != -1) {
-    len = end - start;
-  }
-  QString word = text.mid(start, len);
-  QRegExp regex("^(h|f)t{1,2}ps?:\\/\\/");
-  if(regex.indexIn(word) != -1) {
-    QDesktopServices::openUrl(QUrl(word));
-  }
-  
-}
-
-void ChatWidget::mouseReleaseEvent(QMouseEvent *event) {
-  //QPoint pos = event->pos() + QPoint(0, verticalScrollBar()->value());
-
-  if(event->button() == Qt::LeftButton) {
-    dragStartPos = QPoint();
-    if(mousePos == OverTsSep || mousePos == OverTextSep) setCursor(Qt::OpenHandCursor);
-    else setCursor(Qt::ArrowCursor);
-
-    switch(mouseMode) {
-      case Pressed:
-        mouseMode = Normal;
-        clearSelection();
-        break;
-      case MarkText:
-        mouseMode = Normal;
-        selectionMode = TextSelected;
-        selectionLine = dragStartLine;
-        selectionStart = qMin(dragStartCursor, curCursor);
-        selectionEnd = qMax(dragStartCursor, curCursor);
-        // TODO Make X11SelectionMode configurable!
-#ifdef Q_WS_X11
-        QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection);
-#else
-        QApplication::clipboard()->setText(selectionToString());
-#endif
-        break;
-      case MarkLines:
-        mouseMode = Normal;
-        selectionMode = LinesSelected;
-        selectionStart = qMin(dragStartLine, curLine);
-        selectionEnd = qMax(dragStartLine, curLine);
-        // TODO Make X11SelectionMode configurable!
-#ifdef Q_WS_X11
-        QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection);
-#endif
-//#else
-        QApplication::clipboard()->setText(selectionToString());
-//#endif
-        break;
-      default:
-        mouseMode = Normal;
-    }
-  }
-}
-
-//!\brief React to mouse movements over the ChatWidget.
-/** This is called by Qt whenever the mouse moves. Here we have to do most of the mouse handling,
- * such as changing column widths, marking text or initiating drag & drop.
- */
-void ChatWidget::mouseMoveEvent(QMouseEvent *event) {
-  QPoint pos = event->pos(); pointerPosition = pos;
-  // Scroll if mouse pointer leaves widget while dragging
-  if((mouseMode == MarkText || mouseMode == MarkLines) && (pos.y() > viewport()->height() || pos.y() < 0)) {
-    if(!scrollTimer->isActive()) {
-      scrollTimer->start();
-    }
-  } else {
-    if(scrollTimer->isActive()) {
-      scrollTimer->stop();
-    }
-  }
-  handleMouseMoveEvent(pos);
-}
-
-void ChatWidget::handleMouseMoveEvent(const QPoint &_pos) {
-  // FIXME
-  if(lines.count() <= 0) return;
-  // Set some basic properties of the current position
-  QPoint pos = _pos + QPoint(0, verticalScrollBar()->value());
-  int x = pos.x();
-  int y = pos.y();
-  //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;
-
-  // Pass 1: Do whatever we can before switching mouse mode (if at all).
-  switch(mouseMode) {
-    // No special mode. Set mouse cursor if appropriate.
-    case Normal:
-    {
-      //if(oldpos != mousePos) {
-      if(mousePos == OverTsSep || mousePos == OverTextSep) setCursor(Qt::OpenHandCursor);
-      else {
-        int l = yToLineIdx(y);
-        int c = lines[l]->posToCursor(QPointF(x, y - ycoords[l]));
-        if(c >= 0 && lines[l]->isUrl(c)) {
-          setCursor(Qt::PointingHandCursor);
-        } else {
-          setCursor(Qt::ArrowCursor);
-        }
-      }
-    }
-      break;
-    // Left button pressed. Might initiate marking or drag & drop if we moved past the drag distance.
-    case Pressed:
-      if(!dragStartPos.isNull() && (dragStartPos - pos).manhattanLength() >= QApplication::startDragDistance()) {
-        // Moving a column separator?
-        if(dragStartMode == DragTsSep) mouseMode = DragTsSep;
-        else if(dragStartMode == DragTextSep) mouseMode = DragTextSep;
-        // Nope. Check if we are over a selection to start drag & drop.
-        else if(dragStartMode == Normal) {
-          bool dragdrop = false;
-          if(selectionMode == TextSelected) {
-            int l = yToLineIdx(y);
-            if(selectionLine == l) {
-              int p = lines[l]->posToCursor(QPointF(x, y - ycoords[l]));
-              if(p >= selectionStart && p <= selectionEnd) dragdrop = true;
-            }
-          } else if(selectionMode == LinesSelected) {
-            int l = yToLineIdx(y);
-            if(l >= selectionStart && l <= selectionEnd) dragdrop = true;
-          }
-          // Ok, so just start drag & drop if appropriate.
-          if(dragdrop) {
-            QDrag *drag = new QDrag(this);
-            QMimeData *mimeData = new QMimeData;
-            mimeData->setText(selectionToString());
-            drag->setMimeData(mimeData);
-            drag->start();
-            mouseMode = Normal;
-          // Otherwise, clear the selection and start text marking!
-          } else {
-            setCursor(Qt::ArrowCursor);
-            clearSelection();
-            if(dragStartCursor < 0) { mouseMode = MarkLines; curLine = -1; }
-            else mouseMode = MarkText;
-          }
-        }
-      }
-      break;
-    case DragTsSep:
-      break;
-    case DragTextSep:
-      break;
-    default:
-      break;
-  }
-  // Pass 2: Some mouse modes need work after being set...
-  if(mouseMode == DragTsSep && x < size().width() - QtUi::style()->sepSenderText() - senderWidth - 10) {
-    // Drag first column separator
-    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 + QtUi::style()->sepTsSender() + QtUi::style()->sepSenderText()/2;
-    senderWidth = qMax(x, foo) - foo;
-    computePositions();
-    layout();
-  } else if(mouseMode == MarkText) {
-    // Change currently marked text
-    curLine = yToLineIdx(y);
-    int c = lines[curLine]->posToCursor(QPointF(x, y - ycoords[curLine]));
-    if(curLine == dragStartLine && c >= 0) {
-      if(c != curCursor) {
-        curCursor = c;
-        lines[curLine]->setSelection(ChatLineOld::Partial, dragStartCursor, c);
-        viewport()->update();
-      }
-    } else {
-      mouseMode = MarkLines;
-      selectionStart = qMin(curLine, dragStartLine); selectionEnd = qMax(curLine, dragStartLine);
-      for(int i = selectionStart; i <= selectionEnd; i++) lines[i]->setSelection(ChatLineOld::Full);
-      viewport()->update();
-    }
-  } else if(mouseMode == MarkLines) {
-    // Line marking
-    int l = yToLineIdx(y);
-    if(l != curLine) {
-      selectionStart = qMin(l, dragStartLine); selectionEnd = qMax(l, dragStartLine);
-      if(curLine < 0) {
-        Q_ASSERT(selectionStart == selectionEnd);
-        lines[l]->setSelection(ChatLineOld::Full);
-      } else {
-        if(curLine < selectionStart) {
-          for(int i = curLine; i < selectionStart; i++) lines[i]->setSelection(ChatLineOld::None);
-        } else if(curLine > selectionEnd) {
-          for(int i = selectionEnd+1; i <= curLine; i++) lines[i]->setSelection(ChatLineOld::None);
-        } else if(selectionStart < curLine && l < curLine) {
-          for(int i = selectionStart; i < curLine; i++) lines[i]->setSelection(ChatLineOld::Full);
-        } else if(curLine < selectionEnd && l > curLine) {
-          for(int i = curLine+1; i <= selectionEnd; i++) lines[i]->setSelection(ChatLineOld::Full);
-        }
-      }
-      curLine = l;
-      //ensureVisible(l);
-      viewport()->update();
-    }
-  }
-}
-
-//!\brief Clear current text selection.
-void ChatWidget::clearSelection() {
-  if(selectionMode == TextSelected) {
-    lines[selectionLine]->setSelection(ChatLineOld::None);
-  } else if(selectionMode == LinesSelected) {
-    for(int i = selectionStart; i <= selectionEnd; i++) {
-      lines[i]->setSelection(ChatLineOld::None);
-    }
-  }
-  selectionMode = NoSelection;
-  viewport()->update();
-}
-
-//!\brief Convert current selection to human-readable string.
-QString ChatWidget::selectionToString() {
-  //TODO Make selection format configurable!
-  if(selectionMode == NoSelection) return "";
-  if(selectionMode == LinesSelected) {
-    QString result;
-    for(int l = selectionStart; l <= selectionEnd; l++) {
-      result += QString("[%1] %2 %3\n").arg(lines[l]->timestamp().toLocalTime().toString("hh:mm:ss"))
-  .        arg(lines[l]->sender()).arg(lines[l]->text());
-    }
-    return result;
-  }
-  // selectionMode == TextSelected
-  return lines[selectionLine]->text().mid(selectionStart, selectionEnd - selectionStart);
-}
-
-void ChatWidget::viewportChanged(int newPos) {
-  const int REQUEST_COUNT = 50;
-  QAbstractSlider *vbar = verticalScrollBar();
-  if(!vbar)
-    return;
-
-  int relativePos = 100;
-  if(vbar->maximum() - vbar->minimum() != 0)
-    relativePos = (newPos - vbar->minimum()) * 100 / (vbar->maximum() - vbar->minimum());
-
-  if(relativePos < 20) {
-    Buffer *buffer = Client::buffer(bufferId);
-    Q_CHECK_PTR(buffer);
-    if(buffer->contents().isEmpty())
-      return;
-    MsgId msgId = buffer->contents().first()->msgId();
-    if(!lastBacklogOffset.isValid() || (msgId < lastBacklogOffset && lastBacklogSize + REQUEST_COUNT <= buffer->contents().count())) {
-      Client::backlogManager()->requestBacklog(bufferId, REQUEST_COUNT, msgId.toInt());
-      lastBacklogOffset = msgId;
-      lastBacklogSize = buffer->contents().size();
-    }
-  }
-}
diff --git a/src/qtui/chatwidget.h b/src/qtui/chatwidget.h
deleted file mode 100644 (file)
index 4c01ff1..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005/06 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 _CHATWIDGET_H_
-#define _CHATWIDGET_H_
-
-#include <QtGui>
-
-#include "abstractbuffercontainer.h"
-#include "types.h"
-
-class ChatLineOld;
-class AbstractUiMsg;
-
-//!\brief Scroll area showing part of the chat messages for a given buffer.
-/** The contents of the scroll area, i.e. a widget of type ChatWidgetContents,
- * needs to be provided by calling init(). We don't create this widget ourselves, because
- * while a ChatWidget will be destroyed and recreated quite often (for example when switching
- * buffers), there ususally is no need to re-render its content every time (which can be time-consuming).
- * Before a ChatWidget is destroyed, it gives up its ownership of its contents, referring responsibility
- * back to where it came from.
- *
- * Because we use this as a custom widget in Qt Designer, we cannot use a constructor that takes custom
- * parameters. Instead, it is mandatory to call init() before using this widget.
- */
-class ChatWidget : public QAbstractScrollArea, public AbstractChatView {
-  Q_OBJECT
-
-  public:
-    ChatWidget(BufferId, QWidget *parent = 0);
-    ~ChatWidget();
-    void init(BufferId id);
-
-    virtual QSize minimumSizeHint() const;
-    virtual QSize sizeHint() const;
-
-  public slots:
-    void clear();
-
-    void prependMsg(AbstractUiMsg *);
-    void appendMsg(AbstractUiMsg *);
-
-    void prependChatLine(ChatLineOld *);
-    void appendChatLine(ChatLineOld *);
-    void prependChatLines(QList<ChatLineOld *>);
-    void appendChatLines(QList<ChatLineOld *>);
-    void setContents(const QList<AbstractUiMsg *> &);
-
-  protected:
-    virtual void resizeEvent(QResizeEvent *event);
-    virtual void paintEvent(QPaintEvent * event);
-    virtual void mousePressEvent(QMouseEvent *event);
-    virtual void mouseReleaseEvent(QMouseEvent *event);
-    virtual void mouseMoveEvent(QMouseEvent *event);
-    virtual void mouseDoubleClickEvent(QMouseEvent *event);
-
-  private slots:
-    void layout();
-    void scrollBarAction(int);
-    void scrollBarValChanged(int);
-    void ensureVisible(int line);
-    void handleScrollTimer();
-    void viewportChanged(int newPos);
-
-  private:
-    BufferId bufferId;
-    enum SelectionMode { NoSelection, TextSelected, LinesSelected };
-    enum MouseMode { Normal, Pressed, DragTsSep, DragTextSep, MarkText, MarkLines };
-    enum MousePos { None, OverTsSep, OverTextSep, OverUrl };
-    MouseMode mouseMode;
-    MousePos mousePos;
-    QPoint dragStartPos;
-    MouseMode dragStartMode;
-    int dragStartLine;
-    int dragStartCursor;
-    int curCursor;
-    int curLine;
-    SelectionMode selectionMode;
-    int selectionStart, selectionEnd, selectionLine;
-
-    int bottomLine, bottomLineOffset;
-
-    QList<ChatLineOld *> lines;
-    QList<qreal> ycoords;
-    QTimer *scrollTimer;
-    QPoint pointerPosition;
-
-    int senderX;
-    int textX;
-    int tsWidth;
-    int senderWidth;
-    int textWidth;
-    int tsGrabPos;     ///< X-Position for changing the timestamp width
-    int senderGrabPos;
-    void computePositions();
-
-    int width;
-    qreal height;
-    qreal y;
-
-    void adjustScrollBar();
-
-    int yToLineIdx(qreal y);
-    void clearSelection();
-    QString selectionToString();
-    void handleMouseMoveEvent(const QPoint &pos);
-
-    MsgId lastBacklogOffset;
-    int lastBacklogSize;
-};
-
-#endif
diff --git a/src/uisupport/old-uistyle.cpp b/src/uisupport/old-uistyle.cpp
deleted file mode 100644 (file)
index bbbe48e..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/***************************************************************************
- *   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 <QApplication>
-
-#include "uistyle.h"
-#include "uistylesettings.h"
-
-UiStyle::UiStyle(const QString &settingsKey) : _settingsKey(settingsKey) {
-  // Default format
-  QTextCharFormat def;
-  def.setForeground(QBrush("#000000"));
-  def.setFont(QFont("Monospace", QApplication::font().pointSize()));
-  def.font().setFixedPitch(true);
-  def.font().setStyleHint(QFont::TypeWriter);
-  _defaultFormats = QVector<QTextCharFormat>(NumFormatTypes, def);
-  _customFormats = QVector<QTextCharFormat>(NumFormatTypes, QTextFormat().toCharFormat());
-
-  // Load saved custom formats
-  UiStyleSettings s(_settingsKey);
-  foreach(FormatType type, s.availableFormats()) {
-    _customFormats[type] = s.customFormat(type);
-  }
-
-  // Initialize color codes according to mIRC "standard"
-  QStringList colors;
-  //colors << "white" << "black" << "navy" << "green" << "red" << "maroon" << "purple" << "orange";
-  //colors << "yellow" << "lime" << "teal" << "aqua" << "royalblue" << "fuchsia" << "grey" << "silver";
-  colors << "#ffffff" << "#000000" << "#000080" << "#008000" << "#ff0000" << "#800000" << "#800080" << "#ffa500";
-  colors << "#ffff00" << "#00ff00" << "#008080" << "#00ffff" << "#4169E1" << "#ff00ff" << "#808080" << "#c0c0c0";
-
-  // Now initialize the mapping between FormatCodes and FormatTypes...
-  _formatCodes["%O"] = None;
-  _formatCodes["%B"] = Bold;
-  _formatCodes["%S"] = Italic;
-  _formatCodes["%U"] = Underline;
-  _formatCodes["%R"] = Reverse;
-
-  _formatCodes["%D0"] = PlainMsg;
-  _formatCodes["%Dn"] = NoticeMsg;
-  _formatCodes["%Ds"] = ServerMsg;
-  _formatCodes["%De"] = ErrorMsg;
-  _formatCodes["%Dj"] = JoinMsg;
-  _formatCodes["%Dp"] = PartMsg;
-  _formatCodes["%Dq"] = QuitMsg;
-  _formatCodes["%Dk"] = KickMsg;
-  _formatCodes["%Dr"] = RenameMsg;
-  _formatCodes["%Dm"] = ModeMsg;
-  _formatCodes["%Da"] = ActionMsg;
-
-  _formatCodes["%DT"] = Timestamp;
-  _formatCodes["%DS"] = Sender;
-  _formatCodes["%DN"] = Nick;
-  _formatCodes["%DH"] = Hostmask;
-  _formatCodes["%DC"] = ChannelName;
-  _formatCodes["%DM"] = ModeFlags;
-  _formatCodes["%DU"] = Url;
-
-  // Set color formats
-  for(int i = 0; i < 16; i++) {
-    QString idx = QString("%1").arg(i, (int)2, (int)10, (QChar)'0');
-    _formatCodes[QString("%Dcf%1").arg(idx)] = (FormatType)(FgCol00 + i);
-    _formatCodes[QString("%Dcb%1").arg(idx)] = (FormatType)(BgCol00 + i);
-    QTextCharFormat fgf, bgf;
-    fgf.setForeground(QBrush(QColor(colors[i]))); setFormat((FormatType)(FgCol00 + i), fgf, Settings::Default);
-    bgf.setBackground(QBrush(QColor(colors[i]))); setFormat((FormatType)(BgCol00 + i), bgf, Settings::Default);
-    //FIXME fix the havoc caused by ColorSettingsPage
-    setFormat((FormatType)(FgCol00 + i), fgf, Settings::Custom);
-    setFormat((FormatType)(BgCol00 + i), bgf, Settings::Custom);
-  }
-
-  // Set a few more standard formats
-  QTextCharFormat bold; bold.setFontWeight(QFont::Bold);
-  setFormat(Bold, bold, Settings::Default);
-
-  QTextCharFormat italic; italic.setFontItalic(true);
-  setFormat(Italic, italic, Settings::Default);
-
-  QTextCharFormat underline; underline.setFontUnderline(true);
-  setFormat(Underline, underline, Settings::Default);
-
-  // All other formats should be defined in derived classes.
-}
-
-UiStyle::~ UiStyle() {
-  
-}
-
-void UiStyle::setFormat(FormatType ftype, QTextCharFormat fmt, Settings::Mode mode) {
-  if(mode == Settings::Default) {
-    _defaultFormats[ftype] = fmt;
-  } else {
-    UiStyleSettings s(_settingsKey);
-    if(fmt != _defaultFormats[ftype]) {
-      _customFormats[ftype] = fmt;
-      s.setCustomFormat(ftype, fmt);
-    } else {
-      _customFormats[ftype] = QTextFormat().toCharFormat();
-      s.removeCustomFormat(ftype);
-    }
-  }
-}
-
-QTextCharFormat UiStyle::format(FormatType ftype, Settings::Mode mode) const {
-  if(mode == Settings::Custom && _customFormats[ftype].isValid()) return _customFormats[ftype];
-  else return _defaultFormats[ftype];
-}
-
-UiStyle::FormatType UiStyle::formatType(const QString & code) const {
-  if(_formatCodes.contains(code)) return _formatCodes.value(code);
-  return Invalid;
-}
-
-QString UiStyle::formatCode(FormatType ftype) const {
-  return _formatCodes.key(ftype);
-}
-
-UiStyle::StyledText UiStyle::styleString(const QString &_s) {
-  QString s = _s;
-  StyledText result;
-  QList<FormatType> fmtList;
-  fmtList.append(None);
-  QTextLayout::FormatRange curFmtRng;
-  curFmtRng.format = format(None);
-  curFmtRng.start = 0;
-  result.formatList.append(curFmtRng);
-  int pos = 0; int length = 0;
-  int fgCol = -1, bgCol = -1;  // marks current mIRC color
-  for(;;) {
-    pos = s.indexOf('%', pos);
-    if(pos < 0) break;
-    if(s[pos+1] == '%') { // escaped %, just remove one and continue
-      s.remove(pos, 1);
-      pos++;
-      continue;
-    } else if(s[pos+1] == 'D' && s[pos+2] == 'c') { // color code
-      if(s[pos+3] == '-') { // color off
-        if(fgCol >= 0) {
-          fmtList.removeAll((FormatType)(FgCol00 + fgCol));
-          fgCol = -1;
-        }
-        if(bgCol >= 0) {
-          fmtList.removeAll((FormatType)(BgCol00 + bgCol));
-          bgCol = -1;
-        }
-        curFmtRng.format = mergedFormat(fmtList);
-        length = 4;
-      } else {
-        int color = 10 * s[pos+4].digitValue() + s[pos+5].digitValue();
-        //TODO: use 99 as transparent color (re mirc color "standard")
-        color &= 0x0f;
-        int *colptr; FormatType coltype;
-        if(s[pos+3] == 'f') { // foreground
-          colptr = &fgCol; coltype = FgCol00;
-        } else {              // background
-          Q_ASSERT(s[pos+3] == 'b');
-          colptr = &bgCol; coltype = BgCol00;
-        }
-        if(*colptr >= 0) {
-          // color already set, remove format code and add new one
-          Q_ASSERT(fmtList.contains((FormatType)(coltype + *colptr)));
-          fmtList.removeAll((FormatType)(coltype + *colptr));
-          fmtList.append((FormatType)(coltype + color));
-          curFmtRng.format = mergedFormat(fmtList);
-        } else {
-          fmtList.append((FormatType)(coltype + color));
-          curFmtRng.format.merge(format(fmtList.last()));
-        }
-        *colptr = color;
-        length = 6;
-      }
-    } else if(s[pos+1] == 'O') { // reset formatting
-      fmtList.clear(); fmtList.append(None);
-      curFmtRng.format = format(None);
-      fgCol = bgCol = -1;
-      length = 2;
-    } else if(s[pos+1] == 'R') { // reverse
-      // TODO: implement reverse formatting
-
-      length = 2;
-    } else { // all others are toggles
-      QString code = QString("%") + s[pos+1];
-      if(s[pos+1] == 'D') code += s[pos+2];
-      FormatType ftype = formatType(code);
-      if(ftype == Invalid) {
-        qWarning("%s", qPrintable(QString("Invalid format code in string: %1").arg(s)));
-        continue;
-      }
-      //Q_ASSERT(ftype != Invalid);
-      length = code.length();
-      if(!fmtList.contains(ftype)) {
-        // toggle it on
-        fmtList.append(ftype);
-        curFmtRng.format.merge(format(ftype));
-      } else {
-        // toggle it off
-        fmtList.removeAll(ftype);
-        curFmtRng.format = mergedFormat(fmtList);
-      }
-    }
-    s.remove(pos, length); // remove format code from string
-    // now see if something changed and else insert the format
-    if(curFmtRng.format == result.formatList.last().format) continue;  // no change, so we just ignore
-    curFmtRng.start = pos;
-    if(pos == result.formatList.last().start) {
-      // same starting point -> we just overwrite the old format
-      result.formatList.last() = curFmtRng;
-    } else {
-      // fix length of last format
-      result.formatList.last().length = pos - result.formatList.last().start;
-      result.formatList.append(curFmtRng);
-    }
-  }
-  result.formatList.last().length = s.length() - result.formatList.last().start;
-  if(result.formatList.last().length == 0) result.formatList.removeLast();
-  result.plainText = s;
-  return result;
-}
-
-QTextCharFormat UiStyle::mergedFormat(QList<FormatType> formatList) {
-  QTextCharFormat fmt;
-  foreach(FormatType ftype, formatList) {
-    fmt.merge(format(ftype));
-  }
-  return fmt;
-}
diff --git a/src/uisupport/old-uistyle.h b/src/uisupport/old-uistyle.h
deleted file mode 100644 (file)
index 7b58c12..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/***************************************************************************
- *   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 _OLD_UISTYLE_H_
-#define _OLD_UISTYLE_H_
-
-#include <QTextCharFormat>
-#include <QTextLayout>
-#include <QUrl>
-
-#include "message.h"
-#include "settings.h"
-
-class UiStyle {
-
-  public:
-    UiStyle(const QString &settingsKey);
-    virtual ~UiStyle();
-
-    /** This enumerates the possible formats a text element may have. */
-    enum FormatType {
-      None, Bold, Italic, Underline, Reverse,                                        // Standard formats
-      PlainMsg, NoticeMsg, ServerMsg, ErrorMsg, JoinMsg, PartMsg, QuitMsg, KickMsg,  // Internal message formats
-      RenameMsg, ModeMsg, ActionMsg,                                                 // ...cnt'd
-      Timestamp, Sender, Nick, Hostmask, ChannelName, ModeFlags, Url,                // individual elements
-      FgCol00, FgCol01, FgCol02, FgCol03, FgCol04, FgCol05, FgCol06, FgCol07,        // Color codes
-      FgCol08, FgCol09, FgCol10, FgCol11, FgCol12, FgCol13, FgCol14, FgCol15,
-      BgCol00, BgCol01, BgCol02, BgCol03, BgCol04, BgCol05, BgCol06, BgCol07,
-      BgCol08, BgCol09, BgCol10, BgCol11, BgCol12, BgCol13, BgCol14, BgCol15,
-      NumFormatTypes, Invalid   // Do not add anything after this
-    };
-
-    struct UrlInfo {
-      int start, end;
-      QUrl url;
-    };
-
-    struct StyledText {
-      QString plainText;
-      QList<QTextLayout::FormatRange> formatList;
-      QList<UrlInfo> urls;
-    };
-
-    StyledText styleString(const QString &);
-
-    void setFormat(FormatType, QTextCharFormat, Settings::Mode mode/* = Settings::Custom*/);
-    QTextCharFormat format(FormatType, Settings::Mode mode = Settings::Custom) const;
-
-    FormatType formatType(const QString &code) const;
-    QString formatCode(FormatType) const;
-
-  protected:
-
-
-  private:
-    QTextCharFormat mergedFormat(QList<FormatType>);
-
-    QVector<QTextCharFormat> _defaultFormats;
-    QVector<QTextCharFormat> _customFormats;
-    QHash<QString, FormatType> _formatCodes;
-
-    QString _settingsKey;
-
-};
-
-#endif