summary refs log tree commit diff
path: root/src/timeline/InputBar.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-12-29 06:01:38 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-12-29 06:01:38 +0100
commit19dc6cadea0168f72daff7c0ed679ccdac71a7d5 (patch)
treeb10a86fcd0ab0f12f5e242996b307bb2cac97940 /src/timeline/InputBar.cpp
parentReduce allocations required for the palette (diff)
downloadnheko-19dc6cadea0168f72daff7c0ed679ccdac71a7d5.tar.xz
Reserve size of some containers we are filling
Diffstat (limited to 'src/timeline/InputBar.cpp')
-rw-r--r--src/timeline/InputBar.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp

index 832016e2..767dccc3 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp
@@ -56,7 +56,8 @@ InputBar::insertMimeData(const QMimeData *md) if (!md) return; - nhlog::ui()->debug("Got mime formats: {}", md->formats().join(QStringLiteral(", ")).toStdString()); + nhlog::ui()->debug("Got mime formats: {}", + md->formats().join(QStringLiteral(", ")).toStdString()); const auto formats = md->formats().filter(QStringLiteral("/")); const auto image = formats.filter(QStringLiteral("image/"), Qt::CaseInsensitive); const auto audio = formats.filter(QStringLiteral("audio/"), Qt::CaseInsensitive); @@ -140,7 +141,8 @@ InputBar::updateAtRoom(const QString &t) auto start = finder.position(); finder.toNextBoundary(); auto end = finder.position(); - if (start > 0 && end - start >= 4 && t.mid(start, end - start) == QLatin1String("room") && + if (start > 0 && end - start >= 4 && + t.mid(start, end - start) == QLatin1String("room") && t.at(start - 1) == QChar('@')) { roomMention = true; break; @@ -660,13 +662,15 @@ InputBar::showPreview(const QMimeData &source, const QString &path, const QStrin previewDialog_->setAttribute(Qt::WA_DeleteOnClose); // Force SVG to _not_ be handled as an image, but as raw data - if (source.hasImage() && (formats.empty() || formats.front() != QLatin1String("image/svg+xml"))) { + if (source.hasImage() && + (formats.empty() || formats.front() != QLatin1String("image/svg+xml"))) { if (!formats.empty() && formats.front().startsWith(QLatin1String("image/"))) { // known format, keep as-is previewDialog_->setPreview(qvariant_cast<QImage>(source.imageData()), formats.front()); } else { // unknown image format, default to image/png - previewDialog_->setPreview(qvariant_cast<QImage>(source.imageData()), QStringLiteral("image/png")); + previewDialog_->setPreview(qvariant_cast<QImage>(source.imageData()), + QStringLiteral("image/png")); } } else if (!path.isEmpty()) previewDialog_->setPreview(path);