X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=f3bbdd7b9ff704b32ab9b11136809874b5bbe5a3;hp=19f48ff20f60b13ac17b0faa0d9268567e18dff4;hb=f1227a0a94322ff69ce0f254d980834672bab45a;hpb=46865cac259e0b6e2ee37f8a1d8703e1898219f4 diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 19f48ff2..f3bbdd7b 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -23,8 +23,15 @@ #include #include #include +#include #include +#ifdef HAVE_KDE +# include +#else +# include +#endif + #ifdef HAVE_WEBKIT # include #endif @@ -92,15 +99,15 @@ ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, qreal w setHandleXLimits(); + if(model->rowCount() > 0) + rowsInserted(QModelIndex(), 0, model->rowCount() - 1); + connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), 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); - #ifdef HAVE_WEBKIT webPreview.timer.setSingleShot(true); connect(&webPreview.timer, SIGNAL(timeout()), this, SLOT(webPreviewNextStep())); @@ -170,7 +177,6 @@ void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) { qreal width = _sceneRect.width(); bool atBottom = (start == _lines.count()); bool atTop = !atBottom && (start == 0); - bool moveTop = false; if(start < _lines.count()) { y = _lines.value(start)->y(); @@ -230,25 +236,11 @@ void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) { } // neither pre- or append means we have to do dirty work: move items... - int moveStart = 0; - int moveEnd = _lines.count() - 1; - qreal offset = h; if(!(atTop || atBottom)) { - // move top means: moving 0 to end (aka: end + 1) - // move top means: moving end + 1 to _lines.count() - 1 (aka: _lines.count() - (end + 1) - if(end + 1 < _lines.count() - end - 1) { - // move top part - moveTop = true; - offset = -offset; - moveEnd = end; - } else { - // move bottom part - moveStart = end + 1; - } ChatLine *line = 0; - for(int i = moveStart; i <= moveEnd; i++) { + for(int i = 0; i <= end; i++) { line = _lines.at(i); - line->setPos(0, line->pos().y() + offset); + line->setPos(0, line->pos().y() - h); } } @@ -285,7 +277,7 @@ void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) { _firstLineRow = -1; } updateSceneRect(); - if(atBottom || (!atTop && !moveTop)) { + if(atBottom) { emit lastLineChanged(_lines.last(), h); } } @@ -613,6 +605,9 @@ void ChatScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { // no item -> default scene actions GraphicalUi::contextMenuActionProvider()->addActions(&menu, filter(), BufferId()); + if (QtUi::mainWindow()->menuBar()->isHidden()) + menu.addAction(QtUi::actionCollection("General")->action("ToggleMenuBar")); + menu.exec(event->screenPos()); } @@ -882,7 +877,7 @@ bool ChatScene::event(QEvent *e) { // Webkit Only stuff // ======================================== #ifdef HAVE_WEBKIT -void ChatScene::loadWebPreview(ChatItem *parentItem, const QString &url, const QRectF &urlRect) { +void ChatScene::loadWebPreview(ChatItem *parentItem, const QUrl &url, const QRectF &urlRect) { if(!_showWebPreview) return; @@ -967,7 +962,7 @@ void ChatScene::webPreviewNextStep() { webPreview.previewItem = 0; } webPreview.parentItem = 0; - webPreview.url = QString(); + webPreview.url = QUrl(); webPreview.urlRect = QRectF(); webPreview.previewState = WebPreview::NoPreview; }