diff --git a/autotests/epubextractortest.cpp b/autotests/epubextractortest.cpp --- a/autotests/epubextractortest.cpp +++ b/autotests/epubextractortest.cpp @@ -42,7 +42,7 @@ plugin->extract(&result); QCOMPARE(result.types().size(), 1); - QCOMPARE(result.types().first(), Type::Document); + QCOMPARE(result.types().constFirst(), Type::Document); // We're doing a contains instead of an exact check cause the epub file contains // a ton of css and other garbage. diff --git a/autotests/exiv2extractortest.cpp b/autotests/exiv2extractortest.cpp --- a/autotests/exiv2extractortest.cpp +++ b/autotests/exiv2extractortest.cpp @@ -42,7 +42,7 @@ plugin->extract(&result); QCOMPARE(result.types().size(), 1); - QCOMPARE(result.types().first(), Type::Image); + QCOMPARE(result.types().constFirst(), Type::Image); using namespace KFileMetaData::Property; double lat = 41.4114341666667; diff --git a/autotests/popplerextractortest.cpp b/autotests/popplerextractortest.cpp --- a/autotests/popplerextractortest.cpp +++ b/autotests/popplerextractortest.cpp @@ -42,7 +42,7 @@ plugin->extract(&result); QCOMPARE(result.types().size(), 1); - QCOMPARE(result.types().first(), Type::Document); + QCOMPARE(result.types().constFirst(), Type::Document); QCOMPARE(result.text(), QStringLiteral("This is a sample PDF file for KFileMetaData. ")); QCOMPARE(result.properties().value(Property::Author), QVariant(QStringLiteral("Happy Man"))); diff --git a/autotests/taglibextractortest.cpp b/autotests/taglibextractortest.cpp --- a/autotests/taglibextractortest.cpp +++ b/autotests/taglibextractortest.cpp @@ -43,7 +43,7 @@ plugin->extract(&resultOpus); QCOMPARE(resultOpus.types().size(), 1); - QCOMPARE(resultOpus.types().first(), Type::Audio); + QCOMPARE(resultOpus.types().constFirst(), Type::Audio); QCOMPARE(resultOpus.properties().value(Property::Title), QVariant(QStringLiteral("Title"))); QCOMPARE(resultOpus.properties().value(Property::Artist), QVariant(QStringLiteral("Artist"))); @@ -61,7 +61,7 @@ plugin->extract(&resultFlac); QCOMPARE(resultFlac.types().size(), 1); - QCOMPARE(resultFlac.types().first(), Type::Audio); + QCOMPARE(resultFlac.types().constFirst(), Type::Audio); QCOMPARE(resultFlac.properties().value(Property::Title), QVariant(QStringLiteral("Title"))); QCOMPARE(resultFlac.properties().value(Property::Artist), QVariant(QStringLiteral("Artist"))); @@ -79,7 +79,7 @@ plugin->extract(&resultOgg); QCOMPARE(resultOgg.types().size(), 1); - QCOMPARE(resultOgg.types().first(), Type::Audio); + QCOMPARE(resultOgg.types().constFirst(), Type::Audio); QCOMPARE(resultOgg.properties().value(Property::Title), QVariant(QStringLiteral("Title"))); QCOMPARE(resultOgg.properties().value(Property::Artist), QVariant(QStringLiteral("Artist"))); @@ -97,7 +97,7 @@ plugin->extract(&resultMp3); QCOMPARE(resultMp3.types().size(), 1); - QCOMPARE(resultMp3.types().first(), Type::Audio); + QCOMPARE(resultMp3.types().constFirst(), Type::Audio); QCOMPARE(resultMp3.properties().value(Property::Title), QVariant(QStringLiteral("Title"))); QCOMPARE(resultMp3.properties().value(Property::Artist), QVariant(QStringLiteral("Artist"))); @@ -115,7 +115,7 @@ plugin->extract(&resultMpc); QCOMPARE(resultMpc.types().size(), 1); - QCOMPARE(resultMpc.types().first(), Type::Audio); + QCOMPARE(resultMpc.types().constFirst(), Type::Audio); QCOMPARE(resultMpc.properties().value(Property::Title), QVariant(QStringLiteral("Title"))); QCOMPARE(resultMpc.properties().value(Property::Artist), QVariant(QStringLiteral("Artist"))); @@ -133,7 +133,7 @@ plugin->extract(&resultMp4); QCOMPARE(resultMp4.types().size(), 1); - QCOMPARE(resultMp4.types().first(), Type::Audio); + QCOMPARE(resultMp4.types().constFirst(), Type::Audio); QCOMPARE(resultMp4.properties().value(Property::Title), QVariant(QStringLiteral("Title"))); QCOMPARE(resultMp4.properties().value(Property::Artist), QVariant(QStringLiteral("Artist"))); diff --git a/src/externalextractor.h b/src/externalextractor.h --- a/src/externalextractor.h +++ b/src/externalextractor.h @@ -29,6 +29,9 @@ class ExternalExtractor : public ExtractorPlugin { + + Q_OBJECT + public: explicit ExternalExtractor(QObject* parent = 0); ExternalExtractor(const QString& pluginPath); @@ -38,7 +41,7 @@ void extract(ExtractionResult* result) Q_DECL_OVERRIDE; private: - struct ExternalExtractorPrivate; + class ExternalExtractorPrivate; ExternalExtractorPrivate *d_ptr; Q_DECLARE_PRIVATE(ExternalExtractor) }; diff --git a/src/externalextractor.cpp b/src/externalextractor.cpp --- a/src/externalextractor.cpp +++ b/src/externalextractor.cpp @@ -38,7 +38,8 @@ using namespace KFileMetaData; -struct ExternalExtractor::ExternalExtractorPrivate { +class ExternalExtractor::ExternalExtractorPrivate { +public: QString path; QStringList writeMimetypes; QString mainPath; @@ -78,7 +79,7 @@ QJsonObject rootObject = manifestDoc.object(); QJsonArray mimetypesArray = rootObject.value(QStringLiteral("mimetypes")).toArray(); QStringList mimetypes; - Q_FOREACH(QVariant mimetype, mimetypesArray) { + Q_FOREACH(const QVariant &mimetype, mimetypesArray) { mimetypes << mimetype.toString(); } @@ -135,7 +136,7 @@ QJsonObject rootObject = extractorData.object(); QJsonObject propertiesObject = rootObject[QStringLiteral("properties")].toObject(); - Q_FOREACH(auto key, propertiesObject.keys()) { + Q_FOREACH(const auto &key, propertiesObject.keys()) { if (key == QStringLiteral("typeInfo")) { TypeInfo info = TypeInfo::fromName(propertiesObject.value(key).toString()); result->addType(info.type()); diff --git a/src/externalwriter.h b/src/externalwriter.h --- a/src/externalwriter.h +++ b/src/externalwriter.h @@ -29,9 +29,12 @@ class ExternalWriter : public WriterPlugin { + + Q_OBJECT + public: explicit ExternalWriter(QObject* parent = 0); - ExternalWriter(const QString& pluginPath); + explicit ExternalWriter(const QString& pluginPath); virtual ~ExternalWriter(); void write(const WriteData& data) Q_DECL_OVERRIDE; @@ -41,7 +44,7 @@ bool runtimeInstalled() const; bool dependenciesSatisfied() const; - struct ExternalWriterPrivate; + class ExternalWriterPrivate; ExternalWriterPrivate *d_ptr; Q_DECLARE_PRIVATE(ExternalWriter) }; diff --git a/src/externalwriter.cpp b/src/externalwriter.cpp --- a/src/externalwriter.cpp +++ b/src/externalwriter.cpp @@ -37,7 +37,8 @@ using namespace KFileMetaData; -struct ExternalWriter::ExternalWriterPrivate { +class ExternalWriter::ExternalWriterPrivate { +public: QString path; QStringList writeMimetypes; QString mainPath; @@ -81,7 +82,7 @@ QJsonObject rootObject = manifestDoc.object(); QJsonArray mimetypesArray = rootObject.value(QStringLiteral("mimetypes")).toArray(); QStringList mimetypes; - Q_FOREACH(QVariant mimetype, mimetypesArray) { + Q_FOREACH(const QVariant &mimetype, mimetypesArray) { mimetypes << mimetype.toString(); } @@ -105,8 +106,9 @@ QByteArray errorOutput; QMap properties = data.getAllProperties(); + const auto &propertiesKeys = properties.keys(); - Q_FOREACH(Property::Property property, properties.keys()) { + Q_FOREACH(const Property::Property &property, propertiesKeys) { PropertyInfo propertyInfo(property); propertiesObject[propertyInfo.name()] = QJsonValue::fromVariant(properties[property]); } diff --git a/src/extractorcollection.cpp b/src/extractorcollection.cpp --- a/src/extractorcollection.cpp +++ b/src/extractorcollection.cpp @@ -39,24 +39,26 @@ public: QHash m_extractors; + QList m_allExtractors; + QList allExtractors() const; }; ExtractorCollection::ExtractorCollection() : d(new Private) { - QList all = d->allExtractors(); + d->m_allExtractors = d->allExtractors(); - foreach (Extractor* ex, all) { + foreach (Extractor* ex, d->m_allExtractors) { foreach (const QString& type, ex->mimetypes()) { d->m_extractors.insertMulti(type, ex); } } } ExtractorCollection::~ExtractorCollection() { - qDeleteAll(d->m_extractors.values().toSet()); + qDeleteAll(d->m_allExtractors.begin(), d->m_allExtractors.end()); delete d; } diff --git a/src/writedata.h b/src/writedata.h --- a/src/writedata.h +++ b/src/writedata.h @@ -53,7 +53,7 @@ QMap getAllProperties() const; private: - struct WriteDataPrivate; + class WriteDataPrivate; WriteDataPrivate* d_ptr; Q_DECLARE_PRIVATE(WriteData) }; diff --git a/src/writedata.cpp b/src/writedata.cpp --- a/src/writedata.cpp +++ b/src/writedata.cpp @@ -27,7 +27,8 @@ using namespace KFileMetaData; -struct WriteData::WriteDataPrivate { +class WriteData::WriteDataPrivate { +public: QString url; QString mimetype; PropertyMap properties; @@ -52,7 +53,6 @@ WriteData& WriteData::operator=(const WriteData& rhs) { - Q_D(WriteData); *d_ptr = *rhs.d_ptr; return *this; } diff --git a/src/writer.h b/src/writer.h --- a/src/writer.h +++ b/src/writer.h @@ -47,7 +47,7 @@ void operator =(const Writer&); - struct WriterPrivate; + class WriterPrivate; WriterPrivate *d_ptr; Q_DECLARE_PRIVATE(Writer) diff --git a/src/writer_p.h b/src/writer_p.h --- a/src/writer_p.h +++ b/src/writer_p.h @@ -28,8 +28,9 @@ class WriterPlugin; -struct Writer::WriterPrivate +class Writer::WriterPrivate { +public: WriterPlugin *m_plugin; }; diff --git a/src/writercollection.h b/src/writercollection.h --- a/src/writercollection.h +++ b/src/writercollection.h @@ -41,7 +41,7 @@ QList fetchWriters(const QString& mimetype) const; private: - struct WriterCollectionPrivate; + class WriterCollectionPrivate; WriterCollectionPrivate* d_ptr; Q_DECLARE_PRIVATE(WriterCollection) }; diff --git a/src/writercollection.cpp b/src/writercollection.cpp --- a/src/writercollection.cpp +++ b/src/writercollection.cpp @@ -38,7 +38,8 @@ using namespace KFileMetaData; -struct WriterCollection::WriterCollectionPrivate { +class WriterCollection::WriterCollectionPrivate { +public: QHash m_writers; QList allWriters() const; @@ -60,7 +61,7 @@ WriterCollection::~WriterCollection() { Q_D(WriterCollection); - qDeleteAll(d->m_writers.values().toSet()); + qDeleteAll(d->m_writers.begin(), d->m_writers.end()); delete d; } diff --git a/src/writers/taglibwriter.cpp b/src/writers/taglibwriter.cpp --- a/src/writers/taglibwriter.cpp +++ b/src/writers/taglibwriter.cpp @@ -33,7 +33,6 @@ void TagLibWriter::write(const WriteData& data) { const QString fileUrl = data.inputUrl(); - const QString mimeType = data.inputMimetype(); const PropertyMap properties = data.getAllProperties(); TagLib::FileRef file(fileUrl.toUtf8().constData(), true);