Remove unneeded files
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 25 Aug 2009 20:31:55 +0000 (22:31 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 25 Aug 2009 20:36:26 +0000 (22:36 +0200)
src/client/modelpropertymapper.cpp [deleted file]
src/client/modelpropertymapper.h [deleted file]
src/qtui/CMakeLists.txt
src/qtui/topiclabel.cpp [deleted file]
src/qtui/topiclabel.h [deleted file]

diff --git a/src/client/modelpropertymapper.cpp b/src/client/modelpropertymapper.cpp
deleted file mode 100644 (file)
index 2e3b100..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-09 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 "modelpropertymapper.h"
-
-#include <QItemSelectionModel>
-#include <QDebug>
-
-ModelPropertyMapper::ModelPropertyMapper(QObject *parent)
-  : QObject(parent),
-    _model(0),
-    _selectionModel(0)
-{
-}
-
-ModelPropertyMapper::~ModelPropertyMapper() {
-}
-
-void ModelPropertyMapper::setModel(QAbstractItemModel *model) {
-  if(_model) {
-    disconnect(_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
-              this, SLOT(dataChanged(QModelIndex, QModelIndex)));
-  }
-  _model = model;
-  connect(_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
-         this, SLOT(dataChanged(QModelIndex, QModelIndex)));
-  setSelectionModel(new QItemSelectionModel(model));
-}
-
-QAbstractItemModel *ModelPropertyMapper::model() const {
-  return _model;
-}
-
-void ModelPropertyMapper::setSelectionModel(QItemSelectionModel *selectionModel) {
-  if(selectionModel->model() != model()) {
-    qWarning() << "cannot set itemSelectionModel" << selectionModel << "which uses different basemodel than" << model();
-    return;
-  }
-  if(_selectionModel)
-    disconnect(_selectionModel, 0, this, 0);
-  _selectionModel = selectionModel;
-  connect(_selectionModel, SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
-         this, SLOT(setCurrentRow(QModelIndex, QModelIndex)));
-  connect(_selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
-         this, SLOT(setCurrentIndex(QModelIndex, QModelIndex)));
-  
-  setCurrentRow(selectionModel->currentIndex(), QModelIndex());
-}
-
-QItemSelectionModel *ModelPropertyMapper::selectionModel() const {
-  return _selectionModel;
-}
-
-void ModelPropertyMapper::addMapping(int column, int role, QObject *target, const QByteArray &property) {
-  Mapping mapping(column, role, target, property);
-  if(!_mappings.contains(mapping))
-    _mappings.append(mapping);
-}
-
-void ModelPropertyMapper::removeMapping(int column, int role, QObject *target, const QByteArray &property) {
-  if(column == 0 && role == 0 && target == 0 && !property.isNull()) {
-    _mappings.clear();
-    return;
-  }
-  
-  if(column == 0 && role == 0 && !property.isNull()) {
-    QList<Mapping>::iterator iter = _mappings.begin();
-    while(iter != _mappings.end()) {
-      if((*iter).target == target)
-       iter = _mappings.erase(iter);
-      else
-       iter++;
-    }
-    return;
-  }
-  _mappings.removeAll(Mapping(column, role, target, property));
-}
-
-void ModelPropertyMapper::setCurrentIndex(const QModelIndex &current, const QModelIndex &previous) {
-  if(current.row() == previous.row() && current.parent() != previous.parent())
-    setCurrentRow(current, previous);
-}
-
-void ModelPropertyMapper::setCurrentRow(const QModelIndex &current, const QModelIndex &previous) {
-  Q_UNUSED(previous)
-  foreach(Mapping mapping, _mappings) {
-    QModelIndex index = current.sibling(current.row(), mapping.column);
-    mapping.target->setProperty(mapping.property, index.data(mapping.role));
-  }
-}
-
-void ModelPropertyMapper::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
-  QItemSelectionRange changedRange(topLeft, bottomRight);
-  foreach(Mapping mapping, _mappings) {
-    QModelIndex index = _selectionModel->currentIndex().sibling(_selectionModel->currentIndex().row(), mapping.column);
-    if(changedRange.contains(index)) {
-      mapping.target->setProperty(mapping.property, index.data(mapping.role));
-    }
-  }
-}
-
-void ModelPropertyMapper::targetDestroyed() {
-  removeMapping(0, 0, sender(), QByteArray());
-}
diff --git a/src/client/modelpropertymapper.h b/src/client/modelpropertymapper.h
deleted file mode 100644 (file)
index 263195f..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005-09 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 _MODELPROPERTYMAPPER_H_
-#define _MODELPROPERTYMAPPER_H_
-
-#include <QPointer>
-#include <QModelIndex>
-#include <QObject>
-
-class QAbstractItemModel;
-class QItemSelectionModel;
-
-
-class ModelPropertyMapper : public QObject {
-  Q_OBJECT
-
-public:
-  ModelPropertyMapper(QObject *parent = 0);
-  virtual ~ModelPropertyMapper();
-
-  void setModel(QAbstractItemModel *model);
-  QAbstractItemModel *model() const;
-
-  void setSelectionModel(QItemSelectionModel *selectionModel);
-  QItemSelectionModel *selectionModel() const;
-
-  void addMapping(int column, int role, QObject *target, const QByteArray &property);
-  void removeMapping(int column, int role, QObject *target, const QByteArray &property);
-                                                                                     
-public slots:
-  void setCurrentIndex(const QModelIndex &current, const QModelIndex &previous);
-  void setCurrentRow(const QModelIndex &current, const QModelIndex &previous);
-  void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
-
-private slots:
-  void targetDestroyed();
-  
-private:
-  struct Mapping {
-    int column;
-    int role;
-    QPointer<QObject> target;
-    QByteArray property;
-
-    Mapping(int _column, int _role, QObject *_target, const QByteArray &_property)
-      : column(_column), role(_role), target(_target), property(_property) {};
-    inline bool operator==(const Mapping &other) {
-      return (column == other.column && role == other.role && target == other.target && property == other.property); }
-  };
-    
-  QPointer<QAbstractItemModel> _model;
-  QPointer<QItemSelectionModel> _selectionModel;
-  QList<Mapping> _mappings;
-  
-};
-
-#endif
index 3823c4d..642c84e 100644 (file)
@@ -49,7 +49,6 @@ set(SOURCES
     systraynotificationbackend.cpp
     taskbarnotificationbackend.cpp
     titlesetter.cpp
-    topiclabel.cpp
     topicwidget.cpp
     verticaldock.cpp
     webpreviewitem.cpp)
