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)
Global::RunMode Global::runMode;
uint Global::defaultPort;
+
+bool Global::SPUTDEV;
extern RunMode runMode;
extern unsigned int defaultPort;
+ extern bool SPUTDEV; // FIXME This is for internal use only!
+
void registerMetaTypes();
};
// 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;
setTextInteractionFlags(Qt::TextBrowserInteraction);
}
-void ChatWidget::setContents(QList<ChatLine *> lines) {
+void ChatWidget::setContents(QList<ChatLineOld *> lines) {
clear();
appendChatLines(lines);
}
void ChatWidget::prependMsg(AbstractUiMsg *msg) {
- ChatLine *line = static_cast<ChatLine*>(msg);
+ ChatLineOld *line = static_cast<ChatLineOld*>(msg);
Q_ASSERT(line);
prependChatLine(line);
}
void ChatWidget::appendMsg(AbstractUiMsg *msg) {
- ChatLine *line = static_cast<ChatLine*>(msg);
+ ChatLineOld *line = static_cast<ChatLineOld*>(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");
setTextCursor(cursor);
}
-void ChatWidget::appendChatLines(QList<ChatLine *> list) {
- foreach(ChatLine *line, list) {
+void ChatWidget::appendChatLines(QList<ChatLineOld *> 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();
setTextCursor(cursor);
}
-void ChatWidget::prependChatLines(QList<ChatLine *> list) {
- foreach(ChatLine *line, list) {
+void ChatWidget::prependChatLines(QList<ChatLineOld *> 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(" ");
ChatWidget(QWidget *parent = 0);
public slots:
- void setContents(QList<ChatLine *>);
+ void setContents(QList<ChatLineOld *>);
void appendMsg(AbstractUiMsg *);
void prependMsg(AbstractUiMsg *);
- void prependChatLine(ChatLine *);
- void appendChatLine(ChatLine *);
- void prependChatLines(QList<ChatLine *>);
- void appendChatLines(QList<ChatLine *>);
+ void prependChatLine(ChatLineOld *);
+ void appendChatLine(ChatLineOld *);
+ void prependChatLines(QList<ChatLineOld *>);
+ void appendChatLines(QList<ChatLineOld *>);
private:
- void insertChatLine(ChatLine *);
+ void insertChatLine(ChatLineOld *);
void insertStyledText(const QtopiaUiStyle::StyledText &);
ChatWidget *chatWidget;
if(!chatWidgets.contains(buf)) {
chatWidget = new ChatWidget(this);
- QList<ChatLine *> lines;
+ QList<ChatLineOld *> lines;
QList<AbstractUiMsg *> 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 *)));
}
AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) {
- return new ChatLine(msg);
+ return new ChatLineOld(msg);
//return 0;
}
#include "bufferwidget.h"
#include "buffer.h"
+#include "chatline.h"
#include "chatline-old.h"
#include "chatwidget.h"
#include "settings.h"
#include "network.h"
#include "networkmodel.h"
+#include "global.h"
+
BufferWidget::BufferWidget(QWidget *parent)
: QWidget(parent),
_bufferModel(0),
if(bufferModel) {
connect(bufferModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)),
- this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int)));
+ this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int)));
}
}
if(selectionModel) {
connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- this, SLOT(currentChanged(QModelIndex, QModelIndex)));
+ this, SLOT(currentChanged(QModelIndex, QModelIndex)));
}
}
for(int i = start; i <= end; i++) {
QVariant variant = parent.child(i,0).data(NetworkModel::BufferIdRole);
if(!variant.isValid())
- continue;
+ continue;
BufferId bufferId = qVariantValue<BufferId>(variant);
removeBuffer(bufferId);
}
ChatWidget *chatWidget = 0;
+ ChatView *chatView = 0;
Buffer *buf = Client::buffer(bufferId);
if(!buf) {
qWarning() << "BufferWidget::setBuffer(BufferId): Can't show unknown Buffer:" << 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<ChatLine *> lines;
+ QList<AbstractUiMsg *> msgs = buf->contents();
+ foreach(AbstractUiMsg *msg, msgs) {
+ lines.append(dynamic_cast<ChatLine *>(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<ChatLine *> lines;
- QList<AbstractUiMsg *> msgs = buf->contents();
- foreach(AbstractUiMsg *msg, msgs) {
- lines.append(dynamic_cast<ChatLine*>(msg));
+ if(_chatWidgets.contains(bufferId)) {
+ chatWidget = _chatWidgets[bufferId];
+ } else {
+ chatWidget = new ChatWidget(this);
+ chatWidget->init(bufferId);
+ QList<ChatLineOld *> lines;
+ QList<AbstractUiMsg *> msgs = buf->contents();
+ foreach(AbstractUiMsg *msg, msgs) {
+ lines.append(dynamic_cast<ChatLineOld*>(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();
}
private:
Ui::BufferWidget ui;
QHash<BufferId, ChatWidget *> _chatWidgets;
+ QHash<BufferId, ChatView *> _chatViews;
QPointer<BufferModel> _bufferModel;
QPointer<QItemSelectionModel> _selectionModel;
}
_layout.endLayout();
update();
-}
+} QDateTime _timestamp;
+ MsgId _msgId;
+
QRectF ChatItem::boundingRect() const {
return _layout.boundingRect();
#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();
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());
}
// 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::FormatRange> 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::FormatRange> ChatLineOld::calcFormatRanges(UiStyle::StyledText fs, QTextLayout::FormatRange additional) {
QList<FormatRange> ranges;
if(additional.length > 0) {
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();
}
}
-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;
//!\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;
return 0;
}
-void ChatLine::precomputeLine() {
+void ChatLineOld::precomputeLine() {
tsFormat = calcFormatRanges(styledTimeStamp);
senderFormat = calcFormatRanges(styledSender);
textFormat = calcFormatRanges(styledText);
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;
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) {
* 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 <QtGui>
//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,
* 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; }
#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<MsgId, ChatLineData*> 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 {
private:
UiStyle::StyledText _styledTimestamp, _styledText, _styledSender;
+
QDateTime _timestamp;
MsgId _msgId;
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
_scene = new ChatScene(buf, this);
setScene(_scene);
- QGraphicsTextItem *item = scene()->addText(buf->name());
+ QGraphicsTextItem *item = scene()->addText(buf->bufferInfo().bufferName());
}
return _scene;
}
-/*
+
void ChatView::clear()
{
}
}
void ChatView::prependChatLine(ChatLine *line) {
- qDebug() << "prepending";
+ //qDebug() << "prepending";
}
void ChatView::prependChatLines(QList<ChatLine *> clist) {
}
void ChatView::appendChatLine(ChatLine *line) {
- qDebug() << "appending";
+ //qDebug() << "appending";
}
qDebug() << "setting" << list.count();
appendChatLines(list);
}
-*/
+
ChatScene *scene() const;
public slots:
-/*
+
void clear();
void prependMsg(AbstractUiMsg *);
void appendChatLines(QList<ChatLine *>);
void setContents(QList<ChatLine *>);
-*/
+
private:
ChatScene *_scene;
};
ChatWidget::~ChatWidget() {
//qDebug() << "destroying chatwidget" << bufferName;
- //foreach(ChatLine *l, lines) {
+ //foreach(ChatLineOld *l, lines) {
// delete l;
//}
UiSettings s;
}
void ChatWidget::prependMsg(AbstractUiMsg *msg) {
- ChatLine *line = dynamic_cast<ChatLine*>(msg);
+ ChatLineOld *line = dynamic_cast<ChatLineOld*>(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);
viewport()->update();
}
-void ChatWidget::prependChatLines(QList<ChatLine *> clist) {
+void ChatWidget::prependChatLines(QList<ChatLineOld *> clist) {
QList<qreal> tmpy; tmpy.append(0);
qreal h = 0;
- foreach(ChatLine *l, clist) {
+ foreach(ChatLineOld *l, clist) {
h += l->layout(tsWidth, senderWidth, textWidth);
tmpy.append(h);
}
}
void ChatWidget::appendMsg(AbstractUiMsg *msg) {
- ChatLine *line = dynamic_cast<ChatLine*>(msg);
+ ChatLineOld *line = dynamic_cast<ChatLineOld*>(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;
}
-void ChatWidget::appendChatLines(QList<ChatLine *> list) {
- foreach(ChatLine *line, list) {
+void ChatWidget::appendChatLines(QList<ChatLineOld *> list) {
+ foreach(ChatLineOld *line, list) {
qreal h = line->layout(tsWidth, senderWidth, textWidth);
ycoords.append(h + ycoords[ycoords.count() - 1]);
height += h;
viewport()->update();
}
-void ChatWidget::setContents(QList<ChatLine *> list) {
+void ChatWidget::setContents(QList<ChatLineOld *> list) {
ycoords.clear();
ycoords.append(0);
height = 0;
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);
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) {
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;
//!\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;
#include "types.h"
-class ChatLine;
+class ChatLineOld;
class AbstractUiMsg;
//!\brief Scroll area showing part of the chat messages for a given buffer.
void prependMsg(AbstractUiMsg *);
void appendMsg(AbstractUiMsg *);
- void prependChatLine(ChatLine *);
- void appendChatLine(ChatLine *);
- void prependChatLines(QList<ChatLine *>);
- void appendChatLines(QList<ChatLine *>);
- void setContents(QList<ChatLine *>);
+ void prependChatLine(ChatLineOld *);
+ void appendChatLine(ChatLineOld *);
+ void prependChatLines(QList<ChatLineOld *>);
+ void appendChatLines(QList<ChatLineOld *>);
+ void setContents(QList<ChatLineOld *>);
protected:
virtual void resizeEvent(QResizeEvent *event);
int bottomLine, bottomLineOffset;
- QList<ChatLine *> lines;
+ QList<ChatLineOld *> lines;
QList<qreal> ycoords;
QTimer *scrollTimer;
QPoint pointerPosition;
* 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"
#include "debugconsole.h"
+#include "global.h"
MainWin::MainWin(QtUi *_gui, QWidget *parent)
: QMainWindow(parent),
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);
+ }
}
//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() {
return;
chatWidget->init(BufferId(0));
- QList<ChatLine *> lines;
+ QList<ChatLineOld *> lines;
QList<AbstractUiMsg *> msgs = buf->contents();
foreach(AbstractUiMsg *msg, msgs) {
- lines.append(dynamic_cast<ChatLine*>(msg));
+ lines.append(dynamic_cast<ChatLineOld*>(msg));
}
chatWidget->setContents(lines);
connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), chatWidget, SLOT(appendMsg(AbstractUiMsg *)));
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
}
}
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) {
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
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) {
#include "uisettings.h"
+#include "global.h"
+
/*****************************************
* The TreeView showing the Buffers
*****************************************/
// 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);
}
}
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<QAction *>(sender());
header()->setSectionHidden((action->property("column")).toInt(), !checked);