Checking in current state of QuasselTopia. Probably doesn't even compile.
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 9 Oct 2007 20:59:00 +0000 (20:59 +0000)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 9 Oct 2007 20:59:00 +0000 (20:59 +0000)
src/qtopia/chatline.cpp [new file with mode: 0644]
src/qtopia/chatline.h [new file with mode: 0644]
src/qtopia/chatwidget.cpp [new file with mode: 0644]
src/qtopia/chatwidget.h [new file with mode: 0644]
src/qtopia/qtopia.pro
src/qtopia/qtopiamainwin.cpp
src/qtopia/topicbar.cpp
src/qtopia/topicbar.h

diff --git a/src/qtopia/chatline.cpp b/src/qtopia/chatline.cpp
new file mode 100644 (file)
index 0000000..28ce89d
--- /dev/null
@@ -0,0 +1,49 @@
+/***************************************************************************
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   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 "chatline.h"
+
+ChatLine::ChatLine(Message msg) {
+  
+
+  
+
+}
+
+QString ChatLine::sender() const {
+  return _sender;
+}
+
+QString ChatLine::text() const {
+  return _text;
+}
+
+MsgId ChatLine::msgId() const {
+  return _msgId;
+}
+
+BufferId ChatLine::bufferId() const {
+  return _bufferId;
+}
+
+QDateTime ChatLine::timeStamp() const {
+  return _timeStamp;
+}
+
diff --git a/src/qtopia/chatline.h b/src/qtopia/chatline.h
new file mode 100644 (file)
index 0000000..13d3067
--- /dev/null
@@ -0,0 +1,44 @@
+/***************************************************************************
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   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 _CHATLINE_H_
+#define _CHATLINE_H_
+
+#include "quasselui.h"
+
+class ChatLine : public AbstractUiMsg {
+
+  public:
+    ChatLine(Message msg);
+    virtual QString sender() const;
+    virtual QString text() const;
+    virtual MsgId msgId() const;
+    virtual BufferId bufferId() const;
+    virtual QDateTime timeStamp() const;
+
+  private:
+    QString _sender, _text;
+    MsgId _msgId;
+    BufferId _bufferId;
+    QDateTime _timeStamp;
+
+};
+
+#endif
diff --git a/src/qtopia/chatwidget.cpp b/src/qtopia/chatwidget.cpp
new file mode 100644 (file)
index 0000000..9151cb7
--- /dev/null
@@ -0,0 +1,19 @@
+/***************************************************************************
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   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.             *
+ ***************************************************************************/
diff --git a/src/qtopia/chatwidget.h b/src/qtopia/chatwidget.h
new file mode 100644 (file)
index 0000000..2a25675
--- /dev/null
@@ -0,0 +1,20 @@
+/***************************************************************************
+ *   Copyright (C) 2005-07 by The Quassel IRC Development Team             *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   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.             *
+ ***************************************************************************/
+
index ed8be35..20766bb 100644 (file)
@@ -1,4 +1,4 @@
 # Input
 # Input
-HEADERS += coreconnectdlg.h mainwidget.h qtopiagui.h qtopiamainwin.h topicbar.h
-SOURCES += coreconnectdlg.cpp mainwidget.cpp qtopiagui.cpp qtopiamainwin.cpp main.cpp topicbar.cpp
+HEADERS += chatline.h chatwidget.h coreconnectdlg.h mainwidget.h qtopiagui.h qtopiamainwin.h topicbar.h
+SOURCES += chatline.cpp chatwidget.cpp coreconnectdlg.cpp mainwidget.cpp qtopiagui.cpp qtopiamainwin.cpp main.cpp topicbar.cpp
 FORMS += ui/coreconnectdlg.ui ui/coreconnectprogressdlg.ui ui/editcoreacctdlg.ui ui/mainwidget.ui
 FORMS += ui/coreconnectdlg.ui ui/coreconnectprogressdlg.ui ui/editcoreacctdlg.ui ui/mainwidget.ui
index f41cda9..bbeb456 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "qtopiamainwin.h"
 
 
 #include "qtopiamainwin.h"
 