@@ -94,7 +93,6 @@ set(MOC_HDRS
     systraynotificationbackend.h
     taskbarnotificationbackend.h
     titlesetter.h
-    topiclabel.h
     topicwidget.h
     verticaldock.h)
 
diff --git a/src/qtui/topiclabel.cpp b/src/qtui/topiclabel.cpp
deleted file mode 100644 (file)
index 2bcd740..0000000
+++ /dev/null
@@ -1,173 +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.             *
- ***************************************************************************/
-
-#include "topiclabel.h"
-
-
-#include <QDebug>
-
-#include <QApplication>
-#include <QDesktopServices>
-#include <QPainter>
-// #include <QHBoxLayout>
-#include <QFont>
-#include <QFontMetrics>
-
-#include "qtui.h"
-#include "qtuistyle.h"
-#include "message.h"
-
-TopicLabel::TopicLabel(QWidget *parent)
-  : QFrame(parent),
-    offset(0),
-    dragStartX(0),
-    textWidth(0),
-    dragMode(false)
-{
-  setToolTip(tr("Drag to scroll the topic!"));
-  setCursor(Qt::OpenHandCursor);
-}
-
-void TopicLabel::paintEvent(QPaintEvent *event) {
-  Q_UNUSED(event);
-
-  textPartOffset.clear();
-
-  QPainter painter(this);
-  painter.setBackgroundMode(Qt::OpaqueMode);
-
-  // FIXME use QTextLayout instead
-
-  QRect drawRect = rect().adjusted(offset, 0, 0, 0);
-  QRect brect;
-  QString textPart;
-  foreach(QTextLayout::FormatRange fr, formatList) {
-    textPart = plainText.mid(fr.start, fr.length);
-    textPartOffset << drawRect.left();
-    painter.setFont(fr.format.font());
-    painter.setPen(QPen(fr.format.foreground(), 0));
-    painter.setBackground(fr.format.background());
-    painter.drawText(drawRect, Qt::AlignLeft|Qt::AlignVCenter, textPart, &brect);
-    drawRect.setLeft(brect.right());
-  }
-  textWidth = brect.right();
-}
-
-void TopicLabel::setText(const QString &text) {
-  if(_text == text)
-    return;
-
-  _text = text;
-  offset = 0;
-  update();
-
-  UiStyle::StyledString styledContents = QtUi::style()->styleString(QtUi::style()->mircToInternal(text), UiStyle::PlainMsg);
-  plainText = styledContents.plainText;
-  formatList = QtUi::style()->toTextLayoutList(styledContents.formatList, plainText.length(), 0);
-  int height = 1;
-  foreach(QTextLayout::FormatRange fr, formatList) {
-    height = qMax(height, QFontMetrics(fr.format.font()).height());
-  }
-
-  // ensure the label is editable (height != 1) if there is no text to show
-  if(text.isEmpty())
-    height = QFontMetrics(qApp->font()).height();
-
-  // setFixedHeight(height);
-  // show topic in tooltip
-}
-
-
-void TopicLabel::mouseMoveEvent(QMouseEvent *event) {
-  if(!dragMode)
-    return;
-
-  event->accept();
-  int newOffset = event->pos().x() - dragStartX;
-  if(newOffset > 0)
-    offset = 0;
-  else if(width() + 1 < textWidth || offset < newOffset)
-    offset = newOffset;
-
-  update();
-}
-
-void TopicLabel::mousePressEvent(QMouseEvent *event) {
-  event->accept();
-  dragMode = true;
-  dragStartX = event->pos().x() - offset;
-  setCursor(Qt::ClosedHandCursor);
-}
-
-void TopicLabel::mouseReleaseEvent(QMouseEvent *event) {
-  event->accept();
-  dragMode = false;
-  if(qAbs(offset) < 30) {
-    offset = 0;
-    update();
-  }
-  setCursor(Qt::OpenHandCursor);
-}
-
-void TopicLabel::mouseDoubleClickEvent(QMouseEvent *event) {
-  event->accept();
-  if(textPartOffset.isEmpty())
-    return;
-
-  // find the text part that contains the url. We don't expect color codes in urls so we expect only full parts (yet?)
-  int textPart = 0;
-  int x = event->pos().x() + offset;
-  while(textPart + 1 < textPartOffset.count()) {
-    if(textPartOffset[textPart + 1] < x)
-      textPart++;
-    else
-      break;
-  }
-  int textOffset = textPartOffset[textPart];
-
-  // we've Identified the needed text part \o/
-  QString text = plainText.mid(formatList[textPart].start, formatList[textPart].length);
-
-  // now we have to find the the left and right word delimiters of the clicked word
-  QFontMetrics fontMetric(formatList[textPart].format.font());
-
-  int start = 0;
-  int spacePos = text.indexOf(" ");
-  x -= offset; // offset needs to go here as it's already in the textOffset
-  while(spacePos != -1) {
-    if(fontMetric.width(text.left(spacePos + 1)) + textOffset < x) {
-      start = spacePos + 1;
-      spacePos = text.indexOf(" ", start + 1);
-    } else {
-      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));
-  }
-}
diff --git a/src/qtui/topiclabel.h b/src/qtui/topiclabel.h
deleted file mode 100644 (file)
index 8072ed2..0000000
+++ /dev/null
@@ -1,59 +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 TOPICLABEL_H
-#define TOPICLABEL_H
-
-#include <QSize>
-#include <QFrame>
-
-#include "uistyle.h"
-
-class TopicLabel : public QFrame {
-  Q_OBJECT
-
-public:
-  TopicLabel(QWidget *parent = 0);
-
-  void setText(const QString &text);
-
-protected:
-  virtual void paintEvent(QPaintEvent *event);
-
-  void mouseMoveEvent(QMouseEvent *event);
-  void mousePressEvent(QMouseEvent *event);
-  void mouseReleaseEvent(QMouseEvent *event);
-  void mouseDoubleClickEvent(QMouseEvent *event);
-
-private:
-  QString _text;
-  QSize _sizeHint;
-
-  int offset;
-  int dragStartX;
-  int textWidth;
-  bool dragMode;
-
-  QString plainText;
-  QList<QTextLayout::FormatRange> formatList;
-  QList<int> textPartOffset; // needed for location url positions
-};
-
-#endif