X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fqtui%2Fchatscene.cpp;h=bcfea000e81ccb4e0d6d2e8aa341111fa4b2616b;hb=d7a7c6e5242fd0f500b2c1c75579c9db81a91d0c;hp=4fdf92a06c05e78285d60343b63316b296d518fa;hpb=a540a0285feef171e16fd6225b0e045fc5fc52e4;p=quassel.git diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 4fdf92a0..bcfea000 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -24,7 +24,10 @@ #include #include #include -#include + +#ifdef HAVE_WEBKIT +# include +#endif #include "chatitem.h" #include "chatline.h" @@ -93,6 +96,7 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w this, SLOT(rowsInserted(const QModelIndex &, int, int))); connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), this, SLOT(rowsAboutToBeRemoved(const QModelIndex &, int, int))); + connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(dataChanged(QModelIndex, QModelIndex))); if(model->rowCount() > 0) rowsInserted(QModelIndex(), 0, model->rowCount() - 1); @@ -377,6 +381,13 @@ void ChatScene::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e updateSceneRect(); } +void ChatScene::dataChanged(const QModelIndex &tl, const QModelIndex &br) { + // This should only be sent (currently) if the style is reloaded -> re-layout the whole scene + // TODO: Check range and only do partial relayouts, if appropriate + + layout(); +} + void ChatScene::updateForViewport(qreal width, qreal height) { _viewportHeight = height; setWidth(width); @@ -385,9 +396,15 @@ void ChatScene::updateForViewport(qreal width, qreal height) { void ChatScene::setWidth(qreal width) { if(width == _sceneRect.width()) return; + layout(width); +} +void ChatScene::layout(qreal width) { // clock_t startT = clock(); + if(width < 0) + width = _sceneRect.width(); + // disabling the index while doing this complex updates is about // 2 to 10 times faster! //setItemIndexMethod(QGraphicsScene::NoIndex); @@ -708,7 +725,12 @@ void ChatScene::selectionToClipboard(QClipboard::Mode mode) { stringToClipboard(selection(), mode); } -void ChatScene::stringToClipboard(const QString &str, QClipboard::Mode mode) { +void ChatScene::stringToClipboard(const QString &str_, QClipboard::Mode mode) { + QString str = str_; + // remove trailing linefeeds + if(str.endsWith('\n')) + str.chop(1); + switch(mode) { case QClipboard::Clipboard: QApplication::clipboard()->setText(str);