+#include "buffertreemodel.h"
+#include "chatline.h"
 #include "coreconnectdlg.h"
 #include "global.h"
 #include "mainwidget.h"
 #include "coreconnectdlg.h"
 #include "global.h"
 #include "mainwidget.h"
@@ -46,8 +48,6 @@ QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(pa
   //Style::init();
   QtopiaGui *gui = new QtopiaGui(this);
   Client::init(gui);
   //Style::init();
   QtopiaGui *gui = new QtopiaGui(this);
   Client::init(gui);
-  init();
-  //gui->init();
 
   setWindowTitle("Quassel IRC");
   setWindowIcon(QIcon(":/qirc-icon.png"));
 
   setWindowTitle("Quassel IRC");
   setWindowIcon(QIcon(":/qirc-icon.png"));
@@ -61,11 +61,15 @@ QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(pa
   toolBar->addAction(QIcon(":icon/trash"), "Trash");
   addToolBar(toolBar);
 
   toolBar->addAction(QIcon(":icon/trash"), "Trash");
   addToolBar(toolBar);
 
+  init();
+  //gui->init();
+
 }
 
 // at this point, client is fully initialized
 void QtopiaMainWin::init() {
   Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferId, QVariant, QVariant)));
 }
 
 // at this point, client is fully initialized
 void QtopiaMainWin::init() {
   Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferId, QVariant, QVariant)));
+  connect(Client::bufferModel(), SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *)));
 
   CoreConnectDlg *dlg = new CoreConnectDlg(this);
   //setCentralWidget(dlg);
 
   CoreConnectDlg *dlg = new CoreConnectDlg(this);
   //setCentralWidget(dlg);
@@ -82,6 +86,11 @@ void QtopiaMainWin::connectedToCore() {
   foreach(BufferId id, Client::allBufferIds()) {
     emit requestBacklog(id, 100, -1);
   }
   foreach(BufferId id, Client::allBufferIds()) {
     emit requestBacklog(id, 100, -1);
   }
+  // FIXME just for testing: select first available buffer
+  if(Client::allBufferIds().count()) {
+    Buffer *b = Client::buffer(Client::allBufferIds()[0]);
+    Client::bufferModel()->selectBuffer(b);
+  }
 }
 
 void QtopiaMainWin::disconnectedFromCore() {
 }
 
 void QtopiaMainWin::disconnectedFromCore() {
@@ -90,10 +99,11 @@ void QtopiaMainWin::disconnectedFromCore() {
 }
 
 AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) {
 }
 
 AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) {
-  //return new ChatLine(msg);
-  return 0;
+  return new ChatLine(msg);
+  //return 0;
 }
 
 void QtopiaMainWin::showBuffer(Buffer *b) {
   mainWidget->setBuffer(b);
 }
 
 void QtopiaMainWin::showBuffer(Buffer *b) {
   mainWidget->setBuffer(b);
+
 }
 }
index 8ad87fa..d8d9f45 100644 (file)
@@ -34,11 +34,13 @@ TopicBar::TopicBar(QWidget *parent) : QPushButton(parent) {
   frameWidth = 3; // so we hardcode a more reasonable framewidth than 7
   setFixedHeight(QFontMetrics(topicFont).height() + 2*frameWidth);
 
   frameWidth = 3; // so we hardcode a more reasonable framewidth than 7
   setFixedHeight(QFontMetrics(topicFont).height() + 2*frameWidth);
 
+  textWidth = 0;
   fillText = " *** ";
   oneshot = true;
   timer = new QTimer(this);
   timer->setInterval(20);
   connect(timer, SIGNAL(timeout()), this, SLOT(updateOffset()));
   fillText = " *** ";
   oneshot = true;
   timer = new QTimer(this);
   timer->setInterval(20);
   connect(timer, SIGNAL(timeout()), this, SLOT(updateOffset()));
+  connect(this, SIGNAL(clicked()), this, SLOT(startScrolling()));
 }
 
 TopicBar::~TopicBar() {
 }
 
 TopicBar::~TopicBar() {
@@ -46,30 +48,42 @@ TopicBar::~TopicBar() {
 
 }
 
 
 }
 
