From: Manuel Nickschas Date: Tue, 9 Oct 2007 20:59:00 +0000 (+0000) Subject: Checking in current state of QuasselTopia. Probably doesn't even compile. X-Git-Tag: 0.1.0~141 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=6c6daea183c3a013a91fb8e9f250f6dece3023f8;hp=d7052a3218b115ab68d24ea33e670ed26afd19ce Checking in current state of QuasselTopia. Probably doesn't even compile. --- diff --git a/src/qtopia/chatline.cpp b/src/qtopia/chatline.cpp new file mode 100644 index 00000000..28ce89d8 --- /dev/null +++ b/src/qtopia/chatline.cpp @@ -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 index 00000000..13d30678 --- /dev/null +++ b/src/qtopia/chatline.h @@ -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 index 00000000..9151cb79 --- /dev/null +++ b/src/qtopia/chatwidget.cpp @@ -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 index 00000000..2a25675a --- /dev/null +++ b/src/qtopia/chatwidget.h @@ -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. * + ***************************************************************************/ + diff --git a/src/qtopia/qtopia.pro b/src/qtopia/qtopia.pro index ed8be35b..20766bb3 100644 --- a/src/qtopia/qtopia.pro +++ b/src/qtopia/qtopia.pro @@ -1,4 +1,4 @@ # 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 diff --git a/src/qtopia/qtopiamainwin.cpp b/src/qtopia/qtopiamainwin.cpp index f41cda92..bbeb4569 100644 --- a/src/qtopia/qtopiamainwin.cpp +++ b/src/qtopia/qtopiamainwin.cpp @@ -20,6 +20,8 @@ #include "qtopiamainwin.h" +#include "buffertreemodel.h" +#include "chatline.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); - init(); - //gui->init(); 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); + init(); + //gui->init(); + } // 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); @@ -82,6 +86,11 @@ void QtopiaMainWin::connectedToCore() { 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() { @@ -90,10 +99,11 @@ void QtopiaMainWin::disconnectedFromCore() { } 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); + } diff --git a/src/qtopia/topicbar.cpp b/src/qtopia/topicbar.cpp index 8ad87fa0..d8d9f45a 100644 --- a/src/qtopia/topicbar.cpp +++ b/src/qtopia/topicbar.cpp @@ -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); + textWidth = 0; 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() { @@ -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); - if(boundingRect.width() <= w) { + textWidth = boundingRect.width(); + if(textWidth <= w) { offset = 0; fillTextStart = -1; secondTextStart = -1; + displayText = text; timer->stop(); } else { - fillTextStart = boundingRect.width(); + fillTextStart = textWidth; 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(); } } +// 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); - 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(); } + +void TopicBar::startScrolling() { + if(displayText.length() > text.length()) { + oneshot = false; + timer->start(); + } +} + +void TopicBar::stopScrolling() { + oneshot = true; +} diff --git a/src/qtopia/topicbar.h b/src/qtopia/topicbar.h index 23afb1d6..b09fbcde 100644 --- a/src/qtopia/topicbar.h +++ b/src/qtopia/topicbar.h @@ -38,21 +38,27 @@ class TopicBar : public QPushButton { public slots: void setContents(QString text, bool oneshot = true); + void startScrolling(); + void stopScrolling(); protected: - virtual void paintEvent(QPaintEvent * event); + virtual void paintEvent(QPaintEvent *event); + virtual void resizeEvent (QResizeEvent *event); private slots: void updateOffset(); private: + void calcTextMetrics(); + QTimer *timer; int offset; int fillTextStart, secondTextStart; - QString text; + QString text, displayText; QString fillText; QFont topicFont; int frameWidth; + int textWidth; bool oneshot; };