Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libraries
Baloo Widgets
Commits
aa17b528
Commit
aa17b528
authored
Oct 03, 2021
by
Nicolas Fella
Browse files
Add and make use of ECM clang-format
Helps to keep the code consistent with KDE coding sytle
parent
854f0ef0
Pipeline
#96364
passed with stage
in 41 seconds
Changes
48
Pipelines
3
Expand all
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
aa17b528
...
...
@@ -19,6 +19,8 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Config KIO I18n FileMeta
include
(
KDEInstallDirs
)
include
(
KDECMakeSettings
)
include
(
KDECompilerSettings NO_POLICY_SCOPE
)
include
(
KDEClangFormat
)
include
(
KDEGitCommitHooks
)
include
(
ECMSetupVersion
)
include
(
ECMInstallIcons
)
...
...
@@ -84,3 +86,8 @@ feature_summary(WHAT ALL
INCLUDE_QUIET_PACKAGES
FATAL_ON_MISSING_REQUIRED_PACKAGES
)
file
(
GLOB_RECURSE CLANG_FORMAT_SOURCE_FILES *.cpp *.h
)
kde_clang_format
(
${
CLANG_FORMAT_SOURCE_FILES
}
)
kde_configure_git_pre_commit_hook
(
CHECKS CLANG_FORMAT
)
autotests/extractortest.cpp
View file @
aa17b528
...
...
@@ -23,15 +23,15 @@
#include <KFileMetaData/Properties>
#include <QTest>
#include <QProcess>
#include <QTemporaryFile>
#include <QTemporaryDir>
#include <QTextStream>
#include <QStandardPaths>
#include <QDataStream>
#include <QDebug>
#include <QDir>
#include <QProcess>
#include <QStandardPaths>
#include <QTemporaryDir>
#include <QTemporaryFile>
#include <QTest>
#include <QTextStream>
void
ExtractorTest
::
test
()
{
...
...
autotests/filemetadatadatedisplaytest.cpp
View file @
aa17b528
...
...
@@ -21,16 +21,15 @@
#include "filemetadatadatedisplaytest.h"
#include <QObject>
#include <QTest>
#include <QDateTime>
#include <QLabel>
#include <QSignalSpy>
#include <QStandardPaths>
#include <QRegularExpression>
#include <QMetaType>
#include <QDateTime>
#include <QObject>
#include <QRegularExpression>
#include <QScopedPointer>
#include <QSignalSpy>
#include <QStandardPaths>
#include <QTest>
void
initLocale
()
{
...
...
@@ -40,7 +39,7 @@ Q_CONSTRUCTOR_FUNCTION(initLocale)
QTEST_MAIN
(
FileMetadataDateDisplayTest
)
bool
FileMetadataDateDisplayTest
::
setFileTime
(
const
QString
&
filePath
,
const
QDateTime
&
fileTime
)
bool
FileMetadataDateDisplayTest
::
setFileTime
(
const
QString
&
filePath
,
const
QDateTime
&
fileTime
)
{
bool
ret
;
QScopedPointer
<
QFile
>
file
{
new
QFile
(
filePath
)};
...
...
@@ -55,16 +54,9 @@ void FileMetadataDateDisplayTest::initTestCase()
qRegisterMetaType
<
KFileItemList
>
(
"KFileItemList"
);
QStandardPaths
::
setTestModeEnabled
(
true
);
QVERIFY
(
setFileTime
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
),
QDateTime
::
currentDateTime
().
addDays
(
-
1
))
);
QVERIFY
(
setFileTime
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
),
QDateTime
::
currentDateTime
().
addYears
(
-
10
))
);
QVERIFY
(
setFileTime
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
),
QDateTime
::
currentDateTime
().
addDays
(
-
1
)));
QVERIFY
(
setFileTime
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
),
QDateTime
::
currentDateTime
().
addYears
(
-
10
)));
}
void
FileMetadataDateDisplayTest
::
shouldDisplayLongAndShortDates_data
()
...
...
@@ -73,30 +65,19 @@ void FileMetadataDateDisplayTest::shouldDisplayLongAndShortDates_data()
QTest
::
addColumn
<
QUrl
>
(
"file"
);
QTest
::
addColumn
<
QRegularExpression
>
(
"regex"
);
QTest
::
addRow
(
"Short date, long ago"
)
<<
Baloo
::
DateFormats
::
ShortFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QRegularExpression
(
QStringLiteral
(
"(?:[1-3][0-9]|[1-9]) (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M"
))
;
QTest
::
addRow
(
"Short date, long ago"
)
<<
Baloo
::
DateFormats
::
ShortFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QRegularExpression
(
QStringLiteral
(
"(?:[1-3][0-9]|[1-9]) (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M"
));
QTest
::
addRow
(
"Short date, yesterday"
)
<<
Baloo
::
DateFormats
::
ShortFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
))
<<
QRegularExpression
(
QStringLiteral
(
"Yesterday, (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M"
))
;
QTest
::
addRow
(
"Short date, yesterday"
)
<<
Baloo
::
DateFormats
::
ShortFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
))
<<
QRegularExpression
(
QStringLiteral
(
"Yesterday, (?:[1-2][0-9]|[1-9]):[0-5][0-9] [AP]M"
));
QTest
::
addRow
(
"Long date, long ago"
)
<<
Baloo
::
DateFormats
::
LongFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QRegularExpression
(
QStringLiteral
(
"[A-Z][a-z]+, [A-Z][a-z]+ (?:[1-3][0-9]|[1-9]), 20[0-9]{2} (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}"
))
;
QTest
::
addRow
(
"Long date, yesterday"
)
<<
Baloo
::
DateFormats
::
LongFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
))
<<
QRegularExpression
(
QStringLiteral
(
"Yesterday, (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}"
))
;
<<
Baloo
::
DateFormats
::
LongFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QRegularExpression
(
QStringLiteral
(
"[A-Z][a-z]+, [A-Z][a-z]+ (?:[1-3][0-9]|[1-9]), 20[0-9]{2} (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}"
));
QTest
::
addRow
(
"Long date, yesterday"
)
<<
Baloo
::
DateFormats
::
LongFormat
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
))
<<
QRegularExpression
(
QStringLiteral
(
"Yesterday, (?:1[0-2]|[1-9]):[0-5][0-9]:[0-5][0-9] [AP]M [A-Z]{3,4}"
));
}
void
FileMetadataDateDisplayTest
::
shouldDisplayLongAndShortDates
()
...
...
@@ -111,9 +92,7 @@ void FileMetadataDateDisplayTest::shouldDisplayLongAndShortDates()
widget
->
setItems
(
KFileItemList
()
<<
file
);
QVERIFY
(
spy
.
wait
());
QLabel
*
dateWidget
=
widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#modified"
),
Qt
::
FindDirectChildrenOnly
);
QLabel
*
dateWidget
=
widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#modified"
),
Qt
::
FindDirectChildrenOnly
);
QVERIFY2
(
dateWidget
,
"Date widget not found"
);
QVERIFY2
(
regex
.
match
(
dateWidget
->
text
()).
hasMatch
(),
qPrintable
(
QStringLiteral
(
"
\"
%1
\"
did not match %2"
).
arg
(
dateWidget
->
text
(),
regex
.
pattern
()))
);
QVERIFY2
(
regex
.
match
(
dateWidget
->
text
()).
hasMatch
(),
qPrintable
(
QStringLiteral
(
"
\"
%1
\"
did not match %2"
).
arg
(
dateWidget
->
text
(),
regex
.
pattern
())));
}
autotests/filemetadatadatedisplaytest.h
View file @
aa17b528
...
...
@@ -35,9 +35,9 @@ private Q_SLOTS:
void
shouldDisplayLongAndShortDates
();
void
shouldDisplayLongAndShortDates_data
();
private:
bool
setFileTime
(
const
QString
&
file
,
const
QDateTime
&
filetime
);
private:
bool
setFileTime
(
const
QString
&
file
,
const
QDateTime
&
filetime
);
};
#endif // FILEMETADATADATEDISPLAYTEST_H
autotests/filemetadataitemcounttest.cpp
View file @
aa17b528
/*
* This file is part of the KDE Baloo Project
* Copyright 2018 Michael Heidelbach <ottwolt@gmail.com>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
...
...
@@ -9,52 +9,51 @@
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filemetadataitemcounttest.h"
#include <QObject>
#include <QTest>
#include <QMap>
#include <QDebug>
#include <QLabel>
#include <Q
SignalSpy
>
#include <Q
Map
>
#include <QMetaType>
#include <QObject>
#include <QProcess>
#include <QSignalSpy>
#include <QStandardPaths>
#include <Q
Debug
>
#include <Q
Test
>
#include <KFileItem>
#include <KRatingWidget>
#include <KConfig>
#include <KConfigGroup>
#include <KFileItem>
#include <KRatingWidget>
QTEST_MAIN
(
FileMetadataItemCountTest
)
void
FileMetadataItemCountTest
::
initTestCase
()
{
qRegisterMetaType
<
KFileItemList
>
(
"KFileItemList"
);
QStandardPaths
::
setTestModeEnabled
(
true
);
KConfig
balooConfig
(
QStringLiteral
(
"baloofilerc"
),
KConfig
::
NoGlobals
);
KConfigGroup
balooSettings
=
balooConfig
.
group
(
"General"
);
// If we use .writePathEntry here, the test will fail.
balooSettings
.
writeEntry
(
QStringLiteral
(
"folders"
),
QString
());
// Ensure show configuration
KConfig
config
(
QStringLiteral
(
"baloofileinformationrc"
),
KConfig
::
NoGlobals
);
KConfigGroup
settings
=
config
.
group
(
"Show"
);
const
auto
keys
=
settings
.
keyList
();
for
(
const
auto
&
key
:
keys
)
{
for
(
const
auto
&
key
:
keys
)
{
settings
.
writeEntry
(
key
,
true
);
}
}
...
...
@@ -76,16 +75,13 @@ void FileMetadataItemCountTest::testItemCount()
// The expectedItems count will need to be updated
const
int
expectedItems
=
20
;
const
int
widgetsPerItem
=
2
;
QSignalSpy
spy
(
m_widget
,
&
Baloo
::
FileMetaDataWidget
::
metaDataRequestFinished
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
)));
QVERIFY
(
spy
.
wait
());
QCOMPARE
(
spy
.
count
(),
1
);
QList
<
QWidget
*>
items
=
m_widget
->
findChildren
<
QWidget
*>
(
QString
(),
Qt
::
FindDirectChildrenOnly
);
QCOMPARE
(
items
.
count
(),
expectedItems
*
widgetsPerItem
);
QList
<
QWidget
*>
items
=
m_widget
->
findChildren
<
QWidget
*>
(
QString
(),
Qt
::
FindDirectChildrenOnly
);
QCOMPARE
(
items
.
count
(),
expectedItems
*
widgetsPerItem
);
}
autotests/filemetadataitemcounttest.h
View file @
aa17b528
/*
* This file is part of the KDE Baloo Project
* Copyright 2018 Michael Heidelbach <ottwolt@gmail.com>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
...
...
@@ -9,12 +9,12 @@
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
...
...
@@ -33,9 +33,9 @@ private Q_SLOTS:
void
cleanup
();
void
testItemCount
();
private:
Baloo
::
FileMetaDataWidget
*
m_widget
;
Baloo
::
FileMetaDataWidget
*
m_widget
;
};
#endif // FILEMETADATAITEMCOUNTTEST_H
autotests/filemetadatawidgettest.cpp
View file @
aa17b528
...
...
@@ -21,20 +21,20 @@
#include "filemetadatawidgettest.h"
#include <QObject>
#include <QTest>
#include <QMap>
#include <QDebug>
#include <QLabel>
#include <Q
SignalSpy
>
#include <Q
Map
>
#include <QMetaType>
#include <QObject>
#include <QProcess>
#include <QSignalSpy>
#include <QStandardPaths>
#include <Q
Debug
>
#include <Q
Test
>
#include <KFileItem>
#include <KRatingWidget>
#include <KConfig>
#include <KConfigGroup>
#include <KFileItem>
#include <KRatingWidget>
void
initLocale
()
{
...
...
@@ -59,7 +59,7 @@ void FileMetadataWidgetTest::initTestCase()
KConfig
config
(
QStringLiteral
(
"baloofileinformationrc"
),
KConfig
::
NoGlobals
);
KConfigGroup
settings
=
config
.
group
(
"Show"
);
const
auto
keys
=
settings
.
keyList
();
for
(
const
auto
&
key
:
keys
)
{
for
(
const
auto
&
key
:
keys
)
{
settings
.
writeEntry
(
key
,
true
);
}
...
...
@@ -70,9 +70,9 @@ void FileMetadataWidgetTest::initTestCase()
}
const
QStringList
args
=
{
QStringLiteral
(
"--name=user.baloo.rating"
),
QStringLiteral
(
"--value=5"
)
,
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
),
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
)};
QStringLiteral
(
"--value=5"
),
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
),
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
)};
QProcess
process
;
process
.
start
(
exe
,
args
);
...
...
@@ -109,23 +109,18 @@ void FileMetadataWidgetTest::shouldSignalOnceWithoutFile()
void
FileMetadataWidgetTest
::
shouldSignalOnceFile
()
{
QSignalSpy
spy
(
m_widget
,
&
Baloo
::
FileMetaDataWidget
::
metaDataRequestFinished
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
))
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
)));
QVERIFY
(
spy
.
wait
());
QCOMPARE
(
spy
.
count
(),
1
);
QCOMPARE
(
m_widget
->
items
().
count
(),
1
);
}
void
FileMetadataWidgetTest
::
shouldSignalOnceFiles
()
{
QSignalSpy
spy
(
m_widget
,
&
Baloo
::
FileMetaDataWidget
::
metaDataRequestFinished
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/test.mp3"
))
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
))
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/test.mp3"
))
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
)));
QVERIFY
(
spy
.
wait
());
QCOMPARE
(
spy
.
count
(),
1
);
QCOMPARE
(
m_widget
->
items
().
count
(),
3
);
...
...
@@ -134,54 +129,49 @@ void FileMetadataWidgetTest::shouldSignalOnceFiles()
void
FileMetadataWidgetTest
::
shouldShowProperties
()
{
QSignalSpy
spy
(
m_widget
,
&
Baloo
::
FileMetaDataWidget
::
metaDataRequestFinished
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
)));
QVERIFY
(
spy
.
wait
());
QCOMPARE
(
spy
.
count
(),
1
);
// simple property
QLabel
*
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#type"
));
QLabel
*
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#type"
));
QVERIFY2
(
valueWidget
,
"Type data missing"
);
QCOMPARE
(
valueWidget
->
text
(),
QLatin1String
(
"MP3 audio"
));
if
(
m_mayTestRating
)
{
// editable property
KRatingWidget
*
ratingWidget
=
m_widget
->
findChild
<
KRatingWidget
*>
(
QStringLiteral
(
"rating"
));
KRatingWidget
*
ratingWidget
=
m_widget
->
findChild
<
KRatingWidget
*>
(
QStringLiteral
(
"rating"
));
QVERIFY2
(
ratingWidget
,
"Rating data missing"
);
QCOMPARE
(
ratingWidget
->
rating
(),
5u
);
}
else
{
qDebug
()
<<
"Skipped 'Rating' test"
;
}
// async property
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"albumArtist"
));
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"albumArtist"
));
QVERIFY2
(
valueWidget
,
"albumArtist data was not found"
);
QCOMPARE
(
valueWidget
->
text
(),
QLatin1String
(
"Bill Laswell"
));
}
void
FileMetadataWidgetTest
::
shouldShowCommonProperties
()
{
QSignalSpy
spy
(
m_widget
,
&
Baloo
::
FileMetaDataWidget
::
metaDataRequestFinished
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
))
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.mp3"
))
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/testtagged.m4a"
)));
QVERIFY
(
spy
.
wait
());
QCOMPARE
(
spy
.
count
(),
1
);
// simple property
QLabel
*
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#type"
));
QLabel
*
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#type"
));
QVERIFY
(
!
valueWidget
);
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#totalSize"
));
valueWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"kfileitem#totalSize"
));
// circumvent i18n formatting
QCOMPARE
(
valueWidget
->
text
().
left
(
3
),
QLatin1String
(
"153"
));
// editable property
if
(
m_mayTestRating
)
{
KRatingWidget
*
ratingWidget
=
m_widget
->
findChild
<
KRatingWidget
*>
(
QStringLiteral
(
"rating"
));
KRatingWidget
*
ratingWidget
=
m_widget
->
findChild
<
KRatingWidget
*>
(
QStringLiteral
(
"rating"
));
QVERIFY2
(
ratingWidget
,
"Rating data missing"
);
QCOMPARE
(
ratingWidget
->
rating
(),
5u
);
}
else
{
...
...
@@ -195,15 +185,13 @@ void FileMetadataWidgetTest::shouldShowCommonProperties()
void
FileMetadataWidgetTest
::
shouldShowMultiValueProperties
()
{
QSignalSpy
spy
(
m_widget
,
&
Baloo
::
FileMetaDataWidget
::
metaDataRequestFinished
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/test_multivalue.ogg"
))
);
m_widget
->
setItems
(
KFileItemList
()
<<
QUrl
::
fromLocalFile
(
QFINDTESTDATA
(
"samplefiles/test_multivalue.ogg"
)));
QVERIFY
(
spy
.
wait
());
QCOMPARE
(
spy
.
count
(),
1
);
auto
artistWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"artist"
));
auto
artistWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"artist"
));
QVERIFY2
(
artistWidget
,
"artist not found"
);
QCOMPARE
(
artistWidget
->
text
(),
QStringLiteral
(
"Artist1 and Artist2"
));
auto
genreWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"genre"
));
auto
genreWidget
=
m_widget
->
findChild
<
QLabel
*>
(
QStringLiteral
(
"genre"
));
QVERIFY2
(
genreWidget
,
"genre not found"
);
QCOMPARE
(
genreWidget
->
text
(),
QStringLiteral
(
"Genre1, Genre2, and Genre3"
));
}
autotests/filemetadatawidgettest.h
View file @
aa17b528
/*
* This file is part of the KDE Baloo Project
* Copyright 2018 Michael Heidelbach <ottwolt@gmail.com>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
...
...
@@ -9,12 +9,12 @@
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
...
...
@@ -40,8 +40,8 @@ private Q_SLOTS:
void
shouldShowMultiValueProperties
();
private:
Baloo
::
FileMetaDataWidget
*
m_widget
;
bool
m_mayTestRating
=
false
;
Baloo
::
FileMetaDataWidget
*
m_widget
;
bool
m_mayTestRating
=
false
;
};
#endif // FILEMETADATAWIDGETTEST_H
src/extractor.cpp
View file @
aa17b528
...
...
@@ -22,17 +22,17 @@
#include "extractorutil_p.h"
#include <QCoreApplication>
#include <QCommandLineParser>
#include <Q
MimeDatabase
>
#include <Q
CoreApplication
>
#include <QDataStream>
#include <QDebug>
#include <QFile>
#include <QMimeDatabase>
#include <KFileMetaData/SimpleExtractionResult>
#include <KFileMetaData/ExtractorCollection>
#include <KFileMetaData/Extractor>
#include <KFileMetaData/ExtractorCollection>
#include <KFileMetaData/MimeUtils>
#include <KFileMetaData/SimpleExtractionResult>
#include <iostream>
...
...
src/extractorutil_p.h
View file @
aa17b528
...
...
@@ -17,13 +17,13 @@
* Boston, MA 02110-1301, USA. *
*****************************************************************************/
#include <QDataStream>
#include <KFileMetaData/Properties>
#include <QDataStream>
/*
* Deserialize prop from QDataStream
*/
static
inline
QDataStream
&
operator
>>
(
QDataStream
&
stream
,
KFileMetaData
::
Property
::
Property
&
prop
)
static
inline
QDataStream
&
operator
>>
(
QDataStream
&
stream
,
KFileMetaData
::
Property
::
Property
&
prop
)
{
quint16
intProp
;
stream
>>
intProp
;
...
...
src/filefetchjob.cpp
View file @
aa17b528
...
...
@@ -22,16 +22,15 @@
#include "filemetadatautil_p.h"
#include "widgetsdebug.h"
#include <Baloo/File>
#include <QFileInfo>
#include <QTimer>
#include <Baloo/File>
#include <KFileMetaData/UserMetaData>
using
namespace
Baloo
;
FileFetchJob
::
FileFetchJob
(
const
QStringList
&
urls
,
bool
canEditAll
,
FileFetchJob
::
UseRealtimeIndexing
useRealtime
,
QObject
*
parent
)
FileFetchJob
::
FileFetchJob
(
const
QStringList
&
urls
,
bool
canEditAll
,
FileFetchJob
::
UseRealtimeIndexing
useRealtime
,
QObject
*
parent
)
:
KJob
(
parent
)
,
m_urls
(
urls
)
,
m_canEditAll
(
canEditAll
)
...
...
@@ -46,8 +45,7 @@ void FileFetchJob::start()
void
FileFetchJob
::
doStart
()
{
for
(
const
QString
&
filePath
:
m_urls
)
{
for
(
const
QString
&
filePath
:
m_urls
)
{
bool
extractorRunning
=
false
;
KFileMetaData
::
PropertyMap
fileProperties
;
...
...
@@ -90,7 +88,7 @@ void FileFetchJob::doStart()
emitResult
();
}
QList
<
QVariantMap
>
Baloo
::
FileFetchJob
::
data
()
const
QList
<
QVariantMap
>
Baloo
::
FileFetchJob
::
data
()
const
{
return
m_data
;
}
...
...
src/filefetchjob.h
View file @
aa17b528
...
...
@@ -21,12 +21,12 @@
#ifndef BALOO_FILEFETCHJOB_H
#define BALOO_FILEFETCHJOB_H
#include "ondemandextractor.h"
#include <KJob>
#include <QVariantMap>
#include "ondemandextractor.h"
namespace
Baloo
{
namespace
Baloo
{
class
FileFetchJob
:
public
KJob
{
Q_OBJECT
...
...
@@ -34,10 +34,9 @@ public:
enum
class
UseRealtimeIndexing
:
char
{
Disabled
=
0
,
Only
,
Fallback
Fallback
,
};
explicit
FileFetchJob
(
const
QStringList
&
urls
,
bool
canEditAll
,
UseRealtimeIndexing
useRealtime
,
QObject
*
parent
=
nullptr
);
explicit
FileFetchJob
(
const
QStringList
&
urls
,
bool
canEditAll
,
UseRealtimeIndexing
useRealtime
,
QObject
*
parent
=
nullptr
);
QList
<
QVariantMap
>
data
()
const
;
bool
canEditAll
()
const
;
...
...
src/filemetadataconfigwidget.cpp
View file @
aa17b528
...
...
@@ -24,22 +24,22 @@
#include <KConfig>
#include <KConfigGroup>
#include <QDebug>
#include <QEvent>
#include <QListWidget>
#include <QVBoxLayout>
#include <QDebug>
using
namespace
Baloo
;
class
FileMetaDataConfigWidget
::
Private
{
public:
Private
(
FileMetaDataConfigWidget
*
parent
);
Private
(
FileMetaDataConfigWidget
*
parent
);
~
Private
();
void
init
();
void
loadMetaData
();
void
addItem
(
const
QString
&
property
);
void
addItem
(
const
QString
&
property
);
/**
* Is invoked after the meta data model has finished the loading of
...
...
@@ -50,26 +50,25 @@ public:
int
m_visibleDataTypes
;