-void TopicBar::setContents(QString t, bool _oneshot) {
-  text = t; oneshot = _oneshot;
+void TopicBar::resizeEvent(QResizeEvent *event) {
+  QPushButton::resizeEvent(event);
+  calcTextMetrics();
+}
+
+void TopicBar::calcTextMetrics() {
   int w = width() - 2*frameWidth;
   QRect boundingRect = QFontMetrics(topicFont).boundingRect(text);
   int w = width() - 2*frameWidth;
   QRect boundingRect = QFontMetrics(topicFont).boundingRect(text);
-  if(boundingRect.width() <= w) {
+  textWidth = boundingRect.width();
+  if(textWidth <= w) {
     offset = 0; fillTextStart = -1; secondTextStart = -1;
     offset = 0; fillTextStart = -1; secondTextStart = -1;
+    displayText = text;
     timer->stop();
   } else {
     timer->stop();
   } else {
-    fillTextStart = boundingRect.width();
+    fillTextStart = textWidth;
     boundingRect = QFontMetrics(topicFont).boundingRect(fillText);
     secondTextStart = fillTextStart + boundingRect.width();
     boundingRect = QFontMetrics(topicFont).boundingRect(fillText);
     secondTextStart = fillTextStart + boundingRect.width();
-    text = QString("%1%2%1").arg(text).arg(fillText);
+    displayText = QString("%1%2%1").arg(text).arg(fillText);
     offset = 0;
     timer->start();
   }
 }
 
     offset = 0;
     timer->start();
   }
 }
 
+// TODO catch resizeEvent for scroll settings
+void TopicBar::setContents(QString t, bool _oneshot) {
+  text = t; oneshot = _oneshot;
+  calcTextMetrics();
+}
+
 void TopicBar::paintEvent(QPaintEvent *event) {
   QPushButton::paintEvent(event);
 
   QPainter painter(this);
   painter.setFont(topicFont);
   painter.setClipRect(frameWidth, frameWidth, rect().width() - 2*frameWidth, rect().height() - 2*frameWidth);
 void TopicBar::paintEvent(QPaintEvent *event) {
   QPushButton::paintEvent(event);
 
   QPainter painter(this);
   painter.setFont(topicFont);
   painter.setClipRect(frameWidth, frameWidth, rect().width() - 2*frameWidth, rect().height() - 2*frameWidth);
-  painter.drawText(QPoint(-offset + frameWidth, QFontMetrics(topicFont).ascent() + frameWidth), text);
+  painter.drawText(QPoint(-offset + frameWidth, QFontMetrics(topicFont).ascent() + frameWidth), displayText);
 
 }
 
 
 }
 
@@ -81,3 +95,14 @@ void TopicBar::updateOffset() {
   }
   update();
 }
   }
   update();
 }
+
+void TopicBar::startScrolling() {
+  if(displayText.length() > text.length()) {
+    oneshot = false;
+    timer->start();
+  }
+}
+
+void TopicBar::stopScrolling() {
+  oneshot = true;
+}
index 23afb1d..b09fbcd 100644 (file)
@@ -38,21 +38,27 @@ class TopicBar : public QPushButton {
 
   public slots:
     void setContents(QString text, bool oneshot = true);
 
   public slots:
     void setContents(QString text, bool oneshot = true);
+    void startScrolling();
+    void stopScrolling();
 
   protected:
 
   protected:
-    virtual void paintEvent(QPaintEvent * event);
+    virtual void paintEvent(QPaintEvent *event);
+    virtual void resizeEvent (QResizeEvent *event);
 
   private slots:
     void updateOffset();
 
   private:
 
   private slots:
     void updateOffset();
 
   private:
+    void calcTextMetrics();
+
     QTimer *timer;
     int offset;
     int fillTextStart, secondTextStart;
     QTimer *timer;
     int offset;
     int fillTextStart, secondTextStart;
-    QString text;
+    QString text, displayText;
     QString fillText;
     QFont topicFont;
     int frameWidth;
     QString fillText;
     QFont topicFont;
     int frameWidth;
+    int textWidth;
     bool oneshot;
 };
 
     bool oneshot;
 };