X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatscene.cpp;h=80e24a601d10d305f54b1ee7eeeb413a3425ff7a;hp=78c33c88060c7cfc075410849f8ad022dff9a621;hb=900cce213a6ed000b7131a05a0dec7d04b35b023;hpb=3a3e844f9fcfd12235a0086af75ecd503b621ef4 diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 78c33c88..80e24a60 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -80,13 +80,13 @@ ChatScene::ChatScene(QAbstractItemModel *model, QString idString, qreal width, C _clickHandled(true), _leftButtonPressed(false) { - MessageFilter *filter = qobject_cast(model); + auto *filter = qobject_cast(model); if (filter && filter->isSingleBufferFilter()) { _singleBufferId = filter->singleBufferId(); } addItem(_markerLine); - connect(this, SIGNAL(sceneRectChanged(const QRectF &)), _markerLine, SLOT(sceneRectChanged(const QRectF &))); + connect(this, &QGraphicsScene::sceneRectChanged, _markerLine, &MarkerLineItem::sceneRectChanged); ChatViewSettings defaultSettings; _defaultFirstColHandlePos = defaultSettings.value("FirstColumnHandlePos", 80).toInt(); @@ -99,32 +99,32 @@ ChatScene::ChatScene(QAbstractItemModel *model, QString idString, qreal width, C _firstColHandle = new ColumnHandleItem(QtUi::style()->firstColumnSeparator()); addItem(_firstColHandle); _firstColHandle->setXPos(_firstColHandlePos); - connect(_firstColHandle, SIGNAL(positionChanged(qreal)), this, SLOT(firstHandlePositionChanged(qreal))); - connect(this, SIGNAL(sceneRectChanged(const QRectF &)), _firstColHandle, SLOT(sceneRectChanged(const QRectF &))); + connect(_firstColHandle, &ColumnHandleItem::positionChanged, this, &ChatScene::firstHandlePositionChanged); + connect(this, &QGraphicsScene::sceneRectChanged, _firstColHandle, &ColumnHandleItem::sceneRectChanged); _secondColHandle = new ColumnHandleItem(QtUi::style()->secondColumnSeparator()); addItem(_secondColHandle); _secondColHandle->setXPos(_secondColHandlePos); - connect(_secondColHandle, SIGNAL(positionChanged(qreal)), this, SLOT(secondHandlePositionChanged(qreal))); + connect(_secondColHandle, &ColumnHandleItem::positionChanged, this, &ChatScene::secondHandlePositionChanged); - connect(this, SIGNAL(sceneRectChanged(const QRectF &)), _secondColHandle, SLOT(sceneRectChanged(const QRectF &))); + connect(this, &QGraphicsScene::sceneRectChanged, _secondColHandle, &ColumnHandleItem::sceneRectChanged); 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(rowsRemoved(QModelIndex, int, int)), - this, SLOT(rowsRemoved())); - connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(dataChanged(QModelIndex, QModelIndex))); + connect(model, &QAbstractItemModel::rowsInserted, + this, &ChatScene::rowsInserted); + connect(model, &QAbstractItemModel::rowsAboutToBeRemoved, + this, &ChatScene::rowsAboutToBeRemoved); + connect(model, &QAbstractItemModel::rowsRemoved, + this, &ChatScene::rowsRemoved); + connect(model, &QAbstractItemModel::dataChanged, this, &ChatScene::dataChanged); #if defined HAVE_WEBKIT || defined HAVE_WEBENGINE webPreview.timer.setSingleShot(true); - connect(&webPreview.timer, SIGNAL(timeout()), this, SLOT(webPreviewNextStep())); + connect(&webPreview.timer, &QTimer::timeout, this, &ChatScene::webPreviewNextStep); #endif _showWebPreview = defaultSettings.showWebPreview(); defaultSettings.notify("ShowWebPreview", this, SLOT(showWebPreviewChanged())); @@ -141,17 +141,12 @@ ChatScene::ChatScene(QAbstractItemModel *model, QString idString, qreal width, C _clickTimer.setInterval(QApplication::doubleClickInterval()); _clickTimer.setSingleShot(true); - connect(&_clickTimer, SIGNAL(timeout()), SLOT(clickTimeout())); + connect(&_clickTimer, &QTimer::timeout, this, &ChatScene::clickTimeout); setItemIndexMethod(QGraphicsScene::NoIndex); } -ChatScene::~ChatScene() -{ -} - - ChatView *ChatScene::chatView() const { return _chatView; @@ -190,7 +185,7 @@ ChatLine *ChatScene::chatLine(MsgId msgId, bool matchExact, bool ignoreDayChange QList::ConstIterator end = _lines.end(); QList::ConstIterator middle; - int n = int(end - start); + auto n = int(end - start); int half; while (n > 0) { @@ -243,7 +238,7 @@ ChatLine *ChatScene::chatLine(MsgId msgId, bool matchExact, bool ignoreDayChange ChatItem *ChatScene::chatItemAt(const QPointF &scenePos) const { foreach(QGraphicsItem *item, items(scenePos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder)) { - ChatLine *line = qgraphicsitem_cast(item); + auto *line = qgraphicsitem_cast(item); if (line) return line->itemAt(line->mapFromScene(scenePos)); } @@ -253,7 +248,7 @@ ChatItem *ChatScene::chatItemAt(const QPointF &scenePos) const bool ChatScene::containsBuffer(const BufferId &id) const { - MessageFilter *filter = qobject_cast(model()); + auto *filter = qobject_cast(model()); if (filter) return filter->containsBuffer(id); else @@ -375,7 +370,7 @@ void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) if (atTop) { for (int i = end; i >= start; i--) { - ChatLine *line = new ChatLine(i, model(), + auto *line = new ChatLine(i, model(), width, timestampWidth, senderWidth, contentsWidth, senderPos, contentsPos); @@ -387,7 +382,7 @@ void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) } else { for (int i = start; i <= end; i++) { - ChatLine *line = new ChatLine(i, model(), + auto *line = new ChatLine(i, model(), width, timestampWidth, senderWidth, contentsWidth, senderPos, contentsPos); @@ -740,8 +735,8 @@ void ChatScene::updateSelection(const QPointF &pos) { int curRow = rowByScenePos(pos); if (curRow < 0) return; - int curColumn = (int)columnByScenePos(pos); - ChatLineModel::ColumnType minColumn = (ChatLineModel::ColumnType)qMin(curColumn, _selectionStartCol); + auto curColumn = (int)columnByScenePos(pos); + auto minColumn = (ChatLineModel::ColumnType)qMin(curColumn, _selectionStartCol); if (minColumn != _selectionMinCol) { _selectionMinCol = minColumn; for (int l = qMin(_selectionStart, _selectionEnd); l <= qMax(_selectionStart, _selectionEnd); l++) { @@ -978,8 +973,8 @@ void ChatScene::handleClick(Qt::MouseButton button, const QPointF &scenePos) void ChatScene::initiateDrag(QWidget *source) { - QDrag *drag = new QDrag(source); - QMimeData *mimeData = new QMimeData; + auto *drag = new QDrag(source); + auto *mimeData = new QMimeData; mimeData->setText(selection()); drag->setMimeData(mimeData); @@ -1129,7 +1124,7 @@ void ChatScene::webSearchOnSelection() void ChatScene::requestBacklog() { - MessageFilter *filter = qobject_cast(model()); + auto *filter = qobject_cast(model()); if (filter) return filter->requestBacklog(); return; @@ -1153,7 +1148,7 @@ int ChatScene::rowByScenePos(qreal y) const // ChatLine should be at the bottom of the list for (int i = itemList.count()-1; i >= 0; i--) { - ChatLine *line = qgraphicsitem_cast(itemList.at(i)); + auto *line = qgraphicsitem_cast(itemList.at(i)); if (line) return line->row(); } @@ -1397,7 +1392,7 @@ void ChatScene::updateTimestampHasBrackets() // (^\s*\(.+\)\s*$)|(^\s*\{.+\}\s*$)|(^\s*\[.+\]\s*$)|(^\s*<.+>\s*$) // Note that '\' must be escaped as '\\' // Helpful interactive website for debugging and explaining: https://regex101.com/ - const QRegExp regExpMatchBrackets("^\\s*[({[<].+[)}\\]>]\\s*$"); + const QRegExp regExpMatchBrackets(R"(^\s*[({[<].+[)}\]>]\s*$)"); _timestampHasBrackets = regExpMatchBrackets.exactMatch(_timestampFormatString); } }