--- /dev/null
+/***************************************************************************
+ * 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;
+}
+
--- /dev/null
+/***************************************************************************
+ * 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
--- /dev/null
+/***************************************************************************
+ * 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. *
+ ***************************************************************************/
--- /dev/null
+/***************************************************************************
+ * 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. *
+ ***************************************************************************/
+
# 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
#include "qtopiamainwin.h"
+#include "buffertreemodel.h"
+#include "chatline.h"
#include "coreconnectdlg.h"
#include "global.h"
#include "mainwidget.h"
//Style::init();
QtopiaGui *gui = new QtopiaGui(this);
Client::init(gui);
- init();
- //gui->init();
setWindowTitle("Quassel IRC");
setWindowIcon(QIcon(":/qirc-icon.png"));
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);
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() {
}
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);
+
}
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() {
}
-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);
}
}
update();
}
+
+void TopicBar::startScrolling() {
+ if(displayText.length() > text.length()) {
+ oneshot = false;
+ timer->start();
+ }
+}
+
+void TopicBar::stopScrolling() {
+ oneshot = true;
+}
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;
};