X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatwidget.cpp;h=cf897b6ff42c9efa06329c26bf012ecc92fd7511;hp=566de0d8c2aab235c81da54495f3e231a01a5e05;hb=911ef2eb93db3f86c160dfe22fd186f2221e1d76;hpb=5319f3fbe69a63d1599107e0fc77ae325e4a9b6d diff --git a/src/qtui/chatwidget.cpp b/src/qtui/chatwidget.cpp index 566de0d8..cf897b6f 100644 --- a/src/qtui/chatwidget.cpp +++ b/src/qtui/chatwidget.cpp @@ -27,8 +27,7 @@ #include "buffer.h" #include "clientbacklogmanager.h" -ChatWidget::ChatWidget(QWidget *parent) - : QAbstractScrollArea(parent), +ChatWidget::ChatWidget(BufferId bufid, QWidget *parent) : QAbstractScrollArea(parent), AbstractChatView(), lastBacklogOffset(0), lastBacklogSize(0) { @@ -50,6 +49,8 @@ ChatWidget::ChatWidget(QWidget *parent) pointerPosition = QPoint(0,0); connect(verticalScrollBar(), SIGNAL(actionTriggered(int)), this, SLOT(scrollBarAction(int))); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrollBarValChanged(int))); + + init(bufid); } void ChatWidget::init(BufferId id) { @@ -248,12 +249,14 @@ void ChatWidget::appendChatLines(QList list) { viewport()->update(); } -void ChatWidget::setContents(QList list) { +void ChatWidget::setContents(const QList &list) { ycoords.clear(); ycoords.append(0); height = 0; lines.clear(); - appendChatLines(list); + QList cl; + foreach(AbstractUiMsg *msg, list) cl << dynamic_cast(msg); + appendChatLines(cl); } //!\brief Computes the different x position vars for given tsWidth and senderWidth. @@ -381,7 +384,8 @@ void ChatWidget::mouseDoubleClickEvent(QMouseEvent *event) { len = end - start; } QString word = text.mid(start, len); - if(word.startsWith("http://")) { + QRegExp regex("^(h|f)t{1,2}ps?:\\/\\/"); + if(regex.indexIn(word) != -1) { QDesktopServices::openUrl(QUrl(word)); } @@ -407,7 +411,11 @@ void ChatWidget::mouseReleaseEvent(QMouseEvent *event) { selectionStart = qMin(dragStartCursor, curCursor); selectionEnd = qMax(dragStartCursor, curCursor); // TODO Make X11SelectionMode configurable! +#ifdef Q_WS_X11 + QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection); +#else QApplication::clipboard()->setText(selectionToString()); +#endif break; case MarkLines: mouseMode = Normal; @@ -415,7 +423,12 @@ void ChatWidget::mouseReleaseEvent(QMouseEvent *event) { selectionStart = qMin(dragStartLine, curLine); selectionEnd = qMax(dragStartLine, curLine); // TODO Make X11SelectionMode configurable! +#ifdef Q_WS_X11 + QApplication::clipboard()->setText(selectionToString(), QClipboard::Selection); +#endif +//#else QApplication::clipboard()->setText(selectionToString()); +//#endif break; default: mouseMode = Normal; @@ -616,7 +629,7 @@ void ChatWidget::viewportChanged(int newPos) { if(buffer->contents().isEmpty()) return; MsgId msgId = buffer->contents().first()->msgId(); - if(!lastBacklogOffset.isValid() || msgId < lastBacklogOffset && lastBacklogSize + REQUEST_COUNT <= buffer->contents().count()) { + if(!lastBacklogOffset.isValid() || (msgId < lastBacklogOffset && lastBacklogSize + REQUEST_COUNT <= buffer->contents().count())) { Client::backlogManager()->requestBacklog(bufferId, REQUEST_COUNT, msgId.toInt()); lastBacklogOffset = msgId; lastBacklogSize = buffer->contents().size();