Commit fef79aab authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Port away from foreach and emit

parent 6f4023f9
......@@ -28,6 +28,8 @@ endif()
# URL "https://www.kde.org"
# TYPE REQUIRED PURPOSE "Support for Email previews")
add_definitions(-DQT_NO_FOREACH -DQT_NO_KEYWORDS)
add_subdirectory(lib)
add_subdirectory(plasmoid)
......
......@@ -45,7 +45,7 @@ void DragHelper::setDragIconSize(int size)
if (m_dragIconSize != size) {
m_dragIconSize = size;
emit dragIconSizeChanged();
Q_EMIT dragIconSizeChanged();
}
}
......@@ -79,6 +79,6 @@ void DragHelper::doDrag(QQuickItem *item, QMimeData *mimeData, const QIcon &icon
drag->exec();
emit dropped();
Q_EMIT dropped();
}
......@@ -42,7 +42,7 @@ Preview::Preview(QQuickItem* parent)
//setFlag(QGraphicsItem::ItemHasNoContents, false);
m_plugins = allPlugins();
foreach(PreviewPlugin* plugin, m_plugins) {
for (PreviewPlugin* plugin : qAsConst(m_plugins)) {
connect(plugin, &PreviewPlugin::previewGenerated,
this, &Preview::slotPreviewGenerated);
......@@ -57,7 +57,7 @@ Preview::Preview(QQuickItem* parent)
void Preview::setPluginContexts()
{
QQmlContext* context = qmlContext(parentItem());
foreach(PreviewPlugin* plugin, m_plugins) {
for (PreviewPlugin* plugin : qAsConst(m_plugins)) {
plugin->setContext(context);
}
}
......@@ -70,7 +70,7 @@ void Preview::refresh()
{
if (m_oldUrl == m_url && m_oldMimetype == m_mimetype) {
if (m_declarativeItem)
emit loadingFinished();
Q_EMIT loadingFinished();
return;
}
......@@ -78,8 +78,9 @@ void Preview::refresh()
bool foundPlugin = false;
QUrl url = QUrl::fromLocalFile(m_url);
foreach (PreviewPlugin* plugin, m_plugins) {
foreach (const QString& mime, plugin->mimetypes()) {
for (PreviewPlugin* plugin : qAsConst(m_plugins)) {
const QStringList mimeTypes = plugin->mimetypes();
for (const QString &mime : mimeTypes) {
if (m_mimetype.startsWith(mime)) {
plugin->setUrl(url);
plugin->setMimetype(m_mimetype);
......@@ -111,7 +112,7 @@ void Preview::slotPreviewGenerated(QQuickItem* item)
setHeight(item->height());
m_loaded = true;
emit loadingFinished();
Q_EMIT loadingFinished();
}
void Preview::clear()
......
......@@ -83,10 +83,11 @@ void PreviewPlugin::highlight(const QTextDocument* doc) const
{
QTextCursor cursor;
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
Q_FOREACH (const QString& text, highlight().split(QLatin1Char(' '), QString::SkipEmptyParts)) {
const QStringList highlights = highlight().split(QLatin1Char(' '), QString::SkipEmptyParts);
#else
Q_FOREACH (const QString& text, highlight().split(QLatin1Char(' '), Qt::SkipEmptyParts)) {
const QStringList highlights = highlight().split(QLatin1Char(' '), Qt::SkipEmptyParts);
#endif
for (const QString &text : highlights) {
while (1) {
cursor = doc->find(text, cursor);
if (cursor.isNull())
......
......@@ -59,7 +59,7 @@ void ApplicationPlugin::generatePreview()
item->setProperty("length", 0);
item->setProperty("iconName", service->icon());
emit previewGenerated(item);
Q_EMIT previewGenerated(item);
}
......
......@@ -76,7 +76,7 @@ void AudioPlugin::slotFileReceived(const Baloo::File& file)
item->setProperty("length", keys.length());
item->setProperty("iconName", QLatin1String("audio-x-flac"));
emit previewGenerated(item);
Q_EMIT previewGenerated(item);
}
......
......@@ -34,7 +34,7 @@ void BookmarkPlugin::generatePreview()
webView->load(url());
webView->resize(512, 512);
emit previewGenerated(webView);
Q_EMIT previewGenerated(webView);
}
......
......@@ -128,10 +128,10 @@ void EmailPlugin::slotItemsReceived(const Akonadi::Item::List& itemList)
cursor.insertHtml(htmlContent->decodedText(true, true));
// Attachments
KMime::Content::List list = msg.attachments();
const KMime::Content::List list = msg.attachments();
if (list.count())
cursor.insertText(i18n("\nAttachments:\n\n"), greyCharFormat);
foreach (KMime::Content* c, list) {
for (KMime::Content *c : list) {
KMime::Headers::ContentType* contentType = c->contentType(false);
KMimeType::Ptr mimetype = KMimeType::mimeType(contentType->mimeType());
......@@ -153,7 +153,7 @@ void EmailPlugin::slotItemsReceived(const Akonadi::Item::List& itemList)
edit->resize(384, 384);
highlight(doc);
emit previewGenerated(edit);
Q_EMIT previewGenerated(edit);
}
// Inserts quoted text in green
......
......@@ -66,7 +66,7 @@ void FilePlugin::generatePreview()
if (!mime.isNull())
item->setProperty("iconName", mime->iconName());
emit previewGenerated(item);
Q_EMIT previewGenerated(item);
}
......
......@@ -74,7 +74,7 @@ void ImagePlugin::slotGotPreview(const KFileItem&, const QPixmap& pixmap)
declarativeItem->setWidth(pixmap.width());
declarativeItem->setHeight(pixmap.height());
emit previewGenerated(declarativeItem);
Q_EMIT previewGenerated(declarativeItem);
}
void ImagePlugin::slotJobFinished(KJob* job)
......
......@@ -43,7 +43,7 @@ void OkularPlugin::generatePreview()
QWidget* widget = part->widget();
widget->resize(384, 384);
emit previewGenerated(widget);
Q_EMIT previewGenerated(widget);
}
else {
qWarning() << "Could not load okular service!";
......
......@@ -53,7 +53,7 @@ void TextPlugin::generatePreview()
item->setWidth(700);
item->setHeight(1000);
emit previewGenerated(item);
Q_EMIT previewGenerated(item);
}
MILOU_EXPORT_PREVIEW(TextPlugin, "miloutextplugin")
......
......@@ -52,7 +52,7 @@ void VideoPlugin::generatePreview()
player->play();
player->resize(300, 300);
emit previewGenerated(widget);
Q_EMIT previewGenerated(widget);
}
MILOU_EXPORT_PREVIEW(VideoPlugin, "milouvideoplugin", "milou")
......@@ -160,7 +160,7 @@ public:
}
m_limit = limit;
invalidateFilter();
emit limitChanged();
Q_EMIT limitChanged();
}
Q_SIGNALS:
......
......@@ -138,7 +138,7 @@ void RunnerResultsModel::onMatchesChanged(const QList<Plasma::QueryMatch> &match
// Now that the source data has been updated, emit the data changes we noted down earlier
if (emitDataChanged) {
emit dataChanged(index(0, 0, categoryIdx), index(countCeiling - 1, 0, categoryIdx));
Q_EMIT dataChanged(index(0, 0, categoryIdx), index(countCeiling - 1, 0, categoryIdx));
}
// Signal insertions for any new items
......@@ -195,7 +195,7 @@ void RunnerResultsModel::setQueryString(const QString &queryString)
m_manager->launchQuery(queryString, m_runner);
setQuerying(true);
}
emit queryStringChanged(queryString);
Q_EMIT queryStringChanged(queryString);
}
bool RunnerResultsModel::querying() const
......@@ -207,7 +207,7 @@ void RunnerResultsModel::setQuerying(bool querying)
{
if (m_querying != querying) {
m_querying = querying;
emit queryingChanged();
Q_EMIT queryingChanged();
}
}
......@@ -225,7 +225,7 @@ void RunnerResultsModel::setRunner(const QString &runner)
m_runner = runner;
m_manager->setSingleModeRunnerId(runner);
m_manager->setSingleMode(!runner.isEmpty());
emit runnerChanged();
Q_EMIT runnerChanged();
}
QString RunnerResultsModel::runnerName() const
......@@ -283,7 +283,7 @@ bool RunnerResultsModel::run(const QModelIndex &idx)
}
}
emit queryStringChangeRequested(info, editPos);
Q_EMIT queryStringChangeRequested(info, editPos);
return false;
}
}
......
......@@ -71,7 +71,7 @@ QHash<int, QByteArray> SourcesModel::roleNames() const
Plasma::QueryMatch SourcesModel::fetchMatch(int row) const
{
foreach (const QString& type, m_types) {
for (const QString &type : qAsConst(m_types)) {
const TypeData data = m_matches.value(type);
if (row < data.shown.size()) {
return data.shown[row];
......@@ -179,7 +179,7 @@ void SourcesModel::setRunner(const QString& runner)
m_manager->setSingleModeRunnerId(m_runner);
m_manager->setSingleMode(!m_runner.isEmpty());
emit runnerChanged();
Q_EMIT runnerChanged();
}
}
......@@ -279,7 +279,7 @@ void SourcesModel::slotMatchesChanged(const QList<Plasma::QueryMatch>& l)
#endif
QSet<QString> higherTypes;
foreach (const QString &type, m_types) {
for (const QString &type : qAsConst(m_types)) {
const TypeData td = m_matches.value(type);
for (const Plasma::QueryMatch &match : td.shown) {
......@@ -336,7 +336,7 @@ void SourcesModel::slotMatchAdded(const Plasma::QueryMatch& m)
if (m_size == m_queryLimit) {
int maxShownItems = 0;
QString maxShownType;
foreach (const QString& type, m_types) {
for (const QString &type : qAsConst(m_types)) {
TypeData data = m_matches.value(type);
if (data.shown.size() >= maxShownItems) {
maxShownItems = data.shown.size();
......@@ -405,7 +405,7 @@ bool SourcesModel::run(int index)
}
}
emit updateSearchTerm(info, editPos);
Q_EMIT updateSearchTerm(info, editPos);
return false;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment