From 9d7af8a24a0f5c515fd95ad241c68227e566c3d2 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Mon, 5 May 2014 23:04:42 +0200 Subject: Fix build of tests This is the last commit for review 117395 REVIEW: 117395 --- src/tests/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/tests/CMakeLists.txt') diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 4ba68dd73..73a9d5c03 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -33,7 +33,7 @@ set(kitemlistcontrollertest_SRCS ../kitemviews/kitemlistview.cpp ../kitemviews/kitemlistcontainer.cpp ../kitemviews/kitemlistwidget.cpp - ../kitemviews/kitemlistviewaccessible.cpp +# ../kitemviews/kitemlistviewaccessible.cpp # TODO: enable once accessibility is ported to Qt5 ../kitemviews/kitemset.cpp ../kitemviews/kstandarditemlistview.cpp ../kitemviews/kstandarditemlistwidget.cpp @@ -49,7 +49,7 @@ set(kfileitemlistviewtest_SRCS ../kitemviews/kfileitemlistview.cpp ../kitemviews/kitemmodelbase.cpp ../kitemviews/kitemlistview.cpp - ../kitemviews/kitemlistviewaccessible.cpp +# ../kitemviews/kitemlistviewaccessible.cpp # TODO: enable once accessibility is ported to Qt5 ../kitemviews/kitemlistcontainer.cpp ../kitemviews/kitemlistwidget.cpp ../kitemviews/kitemset.cpp @@ -99,7 +99,7 @@ if (Baloo_FOUND) ../search/dolphin_searchsettings.kcfgc ) kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS}) - target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${BALOO_LIBRARIES} ${QT_QTTEST_LIBRARY}) + target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${BALOO_FILE_LIBRARY} ${BALOO_CORE_LIBRARY} ${QT_QTTEST_LIBRARY}) endif (Baloo_FOUND) # KStandardItemModelTest -- cgit v1.3.1 From ae1960be454eadf2f6b2897824364cc22338a880 Mon Sep 17 00:00:00 2001 From: Christophe Giboudeaux Date: Sun, 29 Jun 2014 02:07:41 +0200 Subject: Reenable tests. --- src/CMakeLists.txt | 5 ++- src/tests/CMakeLists.txt | 90 +++++++++++++++++++++++++++++++++--------------- 2 files changed, 65 insertions(+), 30 deletions(-) (limited to 'src/tests/CMakeLists.txt') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b46182cd4..f3a8bc025 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,9 +13,6 @@ endif() configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h) -# TODO Reenable -#add_subdirectory(tests) - ########### next target ############### set(dolphinprivate_LIB_SRCS @@ -340,3 +337,5 @@ install( FILES settings/kcm/kcmdolphingeneral.desktop DESTINATION ${SERVICES_INS install( FILES settings/services/servicemenu.knsrc DESTINATION ${CONFIG_INSTALL_DIR} ) install( PROGRAMS settings/services/servicemenuinstallation DESTINATION ${BIN_INSTALL_DIR} ) install( PROGRAMS settings/services/servicemenudeinstallation DESTINATION ${BIN_INSTALL_DIR} ) + +add_subdirectory(tests) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 13a0abb58..8455ba368 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,5 +1,7 @@ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} ) -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BUILD_DIR}/.. ${KDE4_INCLUDES} ) + +find_package(Qt5Test CONFIG REQUIRED) +include(ECMMarkAsTest) # needed on windows to correctly use the files from dolphinprivate add_definitions(-DLIBDOLPHINPRIVATE_EXPORT=) @@ -9,15 +11,22 @@ set(kitemsettest_SRCS kitemsettest.cpp ../kitemviews/kitemset.cpp ) -kde4_add_unit_test(kitemsettest TEST ${kitemsettest_SRCS}) -target_link_libraries(kitemsettest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kitemsettest ${kitemsettest_SRCS}) +add_test(kitemsettest kitemsettest) +ecm_mark_as_test(kitemsettest) +target_link_libraries(kitemsettest dolphinprivate Qt5::Test) # KItemRangeTest set(kitemrangetest_SRCS kitemrangetest.cpp ) -kde4_add_unit_test(kitemrangetest TEST ${kitemrangetest_SRCS}) -target_link_libraries(kitemrangetest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kitemrangetest ${kitemrangetest_SRCS}) +add_test(kitemrangetest kitemrangetest) +ecm_mark_as_test(kitemrangetest) +target_link_libraries(kitemrangetest dolphinprivate Qt5::Test) + # KItemListSelectionManagerTest set(kitemlistselectionmanagertest_SRCS @@ -26,8 +35,11 @@ set(kitemlistselectionmanagertest_SRCS ../kitemviews/kitemmodelbase.cpp ../kitemviews/kitemset.cpp ) -kde4_add_unit_test(kitemlistselectionmanagertest TEST ${kitemlistselectionmanagertest_SRCS}) -target_link_libraries(kitemlistselectionmanagertest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kitemlistselectionmanagertest ${kitemlistselectionmanagertest_SRCS}) +add_test(kitemlistselectionmanagertest kitemlistselectionmanagertest) +ecm_mark_as_test(kitemlistselectionmanagertest) +target_link_libraries(kitemlistselectionmanagertest dolphinprivate Qt5::Test) # KItemListControllerTest set(kitemlistcontrollertest_SRCS @@ -45,8 +57,11 @@ set(kitemlistcontrollertest_SRCS ../kitemviews/kstandarditemlistview.cpp ../kitemviews/kstandarditemlistwidget.cpp ) -kde4_add_unit_test(kitemlistcontrollertest TEST ${kitemlistcontrollertest_SRCS}) -target_link_libraries(kitemlistcontrollertest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kitemlistcontrollertest ${kitemlistcontrollertest_SRCS}) +add_test(kitemlistcontrollertest kitemlistcontrollertest) +ecm_mark_as_test(kitemlistcontrollertest) +target_link_libraries(kitemlistcontrollertest dolphinprivate Qt5::Test) # KFileItemListViewTest set(kfileitemlistviewtest_SRCS @@ -63,8 +78,11 @@ set(kfileitemlistviewtest_SRCS ../kitemviews/kstandarditemlistview.cpp ../kitemviews/kstandarditemlistwidget.cpp ) -kde4_add_unit_test(kfileitemlistviewtest TEST ${kfileitemlistviewtest_SRCS}) -target_link_libraries(kfileitemlistviewtest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kfileitemlistviewtest ${kfileitemlistviewtest_SRCS}) +add_test(kfileitemlistviewtest kfileitemlistviewtest) +ecm_mark_as_test(kfileitemlistviewtest) +target_link_libraries(kfileitemlistviewtest dolphinprivate Qt5::Test) # KFileItemModelTest set(kfileitemmodeltest_SRCS @@ -74,8 +92,11 @@ set(kfileitemmodeltest_SRCS ../kitemviews/kitemmodelbase.cpp ../kitemviews/kitemset.cpp ) -kde4_add_unit_test(kfileitemmodeltest TEST ${kfileitemmodeltest_SRCS}) -target_link_libraries(kfileitemmodeltest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kfileitemmodeltest ${kfileitemmodeltest_SRCS}) +add_test(kfileitemmodeltest kfileitemmodeltest) +ecm_mark_as_test(kfileitemmodeltest) +target_link_libraries(kfileitemmodeltest dolphinprivate Qt5::Test) # KFileItemModelBenchmark set(kfileitemmodelbenchmark_SRCS @@ -84,30 +105,39 @@ set(kfileitemmodelbenchmark_SRCS ../kitemviews/kfileitemmodel.cpp ../kitemviews/kitemmodelbase.cpp ) -kde4_add_executable(kfileitemmodelbenchmark TEST ${kfileitemmodelbenchmark_SRCS}) -target_link_libraries(kfileitemmodelbenchmark dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kfileitemmodelbenchmark ${kfileitemmodelbenchmark_SRCS}) +add_test(kfileitemmodelbenchmark kfileitemmodelbenchmark) +ecm_mark_as_test(kfileitemmodelbenchmark) +target_link_libraries(kfileitemmodelbenchmark dolphinprivate Qt5::Test) # KItemListKeyboardSearchManagerTest set(kitemlistkeyboardsearchmanagertest_SRCS kitemlistkeyboardsearchmanagertest.cpp ../kitemviews/private/kitemlistkeyboardsearchmanager.cpp ) -kde4_add_unit_test(kitemlistkeyboardsearchmanagertest TEST ${kitemlistkeyboardsearchmanagertest_SRCS}) -target_link_libraries(kitemlistkeyboardsearchmanagertest ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kitemlistkeyboardsearchmanagertest ${kitemlistkeyboardsearchmanagertest_SRCS}) +add_test(kitemlistkeyboardsearchmanagertest kitemlistkeyboardsearchmanagertest) +ecm_mark_as_test(kitemlistkeyboardsearchmanagertest) +target_link_libraries(kitemlistkeyboardsearchmanagertest dolphinprivate Qt5::Test) # DolphinSearchBox -if (Baloo_FOUND) +if (KF5Baloo_FOUND) set(dolphinsearchboxtest_SRCS dolphinsearchboxtest.cpp ../search/dolphinfacetswidget.cpp ../search/dolphinsearchbox.cpp ) - kde4_add_kcfg_files(dolphinsearchboxtest_SRCS + kconfig_add_kcfg_files(dolphinsearchboxtest_SRCS ../search/dolphin_searchsettings.kcfgc ) - kde4_add_unit_test(dolphinsearchboxtest TEST ${dolphinsearchboxtest_SRCS}) - target_link_libraries(dolphinsearchboxtest ${KDE4_KIO_LIBS} ${BALOO_FILE_LIBRARY} ${BALOO_CORE_LIBRARY} ${QT_QTTEST_LIBRARY}) -endif (Baloo_FOUND) + + add_executable(dolphinsearchboxtest ${dolphinsearchboxtest_SRCS}) + add_test(dolphinsearchboxtest dolphinsearchboxtest) + ecm_mark_as_test(dolphinsearchboxtest) + target_link_libraries(dolphinsearchboxtest dolphinprivate Qt5::Test) +endif() # KStandardItemModelTest set(kstandarditemmodeltest_SRCS @@ -116,8 +146,11 @@ set(kstandarditemmodeltest_SRCS ../kitemviews/kstandarditemmodel.cpp ../kitemviews/kitemmodelbase.cpp ) -kde4_add_unit_test(kstandarditemmodeltest TEST ${kstandarditemmodeltest_SRCS}) -target_link_libraries(kstandarditemmodeltest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(kstandarditemmodeltest ${kstandarditemmodeltest_SRCS}) +add_test(kstandarditemmodeltest kstandarditemmodeltest) +ecm_mark_as_test(kstandarditemmodeltest) +target_link_libraries(kstandarditemmodeltest dolphinprivate Qt5::Test) # ViewPropertiesTest set(viewpropertiestest_SRCS @@ -125,9 +158,12 @@ set(viewpropertiestest_SRCS testdir.cpp ../views/viewproperties.cpp ) -kde4_add_kcfg_files(viewpropertiestest_SRCS +kconfig_add_kcfg_files(viewpropertiestest_SRCS ../settings/dolphin_generalsettings.kcfgc ../settings/dolphin_directoryviewpropertysettings.kcfgc ) -kde4_add_unit_test(viewpropertiestest TEST ${viewpropertiestest_SRCS}) -target_link_libraries(viewpropertiestest dolphinprivate ${KDE4_KIO_LIBS} ${QT_QTTEST_LIBRARY}) + +add_executable(viewpropertiestest ${viewpropertiestest_SRCS}) +add_test(viewpropertiestest viewpropertiestest) +ecm_mark_as_test(viewpropertiestest) +target_link_libraries(viewpropertiestest dolphinprivate Qt5::Test) -- cgit v1.3.1 From 6cddb788a0ebd109412fe882c02fa6f572fe0bc2 Mon Sep 17 00:00:00 2001 From: Christophe Giboudeaux Date: Sun, 29 Jun 2014 21:36:55 +0200 Subject: KFileItemModelBenchmark is a manual test --- src/tests/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) (limited to 'src/tests/CMakeLists.txt') diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 8455ba368..60f6517e8 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -107,7 +107,6 @@ set(kfileitemmodelbenchmark_SRCS ) add_executable(kfileitemmodelbenchmark ${kfileitemmodelbenchmark_SRCS}) -add_test(kfileitemmodelbenchmark kfileitemmodelbenchmark) ecm_mark_as_test(kfileitemmodelbenchmark) target_link_libraries(kfileitemmodelbenchmark dolphinprivate Qt5::Test) -- cgit v1.3.1 From d19d94e60a778d4c19f646224e3b269da515c8fb Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Thu, 18 Dec 2014 14:56:46 +0100 Subject: Ported tests away from KRandomSequence, QTest::kWaitForSignal and KTempDir. All tests passed! --- src/tests/CMakeLists.txt | 4 +- src/tests/dolphinsearchboxtest.cpp | 5 +- src/tests/kfileitemlistviewtest.cpp | 25 +- src/tests/kfileitemmodelbenchmark.cpp | 17 +- src/tests/kfileitemmodeltest.cpp | 518 ++++++++++++----------- src/tests/kitemlistcontrollertest.cpp | 19 +- src/tests/kitemlistkeyboardsearchmanagertest.cpp | 13 +- src/tests/kitemlistselectionmanagertest.cpp | 5 +- src/tests/kitemrangetest.cpp | 3 +- src/tests/kitemsettest.cpp | 3 +- src/tests/kstandarditemmodeltest.cpp | 4 +- src/tests/testdir.cpp | 17 +- src/tests/testdir.h | 8 +- src/tests/viewpropertiestest.cpp | 17 +- 14 files changed, 325 insertions(+), 333 deletions(-) (limited to 'src/tests/CMakeLists.txt') diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 60f6517e8..a69400baa 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -52,7 +52,7 @@ set(kitemlistcontrollertest_SRCS ../kitemviews/kitemlistview.cpp ../kitemviews/kitemlistcontainer.cpp ../kitemviews/kitemlistwidget.cpp -# ../kitemviews/kitemlistviewaccessible.cpp # TODO: enable once accessibility is ported to Qt5 + ../kitemviews/kitemlistviewaccessible.cpp ../kitemviews/kitemset.cpp ../kitemviews/kstandarditemlistview.cpp ../kitemviews/kstandarditemlistwidget.cpp @@ -71,7 +71,7 @@ set(kfileitemlistviewtest_SRCS ../kitemviews/kfileitemlistview.cpp ../kitemviews/kitemmodelbase.cpp ../kitemviews/kitemlistview.cpp -# ../kitemviews/kitemlistviewaccessible.cpp # TODO: enable once accessibility is ported to Qt5 + ../kitemviews/kitemlistviewaccessible.cpp ../kitemviews/kitemlistcontainer.cpp ../kitemviews/kitemlistwidget.cpp ../kitemviews/kitemset.cpp diff --git a/src/tests/dolphinsearchboxtest.cpp b/src/tests/dolphinsearchboxtest.cpp index 49bc7e824..862a398a5 100644 --- a/src/tests/dolphinsearchboxtest.cpp +++ b/src/tests/dolphinsearchboxtest.cpp @@ -17,10 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include - #include "search/dolphinsearchbox.h" -#include + +#include class DolphinSearchBoxTest : public QObject { diff --git a/src/tests/kfileitemlistviewtest.cpp b/src/tests/kfileitemlistviewtest.cpp index 696580c0a..9e1add8cf 100644 --- a/src/tests/kfileitemlistviewtest.cpp +++ b/src/tests/kfileitemlistviewtest.cpp @@ -17,18 +17,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include -#include #include "kitemviews/kfileitemlistview.h" #include "kitemviews/kfileitemmodel.h" #include "kitemviews/private/kfileitemmodeldirlister.h" #include "testdir.h" #include - -namespace { - const int DefaultTimeout = 2000; -}; +#include +#include class KFileItemListViewTest : public QObject { @@ -91,27 +87,24 @@ void KFileItemListViewTest::cleanup() */ void KFileItemListViewTest::testGroupedItemChanges() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); + m_model->setGroupedSorting(true); m_testDir->createFiles({"1", "3", "5"}); - m_model->loadDirectory(m_testDir->url()); - QSignalSpy psy(m_model, SIGNAL(itemsInserted(KItemRangeList))); - QVERIFY(psy.wait(DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 3); m_testDir->createFiles({"2", "4"}); m_model->m_dirLister->updateDirectory(m_testDir->url()); - QSignalSpy psyItemsInserted(m_model, SIGNAL(itemsInserted(KItemRangeList))); - QVERIFY(psyItemsInserted.wait(DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 5); - m_testDir->removeFile("1"); - m_testDir->removeFile("3"); - m_testDir->removeFile("5"); + m_testDir->removeFiles({"1", "3", "5"}); m_model->m_dirLister->updateDirectory(m_testDir->url()); - QSignalSpy psyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList))); - QVERIFY(psyItemsRemoved.wait(DefaultTimeout)); + QVERIFY(itemsRemovedSpy.wait()); QCOMPARE(m_model->count(), 2); } diff --git a/src/tests/kfileitemmodelbenchmark.cpp b/src/tests/kfileitemmodelbenchmark.cpp index 43d7173de..c970a7198 100644 --- a/src/tests/kfileitemmodelbenchmark.cpp +++ b/src/tests/kfileitemmodelbenchmark.cpp @@ -18,15 +18,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include +#include #include + +#include +#include + #include "kitemviews/kfileitemmodel.h" #include "kitemviews/private/kfileitemmodelsortalgorithm.h" #include "testdir.h" -#include - void myMessageOutput(QtMsgType type, const char* msg) { switch (type) { @@ -45,10 +47,6 @@ void myMessageOutput(QtMsgType type, const char* msg) } } -namespace { - const int DefaultTimeout = 5000; -}; - Q_DECLARE_METATYPE(KFileItemList) Q_DECLARE_METATYPE(KItemRangeList) @@ -294,8 +292,9 @@ void KFileItemModelBenchmark::insertManyChildItems() } // Bring the items into random order. - KRandomSequence randomSequence(0); - randomSequence.randomize(newItems); + std::random_device rd; + std::mt19937 g(rd()); + std::shuffle(newItems.begin(), newItems.end(), g); // Measure how long it takes to insert and then remove all files. QBENCHMARK { diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index fbe34e2a7..74b2342c8 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -18,7 +18,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include +#include +#include +#include +#include #include @@ -44,10 +47,6 @@ void myMessageOutput(QtMsgType type, const char* msg) } } -namespace { - const int DefaultTimeout = 5000; -}; - Q_DECLARE_METATYPE(KItemRange) Q_DECLARE_METATYPE(KItemRangeList) Q_DECLARE_METATYPE(QList) @@ -142,15 +141,14 @@ void KFileItemModelTest::testDefaultRoles() void KFileItemModelTest::testDefaultSortRole() { - QCOMPARE(m_model->sortRole(), QByteArray("text")); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); - QStringList files; - files << "c.txt" << "a.txt" << "b.txt"; + QCOMPARE(m_model->sortRole(), QByteArray("text")); - m_testDir->createFiles(files); + m_testDir->createFiles({"c.txt", "a.txt", "b.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 3); QCOMPARE(m_model->data(0)["text"].toString(), QString("a.txt")); @@ -165,12 +163,12 @@ void KFileItemModelTest::testDefaultGroupedSorting() void KFileItemModelTest::testNewItems() { - QStringList files; - files << "a.txt" << "b.txt" << "c.txt"; - m_testDir->createFiles(files); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + + m_testDir->createFiles({"a.txt", "b.txt", "c.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 3); @@ -179,30 +177,32 @@ void KFileItemModelTest::testNewItems() void KFileItemModelTest::testRemoveItems() { - m_testDir->createFile("a.txt"); - m_testDir->createFile("b.txt"); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); + + m_testDir->createFiles({"a.txt", "b.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 2); QVERIFY(m_model->isConsistent()); m_testDir->removeFile("a.txt"); m_model->m_dirLister->updateDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsRemovedSpy.wait()); QCOMPARE(m_model->count(), 1); QVERIFY(m_model->isConsistent()); } void KFileItemModelTest::testDirLoadingCompleted() { - QSignalSpy loadingCompletedSpy(m_model, SIGNAL(directoryLoadingCompleted())); - QSignalSpy itemsInsertedSpy(m_model, SIGNAL(itemsInserted(KItemRangeList))); - QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList))); + QSignalSpy loadingCompletedSpy(m_model, &KFileItemModel::directoryLoadingCompleted); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); m_testDir->createFiles({"a.txt", "b.txt", "c.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + QVERIFY(loadingCompletedSpy.wait()); QCOMPARE(loadingCompletedSpy.count(), 1); QCOMPARE(itemsInsertedSpy.count(), 1); QCOMPARE(itemsRemovedSpy.count(), 0); @@ -210,7 +210,7 @@ void KFileItemModelTest::testDirLoadingCompleted() m_testDir->createFiles({"d.txt", "e.txt"}); m_model->m_dirLister->updateDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + QVERIFY(loadingCompletedSpy.wait()); QCOMPARE(loadingCompletedSpy.count(), 2); QCOMPARE(itemsInsertedSpy.count(), 2); QCOMPARE(itemsRemovedSpy.count(), 0); @@ -219,7 +219,7 @@ void KFileItemModelTest::testDirLoadingCompleted() m_testDir->removeFile("a.txt"); m_testDir->createFile("f.txt"); m_model->m_dirLister->updateDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + QVERIFY(loadingCompletedSpy.wait()); QCOMPARE(loadingCompletedSpy.count(), 3); QCOMPARE(itemsInsertedSpy.count(), 3); QCOMPARE(itemsRemovedSpy.count(), 1); @@ -227,7 +227,7 @@ void KFileItemModelTest::testDirLoadingCompleted() m_testDir->removeFile("b.txt"); m_model->m_dirLister->updateDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsRemovedSpy.wait()); QCOMPARE(loadingCompletedSpy.count(), 4); QCOMPARE(itemsInsertedSpy.count(), 3); QCOMPARE(itemsRemovedSpy.count(), 2); @@ -238,16 +238,18 @@ void KFileItemModelTest::testDirLoadingCompleted() void KFileItemModelTest::testSetData() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsChangedSpy(m_model, &KFileItemModel::itemsChanged); + m_testDir->createFile("a.txt"); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QHash values; values.insert("customRole1", "Test1"); values.insert("customRole2", "Test2"); - QSignalSpy itemsChangedSpy(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet))); m_model->setData(0, values); QCOMPARE(itemsChangedSpy.count(), 1); @@ -289,18 +291,19 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole() QFETCH(int, ratingIndex1); QFETCH(int, ratingIndex2); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved); + // Changing the value of a sort-role must result in // a reordering of the items. QCOMPARE(m_model->sortRole(), QByteArray("text")); m_model->setSortRole("rating"); QCOMPARE(m_model->sortRole(), QByteArray("rating")); - QStringList files; - files << "a.txt" << "b.txt" << "c.txt"; - m_testDir->createFiles(files); + m_testDir->createFiles({"a.txt", "b.txt", "c.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // Fill the "rating" role of each file: // a.txt -> 2 @@ -330,7 +333,7 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole() m_model->setData(changedIndex, rating); if (expectMoveSignal) { - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList)), DefaultTimeout)); + QVERIFY(itemsMovedSpy.wait()); } QCOMPARE(m_model->data(0).value("rating").toInt(), ratingIndex0); @@ -341,14 +344,15 @@ void KFileItemModelTest::testSetDataWithModifiedSortRole() void KFileItemModelTest::testChangeSortRole() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved); + QCOMPARE(m_model->sortRole(), QByteArray("text")); - QStringList files; - files << "a.txt" << "b.jpg" << "c.txt"; - m_testDir->createFiles(files); + m_testDir->createFiles({"a.txt", "b.jpg", "c.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.jpg" << "c.txt"); // Simulate that KFileItemModelRolesUpdater determines the mime type. @@ -359,10 +363,9 @@ void KFileItemModelTest::testChangeSortRole() } // Now: sort by type. - QSignalSpy spyItemsMoved(m_model, SIGNAL(itemsMoved(KItemRange,QList))); m_model->setSortRole("type"); QCOMPARE(m_model->sortRole(), QByteArray("type")); - QVERIFY(!spyItemsMoved.isEmpty()); + QVERIFY(!itemsMovedSpy.isEmpty()); // The actual order of the files might depend on the translation of the // result of KFileItem::mimeComment() in the user's language. @@ -380,16 +383,17 @@ void KFileItemModelTest::testChangeSortRole() void KFileItemModelTest::testResortAfterChangingName() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved); + // We sort by size in a directory where all files have the same size. // Therefore, the files are sorted by their names. m_model->setSortRole("size"); - QStringList files; - files << "a.txt" << "b.txt" << "c.txt"; - m_testDir->createFiles(files); + m_testDir->createFiles({"a.txt", "b.txt", "c.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt"); // We rename a.txt to d.txt. Even though the size has not changed at all, @@ -398,7 +402,7 @@ void KFileItemModelTest::testResortAfterChangingName() data.insert("text", "d.txt"); m_model->setData(0, data); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList)), DefaultTimeout)); + QVERIFY(itemsMovedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "b.txt" << "c.txt" << "d.txt"); // We rename d.txt back to a.txt using the dir lister's refreshItems() signal. @@ -410,13 +414,13 @@ void KFileItemModelTest::testResortAfterChangingName() m_model->slotRefreshItems({qMakePair(fileItemD, fileItemA)}); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList)), DefaultTimeout)); + QVERIFY(itemsMovedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt"); } void KFileItemModelTest::testModelConsistencyWhenInsertingItems() { - //QSKIP("Temporary disabled", SkipSingle); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); // KFileItemModel prevents that inserting a punch of items sequentially // results in an itemsInserted()-signal for each item. Instead internally @@ -426,14 +430,14 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems() // the timeout to 1 millisecond. m_testDir->createFile("1"); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 1); // Insert 10 items for 20 times. After each insert operation the model consistency // is checked. QSet insertedItems; for (int i = 0; i < 20; ++i) { - QSignalSpy spy(m_model, SIGNAL(itemsInserted(KItemRangeList))); + itemsInsertedSpy.clear(); for (int j = 0; j < 10; ++j) { int itemName = qrand(); @@ -446,8 +450,8 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems() } m_model->m_dirLister->updateDirectory(m_testDir->url()); - if (spy.count() == 0) { - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + if (itemsInsertedSpy.count() == 0) { + QVERIFY(itemsInsertedSpy.wait()); } QVERIFY(m_model->isConsistent()); @@ -458,18 +462,17 @@ void KFileItemModelTest::testModelConsistencyWhenInsertingItems() void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems() { - QStringList files; - files << "B" << "E" << "G"; - m_testDir->createFiles(files); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + + m_testDir->createFiles({"B", "E", "G"}); // Due to inserting the 3 items one item-range with index == 0 and // count == 3 must be given - QSignalSpy spy1(m_model, SIGNAL(itemsInserted(KItemRangeList))); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); - QCOMPARE(spy1.count(), 1); - QList arguments = spy1.takeFirst(); + QCOMPARE(itemsInsertedSpy.count(), 1); + QList arguments = itemsInsertedSpy.takeFirst(); KItemRangeList itemRangeList = arguments.at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 3)); @@ -485,22 +488,23 @@ void KFileItemModelTest::testItemRangeConsistencyWhenInsertingItems() // index: 1, count: 2 for B, C // index: 2, count: 1 for G - files.clear(); - files << "A" << "C" << "D" << "F"; - m_testDir->createFiles(files); + m_testDir->createFiles({"A", "C", "D", "F"}); - QSignalSpy spy2(m_model, SIGNAL(itemsInserted(KItemRangeList))); m_model->m_dirLister->updateDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); - QCOMPARE(spy2.count(), 1); - arguments = spy2.takeFirst(); + QCOMPARE(itemsInsertedSpy.count(), 1); + arguments = itemsInsertedSpy.takeFirst(); itemRangeList = arguments.at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 1) << KItemRange(1, 2) << KItemRange(2, 1)); } void KFileItemModelTest::testExpandItems() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); + QSignalSpy loadingCompletedSpy(m_model, &KFileItemModel::directoryLoadingCompleted); + // Test expanding subfolders in a folder with the items "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1". // Besides testing the basic item expansion functionality, the test makes sure that // KFileItemModel::expansionLevelsCompare(const KFileItem& a, const KFileItem& b) @@ -511,18 +515,16 @@ void KFileItemModelTest::testExpandItems() modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a/a/1" << "a/a-1/1"; // missing folders are created automatically - m_testDir->createFiles(files); + m_testDir->createFiles({"a/a/1", "a/a-1/1"}); // Store the URLs of all folders in a set. QSet allFolders; - allFolders << QUrl::fromLocalFile(m_testDir->name() + 'a') - << QUrl::fromLocalFile(m_testDir->name() + "a/a") - << QUrl::fromLocalFile(m_testDir->name() + "a/a-1"); + allFolders << QUrl::fromLocalFile(m_testDir->path() + "/a") + << QUrl::fromLocalFile(m_testDir->path() + "/a/a") + << QUrl::fromLocalFile(m_testDir->path() + "/a/a-1"); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // So far, the model contains only "a/" QCOMPARE(m_model->count(), 1); @@ -530,17 +532,19 @@ void KFileItemModelTest::testExpandItems() QVERIFY(!m_model->isExpanded(0)); QVERIFY(m_model->expandedDirectories().empty()); - QSignalSpy spyInserted(m_model, SIGNAL(itemsInserted(KItemRangeList))); + QCOMPARE(itemsInsertedSpy.count(), 1); + KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value(); + QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 1)); // 1 new item "a/" with index 0 // Expand the folder "a/" -> "a/a/" and "a/a-1/" become visible m_model->setExpanded(0, true); QVERIFY(m_model->isExpanded(0)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/a/", "a/a-1/" - QCOMPARE(m_model->expandedDirectories(), QSet() << QUrl::fromLocalFile(m_testDir->name() + 'a')); + QCOMPARE(m_model->expandedDirectories(), QSet() << QUrl::fromLocalFile(m_testDir->path() + "/a")); - QCOMPARE(spyInserted.count(), 1); - KItemRangeList itemRangeList = spyInserted.takeFirst().at(0).value(); + QCOMPARE(itemsInsertedSpy.count(), 1); + itemRangeList = itemsInsertedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 2)); // 2 new items "a/a/" and "a/a-1/" with indices 1 and 2 QVERIFY(m_model->isExpandable(1)); @@ -551,12 +555,13 @@ void KFileItemModelTest::testExpandItems() // Expand the folder "a/a/" -> "a/a/1" becomes visible m_model->setExpanded(1, true); QVERIFY(m_model->isExpanded(1)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 4); // 4 items: "a/", "a/a/", "a/a/1", "a/a-1/" - QCOMPARE(m_model->expandedDirectories(), QSet() << QUrl::fromLocalFile(m_testDir->name() + 'a') << QUrl::fromLocalFile(m_testDir->name() + "a/a")); + QCOMPARE(m_model->expandedDirectories(), QSet() << QUrl::fromLocalFile(m_testDir->path() + "/a") + << QUrl::fromLocalFile(m_testDir->path() + "/a/a")); - QCOMPARE(spyInserted.count(), 1); - itemRangeList = spyInserted.takeFirst().at(0).value(); + QCOMPARE(itemsInsertedSpy.count(), 1); + itemRangeList = itemsInsertedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(2, 1)); // 1 new item "a/a/1" with index 2 QVERIFY(!m_model->isExpandable(2)); @@ -565,27 +570,25 @@ void KFileItemModelTest::testExpandItems() // Expand the folder "a/a-1/" -> "a/a-1/1" becomes visible m_model->setExpanded(3, true); QVERIFY(m_model->isExpanded(3)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1" QCOMPARE(m_model->expandedDirectories(), allFolders); - QCOMPARE(spyInserted.count(), 1); - itemRangeList = spyInserted.takeFirst().at(0).value(); + QCOMPARE(itemsInsertedSpy.count(), 1); + itemRangeList = itemsInsertedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(4, 1)); // 1 new item "a/a-1/1" with index 4 QVERIFY(!m_model->isExpandable(4)); QVERIFY(!m_model->isExpanded(4)); - QSignalSpy spyRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList))); - // Collapse the top-level folder -> all other items should disappear m_model->setExpanded(0, false); QVERIFY(!m_model->isExpanded(0)); QCOMPARE(m_model->count(), 1); - QVERIFY(!m_model->expandedDirectories().contains(QUrl::fromLocalFile(m_testDir->name() + 'a'))); // TODO: Make sure that child URLs are also removed + QVERIFY(!m_model->expandedDirectories().contains(QUrl::fromLocalFile(m_testDir->path() + "/a"))); // TODO: Make sure that child URLs are also removed - QCOMPARE(spyRemoved.count(), 1); - itemRangeList = spyRemoved.takeFirst().at(0).value(); + QCOMPARE(itemsRemovedSpy.count(), 1); + itemRangeList = itemsRemovedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 4)); // 4 items removed QVERIFY(m_model->isConsistent()); @@ -596,7 +599,7 @@ void KFileItemModelTest::testExpandItems() m_model->loadDirectory(m_testDir->url()); m_model->restoreExpandedDirectories(allFolders); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + QVERIFY(loadingCompletedSpy.wait()); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1" QVERIFY(m_model->isExpanded(0)); QVERIFY(m_model->isExpanded(1)); @@ -608,30 +611,33 @@ void KFileItemModelTest::testExpandItems() // Move to a sub folder, then call restoreExpandedFolders() *before* going back. // This is how DolphinView restores the expanded folders when navigating in history. - m_model->loadDirectory(QUrl::fromLocalFile(m_testDir->name() + "a/a/")); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + m_model->loadDirectory(QUrl::fromLocalFile(m_testDir->path() + "/a/a/")); + QVERIFY(loadingCompletedSpy.wait()); QCOMPARE(m_model->count(), 1); // 1 item: "1" m_model->restoreExpandedDirectories(allFolders); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + QVERIFY(loadingCompletedSpy.wait()); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/a/", "a/a/1", "a/a-1/", "a/a-1/1" QCOMPARE(m_model->expandedDirectories(), allFolders); // Remove all expanded items by changing the roles - spyRemoved.clear(); + itemsRemovedSpy.clear(); m_model->setRoles(originalModelRoles); QVERIFY(!m_model->isExpanded(0)); QCOMPARE(m_model->count(), 1); - QVERIFY(!m_model->expandedDirectories().contains(QUrl::fromLocalFile(m_testDir->name() + 'a'))); + QVERIFY(!m_model->expandedDirectories().contains(QUrl::fromLocalFile(m_testDir->path() + "/a"))); - QCOMPARE(spyRemoved.count(), 1); - itemRangeList = spyRemoved.takeFirst().at(0).value(); + QCOMPARE(itemsRemovedSpy.count(), 1); + itemRangeList = itemsRemovedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(1, 4)); // 4 items removed QVERIFY(m_model->isConsistent()); } void KFileItemModelTest::testExpandParentItems() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy loadingCompletedSpy(m_model, &KFileItemModel::directoryLoadingCompleted); + // Create a tree structure of folders: // a 1/ // a 1/b1/ @@ -644,20 +650,18 @@ void KFileItemModelTest::testExpandParentItems() modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a 1/b1/c1/file.txt" << "a2/b2/c2/d2/file.txt"; // missing folders are created automatically - m_testDir->createFiles(files); + m_testDir->createFiles({"a 1/b1/c1/file.txt", "a2/b2/c2/d2/file.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // So far, the model contains only "a 1/" and "a2/". QCOMPARE(m_model->count(), 2); QVERIFY(m_model->expandedDirectories().empty()); // Expand the parents of "a2/b2/c2". - m_model->expandParentDirectories(QUrl::fromLocalFile(m_testDir->name() + "a2/b2/c2")); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + m_model->expandParentDirectories(QUrl::fromLocalFile(m_testDir->path() + "a2/b2/c2")); + QVERIFY(loadingCompletedSpy.wait()); // The model should now contain "a 1/", "a2/", "a2/b2/", and "a2/b2/c2/". // It's important that only the parents of "a1/b1/c1" are expanded. @@ -668,8 +672,8 @@ void KFileItemModelTest::testExpandParentItems() QVERIFY(!m_model->isExpanded(3)); // Expand the parents of "a 1/b1". - m_model->expandParentDirectories(QUrl::fromLocalFile(m_testDir->name() + "a 1/b1")); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + m_model->expandParentDirectories(QUrl::fromLocalFile(m_testDir->path() + "a 1/b1")); + QVERIFY(loadingCompletedSpy.wait()); // The model should now contain "a 1/", "a 1/b1/", "a2/", "a2/b2", and "a2/b2/c2/". // It's important that only the parents of "a 1/b1/" and "a2/b2/c2/" are expanded. @@ -683,7 +687,7 @@ void KFileItemModelTest::testExpandParentItems() // Expand "a 1/b1/". m_model->setExpanded(1, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(directoryLoadingCompleted()), DefaultTimeout)); + QVERIFY(loadingCompletedSpy.wait()); QCOMPARE(m_model->count(), 6); QVERIFY(m_model->isExpanded(0)); QVERIFY(m_model->isExpanded(1)); @@ -711,28 +715,27 @@ void KFileItemModelTest::testExpandParentItems() */ void KFileItemModelTest::testMakeExpandedItemHidden() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - m_testDir->createFile("1a/2a/3a"); - m_testDir->createFile("1a/2a/3b"); - m_testDir->createFile("1a/2b"); - m_testDir->createFile("1b"); + m_testDir->createFiles({"1a/2a/3a", "1a/2a/3b", "1a/2b", "1b"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // So far, the model contains only "1a/" and "1b". QCOMPARE(m_model->count(), 2); m_model->setExpanded(0, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // Now "1a/2a" and "1a/2b" have appeared. QCOMPARE(m_model->count(), 4); m_model->setExpanded(1, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 6); // Rename "1a/2" and make it hidden. @@ -742,7 +745,7 @@ void KFileItemModelTest::testMakeExpandedItemHidden() KIO::SimpleJob* job = KIO::rename(oldUrl, newUrl, KIO::HideProgressInfo); bool ok = job->exec(); QVERIFY(ok); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsRemoved(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsRemovedSpy.wait()); // "1a/2" and its subfolders have disappeared now. QVERIFY(m_model->isConsistent()); @@ -755,17 +758,17 @@ void KFileItemModelTest::testMakeExpandedItemHidden() void KFileItemModelTest::testRemoveFilteredExpandedItems() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSet originalModelRoles = m_model->roles(); QSet modelRoles = originalModelRoles; modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "folder/child" << "file"; // missing folders are created automatically - m_testDir->createFiles(files); + m_testDir->createFiles({"folder/child", "file"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // So far, the model contains only "folder/" and "file". QCOMPARE(m_model->count(), 2); @@ -778,7 +781,7 @@ void KFileItemModelTest::testRemoveFilteredExpandedItems() // Expand "folder" -> "folder/child" becomes visible. m_model->setExpanded(0, true); QVERIFY(m_model->isExpanded(0)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "folder" << "child" << "file"); // Add a name filter. @@ -800,6 +803,9 @@ void KFileItemModelTest::testRemoveFilteredExpandedItems() void KFileItemModelTest::testSorting() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved); + // Create some files with different sizes and modification times to check the different sorting options QDateTime now = QDateTime::currentDateTime(); @@ -822,15 +828,15 @@ void KFileItemModelTest::testSorting() m_testDir->createFile(".f"); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); - int index = m_model->index(QUrl(m_testDir->url().url() + 'c')); + int index = m_model->index(QUrl(m_testDir->url().url() + "/c")); m_model->setExpanded(index, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); - index = m_model->index(QUrl(m_testDir->url().url() + "c/c-2")); + index = m_model->index(QUrl(m_testDir->url().url() + "/c/c-2")); m_model->setExpanded(index, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // Default: Sort by Name, ascending QCOMPARE(m_model->sortRole(), QByteArray("text")); @@ -839,16 +845,14 @@ void KFileItemModelTest::testSorting() QVERIFY(!m_model->showHiddenFiles()); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "d" << "e"); - QSignalSpy spyItemsMoved(m_model, SIGNAL(itemsMoved(KItemRange,QList))); - // Sort by Name, ascending, 'Sort Folders First' disabled m_model->setSortDirectoriesFirst(false); QCOMPARE(m_model->sortRole(), QByteArray("text")); QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e"); - QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(0, 6)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 2 << 4 << 5 << 3 << 0 << 1); + QCOMPARE(itemsMovedSpy.count(), 1); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(0, 6)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 2 << 4 << 5 << 3 << 0 << 1); // Sort by Name, descending m_model->setSortDirectoriesFirst(true); @@ -856,11 +860,11 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortRole(), QByteArray("text")); QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "d" << "b" << "a"); - QCOMPARE(spyItemsMoved.count(), 2); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(0, 6)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 4 << 5 << 0 << 3 << 1 << 2); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(4, 4)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 7 << 6 << 5 << 4); + QCOMPARE(itemsMovedSpy.count(), 2); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(0, 6)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 4 << 5 << 0 << 3 << 1 << 2); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(4, 4)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 7 << 6 << 5 << 4); // Sort by Date, descending m_model->setSortDirectoriesFirst(true); @@ -868,18 +872,18 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortRole(), QByteArray("date")); QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "b" << "d" << "a" << "e"); - QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(4, 4)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 7 << 5 << 4 << 6); + QCOMPARE(itemsMovedSpy.count(), 1); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(4, 4)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 7 << 5 << 4 << 6); // Sort by Date, ascending m_model->setSortOrder(Qt::AscendingOrder); QCOMPARE(m_model->sortRole(), QByteArray("date")); QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "e" << "a" << "d" << "b"); - QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(4, 4)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 7 << 6 << 5 << 4); + QCOMPARE(itemsMovedSpy.count(), 1); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(4, 4)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 7 << 6 << 5 << 4); // Sort by Date, ascending, 'Sort Folders First' disabled m_model->setSortDirectoriesFirst(false); @@ -887,18 +891,18 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QVERIFY(!m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "e" << "a" << "c" << "c-1" << "c-2" << "c-3" << "d" << "b"); - QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(0, 6)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 2 << 4 << 5 << 3 << 0 << 1); + QCOMPARE(itemsMovedSpy.count(), 1); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(0, 6)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 2 << 4 << 5 << 3 << 0 << 1); // Sort by Name, ascending, 'Sort Folders First' disabled m_model->setSortRole("text"); QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QVERIFY(!m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c" << "c-1" << "c-2" << "c-3" << "d" << "e"); - QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(0, 8)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 7 << 0 << 2 << 3 << 4 << 5 << 6 << 1); + QCOMPARE(itemsMovedSpy.count(), 1); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(0, 8)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 7 << 0 << 2 << 3 << 4 << 5 << 6 << 1); // Sort by Size, ascending, 'Sort Folders First' disabled m_model->setSortRole("size"); @@ -906,9 +910,9 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QVERIFY(!m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d"); - QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(0, 8)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 4 << 5 << 0 << 3 << 1 << 2 << 7 << 6); + QCOMPARE(itemsMovedSpy.count(), 1); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(0, 8)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 4 << 5 << 0 << 3 << 1 << 2 << 7 << 6); // In 'Sort by Size' mode, folders are always first -> changing 'Sort Folders First' does not resort the model m_model->setSortDirectoriesFirst(true); @@ -916,7 +920,7 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::AscendingOrder); QVERIFY(m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "a" << "b" << "e" << "d"); - QCOMPARE(spyItemsMoved.count(), 0); + QCOMPARE(itemsMovedSpy.count(), 0); // Sort by Size, descending, 'Sort Folders First' enabled m_model->setSortOrder(Qt::DescendingOrder); @@ -924,21 +928,21 @@ void KFileItemModelTest::testSorting() QCOMPARE(m_model->sortOrder(), Qt::DescendingOrder); QVERIFY(m_model->sortDirectoriesFirst()); QCOMPARE(itemsInModel(), QStringList() << "c" << "c-2" << "c-3" << "c-1" << "d" << "e" << "b" << "a"); - QCOMPARE(spyItemsMoved.count(), 1); - QCOMPARE(spyItemsMoved.first().at(0).value(), KItemRange(4, 4)); - QCOMPARE(spyItemsMoved.takeFirst().at(1).value >(), QList() << 7 << 6 << 5 << 4); + QCOMPARE(itemsMovedSpy.count(), 1); + QCOMPARE(itemsMovedSpy.first().at(0).value(), KItemRange(4, 4)); + QCOMPARE(itemsMovedSpy.takeFirst().at(1).value >(), QList() << 7 << 6 << 5 << 4); // TODO: Sort by other roles; show/hide hidden files } void KFileItemModelTest::testIndexForKeyboardSearch() { - QStringList files; - files << "a" << "aa" << "Image.jpg" << "Image.png" << "Text" << "Text1" << "Text2" << "Text11"; - m_testDir->createFiles(files); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + + m_testDir->createFiles({"a", "aa", "Image.jpg", "Image.png", "Text", "Text1", "Text2", "Text11"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); // Search from index 0 QCOMPARE(m_model->indexForKeyboardSearch("a", 0), 0); @@ -983,12 +987,12 @@ void KFileItemModelTest::testIndexForKeyboardSearch() void KFileItemModelTest::testNameFilter() { - QStringList files; - files << "A1" << "A2" << "Abc" << "Bcd" << "Cde"; - m_testDir->createFiles(files); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + + m_testDir->createFiles({"A1", "A2", "Abc", "Bcd", "Cde"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); m_model->setNameFilter("A"); // Shows A1, A2 and Abc QCOMPARE(m_model->count(), 3); @@ -1040,28 +1044,27 @@ void KFileItemModelTest::testEmptyPath() */ void KFileItemModelTest::testRefreshExpandedItem() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsChangedSpy(m_model, &KFileItemModel::itemsChanged); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a/1" << "a/2" << "3" << "4"; - m_testDir->createFiles(files); + m_testDir->createFiles({"a/1", "a/2", "3", "4"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 3); // "a/", "3", "4" m_model->setExpanded(0, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 5); // "a/", "a/1", "a/2", "3", "4" QVERIFY(m_model->isExpanded(0)); - QSignalSpy spyItemsChanged(m_model, SIGNAL(itemsChanged(KItemRangeList,QSet))); - const KFileItem item = m_model->fileItem(0); m_model->slotRefreshItems({qMakePair(item, item)}); - QVERIFY(!spyItemsChanged.isEmpty()); + QVERIFY(!itemsChangedSpy.isEmpty()); QCOMPARE(m_model->count(), 5); // "a/", "a/1", "a/2", "3", "4" QVERIFY(m_model->isExpanded(0)); @@ -1079,37 +1082,37 @@ void KFileItemModelTest::testRemoveHiddenItems() m_testDir->createDir("d"); m_testDir->createFiles({".f", ".g", "h", "i"}); - QSignalSpy spyItemsInserted(m_model, SIGNAL(itemsInserted(KItemRangeList))); - QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList))); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); m_model->setShowHiddenFiles(true); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i"); - QCOMPARE(spyItemsInserted.count(), 1); - QCOMPARE(spyItemsRemoved.count(), 0); - KItemRangeList itemRangeList = spyItemsInserted.takeFirst().at(0).value(); + QCOMPARE(itemsInsertedSpy.count(), 1); + QCOMPARE(itemsRemovedSpy.count(), 0); + KItemRangeList itemRangeList = itemsInsertedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 8)); m_model->setShowHiddenFiles(false); QCOMPARE(itemsInModel(), QStringList() << "c" << "d" << "h" << "i"); - QCOMPARE(spyItemsInserted.count(), 0); - QCOMPARE(spyItemsRemoved.count(), 1); - itemRangeList = spyItemsRemoved.takeFirst().at(0).value(); + QCOMPARE(itemsInsertedSpy.count(), 0); + QCOMPARE(itemsRemovedSpy.count(), 1); + itemRangeList = itemsRemovedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 2) << KItemRange(4, 2)); m_model->setShowHiddenFiles(true); QCOMPARE(itemsInModel(), QStringList() << ".a" << ".b" << "c" << "d" <<".f" << ".g" << "h" << "i"); - QCOMPARE(spyItemsInserted.count(), 1); - QCOMPARE(spyItemsRemoved.count(), 0); - itemRangeList = spyItemsInserted.takeFirst().at(0).value(); + QCOMPARE(itemsInsertedSpy.count(), 1); + QCOMPARE(itemsRemovedSpy.count(), 0); + itemRangeList = itemsInsertedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 2) << KItemRange(2, 2)); m_model->clear(); QCOMPARE(itemsInModel(), QStringList()); - QCOMPARE(spyItemsInserted.count(), 0); - QCOMPARE(spyItemsRemoved.count(), 1); - itemRangeList = spyItemsRemoved.takeFirst().at(0).value(); + QCOMPARE(itemsInsertedSpy.count(), 0); + QCOMPARE(itemsRemovedSpy.count(), 1); + itemRangeList = itemsRemovedSpy.takeFirst().at(0).value(); QCOMPARE(itemRangeList, KItemRangeList() << KItemRange(0, 8)); // Hiding hidden files makes the dir lister emit its itemsDeleted signal. @@ -1122,42 +1125,43 @@ void KFileItemModelTest::testRemoveHiddenItems() */ void KFileItemModelTest::collapseParentOfHiddenItems() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1"; - m_testDir->createFiles(files); + m_testDir->createFiles({"a/1", "a/b/1", "a/b/c/1", "a/b/c/d/1"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 1); // Only "a/" // Expand "a/". m_model->setExpanded(0, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/b/", "a/1" // Expand "a/b/". m_model->setExpanded(1, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1" // Expand "a/b/c/". m_model->setExpanded(2, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1" // Set a name filter that matches nothing -> only the expanded folders remain. m_model->setNameFilter("xyz"); + QCOMPARE(itemsRemovedSpy.count(), 1); QCOMPARE(m_model->count(), 3); QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c"); // Collapse the folder "a/". - QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList))); m_model->setExpanded(0, false); - QCOMPARE(spyItemsRemoved.count(), 1); + QCOMPARE(itemsRemovedSpy.count(), 2); QCOMPARE(m_model->count(), 1); QCOMPARE(itemsInModel(), QStringList() << "a"); @@ -1171,42 +1175,43 @@ void KFileItemModelTest::collapseParentOfHiddenItems() */ void KFileItemModelTest::removeParentOfHiddenItems() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a/1" << "a/b/1" << "a/b/c/1" << "a/b/c/d/1"; - m_testDir->createFiles(files); + m_testDir->createFiles({"a/1", "a/b/1", "a/b/c/1", "a/b/c/d/1"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 1); // Only "a/" // Expand "a/". m_model->setExpanded(0, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 3); // 3 items: "a/", "a/b/", "a/1" // Expand "a/b/". m_model->setExpanded(1, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 5); // 5 items: "a/", "a/b/", "a/b/c", "a/b/1", "a/1" // Expand "a/b/c/". m_model->setExpanded(2, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(m_model->count(), 7); // 7 items: "a/", "a/b/", "a/b/c", "a/b/c/d/", "a/b/c/1", "a/b/1", "a/1" // Set a name filter that matches nothing -> only the expanded folders remain. m_model->setNameFilter("xyz"); + QCOMPARE(itemsRemovedSpy.count(), 1); QCOMPARE(m_model->count(), 3); QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c"); // Simulate the deletion of the directory "a/b/". - QSignalSpy spyItemsRemoved(m_model, SIGNAL(itemsRemoved(KItemRangeList))); m_model->slotItemsDeleted(KFileItemList() << m_model->fileItem(1)); - QCOMPARE(spyItemsRemoved.count(), 1); + QCOMPARE(itemsRemovedSpy.count(), 2); QCOMPARE(m_model->count(), 1); QCOMPARE(itemsInModel(), QStringList() << "a"); @@ -1223,33 +1228,34 @@ void KFileItemModelTest::removeParentOfHiddenItems() */ void KFileItemModelTest::testGeneralParentChildRelationships() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsRemovedSpy(m_model, &KFileItemModel::itemsRemoved); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "parent1/realChild1/realGrandChild1" << "parent2/realChild2/realGrandChild2"; - m_testDir->createFiles(files); + m_testDir->createFiles({"parent1/realChild1/realGrandChild1", "parent2/realChild2/realGrandChild2"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "parent2"); // Expand all folders. m_model->setExpanded(0, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "parent2"); m_model->setExpanded(1, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2"); m_model->setExpanded(3, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2" << "realChild2"); m_model->setExpanded(4, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "realGrandChild1" << "parent2" << "realChild2" << "realGrandChild2"); // Add some more children and grand-children. @@ -1279,7 +1285,6 @@ void KFileItemModelTest::testGeneralParentChildRelationships() QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "grandChild1" << "realGrandChild1" << "child1" << "parent2" << "realChild2" << "grandChild2" << "realGrandChild2" << "child2"); // Set a name filter that matches nothing -> only expanded folders remain. - QSignalSpy itemsRemovedSpy(m_model, SIGNAL(itemsRemoved(KItemRangeList))); m_model->setNameFilter("xyz"); QCOMPARE(itemsInModel(), QStringList() << "parent1" << "realChild1" << "parent2" << "realChild2"); QCOMPARE(itemsRemovedSpy.count(), 1); @@ -1310,14 +1315,15 @@ void KFileItemModelTest::testGeneralParentChildRelationships() void KFileItemModelTest::testNameRoleGroups() { - QStringList files; - files << "b.txt" << "c.txt" << "d.txt" << "e.txt"; + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSignalSpy itemsMovedSpy(m_model, &KFileItemModel::itemsMoved); + QSignalSpy groupsChangedSpy(m_model, &KFileItemModel::groupsChanged); - m_testDir->createFiles(files); + m_testDir->createFiles({"b.txt", "c.txt", "d.txt", "e.txt"}); m_model->setGroupedSorting(true); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "b.txt" << "c.txt" << "d.txt" << "e.txt"); QList > expectedGroups; @@ -1331,7 +1337,7 @@ void KFileItemModelTest::testNameRoleGroups() QHash data; data.insert("text", "a.txt"); m_model->setData(2, data); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsMoved(KItemRange,QList)), DefaultTimeout)); + QVERIFY(itemsMovedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "e.txt"); expectedGroups.clear(); @@ -1344,7 +1350,7 @@ void KFileItemModelTest::testNameRoleGroups() // Rename c.txt to d.txt. data.insert("text", "d.txt"); m_model->setData(2, data); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(groupsChanged()), DefaultTimeout)); + QVERIFY(groupsChangedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "d.txt" << "e.txt"); expectedGroups.clear(); @@ -1362,7 +1368,7 @@ void KFileItemModelTest::testNameRoleGroups() fileItemC.setUrl(urlC); m_model->slotRefreshItems({qMakePair(fileItemD, fileItemC)}); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(groupsChanged()), DefaultTimeout)); + QVERIFY(groupsChangedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "e.txt"); expectedGroups.clear(); @@ -1375,18 +1381,17 @@ void KFileItemModelTest::testNameRoleGroups() void KFileItemModelTest::testNameRoleGroupsWithExpandedItems() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a/b.txt" << "a/c.txt" << "d/e.txt" << "d/f.txt"; - - m_testDir->createFiles(files); + m_testDir->createFiles({"a/b.txt", "a/c.txt", "d/e.txt", "d/f.txt"}); m_model->setGroupedSorting(true); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a" << "d"); QList > expectedGroups; @@ -1401,41 +1406,40 @@ void KFileItemModelTest::testNameRoleGroupsWithExpandedItems() m_model->setExpanded(0, true); QVERIFY(m_model->isExpanded(0)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a" << "b.txt" << "c.txt" << "d"); QCOMPARE(m_model->groups(), expectedGroups); m_model->setExpanded(3, true); QVERIFY(m_model->isExpanded(3)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a" << "b.txt" << "c.txt" << "d" << "e.txt" << "f.txt"); QCOMPARE(m_model->groups(), expectedGroups); } void KFileItemModelTest::testInconsistentModel() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a/b/c1.txt" << "a/b/c2.txt"; - - m_testDir->createFiles(files); + m_testDir->createFiles({"a/b/c1.txt", "a/b/c2.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a"); // Expand "a/" and "a/b/". m_model->setExpanded(0, true); QVERIFY(m_model->isExpanded(0)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a" << "b"); m_model->setExpanded(1, true); QVERIFY(m_model->isExpanded(1)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a" << "b" << "c1.txt" << "c2.txt"); // Add the files "c1.txt" and "c2.txt" to the model also as top-level items. @@ -1471,16 +1475,16 @@ void KFileItemModelTest::testInconsistentModel() void KFileItemModelTest::testChangeRolesForFilteredItems() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSet modelRoles = m_model->roles(); modelRoles << "owner"; m_model->setRoles(modelRoles); - QStringList files; - files << "a.txt" << "aa.txt" << "aaa.txt"; - m_testDir->createFiles(files); + m_testDir->createFiles({"a.txt", "aa.txt", "aaa.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "aa.txt" << "aaa.txt"); for (int index = 0; index < m_model->count(); ++index) { @@ -1568,12 +1572,12 @@ void KFileItemModelTest::testChangeSortRoleWhileFiltering() void KFileItemModelTest::testRefreshFilteredItems() { - QStringList files; - files << "a.txt" << "b.txt" << "c.jpg" << "d.jpg"; - m_testDir->createFiles(files); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + + m_testDir->createFiles({"a.txt", "b.txt", "c.jpg", "d.jpg"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.jpg" << "d.jpg"); const KFileItem fileItemC = m_model->fileItem(2); @@ -1585,7 +1589,7 @@ void KFileItemModelTest::testRefreshFilteredItems() // Rename one of the .jpg files. KFileItem fileItemE = fileItemC; QUrl urlE = fileItemE.url().adjusted(QUrl::RemoveFilename); - urlE.setPath(urlE.path() + "e.jpg"); + urlE.setPath(urlE.path() + "/e.jpg"); fileItemE.setUrl(urlE); m_model->slotRefreshItems({qMakePair(fileItemC, fileItemE)}); @@ -1597,21 +1601,21 @@ void KFileItemModelTest::testRefreshFilteredItems() void KFileItemModelTest::testCreateMimeData() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a/1"; - m_testDir->createFiles(files); + m_testDir->createFile("a/1"); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a"); // Expand "a/". m_model->setExpanded(0, true); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a" << "1"); // Verify that creating the MIME data for a child of an expanded folder does @@ -1624,28 +1628,28 @@ void KFileItemModelTest::testCreateMimeData() void KFileItemModelTest::testCollapseFolderWhileLoading() { + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + QSet modelRoles = m_model->roles(); modelRoles << "isExpanded" << "isExpandable" << "expandedParentsCount"; m_model->setRoles(modelRoles); - QStringList files; - files << "a2/b/c1.txt"; - m_testDir->createFiles(files); + m_testDir->createFile("a2/b/c1.txt"); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a2"); // Expand "a2/". m_model->setExpanded(0, true); QVERIFY(m_model->isExpanded(0)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a2" << "b"); // Expand "a2/b/". m_model->setExpanded(1, true); QVERIFY(m_model->isExpanded(1)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a2" << "b" << "c1.txt"); // Simulate that a new item "c2.txt" appears, but that the dir lister's completed() @@ -1677,7 +1681,7 @@ void KFileItemModelTest::testCollapseFolderWhileLoading() // Expand "a2/" again. m_model->setExpanded(0, true); QVERIFY(m_model->isExpanded(0)); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a2" << "b"); // Now simulate that a new folder "a1/" is appears, but that the dir lister's @@ -1702,12 +1706,12 @@ void KFileItemModelTest::testCollapseFolderWhileLoading() void KFileItemModelTest::testDeleteFileMoreThanOnce() { - QStringList files; - files << "a.txt" << "b.txt" << "c.txt" << "d.txt"; - m_testDir->createFiles(files); + QSignalSpy itemsInsertedSpy(m_model, &KFileItemModel::itemsInserted); + + m_testDir->createFiles({"a.txt", "b.txt", "c.txt", "d.txt"}); m_model->loadDirectory(m_testDir->url()); - QVERIFY(QTest::kWaitForSignal(m_model, SIGNAL(itemsInserted(KItemRangeList)), DefaultTimeout)); + QVERIFY(itemsInsertedSpy.wait()); QCOMPARE(itemsInModel(), QStringList() << "a.txt" << "b.txt" << "c.txt" << "d.txt"); const KFileItem fileItemB = m_model->fileItem(1); @@ -1730,6 +1734,6 @@ QStringList KFileItemModelTest::itemsInModel() const return items; } -QTEST_KDEMAIN(KFileItemModelTest, NoGUI) +QTEST_MAIN(KFileItemModelTest) #include "kfileitemmodeltest.moc" diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp index 42c0a8ed2..cd4d0a681 100644 --- a/src/tests/kitemlistcontrollertest.cpp +++ b/src/tests/kitemlistcontrollertest.cpp @@ -17,10 +17,6 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include -#include -#include - #include "kitemviews/kitemlistcontainer.h" #include "kitemviews/kfileitemlistview.h" #include "kitemviews/kfileitemmodel.h" @@ -32,13 +28,10 @@ #include #include +#include #include #include -namespace { - const int DefaultTimeout = 2000; -}; - Q_DECLARE_METATYPE(KFileItemListView::ItemLayout); Q_DECLARE_METATYPE(Qt::Orientation); Q_DECLARE_METATYPE(KItemListController::SelectionBehavior); @@ -104,7 +97,7 @@ void KItemListControllerTest::initTestCase() m_testDir->createFiles(files); m_model->loadDirectory(m_testDir->url()); QSignalSpy spyDirectoryLoadingCompleted(m_model, SIGNAL(directoryLoadingCompleted())); - QVERIFY(spyDirectoryLoadingCompleted.wait(DefaultTimeout)); + QVERIFY(spyDirectoryLoadingCompleted.wait()); m_container->show(); QTest::qWaitForWindowShown(m_container); @@ -567,7 +560,7 @@ void KItemListControllerTest::testMouseClickActivation() if (!KGlobalSettings::singleClick()) { // TODO: Try to find a way to make sure that changing the global setting works. - QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle); + QSKIP("Failed to change the KGlobalSettings::singleClick() setting!"); } m_view->event(&mousePressEvent); @@ -588,7 +581,7 @@ void KItemListControllerTest::testMouseClickActivation() if (KGlobalSettings::singleClick()) { // TODO: Try to find a way to make sure that changing the global setting works. - QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle); + QSKIP("Failed to change the KGlobalSettings::singleClick() setting!"); } m_view->event(&mousePressEvent); @@ -623,7 +616,7 @@ void KItemListControllerTest::testMouseClickActivation() if (!KGlobalSettings::singleClick()) { // TODO: Try to find a way to make sure that changing the global setting works. - QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle); + QSKIP("Failed to change the KGlobalSettings::singleClick() setting!"); } m_view->event(&mousePressEvent); @@ -652,7 +645,7 @@ void KItemListControllerTest::testMouseClickActivation() if (KGlobalSettings::singleClick() != restoreKGlobalSettingsSingleClick) { // TODO: Try to find a way to make sure that changing the global setting works. - QSKIP("Failed to change the KGlobalSettings::singleClick() setting!", SkipSingle); + QSKIP("Failed to change the KGlobalSettings::singleClick() setting!"); } } diff --git a/src/tests/kitemlistkeyboardsearchmanagertest.cpp b/src/tests/kitemlistkeyboardsearchmanagertest.cpp index 373f4f301..41475660d 100644 --- a/src/tests/kitemlistkeyboardsearchmanagertest.cpp +++ b/src/tests/kitemlistkeyboardsearchmanagertest.cpp @@ -17,10 +17,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include -#include #include "kitemviews/private/kitemlistkeyboardsearchmanager.h" +#include +#include + class KItemListKeyboardSearchManagerTest : public QObject { Q_OBJECT @@ -45,7 +46,7 @@ void KItemListKeyboardSearchManagerTest::init() void KItemListKeyboardSearchManagerTest::testBasicKeyboardSearch() { - QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool))); + QSignalSpy spy(&m_keyboardSearchManager, &KItemListKeyboardSearchManager::changeCurrentItem); m_keyboardSearchManager.addKeys("f"); QCOMPARE(spy.count(), 1); @@ -70,7 +71,7 @@ void KItemListKeyboardSearchManagerTest::testAbortedKeyboardSearch() // to save time when running this test. m_keyboardSearchManager.setTimeout(100); - QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool))); + QSignalSpy spy(&m_keyboardSearchManager, &KItemListKeyboardSearchManager::changeCurrentItem); m_keyboardSearchManager.addKeys("f"); QCOMPARE(spy.count(), 1); @@ -101,7 +102,7 @@ void KItemListKeyboardSearchManagerTest::testRepeatedKeyPress() // 1. the string contains the repeated key only once, and // 2. the bool searchFromNextItem is true. - QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool))); + QSignalSpy spy(&m_keyboardSearchManager, &KItemListKeyboardSearchManager::changeCurrentItem); m_keyboardSearchManager.addKeys("p"); QCOMPARE(spy.count(), 1); @@ -128,7 +129,7 @@ void KItemListKeyboardSearchManagerTest::testPressShift() // string. Make sure that this does not reset the current search. See // https://bugs.kde.org/show_bug.cgi?id=321286 - QSignalSpy spy(&m_keyboardSearchManager, SIGNAL(changeCurrentItem(QString,bool))); + QSignalSpy spy(&m_keyboardSearchManager, &KItemListKeyboardSearchManager::changeCurrentItem); // Simulate that the user enters "a_b". m_keyboardSearchManager.addKeys("a"); diff --git a/src/tests/kitemlistselectionmanagertest.cpp b/src/tests/kitemlistselectionmanagertest.cpp index fb0f4fc2b..8403de701 100644 --- a/src/tests/kitemlistselectionmanagertest.cpp +++ b/src/tests/kitemlistselectionmanagertest.cpp @@ -18,11 +18,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include -#include #include "kitemviews/kitemmodelbase.h" #include "kitemviews/kitemlistselectionmanager.h" +#include +#include + class DummyModel : public KItemModelBase { public: diff --git a/src/tests/kitemrangetest.cpp b/src/tests/kitemrangetest.cpp index 011f5ae86..882cd66e7 100644 --- a/src/tests/kitemrangetest.cpp +++ b/src/tests/kitemrangetest.cpp @@ -17,10 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include - #include "kitemviews/kitemrange.h" +#include #include Q_DECLARE_METATYPE(QVector); diff --git a/src/tests/kitemsettest.cpp b/src/tests/kitemsettest.cpp index 9cc02d060..ed683e1a8 100644 --- a/src/tests/kitemsettest.cpp +++ b/src/tests/kitemsettest.cpp @@ -17,10 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include - #include "kitemviews/kitemset.h" +#include #include Q_DECLARE_METATYPE(KItemRangeList); diff --git a/src/tests/kstandarditemmodeltest.cpp b/src/tests/kstandarditemmodeltest.cpp index f7e61ce90..e83e2031d 100644 --- a/src/tests/kstandarditemmodeltest.cpp +++ b/src/tests/kstandarditemmodeltest.cpp @@ -18,11 +18,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include - #include "kitemviews/kstandarditem.h" #include "kitemviews/kstandarditemmodel.h" +#include + class KStandardItemModelTest : public QObject { Q_OBJECT diff --git a/src/tests/testdir.cpp b/src/tests/testdir.cpp index dcc4c87a5..b84b344b7 100644 --- a/src/tests/testdir.cpp +++ b/src/tests/testdir.cpp @@ -28,7 +28,7 @@ #endif TestDir::TestDir(const QString& directoryPrefix) : - KTempDir(directoryPrefix) + QTemporaryDir(directoryPrefix) { } @@ -38,7 +38,7 @@ TestDir::~TestDir() QUrl TestDir::url() const { - return QUrl::fromLocalFile(name()); + return QUrl::fromLocalFile(path()); } /** The following function is taken from kdelibs/kio/tests/kiotesthelper.h, copyright (C) 2006 by David Faure */ @@ -85,7 +85,7 @@ void TestDir::createDir(const QString& path, const QDateTime& time) { QString absolutePath = path; makePathAbsoluteAndCreateParents(absolutePath); - QDir(name()).mkdir(absolutePath); + QDir(TestDir::path()).mkdir(absolutePath); if (time.isValid()) { setTimeStamp(absolutePath, time); @@ -94,12 +94,19 @@ void TestDir::createDir(const QString& path, const QDateTime& time) Q_ASSERT(QFile::exists(absolutePath)); } +void TestDir::removeFiles(const QStringList& files) +{ + foreach (const QString& path, files) { + removeFile(path); + } +} + void TestDir::removeFile(const QString& path) { QString absolutePath = path; QFileInfo fileInfo(absolutePath); if (!fileInfo.isAbsolute()) { - absolutePath = name() + path; + absolutePath = TestDir::path() + QLatin1Char('/') + path; } QFile::remove(absolutePath); } @@ -108,7 +115,7 @@ void TestDir::makePathAbsoluteAndCreateParents(QString& path) { QFileInfo fileInfo(path); if (!fileInfo.isAbsolute()) { - path = name() + path; + path = TestDir::path() + QLatin1Char('/') + path; fileInfo.setFile(path); } diff --git a/src/tests/testdir.h b/src/tests/testdir.h index 24c4d77b0..3f244448c 100644 --- a/src/tests/testdir.h +++ b/src/tests/testdir.h @@ -20,16 +20,15 @@ #ifndef TESTDIR_H #define TESTDIR_H -#include #include - +#include #include /** - * TestDir provides a temporary directory. In addition to KTempDir, it has + * TestDir provides a temporary directory. In addition to QTemporaryDir, it has * methods that create files and subdirectories inside the directory. */ -class TestDir : public KTempDir +class TestDir : public QTemporaryDir { public: @@ -50,6 +49,7 @@ public: void createDir(const QString& path, const QDateTime& time = QDateTime()); void removeFile(const QString& path); + void removeFiles(const QStringList& files); private: void makePathAbsoluteAndCreateParents(QString& path); diff --git a/src/tests/viewpropertiestest.cpp b/src/tests/viewpropertiestest.cpp index d5584ce82..ba2ca307c 100644 --- a/src/tests/viewpropertiestest.cpp +++ b/src/tests/viewpropertiestest.cpp @@ -17,12 +17,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ -#include - #include "dolphin_generalsettings.h" #include "views/viewproperties.h" #include "testdir.h" +#include #include class ViewPropertiesTest : public QObject @@ -68,29 +67,27 @@ void ViewPropertiesTest::cleanup() */ void ViewPropertiesTest::testReadOnlyBehavior() { - QString dotDirectoryFile = m_testDir->url().toLocalFile() + ".directory"; + QString dotDirectoryFile = m_testDir->url().toLocalFile() + "/.directory"; QVERIFY(!QFile::exists(dotDirectoryFile)); - ViewProperties* props = new ViewProperties(m_testDir->url()); + QScopedPointer props(new ViewProperties(m_testDir->url())); QVERIFY(props->isAutoSaveEnabled()); const QByteArray sortRole = props->sortRole(); Q_UNUSED(sortRole); - delete props; - props = 0; + props.reset(); QVERIFY(!QFile::exists(dotDirectoryFile)); } void ViewPropertiesTest::testAutoSave() { - QString dotDirectoryFile = m_testDir->url().toLocalFile() + ".directory"; + QString dotDirectoryFile = m_testDir->url().toLocalFile() + "/.directory"; QVERIFY(!QFile::exists(dotDirectoryFile)); - ViewProperties* props = new ViewProperties(m_testDir->url()); + QScopedPointer props(new ViewProperties(m_testDir->url())); QVERIFY(props->isAutoSaveEnabled()); props->setSortRole("someNewSortRole"); - delete props; - props = 0; + props.reset(); QVERIFY(QFile::exists(dotDirectoryFile)); } -- cgit v1.3.1 From fdb5c0d33e38e9d5fedc821c586bbb5ca8a0d2a5 Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Fri, 30 Jan 2015 13:08:35 +0100 Subject: Port away from KGlobalSettings::naturalSorting() by moving it to Dolphin's GeneralSettings REVIEW: 122310 --- src/CMakeLists.txt | 4 ++-- src/kitemviews/kfileitemmodel.cpp | 9 +++++---- src/settings/dolphin_generalsettings.kcfg | 6 ++++++ src/settings/general/behaviorsettingspage.cpp | 10 ++-------- src/tests/CMakeLists.txt | 18 +++++++++++++++++- 5 files changed, 32 insertions(+), 15 deletions(-) (limited to 'src/tests/CMakeLists.txt') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d2ea49314..748b09316 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,7 +81,7 @@ if(HAVE_BALOO) ) endif() -kconfig_add_kcfg_files(dolphinprivate_LIB_SRCS +kconfig_add_kcfg_files(dolphinprivate_LIB_SRCS GENERATE_MOC settings/dolphin_compactmodesettings.kcfgc settings/dolphin_directoryviewpropertysettings.kcfgc settings/dolphin_detailsmodesettings.kcfgc @@ -204,7 +204,7 @@ set(dolphin_SRCS views/zoomlevelinfo.cpp ) -kconfig_add_kcfg_files(dolphin_SRCS +kconfig_add_kcfg_files(dolphin_SRCS GENERATE_MOC panels/folders/dolphin_folderspanelsettings.kcfgc panels/information/dolphin_informationpanelsettings.kcfgc panels/places/dolphin_placespanelsettings.kcfgc diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 98249dbd9..019891211 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -21,7 +21,8 @@ #include "kfileitemmodel.h" -#include +#include "dolphin_generalsettings.h" + #include #include #include @@ -41,7 +42,7 @@ KFileItemModel::KFileItemModel(QObject* parent) : KItemModelBase("text", parent), m_dirLister(0), - m_naturalSorting(KGlobalSettings::naturalSorting()), + m_naturalSorting(GeneralSettings::naturalSorting()), m_sortDirsFirst(true), m_sortRole(NameRole), m_sortingProgressPercent(-1), @@ -106,7 +107,7 @@ KFileItemModel::KFileItemModel(QObject* parent) : m_resortAllItemsTimer->setSingleShot(true); connect(m_resortAllItemsTimer, &QTimer::timeout, this, &KFileItemModel::resortAllItems); - connect(KGlobalSettings::self(), &KGlobalSettings::naturalSortingChanged, + connect(GeneralSettings::self(), &GeneralSettings::naturalSortingChanged, this, &KFileItemModel::slotNaturalSortingChanged); } @@ -1105,7 +1106,7 @@ void KFileItemModel::slotClear() void KFileItemModel::slotNaturalSortingChanged() { - m_naturalSorting = KGlobalSettings::naturalSorting(); + m_naturalSorting = GeneralSettings::naturalSorting(); resortAllItems(); } diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg index 3c820e28e..2f230bf51 100644 --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -8,6 +8,7 @@ QUrl kglobalsettings.h + @@ -92,5 +93,10 @@ true + + + true + + diff --git a/src/settings/general/behaviorsettingspage.cpp b/src/settings/general/behaviorsettingspage.cpp index 83515beb0..093a1f4e1 100644 --- a/src/settings/general/behaviorsettingspage.cpp +++ b/src/settings/general/behaviorsettingspage.cpp @@ -97,6 +97,7 @@ void BehaviorSettingsPage::applySettings() settings->setShowToolTips(m_showToolTips->isChecked()); settings->setShowSelectionToggle(m_showSelectionToggle->isChecked()); + settings->setNaturalSorting(m_naturalSorting->isChecked()); settings->setRenameInline(m_renameInline->isChecked()); settings->save(); @@ -108,13 +109,6 @@ void BehaviorSettingsPage::applySettings() ViewProperties globalProps(m_url); globalProps.setDirProperties(props); } - - const bool naturalSorting = m_naturalSorting->isChecked(); - if (KGlobalSettings::naturalSorting() != naturalSorting) { - KConfigGroup group(KSharedConfig::openConfig(), "KDE"); - group.writeEntry("NaturalSorting", naturalSorting, KConfig::Persistent | KConfig::Global); - KGlobalSettings::emitChange(KGlobalSettings::NaturalSortingChanged); - } } void BehaviorSettingsPage::restoreDefaults() @@ -133,7 +127,7 @@ void BehaviorSettingsPage::loadSettings() m_showToolTips->setChecked(GeneralSettings::showToolTips()); m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle()); - m_naturalSorting->setChecked(KGlobalSettings::naturalSorting()); + m_naturalSorting->setChecked(GeneralSettings::naturalSorting()); m_renameInline->setChecked(GeneralSettings::renameInline()); } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index a69400baa..fe9665d11 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -58,6 +58,10 @@ set(kitemlistcontrollertest_SRCS ../kitemviews/kstandarditemlistwidget.cpp ) +kconfig_add_kcfg_files(kitemlistcontrollertest_SRCS GENERATE_MOC + ../settings/dolphin_generalsettings.kcfgc +) + add_executable(kitemlistcontrollertest ${kitemlistcontrollertest_SRCS}) add_test(kitemlistcontrollertest kitemlistcontrollertest) ecm_mark_as_test(kitemlistcontrollertest) @@ -79,6 +83,10 @@ set(kfileitemlistviewtest_SRCS ../kitemviews/kstandarditemlistwidget.cpp ) +kconfig_add_kcfg_files(kfileitemlistviewtest_SRCS GENERATE_MOC + ../settings/dolphin_generalsettings.kcfgc +) + add_executable(kfileitemlistviewtest ${kfileitemlistviewtest_SRCS}) add_test(kfileitemlistviewtest kfileitemlistviewtest) ecm_mark_as_test(kfileitemlistviewtest) @@ -93,6 +101,10 @@ set(kfileitemmodeltest_SRCS ../kitemviews/kitemset.cpp ) +kconfig_add_kcfg_files(kfileitemmodeltest_SRCS GENERATE_MOC + ../settings/dolphin_generalsettings.kcfgc +) + add_executable(kfileitemmodeltest ${kfileitemmodeltest_SRCS}) add_test(kfileitemmodeltest kfileitemmodeltest) ecm_mark_as_test(kfileitemmodeltest) @@ -106,6 +118,10 @@ set(kfileitemmodelbenchmark_SRCS ../kitemviews/kitemmodelbase.cpp ) +kconfig_add_kcfg_files(kfileitemmodelbenchmark_SRCS GENERATE_MOC + ../settings/dolphin_generalsettings.kcfgc +) + add_executable(kfileitemmodelbenchmark ${kfileitemmodelbenchmark_SRCS}) ecm_mark_as_test(kfileitemmodelbenchmark) target_link_libraries(kfileitemmodelbenchmark dolphinprivate Qt5::Test) @@ -157,7 +173,7 @@ set(viewpropertiestest_SRCS testdir.cpp ../views/viewproperties.cpp ) -kconfig_add_kcfg_files(viewpropertiestest_SRCS +kconfig_add_kcfg_files(viewpropertiestest_SRCS GENERATE_MOC ../settings/dolphin_generalsettings.kcfgc ../settings/dolphin_directoryviewpropertysettings.kcfgc ) -- cgit v1.3.1 From f6b4f562167969365d4aae14d73060c6fdb8270f Mon Sep 17 00:00:00 2001 From: Hrvoje Senjan Date: Tue, 24 Feb 2015 17:07:55 +0100 Subject: Fix build on Jenkins (or with BUILD_TESTING=ON) --- src/CMakeLists.txt | 2 ++ src/dolphinpart.cpp | 6 +++--- src/main.cpp | 4 ++-- src/tests/CMakeLists.txt | 6 ++++++ src/tests/kstandarditemmodeltest.cpp | 2 ++ 5 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/tests/CMakeLists.txt') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4637e09d0..ea21f1af2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -129,6 +129,7 @@ install(TARGETS dolphinprivate ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) set(dolphinpart_SRCS dolphinpart.cpp dolphinpart_ext.cpp + dolphindebug.cpp ) add_library(dolphinpart MODULE ${dolphinpart_SRCS}) @@ -202,6 +203,7 @@ set(dolphin_SRCS statusbar/spaceinfoobserver.cpp statusbar/statusbarspaceinfo.cpp views/zoomlevelinfo.cpp + dolphindebug.cpp ) kconfig_add_kcfg_files(dolphin_SRCS GENERATE_MOC diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 2679ac3df..35f328be5 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -138,7 +138,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL connect(lister, &KDirLister::newItems, notifyExt, &DolphinPartListingNotificationExtension::slotNewItems); connect(lister, &KDirLister::itemsDeleted, notifyExt, &DolphinPartListingNotificationExtension::slotItemsDeleted); } else { - // qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported"; + qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported"; } createActions(); @@ -340,7 +340,7 @@ void DolphinPart::slotMessage(const QString& msg) void DolphinPart::slotErrorMessage(const QString& msg) { - // qCDebug(DolphinDebug) << msg; + qCDebug(DolphinDebug) << msg; emit canceled(msg); //KMessageBox::error(m_view, msg); } @@ -471,7 +471,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos, void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl) { - // qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url(); + qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url(); if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) { KParts::ReadOnlyPart::setUrl(newUrl); const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile); diff --git a/src/main.cpp b/src/main.cpp index 3c9dd6130..b8eb9a556 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -109,7 +109,7 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) if (url.isValid()) { urls.append(url); } else { - // qCWarning(DolphinDebug) << "Invalid URL: " << str; + qCWarning(DolphinDebug) << "Invalid URL: " << str; } } @@ -152,7 +152,7 @@ extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv) if (className == QLatin1String("DolphinMainWindow")) { m_mainWindow->restore(1); } else { - // qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!"; + qCWarning(DolphinDebug) << "Unknown class " << className << " in session saved data!"; } } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index fe9665d11..1c6c5b40c 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -56,6 +56,7 @@ set(kitemlistcontrollertest_SRCS ../kitemviews/kitemset.cpp ../kitemviews/kstandarditemlistview.cpp ../kitemviews/kstandarditemlistwidget.cpp + ../dolphindebug.cpp ) kconfig_add_kcfg_files(kitemlistcontrollertest_SRCS GENERATE_MOC @@ -81,6 +82,7 @@ set(kfileitemlistviewtest_SRCS ../kitemviews/kitemset.cpp ../kitemviews/kstandarditemlistview.cpp ../kitemviews/kstandarditemlistwidget.cpp + ../dolphindebug.cpp ) kconfig_add_kcfg_files(kfileitemlistviewtest_SRCS GENERATE_MOC @@ -99,6 +101,7 @@ set(kfileitemmodeltest_SRCS ../kitemviews/kfileitemmodel.cpp ../kitemviews/kitemmodelbase.cpp ../kitemviews/kitemset.cpp + ../dolphindebug.cpp ) kconfig_add_kcfg_files(kfileitemmodeltest_SRCS GENERATE_MOC @@ -116,6 +119,7 @@ set(kfileitemmodelbenchmark_SRCS testdir.cpp ../kitemviews/kfileitemmodel.cpp ../kitemviews/kitemmodelbase.cpp + ../dolphindebug.cpp ) kconfig_add_kcfg_files(kfileitemmodelbenchmark_SRCS GENERATE_MOC @@ -160,6 +164,7 @@ set(kstandarditemmodeltest_SRCS ../kitemviews/kstandarditem.cpp ../kitemviews/kstandarditemmodel.cpp ../kitemviews/kitemmodelbase.cpp + ../dolphindebug.cpp ) add_executable(kstandarditemmodeltest ${kstandarditemmodeltest_SRCS}) @@ -172,6 +177,7 @@ set(viewpropertiestest_SRCS viewpropertiestest.cpp testdir.cpp ../views/viewproperties.cpp + ../dolphindebug.cpp ) kconfig_add_kcfg_files(viewpropertiestest_SRCS GENERATE_MOC ../settings/dolphin_generalsettings.kcfgc diff --git a/src/tests/kstandarditemmodeltest.cpp b/src/tests/kstandarditemmodeltest.cpp index ea65cc4ce..93aaf3686 100644 --- a/src/tests/kstandarditemmodeltest.cpp +++ b/src/tests/kstandarditemmodeltest.cpp @@ -18,6 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ +#include "dolphindebug.h" + #include "kitemviews/kstandarditem.h" #include "kitemviews/kstandarditemmodel.h" -- cgit v1.3.1 From 25751088c33ce507096a3e25ee1eeaa7de38c76b Mon Sep 17 00:00:00 2001 From: Emmanuel Pescosta Date: Wed, 25 Feb 2015 12:12:55 +0100 Subject: Move the KVersionControlPlugin2 interface from konqlib to Dolphin and remove the deprecated KVersionControlPlugin interface from konqlib REVIEW: 122687 --- CMakeLists.txt | 42 +++- DolphinVcsConfig.cmake.in | 6 + src/CMakeLists.txt | 50 ++++- src/dolphinnewfilemenu.h | 4 +- src/dolphinremoveaction.h | 4 +- src/kitemviews/kfileitemlistview.h | 4 +- src/kitemviews/kfileitemlistwidget.h | 6 +- src/kitemviews/kfileitemmodel.h | 4 +- src/kitemviews/kfileitemmodelrolesupdater.cpp | 1 + src/kitemviews/kfileitemmodelrolesupdater.h | 4 +- src/kitemviews/kitemlistcontainer.h | 4 +- src/kitemviews/kitemlistcontroller.h | 4 +- src/kitemviews/kitemlistgroupheader.h | 4 +- src/kitemviews/kitemlistheader.h | 4 +- src/kitemviews/kitemlistselectionmanager.h | 4 +- src/kitemviews/kitemliststyleoption.h | 4 +- src/kitemviews/kitemlistview.h | 10 +- src/kitemviews/kitemlistviewaccessible.h | 8 +- src/kitemviews/kitemlistwidget.h | 6 +- src/kitemviews/kitemmodelbase.h | 4 +- src/kitemviews/kstandarditem.h | 4 +- src/kitemviews/kstandarditemlistgroupheader.h | 4 +- src/kitemviews/kstandarditemlistview.h | 4 +- src/kitemviews/kstandarditemlistwidget.h | 6 +- src/kitemviews/kstandarditemmodel.h | 4 +- src/kitemviews/private/kbaloorolesprovider.h | 4 +- src/kitemviews/private/kfileitemclipboard.h | 4 +- src/kitemviews/private/kfileitemmodeldirlister.h | 4 +- src/kitemviews/private/kfileitemmodelfilter.h | 4 +- src/kitemviews/private/kitemlistheaderwidget.h | 4 +- .../private/kitemlistkeyboardsearchmanager.h | 4 +- src/kitemviews/private/kitemlistroleeditor.h | 4 +- src/kitemviews/private/kitemlistrubberband.h | 4 +- src/kitemviews/private/kitemlistselectiontoggle.h | 4 +- src/kitemviews/private/kitemlistsizehintresolver.h | 4 +- src/kitemviews/private/kitemlistsmoothscroller.h | 4 +- src/kitemviews/private/kitemlistviewanimation.h | 4 +- src/kitemviews/private/kitemlistviewlayouter.h | 4 +- src/kitemviews/private/kpixmapmodifier.h | 4 +- src/settings/viewpropertiesdialog.h | 4 +- src/tests/CMakeLists.txt | 2 +- src/views/dolphinfileitemlistwidget.cpp | 29 ++- src/views/dolphinfileitemlistwidget.h | 8 +- src/views/dolphinitemlistview.h | 4 +- src/views/dolphinnewfilemenuobserver.h | 4 +- src/views/dolphinremoteencoding.h | 4 +- src/views/dolphinview.h | 4 +- src/views/dolphinviewactionhandler.h | 4 +- src/views/draganddrophelper.h | 4 +- src/views/renamedialog.h | 4 +- src/views/versioncontrol/kversioncontrolplugin.cpp | 29 +++ src/views/versioncontrol/kversioncontrolplugin.h | 223 +++++++++++++++++++++ .../versioncontrol/updateitemstatesthread.cpp | 20 +- src/views/versioncontrol/updateitemstatesthread.h | 6 +- .../versioncontrol/versioncontrolobserver.cpp | 41 +--- src/views/versioncontrol/versioncontrolobserver.h | 10 +- src/views/viewmodecontroller.h | 4 +- src/views/viewproperties.h | 4 +- 58 files changed, 469 insertions(+), 194 deletions(-) create mode 100644 DolphinVcsConfig.cmake.in create mode 100644 src/views/versioncontrol/kversioncontrolplugin.cpp create mode 100644 src/views/versioncontrol/kversioncontrolplugin.h (limited to 'src/tests/CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 570910497..3a3ab6d4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,18 +3,25 @@ cmake_minimum_required(VERSION 2.8.12) project(Dolphin) # ECM setup -find_package(ECM 1.2.0 CONFIG REQUIRED) +find_package(ECM 1.6.0 CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(DOLPHIN_VERSION "4.97.0") include(ECMSetupVersion) +include(ECMGenerateHeaders) include(GenerateExportHeader) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings) +ecm_setup_version(${DOLPHIN_VERSION} VARIABLE_PREFIX DOLPHINVCS + VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h" + PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake" + SOVERSION 5 +) + ecm_setup_version(${DOLPHIN_VERSION} VARIABLE_PREFIX DOLPHINPRIVATE SOVERSION 5 ) @@ -24,12 +31,6 @@ find_package(KF5 COMPONENTS Activities) find_package(Phonon4Qt5 CONFIG REQUIRED) -if ("${CMAKE_SOURCE_DIR}" STREQUAL "${Dolphin_SOURCE_DIR}") - find_package(KF5Konq CONFIG REQUIRED) -else() - include_directories(${LibKonq_SOURCE_DIR}/src) -endif() - find_package(KF5Baloo 4.97) set_package_properties(KF5Baloo PROPERTIES DESCRIPTION "Baloo Core libraries" URL "http://www.kde.org" @@ -58,6 +59,33 @@ endif() add_subdirectory(src) add_subdirectory(docs) +# CMake files +set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/Dolphin") + +ecm_configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/DolphinVcsConfig.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfig.cmake" + INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/DolphinVcsConfigVersion.cmake" + DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + COMPONENT Devel +) + +install(EXPORT DolphinVcsTargets + DESTINATION "${CMAKECONFIG_INSTALL_DIR}" + FILE DolphinVcsTargets.cmake +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/dolphinvcs_version.h" + DESTINATION "${KDE_INSTALL_INCLUDEDIR}/Dolphin" + COMPONENT Devel +) + # TODO Remove the if/endif lines if Dolphin is split. if ("${CMAKE_SOURCE_DIR}" STREQUAL "${Dolphin_SOURCE_DIR}") feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/DolphinVcsConfig.cmake.in b/DolphinVcsConfig.cmake.in new file mode 100644 index 000000000..7e7a2296f --- /dev/null +++ b/DolphinVcsConfig.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ + +find_dependency(Qt5Widgets) +find_dependency(KF5KIO) + +include("${CMAKE_CURRENT_LIST_DIR}/DolphinVcsTargets.cmake") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea21f1af2..2b65671da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,42 @@ endif() configure_file(config-X11.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-X11.h) +########################################## + +set(dolphinvcs_LIB_SRCS + views/versioncontrol/kversioncontrolplugin.cpp +) + +add_library(dolphinvcs ${dolphinvcs_LIB_SRCS}) + +generate_export_header(dolphinvcs BASE_NAME dolphin) + +target_link_libraries( + dolphinvcs PUBLIC + Qt5::Widgets + KF5::KIOCore +) + +set_target_properties(dolphinvcs PROPERTIES + VERSION ${DOLPHINVCS_VERSION_STRING} + SOVERSION ${DOLPHINVCS_SOVERSION} + EXPORT_NAME DolphinVcs +) + +ecm_generate_headers(dolphinvcs_LIB_HEADERS + HEADER_NAMES + KVersionControlPlugin + + RELATIVE "views/versioncontrol" + REQUIRED_HEADERS dolphinvcs_LIB_HEADERS +) + +install(TARGETS dolphinvcs EXPORT DolphinVcsTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + +install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPES5DIR}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dolphin_export.h DESTINATION ${KDE_INSTALL_INCLUDEDIR} COMPONENT Devel) +install(FILES ${dolphinvcs_LIB_HEADERS} DESTINATION "${KDE_INSTALL_INCLUDEDIR}/Dolphin" COMPONENT Devel) + ########### next target ############### set(dolphinprivate_LIB_SRCS @@ -93,13 +129,10 @@ kconfig_add_kcfg_files(dolphinprivate_LIB_SRCS GENERATE_MOC add_library(dolphinprivate ${dolphinprivate_LIB_SRCS}) -generate_export_header(dolphinprivate BASE_NAME libdolphinprivate - EXPORT_FILE_NAME libdolphin_export.h) - target_link_libraries( dolphinprivate PUBLIC + dolphinvcs KF5::KDELibs4Support - KF5::Konq KF5::NewStuff ) @@ -122,7 +155,7 @@ set_target_properties(dolphinprivate PROPERTIES SOVERSION ${DOLPHINPRIVATE_SOVERSION} ) -install(TARGETS dolphinprivate ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS dolphinprivate ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) ########################################## @@ -136,7 +169,6 @@ add_library(dolphinpart MODULE ${dolphinpart_SRCS}) target_link_libraries(dolphinpart dolphinprivate - KF5::Konq KF5::KDELibs4Support ) @@ -144,7 +176,6 @@ install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR}) install(FILES dolphinpart.rc DESTINATION ${CMAKE_INSTALL_KXMLGUI5DIR}/dolphinpart) install(FILES dolphinpart.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install(FILES views/versioncontrol/fileviewversioncontrolplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR}) ########################################## @@ -230,7 +261,6 @@ kf5_add_kdeinit_executable(dolphin ${dolphin_SRCS}) target_include_directories(kdeinit_dolphin PRIVATE ${PHONON_INCLUDES}) target_link_libraries(kdeinit_dolphin - KF5::Konq dolphinprivate KF5::NewStuff KF5::Parts @@ -251,8 +281,8 @@ if (KF5Activities_FOUND) ) endif() -install(TARGETS kdeinit_dolphin ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) -install(TARGETS dolphin ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS kdeinit_dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) +install(TARGETS dolphin ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) ########################################## diff --git a/src/dolphinnewfilemenu.h b/src/dolphinnewfilemenu.h index 254571eb9..9f1cb5599 100644 --- a/src/dolphinnewfilemenu.h +++ b/src/dolphinnewfilemenu.h @@ -23,7 +23,7 @@ #include -#include "libdolphin_export.h" +#include "dolphin_export.h" class KJob; @@ -35,7 +35,7 @@ class KJob; * All errors are shown in the status bar of Dolphin * instead as modal error dialog with an OK button. */ -class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenu : public KNewFileMenu +class DOLPHIN_EXPORT DolphinNewFileMenu : public KNewFileMenu { Q_OBJECT diff --git a/src/dolphinremoveaction.h b/src/dolphinremoveaction.h index 1a123ace5..85f404318 100644 --- a/src/dolphinremoveaction.h +++ b/src/dolphinremoveaction.h @@ -20,7 +20,7 @@ #ifndef DOLPHINREMOVEACTION_H #define DOLPHINREMOVEACTION_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -34,7 +34,7 @@ * This class expects the presence of both the "move_to_trash" and "delete" * actions in @ref collection. */ -class LIBDOLPHINPRIVATE_EXPORT DolphinRemoveAction : public QAction +class DOLPHIN_EXPORT DolphinRemoveAction : public QAction { Q_OBJECT public: diff --git a/src/kitemviews/kfileitemlistview.h b/src/kitemviews/kfileitemlistview.h index 72688893e..84aa17d89 100644 --- a/src/kitemviews/kfileitemlistview.h +++ b/src/kitemviews/kfileitemlistview.h @@ -20,7 +20,7 @@ #ifndef KFILEITEMLISTVIEW_H #define KFILEITEMLISTVIEW_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -36,7 +36,7 @@ class QTimer; * KItemListView::setWidgetCreator() and KItemListView::setGroupHeaderCreator() * to apply customized generators. */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemListView : public KStandardItemListView +class DOLPHIN_EXPORT KFileItemListView : public KStandardItemListView { Q_OBJECT diff --git a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h index 32959e4f6..07ca59b44 100644 --- a/src/kitemviews/kfileitemlistwidget.h +++ b/src/kitemviews/kfileitemlistwidget.h @@ -20,11 +20,11 @@ #ifndef KFILEITEMLISTWIDGET_H #define KFILEITEMLISTWIDGET_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include -class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant +class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidgetInformant { public: KFileItemListWidgetInformant(); @@ -37,7 +37,7 @@ protected: virtual QFont customizedFontForLinks(const QFont& baseFont) const Q_DECL_OVERRIDE; }; -class LIBDOLPHINPRIVATE_EXPORT KFileItemListWidget : public KStandardItemListWidget +class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget { Q_OBJECT diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 8e36294e9..167f508cf 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -20,7 +20,7 @@ #ifndef KFILEITEMMODEL_H #define KFILEITEMMODEL_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include #include @@ -43,7 +43,7 @@ class QTimer; * Recursive expansion of sub-directories is supported by * KFileItemModel::setExpanded(). */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemModel : public KItemModelBase +class DOLPHIN_EXPORT KFileItemModel : public KItemModelBase { Q_OBJECT diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index f17a77e0a..c18d65892 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index 6c82dbe4a..216b0a501 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -25,7 +25,7 @@ #include #include -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -87,7 +87,7 @@ namespace KIO { * 3. Finally, the entire process is repeated for any items that might have * changed in the mean time. */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemModelRolesUpdater : public QObject +class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject { Q_OBJECT diff --git a/src/kitemviews/kitemlistcontainer.h b/src/kitemviews/kitemlistcontainer.h index 6f2851b3e..9fc3d4957 100644 --- a/src/kitemviews/kitemlistcontainer.h +++ b/src/kitemviews/kitemlistcontainer.h @@ -23,7 +23,7 @@ #ifndef KITEMLISTCONTAINER_H #define KITEMLISTCONTAINER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -39,7 +39,7 @@ class KItemModelBase; * * @see KItemListController */ -class LIBDOLPHINPRIVATE_EXPORT KItemListContainer : public QAbstractScrollArea +class DOLPHIN_EXPORT KItemListContainer : public QAbstractScrollArea { Q_OBJECT diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index 2824a1fc9..b8a93edac 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -23,7 +23,7 @@ #ifndef KITEMLISTCONTROLLER_H #define KITEMLISTCONTROLLER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include "kitemset.h" @@ -56,7 +56,7 @@ class QTransform; * @see KItemModelBase * @see KItemListSelectionManager */ -class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject +class DOLPHIN_EXPORT KItemListController : public QObject { Q_OBJECT Q_ENUMS(SelectionBehavior) diff --git a/src/kitemviews/kitemlistgroupheader.h b/src/kitemviews/kitemlistgroupheader.h index c89da5027..4612bc4da 100644 --- a/src/kitemviews/kitemlistgroupheader.h +++ b/src/kitemviews/kitemlistgroupheader.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTGROUPHEADER_H #define KITEMLISTGROUPHEADER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -37,7 +37,7 @@ class KItemListView; * the method paint() and draw the role within the given roleBounds() with * the color roleColor(). */ -class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeader : public QGraphicsWidget +class DOLPHIN_EXPORT KItemListGroupHeader : public QGraphicsWidget { Q_OBJECT diff --git a/src/kitemviews/kitemlistheader.h b/src/kitemviews/kitemlistheader.h index b361b912b..cc2b74793 100644 --- a/src/kitemviews/kitemlistheader.h +++ b/src/kitemviews/kitemlistheader.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTHEADER_H #define KITEMLISTHEADER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -33,7 +33,7 @@ class KItemListView; * Each column of the header represents a visible role * accessible by KItemListView::visibleRoles(). */ -class LIBDOLPHINPRIVATE_EXPORT KItemListHeader : public QObject +class DOLPHIN_EXPORT KItemListHeader : public QObject { Q_OBJECT diff --git a/src/kitemviews/kitemlistselectionmanager.h b/src/kitemviews/kitemlistselectionmanager.h index a8318388c..16761428b 100644 --- a/src/kitemviews/kitemlistselectionmanager.h +++ b/src/kitemviews/kitemlistselectionmanager.h @@ -23,7 +23,7 @@ #ifndef KITEMLISTSELECTIONMANAGER_H #define KITEMLISTSELECTIONMANAGER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -35,7 +35,7 @@ class KItemModelBase; /** * @brief Allows to select and deselect items of a KItemListView. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionManager : public QObject +class DOLPHIN_EXPORT KItemListSelectionManager : public QObject { Q_OBJECT diff --git a/src/kitemviews/kitemliststyleoption.h b/src/kitemviews/kitemliststyleoption.h index 9290dc341..09b787c27 100644 --- a/src/kitemviews/kitemliststyleoption.h +++ b/src/kitemviews/kitemliststyleoption.h @@ -20,14 +20,14 @@ #ifndef KITEMLISTSTYLEOPTION_H #define KITEMLISTSTYLEOPTION_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include #include #include -class LIBDOLPHINPRIVATE_EXPORT KItemListStyleOption +class DOLPHIN_EXPORT KItemListStyleOption { public: KItemListStyleOption(); diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 8130e45ed..f20180289 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -23,7 +23,7 @@ #ifndef KITEMLISTVIEW_H #define KITEMLISTVIEW_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -59,7 +59,7 @@ class QTimer; * @see KItemListWidget * @see KItemModelBase */ -class LIBDOLPHINPRIVATE_EXPORT KItemListView : public QGraphicsWidget +class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget { Q_OBJECT @@ -769,7 +769,7 @@ private: * KItemListWidgetCreatorBase and KItemListGroupHeaderCreatorBase. * @internal */ -class LIBDOLPHINPRIVATE_EXPORT KItemListCreatorBase +class DOLPHIN_EXPORT KItemListCreatorBase { public: virtual ~KItemListCreatorBase(); @@ -793,7 +793,7 @@ private: * expensive instantiations and deletions of KItemListWidgets by recycling existing widget * instances. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase +class DOLPHIN_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase { public: virtual ~KItemListWidgetCreatorBase(); @@ -875,7 +875,7 @@ qreal KItemListWidgetCreator::preferredRoleColumnWidth(const QByteArray& role * The intention of the group-header creator is to prevent repetitive and expensive instantiations and * deletions of KItemListGroupHeaders by recycling existing header instances. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase +class DOLPHIN_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase { public: virtual ~KItemListGroupHeaderCreatorBase(); diff --git a/src/kitemviews/kitemlistviewaccessible.h b/src/kitemviews/kitemlistviewaccessible.h index 28b0be4e6..afef2d5fe 100644 --- a/src/kitemviews/kitemlistviewaccessible.h +++ b/src/kitemviews/kitemlistviewaccessible.h @@ -22,7 +22,7 @@ #ifndef QT_NO_ACCESSIBILITY -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -32,7 +32,7 @@ class KItemListView; class KItemListContainer; -class LIBDOLPHINPRIVATE_EXPORT KItemListViewAccessible: public QAccessibleObject, public QAccessibleTableInterface +class DOLPHIN_EXPORT KItemListViewAccessible: public QAccessibleObject, public QAccessibleTableInterface { public: explicit KItemListViewAccessible(KItemListView* view); @@ -89,7 +89,7 @@ private: mutable QVector m_cells; }; -class LIBDOLPHINPRIVATE_EXPORT KItemListAccessibleCell: public QAccessibleInterface, public QAccessibleTableCellInterface +class DOLPHIN_EXPORT KItemListAccessibleCell: public QAccessibleInterface, public QAccessibleTableCellInterface { public: KItemListAccessibleCell(KItemListView* view, int m_index); @@ -128,7 +128,7 @@ private: int m_index; }; -class LIBDOLPHINPRIVATE_EXPORT KItemListContainerAccessible : public QAccessibleWidget +class DOLPHIN_EXPORT KItemListContainerAccessible : public QAccessibleWidget { public: explicit KItemListContainerAccessible(KItemListContainer* container); diff --git a/src/kitemviews/kitemlistwidget.h b/src/kitemviews/kitemlistwidget.h index 723847c43..ae99a1f29 100644 --- a/src/kitemviews/kitemlistwidget.h +++ b/src/kitemviews/kitemlistwidget.h @@ -23,7 +23,7 @@ #ifndef KITEMLISTWIDGET_H #define KITEMLISTWIDGET_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -43,7 +43,7 @@ class QPropertyAnimation; * size for the invisible items must be accessible. KItemListWidgetInformant * provides this information. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetInformant +class DOLPHIN_EXPORT KItemListWidgetInformant { public: KItemListWidgetInformant(); @@ -63,7 +63,7 @@ public: * All properties are set by KItemListView, for each property there is a corresponding * virtual protected method that allows to react on property changes. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListWidget : public QGraphicsWidget +class DOLPHIN_EXPORT KItemListWidget : public QGraphicsWidget { Q_OBJECT diff --git a/src/kitemviews/kitemmodelbase.h b/src/kitemviews/kitemmodelbase.h index e46d761fc..bd5ca1d65 100644 --- a/src/kitemviews/kitemmodelbase.h +++ b/src/kitemviews/kitemmodelbase.h @@ -23,7 +23,7 @@ #ifndef KITEMMODELBASE_H #define KITEMMODELBASE_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -49,7 +49,7 @@ class QMimeData; * Also optionally it is possible to provide a tree of items by implementing the methods * setExpanded(), isExpanded(), isExpandable() and expandedParentsCount(). */ -class LIBDOLPHINPRIVATE_EXPORT KItemModelBase : public QObject +class DOLPHIN_EXPORT KItemModelBase : public QObject { Q_OBJECT diff --git a/src/kitemviews/kstandarditem.h b/src/kitemviews/kstandarditem.h index b1d5edf2e..5bb2bb36f 100644 --- a/src/kitemviews/kstandarditem.h +++ b/src/kitemviews/kstandarditem.h @@ -20,7 +20,7 @@ #ifndef KSTANDARDITEM_H #define KSTANDARDITEM_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -36,7 +36,7 @@ class KStandardItemModel; * used roles. It is possible to assign values for custom * roles by using setDataValue(). */ -class LIBDOLPHINPRIVATE_EXPORT KStandardItem +class DOLPHIN_EXPORT KStandardItem { public: diff --git a/src/kitemviews/kstandarditemlistgroupheader.h b/src/kitemviews/kstandarditemlistgroupheader.h index caf906ddf..f0eacfd49 100644 --- a/src/kitemviews/kstandarditemlistgroupheader.h +++ b/src/kitemviews/kstandarditemlistgroupheader.h @@ -20,14 +20,14 @@ #ifndef KSTANDARDITEMLISTGROUPHEADER_H #define KSTANDARDITEMLISTGROUPHEADER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include #include -class LIBDOLPHINPRIVATE_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader +class DOLPHIN_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader { Q_OBJECT diff --git a/src/kitemviews/kstandarditemlistview.h b/src/kitemviews/kstandarditemlistview.h index 9fc43a940..2e4c7a0a0 100644 --- a/src/kitemviews/kstandarditemlistview.h +++ b/src/kitemviews/kstandarditemlistview.h @@ -20,7 +20,7 @@ #ifndef KSTANDARDITEMLISTVIEW_H #define KSTANDARDITEMLISTVIEW_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -40,7 +40,7 @@ * KItemListContainer* container = new KItemListContainer(controller, parentWidget); * */ -class LIBDOLPHINPRIVATE_EXPORT KStandardItemListView : public KItemListView +class DOLPHIN_EXPORT KStandardItemListView : public KItemListView { Q_OBJECT diff --git a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h index 8e61d06b4..826452255 100644 --- a/src/kitemviews/kstandarditemlistwidget.h +++ b/src/kitemviews/kstandarditemlistwidget.h @@ -20,7 +20,7 @@ #ifndef KSTANDARDITEMLISTWIDGET_H #define KSTANDARDITEMLISTWIDGET_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -32,7 +32,7 @@ class KItemListRoleEditor; class KItemListStyleOption; class KItemListView; -class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant +class DOLPHIN_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetInformant { public: KStandardItemListWidgetInformant(); @@ -83,7 +83,7 @@ protected: /** * @brief Itemlist widget implementation for KStandardItemView and KStandardItemModel. */ -class LIBDOLPHINPRIVATE_EXPORT KStandardItemListWidget : public KItemListWidget +class DOLPHIN_EXPORT KStandardItemListWidget : public KItemListWidget { Q_OBJECT diff --git a/src/kitemviews/kstandarditemmodel.h b/src/kitemviews/kstandarditemmodel.h index 3b5f5bd39..58c5a5d88 100644 --- a/src/kitemviews/kstandarditemmodel.h +++ b/src/kitemviews/kstandarditemmodel.h @@ -20,7 +20,7 @@ #ifndef KSTANDARDITEMMODEL_H #define KSTANDARDITEMMODEL_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include #include @@ -35,7 +35,7 @@ class KStandardItem; * * @see KStandardItem */ -class LIBDOLPHINPRIVATE_EXPORT KStandardItemModel : public KItemModelBase +class DOLPHIN_EXPORT KStandardItemModel : public KItemModelBase { Q_OBJECT diff --git a/src/kitemviews/private/kbaloorolesprovider.h b/src/kitemviews/private/kbaloorolesprovider.h index ef073a367..9673bff4f 100644 --- a/src/kitemviews/private/kbaloorolesprovider.h +++ b/src/kitemviews/private/kbaloorolesprovider.h @@ -21,7 +21,7 @@ #ifndef KBALOO_ROLESPROVIDER_H #define KBALOO_ROLESPROVIDER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -36,7 +36,7 @@ namespace Baloo { * Is a helper class for KFileItemModelRolesUpdater to retrieve roles that * are only accessible with Baloo. */ -class LIBDOLPHINPRIVATE_EXPORT KBalooRolesProvider +class DOLPHIN_EXPORT KBalooRolesProvider { public: static KBalooRolesProvider& instance(); diff --git a/src/kitemviews/private/kfileitemclipboard.h b/src/kitemviews/private/kfileitemclipboard.h index d02fc0d47..3ee50d661 100644 --- a/src/kitemviews/private/kfileitemclipboard.h +++ b/src/kitemviews/private/kfileitemclipboard.h @@ -25,13 +25,13 @@ #include #include -#include "libdolphin_export.h" +#include "dolphin_export.h" /** * @brief Wrapper for QClipboard to provide fast access for checking * whether a KFileItem has been clipped. */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemClipboard : public QObject +class DOLPHIN_EXPORT KFileItemClipboard : public QObject { Q_OBJECT diff --git a/src/kitemviews/private/kfileitemmodeldirlister.h b/src/kitemviews/private/kfileitemmodeldirlister.h index a9c8c845a..c2c621aed 100644 --- a/src/kitemviews/private/kfileitemmodeldirlister.h +++ b/src/kitemviews/private/kfileitemmodeldirlister.h @@ -20,7 +20,7 @@ #ifndef KFILEITEMMODELDIRLISTER_H #define KFILEITEMMODELDIRLISTER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -29,7 +29,7 @@ * error occurred instead of showing an error dialog. * KDirLister::autoErrorHandlingEnabled() is set to false. */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemModelDirLister : public KDirLister +class DOLPHIN_EXPORT KFileItemModelDirLister : public KDirLister { Q_OBJECT diff --git a/src/kitemviews/private/kfileitemmodelfilter.h b/src/kitemviews/private/kfileitemmodelfilter.h index b26e31a00..67c1c280c 100644 --- a/src/kitemviews/private/kfileitemmodelfilter.h +++ b/src/kitemviews/private/kfileitemmodelfilter.h @@ -21,7 +21,7 @@ #ifndef KFILEITEMMODELFILTER_H #define KFILEITEMMODELFILTER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include class KFileItem; @@ -35,7 +35,7 @@ class QRegExp; * property of the KFileItem, but this might get extended in * future. */ -class LIBDOLPHINPRIVATE_EXPORT KFileItemModelFilter +class DOLPHIN_EXPORT KFileItemModelFilter { public: diff --git a/src/kitemviews/private/kitemlistheaderwidget.h b/src/kitemviews/private/kitemlistheaderwidget.h index 74c9ac518..307def74d 100644 --- a/src/kitemviews/private/kitemlistheaderwidget.h +++ b/src/kitemviews/private/kitemlistheaderwidget.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTHEADERWIDGET_H #define KITEMLISTHEADERWIDGET_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include #include @@ -33,7 +33,7 @@ class KItemModelBase; * The widget is an internal API, the user of KItemListView may only access the * class KItemListHeader. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListHeaderWidget : public QGraphicsWidget +class DOLPHIN_EXPORT KItemListHeaderWidget : public QGraphicsWidget { Q_OBJECT diff --git a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h index 1f315dabd..2a14ca470 100644 --- a/src/kitemviews/private/kitemlistkeyboardsearchmanager.h +++ b/src/kitemviews/private/kitemlistkeyboardsearchmanager.h @@ -23,7 +23,7 @@ #ifndef KITEMLISTKEYBOARDSEARCHMANAGER_H #define KITEMLISTKEYBOARDSEARCHMANAGER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -35,7 +35,7 @@ * @see KItemListController * @see KItemModelBase */ -class LIBDOLPHINPRIVATE_EXPORT KItemListKeyboardSearchManager : public QObject +class DOLPHIN_EXPORT KItemListKeyboardSearchManager : public QObject { Q_OBJECT diff --git a/src/kitemviews/private/kitemlistroleeditor.h b/src/kitemviews/private/kitemlistroleeditor.h index 7c2b61e2d..3b8f96865 100644 --- a/src/kitemviews/private/kitemlistroleeditor.h +++ b/src/kitemviews/private/kitemlistroleeditor.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTROLEEDITOR_H #define KITEMLISTROLEEDITOR_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -33,7 +33,7 @@ * * The size automatically gets increased if the text does not fit. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListRoleEditor : public KTextEdit +class DOLPHIN_EXPORT KItemListRoleEditor : public KTextEdit { Q_OBJECT diff --git a/src/kitemviews/private/kitemlistrubberband.h b/src/kitemviews/private/kitemlistrubberband.h index 39c7573ae..b47c30c1f 100644 --- a/src/kitemviews/private/kitemlistrubberband.h +++ b/src/kitemviews/private/kitemlistrubberband.h @@ -20,14 +20,14 @@ #ifndef KITEMLISTRUBBERBAND_H #define KITEMLISTRUBBERBAND_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include /** * @brief Manages the rubberband when selecting items. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListRubberBand : public QObject +class DOLPHIN_EXPORT KItemListRubberBand : public QObject { Q_OBJECT diff --git a/src/kitemviews/private/kitemlistselectiontoggle.h b/src/kitemviews/private/kitemlistselectiontoggle.h index bd64879af..d058ee988 100644 --- a/src/kitemviews/private/kitemlistselectiontoggle.h +++ b/src/kitemviews/private/kitemlistselectiontoggle.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTSELECTIONTOGGLE_H #define KITEMLISTSELECTIONTOGGLE_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -29,7 +29,7 @@ /** * @brief Allows to toggle between the selected and unselected state of an item. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListSelectionToggle : public QGraphicsWidget +class DOLPHIN_EXPORT KItemListSelectionToggle : public QGraphicsWidget { Q_OBJECT diff --git a/src/kitemviews/private/kitemlistsizehintresolver.h b/src/kitemviews/private/kitemlistsizehintresolver.h index 3bd2319dd..ff17f2de2 100644 --- a/src/kitemviews/private/kitemlistsizehintresolver.h +++ b/src/kitemviews/private/kitemlistsizehintresolver.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTSIZEHINTRESOLVER_H #define KITEMLISTSIZEHINTRESOLVER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -31,7 +31,7 @@ class KItemListView; /** * @brief Calculates and caches the sizehints of items in KItemListView. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListSizeHintResolver +class DOLPHIN_EXPORT KItemListSizeHintResolver { public: KItemListSizeHintResolver(const KItemListView* itemListView); diff --git a/src/kitemviews/private/kitemlistsmoothscroller.h b/src/kitemviews/private/kitemlistsmoothscroller.h index 963cf7b24..fca4b0c53 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.h +++ b/src/kitemviews/private/kitemlistsmoothscroller.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTSMOOTHSCROLLER_H #define KITEMLISTSMOOTHSCROLLER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -33,7 +33,7 @@ class QWheelEvent; * @brief Helper class for KItemListContainer to have a smooth * scrolling when adjusting the scrollbars. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListSmoothScroller : public QObject +class DOLPHIN_EXPORT KItemListSmoothScroller : public QObject { Q_OBJECT diff --git a/src/kitemviews/private/kitemlistviewanimation.h b/src/kitemviews/private/kitemlistviewanimation.h index ed4ec4902..06c81c9b8 100644 --- a/src/kitemviews/private/kitemlistviewanimation.h +++ b/src/kitemviews/private/kitemlistviewanimation.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTVIEWANIMATION_H #define KITEMLISTVIEWANIMATION_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -36,7 +36,7 @@ class QPropertyAnimation; * Supports item animations for moving, creating, deleting and resizing * an item. Several applications can be applied to one item in parallel. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListViewAnimation : public QObject +class DOLPHIN_EXPORT KItemListViewAnimation : public QObject { Q_OBJECT diff --git a/src/kitemviews/private/kitemlistviewlayouter.h b/src/kitemviews/private/kitemlistviewlayouter.h index fc82d6061..3f1cf68d4 100644 --- a/src/kitemviews/private/kitemlistviewlayouter.h +++ b/src/kitemviews/private/kitemlistviewlayouter.h @@ -20,7 +20,7 @@ #ifndef KITEMLISTVIEWLAYOUTER_H #define KITEMLISTVIEWLAYOUTER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -45,7 +45,7 @@ class KItemListSizeHintResolver; * changing properties of the layouter is not expensive, only the * first read of a property can get expensive. */ -class LIBDOLPHINPRIVATE_EXPORT KItemListViewLayouter : public QObject +class DOLPHIN_EXPORT KItemListViewLayouter : public QObject { Q_OBJECT diff --git a/src/kitemviews/private/kpixmapmodifier.h b/src/kitemviews/private/kpixmapmodifier.h index b5eec6542..e8ca11ac1 100644 --- a/src/kitemviews/private/kpixmapmodifier.h +++ b/src/kitemviews/private/kpixmapmodifier.h @@ -20,12 +20,12 @@ #ifndef KPIXMAPMODIFIER_H #define KPIXMAPMODIFIER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" class QPixmap; class QSize; -class LIBDOLPHINPRIVATE_EXPORT KPixmapModifier +class DOLPHIN_EXPORT KPixmapModifier { public: static void scale(QPixmap& pixmap, const QSize& scaledSize); diff --git a/src/settings/viewpropertiesdialog.h b/src/settings/viewpropertiesdialog.h index 63c534b30..5490be85b 100644 --- a/src/settings/viewpropertiesdialog.h +++ b/src/settings/viewpropertiesdialog.h @@ -21,7 +21,7 @@ #ifndef VIEWPROPERTIESDIALOG_H #define VIEWPROPERTIESDIALOG_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include @@ -39,7 +39,7 @@ class DolphinView; * and previews should be shown. The properties can be assigned to the current folder, * or recursively to all sub folders. */ -class LIBDOLPHINPRIVATE_EXPORT ViewPropertiesDialog : public QDialog +class DOLPHIN_EXPORT ViewPropertiesDialog : public QDialog { Q_OBJECT diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 1c6c5b40c..22a8b4849 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -4,7 +4,7 @@ find_package(Qt5Test CONFIG REQUIRED) include(ECMMarkAsTest) # needed on windows to correctly use the files from dolphinprivate -add_definitions(-DLIBDOLPHINPRIVATE_EXPORT=) +add_definitions(-DDOLPHIN_EXPORT=) # KItemSetTest set(kitemsettest_SRCS diff --git a/src/views/dolphinfileitemlistwidget.cpp b/src/views/dolphinfileitemlistwidget.cpp index e8345435e..f15230841 100644 --- a/src/views/dolphinfileitemlistwidget.cpp +++ b/src/views/dolphinfileitemlistwidget.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include "dolphindebug.h" @@ -43,7 +42,7 @@ void DolphinFileItemListWidget::refreshCache() if (values.contains("version")) { // The item is under version control. Apply the text color corresponding // to its version state. - const KVersionControlPlugin2::ItemVersion version = static_cast(values.value("version").toInt()); + const KVersionControlPlugin::ItemVersion version = static_cast(values.value("version").toInt()); const QColor textColor = styleOption().palette.text().color(); QColor tintColor = textColor; @@ -51,16 +50,16 @@ void DolphinFileItemListWidget::refreshCache() // as tint colors and are mixed with the current set text color. The tint colors // have been optimized for the base colors of the corresponding Oxygen emblems. switch (version) { - case KVersionControlPlugin2::UpdateRequiredVersion: tintColor = Qt::yellow; break; - case KVersionControlPlugin2::LocallyModifiedUnstagedVersion: tintColor = Qt::green; break; - case KVersionControlPlugin2::LocallyModifiedVersion: tintColor = Qt::green; break; - case KVersionControlPlugin2::AddedVersion: tintColor = Qt::green; break; - case KVersionControlPlugin2::RemovedVersion: tintColor = Qt::darkRed; break; - case KVersionControlPlugin2::ConflictingVersion: tintColor = Qt::red; break; - case KVersionControlPlugin2::IgnoredVersion: tintColor = Qt::white; break; - case KVersionControlPlugin2::MissingVersion: tintColor = Qt::red; break; - case KVersionControlPlugin2::NormalVersion: - case KVersionControlPlugin2::UnversionedVersion: + case KVersionControlPlugin::UpdateRequiredVersion: tintColor = Qt::yellow; break; + case KVersionControlPlugin::LocallyModifiedUnstagedVersion: tintColor = Qt::green; break; + case KVersionControlPlugin::LocallyModifiedVersion: tintColor = Qt::green; break; + case KVersionControlPlugin::AddedVersion: tintColor = Qt::green; break; + case KVersionControlPlugin::RemovedVersion: tintColor = Qt::darkRed; break; + case KVersionControlPlugin::ConflictingVersion: tintColor = Qt::red; break; + case KVersionControlPlugin::IgnoredVersion: tintColor = Qt::white; break; + case KVersionControlPlugin::MissingVersion: tintColor = Qt::red; break; + case KVersionControlPlugin::NormalVersion: + case KVersionControlPlugin::UnversionedVersion: default: break; } @@ -78,7 +77,7 @@ void DolphinFileItemListWidget::refreshCache() setTextColor(color); } -QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin2::ItemVersion version, int size) +QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin::ItemVersion version, int size) { int overlayHeight = KIconLoader::SizeSmall; if (size >= KIconLoader::SizeEnormous) { @@ -115,8 +114,8 @@ QPixmap DolphinFileItemListWidget::overlayForState(KVersionControlPlugin2::ItemV iconName = "vcs-conflicting"; break; case KVersionControlPlugin::UnversionedVersion: - case KVersionControlPlugin2::IgnoredVersion: - case KVersionControlPlugin2::MissingVersion: + case KVersionControlPlugin::IgnoredVersion: + case KVersionControlPlugin::MissingVersion: break; default: Q_ASSERT(false); diff --git a/src/views/dolphinfileitemlistwidget.h b/src/views/dolphinfileitemlistwidget.h index 5f9cc3a5a..af73ac937 100644 --- a/src/views/dolphinfileitemlistwidget.h +++ b/src/views/dolphinfileitemlistwidget.h @@ -20,10 +20,10 @@ #ifndef DOLPHINFILEITEMLISTWIDGET_H #define DOLPHINFILEITEMLISTWIDGET_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include -#include +#include "versioncontrol/kversioncontrolplugin.h" /** * @brief Extends KFileItemListWidget to handle the "version" role. @@ -31,7 +31,7 @@ * The "version" role is set if version-control-plugins have been enabled. * @see KVersionControlPlugin */ -class LIBDOLPHINPRIVATE_EXPORT DolphinFileItemListWidget : public KFileItemListWidget +class DOLPHIN_EXPORT DolphinFileItemListWidget : public KFileItemListWidget { Q_OBJECT @@ -43,7 +43,7 @@ protected: virtual void refreshCache() Q_DECL_OVERRIDE; private: - static QPixmap overlayForState(KVersionControlPlugin2::ItemVersion version, int size); + static QPixmap overlayForState(KVersionControlPlugin::ItemVersion version, int size); }; diff --git a/src/views/dolphinitemlistview.h b/src/views/dolphinitemlistview.h index 2b16825f4..7eec6f17a 100644 --- a/src/views/dolphinitemlistview.h +++ b/src/views/dolphinitemlistview.h @@ -23,7 +23,7 @@ #include #include -#include "libdolphin_export.h" +#include "dolphin_export.h" class KFileItemListView; @@ -34,7 +34,7 @@ class KFileItemListView; * the view-properties into the corresponding KItemListView * properties. */ -class LIBDOLPHINPRIVATE_EXPORT DolphinItemListView : public KFileItemListView +class DOLPHIN_EXPORT DolphinItemListView : public KFileItemListView { Q_OBJECT diff --git a/src/views/dolphinnewfilemenuobserver.h b/src/views/dolphinnewfilemenuobserver.h index b9b18e229..df4621f17 100644 --- a/src/views/dolphinnewfilemenuobserver.h +++ b/src/views/dolphinnewfilemenuobserver.h @@ -22,7 +22,7 @@ #include -#include "libdolphin_export.h" +#include "dolphin_export.h" class DolphinNewFileMenu; @@ -33,7 +33,7 @@ class DolphinNewFileMenu; * As soon as a DolphinNewFileMenu instance created a new item, * the observer will emit the signal itemCreated(). */ -class LIBDOLPHINPRIVATE_EXPORT DolphinNewFileMenuObserver : public QObject +class DOLPHIN_EXPORT DolphinNewFileMenuObserver : public QObject { Q_OBJECT diff --git a/src/views/dolphinremoteencoding.h b/src/views/dolphinremoteencoding.h index 0351abad7..28ff52cb3 100644 --- a/src/views/dolphinremoteencoding.h +++ b/src/views/dolphinremoteencoding.h @@ -23,7 +23,7 @@ #include #include #include -#include "libdolphin_export.h" +#include "dolphin_export.h" class KActionMenu; @@ -35,7 +35,7 @@ class DolphinViewActionHandler; * When browsing remote url, its possible to change encoding from Tools Menu. */ -class LIBDOLPHINPRIVATE_EXPORT DolphinRemoteEncoding: public QObject +class DOLPHIN_EXPORT DolphinRemoteEncoding: public QObject { Q_OBJECT public: diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index aa4492bc3..24b560f10 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -23,7 +23,7 @@ #include -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -57,7 +57,7 @@ class QRegExp; * - show previews * - enable grouping */ -class LIBDOLPHINPRIVATE_EXPORT DolphinView : public QWidget +class DOLPHIN_EXPORT DolphinView : public QWidget { Q_OBJECT diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h index bf664f731..eb375b5c9 100644 --- a/src/views/dolphinviewactionhandler.h +++ b/src/views/dolphinviewactionhandler.h @@ -22,7 +22,7 @@ #ifndef DOLPHINVIEWACTIONHANDLER_H #define DOLPHINVIEWACTIONHANDLER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include "views/dolphinview.h" #include @@ -46,7 +46,7 @@ class KActionCollection; * @see DolphinMainWindow * @see DolphinPart */ -class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler : public QObject +class DOLPHIN_EXPORT DolphinViewActionHandler : public QObject { Q_OBJECT diff --git a/src/views/draganddrophelper.h b/src/views/draganddrophelper.h index 0fbe3a128..fe77b1e6e 100644 --- a/src/views/draganddrophelper.h +++ b/src/views/draganddrophelper.h @@ -21,7 +21,7 @@ #ifndef DRAGANDDROPHELPER_H #define DRAGANDDROPHELPER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" class QUrl; @@ -29,7 +29,7 @@ class QDropEvent; class QWidget; namespace KIO { class DropJob; } -class LIBDOLPHINPRIVATE_EXPORT DragAndDropHelper +class DOLPHIN_EXPORT DragAndDropHelper { public: /** diff --git a/src/views/renamedialog.h b/src/views/renamedialog.h index 7c02d1b87..a1953e8b3 100644 --- a/src/views/renamedialog.h +++ b/src/views/renamedialog.h @@ -20,7 +20,7 @@ #ifndef RENAMEDIALOG_H #define RENAMEDIALOG_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include @@ -33,7 +33,7 @@ class QPushButton; /** * @brief Dialog for renaming a variable number of files. */ -class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public QDialog +class DOLPHIN_EXPORT RenameDialog : public QDialog { Q_OBJECT diff --git a/src/views/versioncontrol/kversioncontrolplugin.cpp b/src/views/versioncontrol/kversioncontrolplugin.cpp new file mode 100644 index 000000000..2c0632878 --- /dev/null +++ b/src/views/versioncontrol/kversioncontrolplugin.cpp @@ -0,0 +1,29 @@ +/***************************************************************************** + * Copyright (C) 2011 by Vishesh Yadav * + * Copyright (C) 2011 by Peter Penz * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License version 2 as published by the Free Software Foundation. * + * * + * This library 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 * + * Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public License * + * along with this library; see the file COPYING.LIB. If not, write to * + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301, USA. * + *****************************************************************************/ + +#include "kversioncontrolplugin.h" + +KVersionControlPlugin::KVersionControlPlugin(QObject* parent) : + QObject(parent) +{ +} + +KVersionControlPlugin::~KVersionControlPlugin() +{ +} diff --git a/src/views/versioncontrol/kversioncontrolplugin.h b/src/views/versioncontrol/kversioncontrolplugin.h new file mode 100644 index 000000000..e5a267848 --- /dev/null +++ b/src/views/versioncontrol/kversioncontrolplugin.h @@ -0,0 +1,223 @@ +/***************************************************************************** + * Copyright (C) 2011 by Vishesh Yadav * + * Copyright (C) 2011 by Peter Penz * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License version 2 as published by the Free Software Foundation. * + * * + * This library 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 * + * Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public License * + * along with this library; see the file COPYING.LIB. If not, write to * + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301, USA. * + *****************************************************************************/ + +#ifndef KVERSIONCONTROLPLUGIN_H +#define KVERSIONCONTROLPLUGIN_H + +#include + +#include +#include +#include + +/** + * @brief Base class for version control plugins. + * + * Enables the file manager to show the version state + * of a versioned file. To write a custom plugin, the following + * steps are required (in the example below it is assumed that a plugin for + * Subversion will be written): + * + * - Create a fileviewsvnplugin.desktop file with the following content: + * + * [Desktop Entry] + * Type=Service + * Name=Subversion + * X-KDE-ServiceTypes=FileViewVersionControlPlugin + * MimeType=text/plain; + * X-KDE-Library=fileviewsvnplugin + * + * + * - Create a class FileViewSvnPlugin derived from KVersionControlPlugin and + * implement all abstract interfaces (fileviewsvnplugin.h, fileviewsvnplugin.cpp). + * + * - Take care that the constructor has the following signature: + * + * FileViewSvnPlugin(QObject* parent, const QList& args); + * + * + * - Add the following lines at the top of fileviewsvnplugin.cpp: + * + * #include + * #include + * K_PLUGIN_FACTORY(FileViewSvnPluginFactory, registerPlugin();) + * K_EXPORT_PLUGIN(FileViewSvnPluginFactory("fileviewsvnplugin")) + * + * + * - Add the following lines to your CMakeLists.txt file: + * + * kde4_add_plugin(fileviewsvnplugin fileviewsvnplugin.cpp) + * target_link_libraries(fileviewsvnplugin konq) + * install(FILES fileviewsvnplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR}) + * + * + * General implementation notes: + * + * - The implementations of beginRetrieval(), endRetrieval() and versionState() + * can contain blocking operations, as Dolphin will execute + * those methods in a separate thread. It is assured that + * all other methods are invoked in a serialized way, so that it is not necessary for + * the plugin to use any mutex. + * + * - Dolphin keeps only one instance of the plugin, which is instantiated shortly after + * starting Dolphin. Take care that the constructor does no expensive and time + * consuming operations. + * + * @since 4.8 + */ +class DOLPHIN_EXPORT KVersionControlPlugin : public QObject +{ + Q_OBJECT + +public: + enum ItemVersion + { + /** The file is not under version control. */ + UnversionedVersion, + /** + * The file is under version control and represents + * the latest version. + */ + NormalVersion, + /** + * The file is under version control and a newer + * version exists on the main branch. + */ + UpdateRequiredVersion, + /** + * The file is under version control and has been + * modified locally. All modifications will be part + * of the next commit. + */ + LocallyModifiedVersion, + /** + * The file has not been under version control but + * has been marked to get added with the next commit. + */ + AddedVersion, + /** + * The file is under version control but has been marked + * for getting removed with the next commit. + */ + RemovedVersion, + /** + * The file is under version control and has been locally + * modified. A modification has also been done on the main + * branch. + */ + ConflictingVersion, + /** + * The file is under version control and has local + * modifications, which will not be part of the next + * commit (or are "unstaged" in git jargon). + * @since 4.6 + */ + LocallyModifiedUnstagedVersion, + /** + * The file is not under version control and is listed + * in the ignore list of the version control system. + * @since 4.8 + */ + IgnoredVersion, + /** + * The file is is tracked by the version control system, but + * is missing in the directory (e.g. by deleted without using + * a version control command). + * @since 4.8 + */ + MissingVersion + }; + + KVersionControlPlugin(QObject* parent = 0); + virtual ~KVersionControlPlugin(); + + /** + * Returns the name of the file which stores + * the version controls information. + * (e. g. .svn, .cvs, .git). + */ + virtual QString fileName() const = 0; + + /** + * Is invoked whenever the version control + * information will get retrieved for the directory + * \p directory. It is assured that the directory + * contains a trailing slash. + */ + virtual bool beginRetrieval(const QString& directory) = 0; + + /** + * Is invoked after the version control information has been + * received. It is assured that + * KVersionControlPluginV2::beginInfoRetrieval() has been + * invoked before. + */ + virtual void endRetrieval() = 0; + + /** + * @return The version for the item \p item. + * It is assured that KVersionControlPlugin::beginInfoRetrieval() has been + * invoked before and that the file is part of the directory specified + * in beginInfoRetrieval(). + */ + virtual ItemVersion itemVersion(const KFileItem& item) const = 0; + + /** + * @return List of actions that are available for the items \p items. + * It is recommended to keep the number of returned actions small + * in case if an item is an unversioned directory that is not + * inside the hierarchy tree of the version control system. This + * prevents having a cluttered context menu for directories + * outside the version control system. + */ + virtual QList actions(const KFileItemList& items) const = 0; + +Q_SIGNALS: + /** + * Should be emitted when the version state of items might have been changed + * after the last retrieval (e. g. by executing a context menu action + * of the version control plugin). The file manager will be triggered to + * update the version states of the directory \p directory by invoking + * KVersionControlPlugin::beginRetrieval(), + * KVersionControlPlugin::itemVersion() and + * KVersionControlPlugin::endRetrieval(). + */ + void itemVersionsChanged(); + + /** + * Is emitted if an information message with the content \a msg + * should be shown. + */ + void infoMessage(const QString& msg); + + /** + * Is emitted if an error message with the content \a msg + * should be shown. + */ + void errorMessage(const QString& msg); + + /** + * Is emitted if an "operation completed" message with the content \a msg + * should be shown. + */ + void operationCompletedMessage(const QString& msg); +}; + +#endif // KVERSIONCONTROLPLUGIN_H + diff --git a/src/views/versioncontrol/updateitemstatesthread.cpp b/src/views/versioncontrol/updateitemstatesthread.cpp index 4f0122e0f..e4413fabf 100644 --- a/src/views/versioncontrol/updateitemstatesthread.cpp +++ b/src/views/versioncontrol/updateitemstatesthread.cpp @@ -19,9 +19,7 @@ #include "updateitemstatesthread.h" -#include #include - #include UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin* plugin, @@ -53,20 +51,10 @@ void UpdateItemStatesThread::run() if (m_plugin->beginRetrieval(it.key())) { QVector& items = it.value(); const int count = items.count(); - - KVersionControlPlugin2* pluginV2 = qobject_cast(m_plugin); - if (pluginV2) { - for (int i = 0; i < count; ++i) { - const KFileItem& item = items.at(i).first; - const KVersionControlPlugin2::ItemVersion version = pluginV2->itemVersion(item); - items[i].second = version; - } - } else { - for (int i = 0; i < count; ++i) { - const KFileItem& item = items.at(i).first; - const KVersionControlPlugin::VersionState state = m_plugin->versionState(item); - items[i].second = static_cast(state); - } + for (int i = 0; i < count; ++i) { + const KFileItem& item = items.at(i).first; + const KVersionControlPlugin::ItemVersion version = m_plugin->itemVersion(item); + items[i].second = version; } } diff --git a/src/views/versioncontrol/updateitemstatesthread.h b/src/views/versioncontrol/updateitemstatesthread.h index 92a9d59c9..3dc03fc75 100644 --- a/src/views/versioncontrol/updateitemstatesthread.h +++ b/src/views/versioncontrol/updateitemstatesthread.h @@ -20,20 +20,18 @@ #ifndef UPDATEITEMSTATESTHREAD_H #define UPDATEITEMSTATESTHREAD_H -#include "libdolphin_export.h" +#include "dolphin_export.h" #include #include #include -class KVersionControlPlugin; - /** * The performance of updating the version state of items depends * on the used plugin. To prevent that Dolphin gets blocked by a * slow plugin, the updating is delegated to a thread. */ -class LIBDOLPHINPRIVATE_EXPORT UpdateItemStatesThread : public QThread +class DOLPHIN_EXPORT UpdateItemStatesThread : public QThread { Q_OBJECT diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp index 47e3da357..13481cc7a 100644 --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -26,7 +26,6 @@ #include "dolphindebug.h" #include #include -#include #include "updateitemstatesthread.h" @@ -89,8 +88,6 @@ KFileItemModel* VersionControlObserver::model() const QList VersionControlObserver::actions(const KFileItemList& items) const { - QList actions; - bool hasNullItems = false; foreach (const KFileItem& item, items) { if (item.isNull()) { @@ -101,30 +98,10 @@ QList VersionControlObserver::actions(const KFileItemList& items) cons } if (!m_model || hasNullItems) { - return actions; - } - - KVersionControlPlugin2* pluginV2 = qobject_cast(m_plugin); - if (pluginV2) { - // Use version 2 of the KVersionControlPlugin which allows providing actions - // also for non-versioned directories. - actions = pluginV2->actions(items); - } else if (isVersioned()) { - // Support deprecated interfaces from KVersionControlPlugin version 1. - // Context menu actions where only available for versioned directories. - QString directory; - if (items.count() == 1) { - const KFileItem rootItem = m_model->rootItem(); - if (!rootItem.isNull() && items.first().url() == rootItem.url()) { - directory = rootItem.url().path(); - } - } - - actions = directory.isEmpty() ? m_plugin->contextMenuActions(items) - : m_plugin->contextMenuActions(directory); + return {}; } - return actions; + return m_plugin->actions(items); } void VersionControlObserver::delayedDirectoryVerification() @@ -156,14 +133,8 @@ void VersionControlObserver::verifyDirectory() m_plugin = searchPlugin(rootItem.url()); if (m_plugin) { - KVersionControlPlugin2* pluginV2 = qobject_cast(m_plugin); - if (pluginV2) { - connect(pluginV2, &KVersionControlPlugin2::itemVersionsChanged, - this, &VersionControlObserver::silentDirectoryVerification); - } else { - connect(m_plugin, &KVersionControlPlugin::versionStatesChanged, - this, &VersionControlObserver::silentDirectoryVerification); - } + connect(m_plugin, &KVersionControlPlugin::itemVersionsChanged, + this, &VersionControlObserver::silentDirectoryVerification); connect(m_plugin, &KVersionControlPlugin::infoMessage, this, &VersionControlObserver::infoMessage); connect(m_plugin, &KVersionControlPlugin::errorMessage, @@ -205,7 +176,7 @@ void VersionControlObserver::slotThreadFinished() foreach (const ItemState& item, items) { const KFileItem& fileItem = item.first; - const KVersionControlPlugin2::ItemVersion version = item.second; + const KVersionControlPlugin::ItemVersion version = item.second; QHash values; values.insert("version", QVariant(version)); m_model->setData(m_model->index(fileItem), values); @@ -268,7 +239,7 @@ int VersionControlObserver::createItemStatesList(QMapfileItem(index); - itemState.second = KVersionControlPlugin2::UnversionedVersion; + itemState.second = KVersionControlPlugin::UnversionedVersion; items.append(itemState); } else if (expansionLevel > currentExpansionLevel) { diff --git a/src/views/versioncontrol/versioncontrolobserver.h b/src/views/versioncontrol/versioncontrolobserver.h index a43dc3415..c817c2187 100644 --- a/src/views/versioncontrol/versioncontrolobserver.h +++ b/src/views/versioncontrol/versioncontrolobserver.h @@ -20,11 +20,13 @@ #ifndef VERSIONCONTROLOBSERVER_H #define VERSIONCONTROLOBSERVER_H -#include "libdolphin_export.h" +#include "dolphin_export.h" + +#include "kversioncontrolplugin.h" #include + #include -#include #include #include #include @@ -43,7 +45,7 @@ class UpdateItemStatesThread; * * @see VersionControlPlugin */ -class LIBDOLPHINPRIVATE_EXPORT VersionControlObserver : public QObject +class DOLPHIN_EXPORT VersionControlObserver : public QObject { Q_OBJECT @@ -100,7 +102,7 @@ private slots: void slotThreadFinished(); private: - typedef QPair ItemState; + typedef QPair ItemState; void updateItemStates(); diff --git a/src/views/viewmodecontroller.h b/src/views/viewmodecontroller.h index 89f1020b5..4b1ff2083 100644 --- a/src/views/viewmodecontroller.h +++ b/src/views/viewmodecontroller.h @@ -22,7 +22,7 @@ #include #include -#include "libdolphin_export.h" +#include "dolphin_export.h" #include /** @@ -33,7 +33,7 @@ * connect to signals of the ViewModeController to react on changes. The view * implementations get only read-access to the ViewModeController. */ -class LIBDOLPHINPRIVATE_EXPORT ViewModeController : public QObject +class DOLPHIN_EXPORT ViewModeController : public QObject { Q_OBJECT diff --git a/src/views/viewproperties.h b/src/views/viewproperties.h index b9c2fa546..dc118e2d7 100644 --- a/src/views/viewproperties.h +++ b/src/views/viewproperties.h @@ -23,7 +23,7 @@ #include #include -#include "libdolphin_export.h" +#include "dolphin_export.h" class ViewPropertySettings; /** @@ -47,7 +47,7 @@ class ViewPropertySettings; * (see GeneralSettings::globalViewMode()), the values from the global .directory file * are used for initialization. */ -class LIBDOLPHINPRIVATE_EXPORT ViewProperties +class DOLPHIN_EXPORT ViewProperties { public: explicit ViewProperties(const QUrl& url); -- cgit v1.3.1