_clickHandled(true),
_leftButtonPressed(false)
{
- MessageFilter *filter = qobject_cast<MessageFilter *>(model);
+ auto *filter = qobject_cast<MessageFilter *>(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();
_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()));
+ defaultSettings.notify("ShowWebPreview", this, &ChatScene::showWebPreviewChanged);
_showSenderBrackets = defaultSettings.showSenderBrackets();
- defaultSettings.notify("ShowSenderBrackets", this, SLOT(showSenderBracketsChanged()));
+ defaultSettings.notify("ShowSenderBrackets", this, &ChatScene::showSenderBracketsChanged);
_useCustomTimestampFormat = defaultSettings.useCustomTimestampFormat();
- defaultSettings.notify("UseCustomTimestampFormat", this, SLOT(useCustomTimestampFormatChanged()));
+ defaultSettings.notify("UseCustomTimestampFormat", this, &ChatScene::useCustomTimestampFormatChanged);
_timestampFormatString = defaultSettings.timestampFormatString();
- defaultSettings.notify("TimestampFormat", this, SLOT(timestampFormatStringChanged()));
+ defaultSettings.notify("TimestampFormat", this, &ChatScene::timestampFormatStringChanged);
updateTimestampHasBrackets();
_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;
QList<ChatLine *>::ConstIterator end = _lines.end();
QList<ChatLine *>::ConstIterator middle;
- int n = int(end - start);
+ auto n = int(end - start);
int half;
while (n > 0) {
ChatItem *ChatScene::chatItemAt(const QPointF &scenePos) const
{
foreach(QGraphicsItem *item, items(scenePos, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder)) {
- ChatLine *line = qgraphicsitem_cast<ChatLine *>(item);
+ auto *line = qgraphicsitem_cast<ChatLine *>(item);
if (line)
return line->itemAt(line->mapFromScene(scenePos));
}
bool ChatScene::containsBuffer(const BufferId &id) const
{
- MessageFilter *filter = qobject_cast<MessageFilter *>(model());
+ auto *filter = qobject_cast<MessageFilter *>(model());
if (filter)
return filter->containsBuffer(id);
else
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);
}
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);
{
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++) {
// If we have text selected, insert the Copy Selection as first item
if (isPosOverSelection(pos)) {
QAction *sep = menu.insertSeparator(menu.actions().first());
- QAction *act = new Action(icon::get("edit-copy"), tr("Copy Selection"), &menu, this,
- SLOT(selectionToClipboard()), QKeySequence::Copy);
+ QAction *act = new Action(icon::get("edit-copy"), tr("Copy Selection"), &menu, this, [this]() { selectionToClipboard(); }, QKeySequence::Copy);
menu.insertAction(sep, act);
QString searchSelectionText = selection();
searchSelectionText = searchSelectionText.left(_webSearchSelectionTextMaxVisible).append(QString::fromUtf8("…"));
searchSelectionText = tr("Search '%1'").arg(searchSelectionText);
- QAction *webSearchAction = new Action(icon::get("edit-find"), searchSelectionText, &menu, this, SLOT(webSearchOnSelection()));
+ QAction *webSearchAction = new Action(icon::get("edit-find"), searchSelectionText, &menu, this, &ChatScene::webSearchOnSelection);
menu.insertAction(sep, webSearchAction);
}
// show column reset action if columns have been resized in this session or there is at least one very narrow column
if ((_firstColHandlePos != _defaultFirstColHandlePos) || (_secondColHandlePos != _defaultSecondColHandlePos) ||
(_firstColHandlePos <= 10) || (_secondColHandlePos - _firstColHandlePos <= 10))
- menu.addAction(new Action(tr("Reset Column Widths"), &menu, this, SLOT(resetColumnWidths()), 0));
+ menu.addAction(new Action(tr("Reset Column Widths"), &menu, this, &ChatScene::resetColumnWidths));
menu.exec(event->screenPos());
}
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);
void ChatScene::requestBacklog()
{
- MessageFilter *filter = qobject_cast<MessageFilter *>(model());
+ auto *filter = qobject_cast<MessageFilter *>(model());
if (filter)
return filter->requestBacklog();
return;
// ChatLine should be at the bottom of the list
for (int i = itemList.count()-1; i >= 0; i--) {
- ChatLine *line = qgraphicsitem_cast<ChatLine *>(itemList.at(i));
+ auto *line = qgraphicsitem_cast<ChatLine *>(itemList.at(i));
if (line)
return line->row();
}
// (^\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);
}
}