From: Manuel Nickschas Date: Fri, 7 Mar 2008 20:59:13 +0000 (+0000) Subject: Used the trip back from CeBIT to prepare everything for a huge X-Git-Tag: 0.2.0-alpha3~23 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=d298e7275374e2da41b0ed9ef1080464a77c8cf1 Used the trip back from CeBIT to prepare everything for a huge let's-rewrite-the-ChatWidget action... * ChatLine -> ChatLineOld * Added ChatItem, -Line, -Scene, -View to the build system again * #define SPUTDEV -> Global::SPUTDEV and ./quasselclient --sputdev * Started some random hacking in the ChatView related sources Disclaimer: DO NOT USE --sputdev, it might eat your babies (and does not look good anyway yet :P) --- diff --git a/src/common/global.cpp b/src/common/global.cpp index 95f43e7b..57de1986 100644 --- a/src/common/global.cpp +++ b/src/common/global.cpp @@ -109,3 +109,5 @@ QString Global::coreVersionNeeded; Global::RunMode Global::runMode; uint Global::defaultPort; + +bool Global::SPUTDEV; diff --git a/src/common/global.h b/src/common/global.h index 39633675..d5fbdec8 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -53,6 +53,8 @@ namespace Global { extern RunMode runMode; extern unsigned int defaultPort; + extern bool SPUTDEV; // FIXME This is for internal use only! + void registerMetaTypes(); }; diff --git a/src/common/main.cpp b/src/common/main.cpp index 0209647a..a8421e89 100644 --- a/src/common/main.cpp +++ b/src/common/main.cpp @@ -103,6 +103,7 @@ int main(int argc, char **argv) { // Check if a non-standard core port is requested QStringList args = QCoreApplication::arguments(); // TODO Build a CLI parser + Global::SPUTDEV = args.contains("--sputdev"); // This enables various debug features for Sput. Do not touch. Global::defaultPort = 4242; int idx; diff --git a/src/qtopia/chatwidget.cpp b/src/qtopia/chatwidget.cpp index d676df43..43758d36 100644 --- a/src/qtopia/chatwidget.cpp +++ b/src/qtopia/chatwidget.cpp @@ -27,25 +27,25 @@ ChatWidget::ChatWidget(QWidget *parent) : QTextEdit(parent) { setTextInteractionFlags(Qt::TextBrowserInteraction); } -void ChatWidget::setContents(QList lines) { +void ChatWidget::setContents(QList lines) { clear(); appendChatLines(lines); } void ChatWidget::prependMsg(AbstractUiMsg *msg) { - ChatLine *line = static_cast(msg); + ChatLineOld *line = static_cast(msg); Q_ASSERT(line); prependChatLine(line); } void ChatWidget::appendMsg(AbstractUiMsg *msg) { - ChatLine *line = static_cast(msg); + ChatLineOld *line = static_cast(msg); Q_ASSERT(line); appendChatLine(line); } -void ChatWidget::appendChatLine(ChatLine *line) { +void ChatWidget::appendChatLine(ChatLineOld *line) { QTextCursor cursor = textCursor(); moveCursor(QTextCursor::End); if(!document()->isEmpty()) insertPlainText("\n"); @@ -55,13 +55,13 @@ void ChatWidget::appendChatLine(ChatLine *line) { setTextCursor(cursor); } -void ChatWidget::appendChatLines(QList list) { - foreach(ChatLine *line, list) { +void ChatWidget::appendChatLines(QList list) { + foreach(ChatLineOld *line, list) { appendChatLine(line); } } -void ChatWidget::prependChatLine(ChatLine *line) { +void ChatWidget::prependChatLine(ChatLineOld *line) { QTextCursor cursor = textCursor(); moveCursor(QTextCursor::Start); bool flg = document()->isEmpty(); @@ -72,13 +72,13 @@ void ChatWidget::prependChatLine(ChatLine *line) { setTextCursor(cursor); } -void ChatWidget::prependChatLines(QList list) { - foreach(ChatLine *line, list) { +void ChatWidget::prependChatLines(QList list) { + foreach(ChatLineOld *line, list) { prependChatLine(line); } } -void ChatWidget::insertChatLine(ChatLine *line) { +void ChatWidget::insertChatLine(ChatLineOld *line) { if(!document()->isEmpty()) insertPlainText("\n"); insertStyledText(line->styledSender()); insertPlainText(" "); diff --git a/src/qtopia/chatwidget.h b/src/qtopia/chatwidget.h index a85f2635..052adc46 100644 --- a/src/qtopia/chatwidget.h +++ b/src/qtopia/chatwidget.h @@ -33,16 +33,16 @@ class ChatWidget : public QTextEdit { ChatWidget(QWidget *parent = 0); public slots: - void setContents(QList); + void setContents(QList); void appendMsg(AbstractUiMsg *); void prependMsg(AbstractUiMsg *); - void prependChatLine(ChatLine *); - void appendChatLine(ChatLine *); - void prependChatLines(QList); - void appendChatLines(QList); + void prependChatLine(ChatLineOld *); + void appendChatLine(ChatLineOld *); + void prependChatLines(QList); + void appendChatLines(QList); private: - void insertChatLine(ChatLine *); + void insertChatLine(ChatLineOld *); void insertStyledText(const QtopiaUiStyle::StyledText &); diff --git a/src/qtopia/mainwidget.cpp b/src/qtopia/mainwidget.cpp index e8d11846..4fde19b7 100644 --- a/src/qtopia/mainwidget.cpp +++ b/src/qtopia/mainwidget.cpp @@ -55,10 +55,10 @@ void MainWidget::setBuffer(Buffer *buf) { ChatWidget *chatWidget; if(!chatWidgets.contains(buf)) { chatWidget = new ChatWidget(this); - QList lines; + QList lines; QList msgs = buf->contents(); foreach(AbstractUiMsg *msg, msgs) { - lines.append((ChatLine*)(msg)); + lines.append((ChatLineOld*)(msg)); } chatWidget->setContents(lines); connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); diff --git a/src/qtopia/qtopiamainwin.cpp b/src/qtopia/qtopiamainwin.cpp index 0b896f35..e6071e62 100644 --- a/src/qtopia/qtopiamainwin.cpp +++ b/src/qtopia/qtopiamainwin.cpp @@ -142,7 +142,7 @@ void QtopiaMainWin::disconnectedFromCore() { } AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) { - return new ChatLine(msg); + return new ChatLineOld(msg); //return 0; } diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index 0ebcffbf..51c551c3 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -20,6 +20,7 @@ #include "bufferwidget.h" #include "buffer.h" +#include "chatline.h" #include "chatline-old.h" #include "chatwidget.h" #include "settings.h" @@ -28,6 +29,8 @@ #include "network.h" #include "networkmodel.h" +#include "global.h" + BufferWidget::BufferWidget(QWidget *parent) : QWidget(parent), _bufferModel(0), @@ -51,7 +54,7 @@ void BufferWidget::setModel(BufferModel *bufferModel) { if(bufferModel) { connect(bufferModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); + this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); } } @@ -63,7 +66,7 @@ void BufferWidget::setSelectionModel(QItemSelectionModel *selectionModel) { if(selectionModel) { connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - this, SLOT(currentChanged(QModelIndex, QModelIndex))); + this, SLOT(currentChanged(QModelIndex, QModelIndex))); } } @@ -90,7 +93,7 @@ void BufferWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, in for(int i = start; i <= end; i++) { QVariant variant = parent.child(i,0).data(NetworkModel::BufferIdRole); if(!variant.isValid()) - continue; + continue; BufferId bufferId = qVariantValue(variant); removeBuffer(bufferId); @@ -122,6 +125,7 @@ void BufferWidget::setCurrentBuffer(BufferId bufferId) { } ChatWidget *chatWidget = 0; + ChatView *chatView = 0; Buffer *buf = Client::buffer(bufferId); if(!buf) { qWarning() << "BufferWidget::setBuffer(BufferId): Can't show unknown Buffer:" << bufferId; @@ -129,25 +133,47 @@ void BufferWidget::setCurrentBuffer(BufferId bufferId) { } Buffer *prevBuffer = Client::buffer(currentBuffer()); if(prevBuffer) prevBuffer->setVisible(false); - if(_chatWidgets.contains(bufferId)) { - chatWidget = _chatWidgets[bufferId]; + if(Global::SPUTDEV) { + if(_chatViews.contains(bufferId)) { + chatView = _chatViews[bufferId]; + } else { + chatView = new ChatView(buf, this); + //chatView->init(bufferId); + QList lines; + QList msgs = buf->contents(); + foreach(AbstractUiMsg *msg, msgs) { + lines.append(dynamic_cast(msg)); + } + chatView->setContents(lines); + connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatView, SLOT(appendMsg(AbstractUiMsg *))); + connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatView, SLOT(prependMsg(AbstractUiMsg *))); + _chatViews[bufferId] = chatView; + ui.stackedWidget->addWidget(chatView); + chatView->setFocusProxy(this); + } + _currentBuffer = bufferId; + ui.stackedWidget->setCurrentWidget(chatView); } else { - chatWidget = new ChatWidget(this); - chatWidget->init(bufferId); - QList lines; - QList msgs = buf->contents(); - foreach(AbstractUiMsg *msg, msgs) { - lines.append(dynamic_cast(msg)); + if(_chatWidgets.contains(bufferId)) { + chatWidget = _chatWidgets[bufferId]; + } else { + chatWidget = new ChatWidget(this); + chatWidget->init(bufferId); + QList lines; + QList msgs = buf->contents(); + foreach(AbstractUiMsg *msg, msgs) { + lines.append(dynamic_cast(msg)); + } + chatWidget->setContents(lines); + connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); + connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *))); + _chatWidgets[bufferId] = chatWidget; + ui.stackedWidget->addWidget(chatWidget); + chatWidget->setFocusProxy(this); } - chatWidget->setContents(lines); - connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); - connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), chatWidget, SLOT(prependMsg(AbstractUiMsg *))); - _chatWidgets[bufferId] = chatWidget; - ui.stackedWidget->addWidget(chatWidget); - chatWidget->setFocusProxy(this); + _currentBuffer = bufferId; + ui.stackedWidget->setCurrentWidget(chatWidget); } - _currentBuffer = bufferId; - ui.stackedWidget->setCurrentWidget(chatWidget); buf->setVisible(true); setFocus(); } diff --git a/src/qtui/bufferwidget.h b/src/qtui/bufferwidget.h index e484a187..40413b37 100644 --- a/src/qtui/bufferwidget.h +++ b/src/qtui/bufferwidget.h @@ -69,6 +69,7 @@ private slots: private: Ui::BufferWidget ui; QHash _chatWidgets; + QHash _chatViews; QPointer _bufferModel; QPointer _selectionModel; diff --git a/src/qtui/chatitem.cpp b/src/qtui/chatitem.cpp index 2e3e22d8..e6f602e1 100644 --- a/src/qtui/chatitem.cpp +++ b/src/qtui/chatitem.cpp @@ -91,7 +91,9 @@ void ChatItem::layout() { } _layout.endLayout(); update(); -} +} QDateTime _timestamp; + MsgId _msgId; + QRectF ChatItem::boundingRect() const { return _layout.boundingRect(); diff --git a/src/qtui/chatline-old.cpp b/src/qtui/chatline-old.cpp index b7ebf9b5..2c9cb0d3 100644 --- a/src/qtui/chatline-old.cpp +++ b/src/qtui/chatline-old.cpp @@ -23,11 +23,11 @@ #include "network.h" #include "qtui.h" -//! Construct a ChatLine object from a message. +//! Construct a ChatLineOld object from a message. /** * \param m The message to be layouted and rendered */ -ChatLine::ChatLine(Message m) { +ChatLineOld::ChatLineOld(Message m) { hght = 0; //networkName = m.buffer.network(); //bufferName = m.buffer.buffer(); @@ -37,11 +37,11 @@ ChatLine::ChatLine(Message m) { formatMsg(msg); } -ChatLine::~ChatLine() { +ChatLineOld::~ChatLineOld() { } -void ChatLine::formatMsg(Message msg) { +void ChatLineOld::formatMsg(Message msg) { isHighlight = msg.flags() & Message::Highlight; QTextOption tsOption, senderOption, textOption; styledTimeStamp = QtUi::style()->styleString(msg.formattedTimestamp()); @@ -51,8 +51,8 @@ void ChatLine::formatMsg(Message msg) { } // 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 ChatLine, so I won't bother making this actually nice. -QList ChatLine::calcFormatRanges(UiStyle::StyledText fs, QTextLayout::FormatRange additional) { +// We don't know yet if we keep this implementation of ChatLineOld, so I won't bother making this actually nice. +QList ChatLineOld::calcFormatRanges(UiStyle::StyledText fs, QTextLayout::FormatRange additional) { QList ranges; if(additional.length > 0) { @@ -89,7 +89,7 @@ QList ChatLine::calcFormatRanges(UiStyle::StyledText fs, return ranges; } -void ChatLine::setSelection(SelectionMode mode, int start, int end) { +void ChatLineOld::setSelection(SelectionMode mode, int start, int end) { selectionMode = mode; //tsFormat.clear(); senderFormat.clear(); textFormat.clear(); QPalette pal = QApplication::palette(); @@ -125,32 +125,32 @@ void ChatLine::setSelection(SelectionMode mode, int start, int end) { } } -MsgId ChatLine::msgId() const { +MsgId ChatLineOld::msgId() const { return msg.msgId(); } -BufferInfo ChatLine::bufferInfo() const { +BufferInfo ChatLineOld::bufferInfo() const { return msg.bufferInfo(); } -QDateTime ChatLine::timestamp() const { +QDateTime ChatLineOld::timestamp() const { return msg.timestamp(); } -QString ChatLine::sender() const { +QString ChatLineOld::sender() const { return styledSender.text; } -QString ChatLine::text() const { +QString ChatLineOld::text() const { return styledText.text; } -bool ChatLine::isUrl(int c) const { +bool ChatLineOld::isUrl(int c) const { if(c < 0 || c >= charUrlIdx.count()) return false;; return charUrlIdx[c] >= 0; } -QUrl ChatLine::getUrl(int c) const { +QUrl ChatLineOld::getUrl(int c) const { if(c < 0 || c >= charUrlIdx.count()) return QUrl(); int i = charUrlIdx[c]; if(i >= 0) return styledText.urls[i].url; @@ -159,10 +159,10 @@ QUrl ChatLine::getUrl(int c) const { //!\brief Return the cursor position for the given coordinate pos. /** - * \param pos The position relative to the ChatLine + * \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 ChatLine::posToCursor(QPointF pos) { +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; @@ -180,7 +180,7 @@ int ChatLine::posToCursor(QPointF pos) { return 0; } -void ChatLine::precomputeLine() { +void ChatLineOld::precomputeLine() { tsFormat = calcFormatRanges(styledTimeStamp); senderFormat = calcFormatRanges(styledSender); textFormat = calcFormatRanges(styledText); @@ -233,7 +233,7 @@ void ChatLine::precomputeLine() { if(wr.start >= 0) words.append(wr); } -qreal ChatLine::layout(qreal tsw, qreal senderw, qreal textw) { +qreal ChatLineOld::layout(qreal tsw, qreal senderw, qreal textw) { tsWidth = tsw; senderWidth = senderw; textWidth = textw; if(textw <= 0) return minHeight; lineLayouts.clear(); LineLayout line; @@ -298,8 +298,8 @@ qreal ChatLine::layout(qreal tsw, qreal senderw, qreal textw) { return hght; } -//!\brief Draw ChatLine on the given QPainter at the given position. -void ChatLine::draw(QPainter *p, const QPointF &pos) { +//!\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) { diff --git a/src/qtui/chatline-old.h b/src/qtui/chatline-old.h index b29aca23..ac95494b 100644 --- a/src/qtui/chatline-old.h +++ b/src/qtui/chatline-old.h @@ -18,8 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef _CHATLINE_H_ -#define _CHATLINE_H_ +#ifndef _CHATLINE_OLD_H_ +#define _CHATLINE_OLD_H_ #include @@ -29,7 +29,7 @@ //FIXME: chatline doku //!\brief Containing the layout and providing the rendering of a single message. -/** A ChatLine takes a Message object, +/** 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, @@ -40,12 +40,12 @@ * per message) from the actual layouting and painting, we gain a lot of speed compared to the standard Qt rendering * functions. */ -class ChatLine : public QObject, public AbstractUiMsg { +class ChatLineOld : public QObject, public AbstractUiMsg { Q_OBJECT public: - ChatLine(Message message); - virtual ~ChatLine(); + ChatLineOld(Message message); + virtual ~ChatLineOld(); qreal layout(qreal tsWidth, qreal nickWidth, qreal textWidth); qreal height() const { return hght; } diff --git a/src/qtui/chatline.h b/src/qtui/chatline.h index 2a6daed3..fca296fa 100644 --- a/src/qtui/chatline.h +++ b/src/qtui/chatline.h @@ -28,6 +28,17 @@ #include "uistyle.h" class ChatItem; +class ChatLineData; + +/* Concept Ideas +* Probably makes sense to have ChatLineData be the AbstractUiMsg instead, if it turns out that creating ChatLineData +is the expensive part... In that case, we could have a QHash in the Client, and ChatLine just +gets a data pointer. This would allow us to share most data between AbstractUiMsgs, and ChatLines themselves could +be pretty cheap - that'd be a clean solution for having a monitor buffer, highlight buffer etcpp. + +* ItemLayoutData + +*/ class ChatLine : public QGraphicsItem, public AbstractUiMsg { @@ -53,6 +64,7 @@ class ChatLine : public QGraphicsItem, public AbstractUiMsg { private: UiStyle::StyledText _styledTimestamp, _styledText, _styledSender; + QDateTime _timestamp; MsgId _msgId; @@ -60,4 +72,30 @@ class ChatLine : public QGraphicsItem, public AbstractUiMsg { int _tsColWidth, _senderColWidth, _textColWidth; }; +//! This contains the data of a ChatLine, i.e. mainly the styled message contents. +/** By separating ChatLine and ChatLineData, ChatLine itself is very small and we can reuse the + * same contents in several ChatLine objects without duplicating data. + */ +class ChatLineData { + + public: + ChatLineData(const Message &msg); + + inline UiStyle::StyledText styledSender() const { return _styledSender; } + inline UiStyle::StyledText styledTimestamp() const { return _styledTimestamp; } + inline UiStyle::StyledText styledText() const { return _styledText; } + + inline QString sender() const { return _styledSender.text; } + inline QString text() const { return _styledText.text; } + inline QDateTime timestamp() const { return _timestamp; } + inline MsgId msgId() const { return _msgId; } + + private: + UiStyle::StyledText _styledSender, _styledText, _styledTimestamp; + QDateTime _timestamp; + MsgId _msgId; + +}; + + #endif diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index dc337d57..f9bc1751 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -30,7 +30,7 @@ ChatView::ChatView(Buffer *buf, QWidget *parent) : QGraphicsView(parent) { _scene = new ChatScene(buf, this); setScene(_scene); - QGraphicsTextItem *item = scene()->addText(buf->name()); + QGraphicsTextItem *item = scene()->addText(buf->bufferInfo().bufferName()); } @@ -44,7 +44,7 @@ ChatScene *ChatView::scene() const { return _scene; } -/* + void ChatView::clear() { } @@ -56,7 +56,7 @@ void ChatView::prependMsg(AbstractUiMsg *msg) { } void ChatView::prependChatLine(ChatLine *line) { - qDebug() << "prepending"; + //qDebug() << "prepending"; } void ChatView::prependChatLines(QList clist) { @@ -70,7 +70,7 @@ void ChatView::appendMsg(AbstractUiMsg *msg) { } void ChatView::appendChatLine(ChatLine *line) { - qDebug() << "appending"; + //qDebug() << "appending"; } @@ -84,4 +84,4 @@ void ChatView::setContents(QList list) { qDebug() << "setting" << list.count(); appendChatLines(list); } -*/ + diff --git a/src/qtui/chatview.h b/src/qtui/chatview.h index 4a46d30c..ef9d9236 100644 --- a/src/qtui/chatview.h +++ b/src/qtui/chatview.h @@ -38,7 +38,7 @@ class ChatView : public QGraphicsView { ChatScene *scene() const; public slots: -/* + void clear(); void prependMsg(AbstractUiMsg *); @@ -50,7 +50,7 @@ class ChatView : public QGraphicsView { void appendChatLines(QList); void setContents(QList); -*/ + private: ChatScene *_scene; }; diff --git a/src/qtui/chatwidget.cpp b/src/qtui/chatwidget.cpp index 3a04383f..8a9b7a2f 100644 --- a/src/qtui/chatwidget.cpp +++ b/src/qtui/chatwidget.cpp @@ -71,7 +71,7 @@ void ChatWidget::init(BufferId id) { ChatWidget::~ChatWidget() { //qDebug() << "destroying chatwidget" << bufferName; - //foreach(ChatLine *l, lines) { + //foreach(ChatLineOld *l, lines) { // delete l; //} UiSettings s; @@ -161,12 +161,12 @@ void ChatWidget::clear() { } void ChatWidget::prependMsg(AbstractUiMsg *msg) { - ChatLine *line = dynamic_cast(msg); + ChatLineOld *line = dynamic_cast(msg); Q_ASSERT(line); prependChatLine(line); } -void ChatWidget::prependChatLine(ChatLine *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); @@ -181,10 +181,10 @@ void ChatWidget::prependChatLine(ChatLine *line) { viewport()->update(); } -void ChatWidget::prependChatLines(QList clist) { +void ChatWidget::prependChatLines(QList clist) { QList tmpy; tmpy.append(0); qreal h = 0; - foreach(ChatLine *l, clist) { + foreach(ChatLineOld *l, clist) { h += l->layout(tsWidth, senderWidth, textWidth); tmpy.append(h); } @@ -208,12 +208,12 @@ void ChatWidget::prependChatLines(QList clist) { } void ChatWidget::appendMsg(AbstractUiMsg *msg) { - ChatLine *line = dynamic_cast(msg); + ChatLineOld *line = dynamic_cast(msg); Q_ASSERT(line); appendChatLine(line); } -void ChatWidget::appendChatLine(ChatLine *line) { +void ChatWidget::appendChatLine(ChatLineOld *line) { qreal h = line->layout(tsWidth, senderWidth, textWidth); ycoords.append(h + ycoords[ycoords.count() - 1]); height += h; @@ -225,8 +225,8 @@ void ChatWidget::appendChatLine(ChatLine *line) { } -void ChatWidget::appendChatLines(QList list) { - foreach(ChatLine *line, list) { +void ChatWidget::appendChatLines(QList list) { + foreach(ChatLineOld *line, list) { qreal h = line->layout(tsWidth, senderWidth, textWidth); ycoords.append(h + ycoords[ycoords.count() - 1]); height += h; @@ -238,7 +238,7 @@ void ChatWidget::appendChatLines(QList list) { viewport()->update(); } -void ChatWidget::setContents(QList list) { +void ChatWidget::setContents(QList list) { ycoords.clear(); ycoords.append(0); height = 0; @@ -351,7 +351,7 @@ void ChatWidget::mouseDoubleClickEvent(QMouseEvent *event) { if(lines.count() <= l) return; - ChatLine *line = lines[l]; + ChatLineOld *line = lines[l]; QString text = line->text(); int cursorAt = qMax(0, line->posToCursor(QPointF(x, y - ycoords[l])) - 1); @@ -526,13 +526,13 @@ void ChatWidget::handleMouseMoveEvent(const QPoint &_pos) { if(curLine == dragStartLine && c >= 0) { if(c != curCursor) { curCursor = c; - lines[curLine]->setSelection(ChatLine::Partial, dragStartCursor, 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(ChatLine::Full); + for(int i = selectionStart; i <= selectionEnd; i++) lines[i]->setSelection(ChatLineOld::Full); viewport()->update(); } } else if(mouseMode == MarkLines) { @@ -542,16 +542,16 @@ void ChatWidget::handleMouseMoveEvent(const QPoint &_pos) { selectionStart = qMin(l, dragStartLine); selectionEnd = qMax(l, dragStartLine); if(curLine < 0) { Q_ASSERT(selectionStart == selectionEnd); - lines[l]->setSelection(ChatLine::Full); + lines[l]->setSelection(ChatLineOld::Full); } else { if(curLine < selectionStart) { - for(int i = curLine; i < selectionStart; i++) lines[i]->setSelection(ChatLine::None); + 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(ChatLine::None); + 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(ChatLine::Full); + 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(ChatLine::Full); + for(int i = curLine+1; i <= selectionEnd; i++) lines[i]->setSelection(ChatLineOld::Full); } } curLine = l; @@ -564,10 +564,10 @@ void ChatWidget::handleMouseMoveEvent(const QPoint &_pos) { //!\brief Clear current text selection. void ChatWidget::clearSelection() { if(selectionMode == TextSelected) { - lines[selectionLine]->setSelection(ChatLine::None); + lines[selectionLine]->setSelection(ChatLineOld::None); } else if(selectionMode == LinesSelected) { for(int i = selectionStart; i <= selectionEnd; i++) { - lines[i]->setSelection(ChatLine::None); + lines[i]->setSelection(ChatLineOld::None); } } selectionMode = NoSelection; diff --git a/src/qtui/chatwidget.h b/src/qtui/chatwidget.h index b8aa5a7d..801203c3 100644 --- a/src/qtui/chatwidget.h +++ b/src/qtui/chatwidget.h @@ -25,7 +25,7 @@ #include "types.h" -class ChatLine; +class ChatLineOld; class AbstractUiMsg; //!\brief Scroll area showing part of the chat messages for a given buffer. @@ -56,11 +56,11 @@ class ChatWidget : public QAbstractScrollArea { void prependMsg(AbstractUiMsg *); void appendMsg(AbstractUiMsg *); - void prependChatLine(ChatLine *); - void appendChatLine(ChatLine *); - void prependChatLines(QList); - void appendChatLines(QList); - void setContents(QList); + void prependChatLine(ChatLineOld *); + void appendChatLine(ChatLineOld *); + void prependChatLines(QList); + void appendChatLines(QList); + void setContents(QList); protected: virtual void resizeEvent(QResizeEvent *event); @@ -95,7 +95,7 @@ class ChatWidget : public QAbstractScrollArea { int bottomLine, bottomLineOffset; - QList lines; + QList lines; QList ycoords; QTimer *scrollTimer; QPoint pointerPosition; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index aaa59f45..5c3e73f1 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -17,13 +17,12 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -//#define SPUTDEV - #include "mainwin.h" #include "aboutdlg.h" #include "chatwidget.h" #include "bufferview.h" +#include "chatline.h" #include "chatline-old.h" #include "client.h" #include "coreconnectdlg.h" @@ -51,6 +50,7 @@ #include "debugconsole.h" +#include "global.h" MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), @@ -115,12 +115,12 @@ void MainWin::init() { ui.bufferWidget->setModel(Client::bufferModel()); ui.bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel()); -#ifdef SPUTDEV - //showSettingsDlg(); - //showAboutDlg(); - showNetworkDlg(); - exit(1); -#endif + if(Global::SPUTDEV) { + //showSettingsDlg(); + //showAboutDlg(); + //showNetworkDlg(); + //exit(1); + } } @@ -188,11 +188,6 @@ void MainWin::setupSettingsDlg() { //Category: General settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg)); settingsDlg->registerSettingsPage(new NetworksSettingsPage(settingsDlg)); - - -#ifdef SPUTDEV - connect(settingsDlg, SIGNAL(finished(int)), QApplication::instance(), SLOT(quit())); // FIXME -#endif } void MainWin::setupNickWidget() { @@ -229,10 +224,10 @@ void MainWin::setupChatMonitor() { return; chatWidget->init(BufferId(0)); - QList lines; + QList lines; QList msgs = buf->contents(); foreach(AbstractUiMsg *msg, msgs) { - lines.append(dynamic_cast(msg)); + lines.append(dynamic_cast(msg)); } chatWidget->setContents(lines); connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *))); @@ -294,11 +289,11 @@ void MainWin::setupSystray() { if(s.value("UseSystemTrayIcon", QVariant(true)).toBool()) { systray->show(); } - - #ifndef Q_WS_MAC + +#ifndef Q_WS_MAC connect(systray, SIGNAL(activated( QSystemTrayIcon::ActivationReason )), this, SLOT(systrayActivated( QSystemTrayIcon::ActivationReason ))); - #endif +#endif } @@ -348,7 +343,8 @@ void MainWin::disconnectedFromCore() { } AbstractUiMsg *MainWin::layoutMsg(const Message &msg) { - return new ChatLine(msg); + if(Global::SPUTDEV) return new ChatLine(msg); + return new ChatLineOld(msg); } void MainWin::showCoreConnectionDlg(bool autoConnect) { diff --git a/src/qtui/qtui.pri b/src/qtui/qtui.pri index b76a1c8e..096fc71a 100644 --- a/src/qtui/qtui.pri +++ b/src/qtui/qtui.pri @@ -1,11 +1,13 @@ DEPMOD = uisupport common client QT_MOD = core gui network -SRCS += aboutdlg.cpp bufferwidget.cpp chatline-old.cpp chatwidget.cpp coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \ +SRCS += aboutdlg.cpp bufferwidget.cpp chatitem.cpp chatline.cpp chatline-old.cpp chatscene.cpp chatview.cpp chatwidget.cpp \ + coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \ mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \ topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp -HDRS += aboutdlg.h bufferwidget.h chatline-old.h chatwidget.h coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \ +HDRS += aboutdlg.h bufferwidget.h chatitem.h chatline.h chatline-old.h chatscene.h chatview.h chatwidget.h \ + coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \ coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \ topicwidget.h verticaldock.h jumpkeyhandler.h diff --git a/src/qtui/settingsdlg.cpp b/src/qtui/settingsdlg.cpp index b5fc125c..a249c79b 100644 --- a/src/qtui/settingsdlg.cpp +++ b/src/qtui/settingsdlg.cpp @@ -67,7 +67,7 @@ void SettingsDlg::registerSettingsPage(SettingsPage *sp) { pages[QString("%1$%2").arg(sp->category(), sp->title())] = sp; sp->load(); // TESTING - selectPage(sp->category(), sp->title()); + // selectPage(sp->category(), sp->title()); } void SettingsDlg::selectPage(const QString &cat, const QString &title) { diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index 6bc01d87..c4529cbf 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -26,6 +26,8 @@ #include "uisettings.h" +#include "global.h" + /***************************************** * The TreeView showing the Buffers *****************************************/ @@ -115,9 +117,10 @@ void BufferView::keyPressEvent(QKeyEvent *event) { // ensure that newly inserted network nodes are expanded per default void BufferView::rowsInserted(const QModelIndex & parent, int start, int end) { QTreeView::rowsInserted(parent, start, end); - if(model()->rowCount(parent) == 1 && parent.data(NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType && parent.data(NetworkModel::ItemActiveRole) == true) { + if(model()->rowCount(parent) == 1 && parent.data(NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType + && (Global::SPUTDEV || parent.data(NetworkModel::ItemActiveRole) == true)) { // without updating the parent the expand will have no effect... Qt Bug? - update(parent); + update(parent); expand(parent); } } @@ -136,12 +139,16 @@ void BufferView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bott continue; bool isActive = networkIdx.data(NetworkModel::ItemActiveRole).toBool(); - if(isExpanded(networkIdx) != isActive) - setExpanded(networkIdx, isActive); + if(Global::SPUTDEV) { + if(isExpanded(networkIdx) != isActive) setExpanded(networkIdx, true); + } else { + if(isExpanded(networkIdx) != isActive) + setExpanded(networkIdx, isActive); + } } } - + void BufferView::toggleHeader(bool checked) { QAction *action = qobject_cast(sender()); header()->setSectionHidden((action->property("column")).toInt(), !checked);