Hello community, here is the log from the commit of package kactivities-stats for openSUSE:Factory checked in at 2017-04-30 21:15:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kactivities-stats (Old) and /work/SRC/openSUSE:Factory/.kactivities-stats.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kactivities-stats" Sun Apr 30 21:15:40 2017 rev:12 rq:492038 version:5.33.0 Changes: -------- --- /work/SRC/openSUSE:Factory/kactivities-stats/kactivities-stats.changes 2017-03-28 15:08:50.543280287 +0200 +++ /work/SRC/openSUSE:Factory/.kactivities-stats.new/kactivities-stats.changes 2017-04-30 21:17:41.557195615 +0200 @@ -1,0 +2,18 @@ +Sat Apr 15 10:11:43 CEST 2017 - [email protected] + +- Update to 5.33.0 + * New feature release + * For more details please see: + * https://www.kde.org/announcements/kde-frameworks-5.33.0.php +- Changes since 5.32.0: + * Upgrade ECM and KF5 version requirements for 5.33.0 release. + * Fix build with Qt 5.9 + * Added presets to the testing application + * Added F5 to reload the data in the test application + * Properly moving items to the desired position + * Syncing reordering to other model instances + * If the order is not defined, sort the entries by the id + * Using KSharedConfig instead of the normal one + * Upgrade KF5 version to 5.33.0. + +------------------------------------------------------------------- Old: ---- kactivities-stats-5.32.0.tar.xz New: ---- kactivities-stats-5.33.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kactivities-stats.spec ++++++ --- /var/tmp/diff_new_pack.nCVxuZ/_old 2017-04-30 21:17:42.157111028 +0200 +++ /var/tmp/diff_new_pack.nCVxuZ/_new 2017-04-30 21:17:42.161110464 +0200 @@ -17,9 +17,9 @@ %define lname libKF5ActivitiesStats1 -%define _tar_path 5.32 +%define _tar_path 5.33 Name: kactivities-stats -Version: 5.32.0 +Version: 5.33.0 Release: 0 %define kf5_version %{version} Summary: KDE Plasma Activities support ++++++ kactivities-stats-5.32.0.tar.xz -> kactivities-stats-5.33.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/CMakeLists.txt new/kactivities-stats-5.33.0/CMakeLists.txt --- old/kactivities-stats-5.32.0/CMakeLists.txt 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/CMakeLists.txt 2017-04-01 11:07:27.000000000 +0200 @@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.0) -set(KF5_VERSION "5.32.0") # handled by release scripts -set(KF5_DEP_VERSION "5.32.0") # handled by release scripts +set(KF5_VERSION "5.33.0") # handled by release scripts +set(KF5_DEP_VERSION "5.33.0") # handled by release scripts project (KActivitiesStats VERSION ${KF5_VERSION}) set (REQUIRED_QT_VERSION 5.6.0) @@ -20,7 +20,7 @@ # Extra CMake stuff include (FeatureSummary) -find_package (ECM 5.32.0 NO_MODULE) +find_package (ECM 5.33.0 NO_MODULE) set_package_properties (ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary (WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/src/resultmodel.cpp new/kactivities-stats-5.33.0/src/resultmodel.cpp --- old/kactivities-stats-5.32.0/src/resultmodel.cpp 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/src/resultmodel.cpp 2017-04-01 11:07:27.000000000 +0200 @@ -31,10 +31,10 @@ // STL and Boost #include <functional> #include <boost/range/algorithm/find_if.hpp> -#include <boost/range/algorithm/lower_bound.hpp> +#include <boost/range/algorithm/count_if.hpp> // KDE -#include <KConfig> +#include <KSharedConfig> #include <KConfigGroup> // Local @@ -68,6 +68,12 @@ { using Common::Database; database = Database::instance(Database::ResourcesDatabase, Database::ReadOnly); + s_privates << this; + } + + ~ResultModelPrivate() + { + s_privates.removeAll(this); } enum Fetch { @@ -86,18 +92,7 @@ , m_clientId(clientId) { if (!m_clientId.isEmpty()) { - m_configFile.reset(new KConfig( - QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) - + QStringLiteral("/kactivitymanagerd-statsrc"))); - - m_config = KConfigGroup(m_configFile.get(), "ResultModel-OrderingFor-" + clientId); - - if (m_config.isValid()) { - m_fixedItems = m_config.readEntry("kactivitiesLinkedItemsOrder", - QStringList()); - } - - qDebug() << "Configuration activated " << m_configFile->name(); + m_configFile = KSharedConfig::openConfig("kactivitymanagerd-statsrc"); } } @@ -110,10 +105,10 @@ return m_items.size(); } - inline void setLinkedResultPosition(const QString &resource, + inline void setLinkedResultPosition(const QString &resourcePath, int position) { - if (!m_config.isValid()) { + if (!m_orderingConfig.isValid()) { qWarning() << "We can not reorder the results, no clientId was specified"; return; } @@ -121,19 +116,21 @@ // Preconditions: // - cache is ordered properly, first on the user's desired order, // then on the query specified order - // - the resource that needs to be moved is already in the cache // - the resource that needs to be moved is a linked resource, not // one that comes from the stats (there are overly many // corner-cases that need to be covered in order to support // reordering of the statistics-based resources) // - the new position for the resource is not outside of the cache - qDebug() << "Searching for " << resource; - auto resourcePosition = find(resource); + auto resourcePosition = find(resourcePath); - qDebug() << "Was resource found? " << (bool)resourcePosition; if (resourcePosition) { - qDebug() << "What is the status? " << resourcePosition.iterator->linkStatus(); + if (resourcePosition.index == position) { + return; + } + if (resourcePosition.iterator->linkStatus() == ResultSet::Result::NotLinked) { + return; + } } // Lets make a list of linked items - we can only reorder them, @@ -145,12 +142,6 @@ linkedItems << item.resource(); } - // We can not accept the new position to be outside - // of the linked items area - if (position > linkedItems.size()) { - position = linkedItems.size(); - } - // We have two options: // - we are planning to add an item to the desired position, // but the item is not yet in the model @@ -158,30 +149,44 @@ if (!resourcePosition || resourcePosition.iterator->linkStatus() == ResultSet::Result::NotLinked) { - qDebug() << "Trying to reposition a resource that we do not have, or is not linked"; + linkedItems.insert(position, resourcePath); - linkedItems.insert(position, resource); - - m_fixedItems = linkedItems; + m_fixedOrderedItems = linkedItems; } else { + // We can not accept the new position to be outside + // of the linked items area + if (position >= linkedItems.size()) { + position = linkedItems.size() - 1; + } - auto oldPosition = linkedItems.indexOf(resource); + Q_ASSERT(resourcePosition.index == linkedItems.indexOf(resourcePath)); + auto oldPosition = linkedItems.indexOf(resourcePath); - kamd::utils::slide_one( + const auto oldLinkedItems = linkedItems; + + kamd::utils::move_one( linkedItems.begin() + oldPosition, linkedItems.begin() + position); - m_fixedItems = linkedItems; + // When we change this, the cache is not valid anymore, + // destinationFor will fail and we can not use it + m_fixedOrderedItems = linkedItems; // We are prepared to reorder the cache d->repositionResult(resourcePosition, d->destinationFor(*resourcePosition)); } - m_config.writeEntry("kactivitiesLinkedItemsOrder", m_fixedItems); - m_config.sync(); + m_orderingConfig.writeEntry("kactivitiesLinkedItemsOrder", m_fixedOrderedItems); + m_orderingConfig.sync(); + // We need to notify others to reload + for (const auto& other: s_privates) { + if (other != d && other->cache.m_clientId == m_clientId) { + other->fetch(FetchReset); + } + } } inline void debug() const @@ -191,6 +196,29 @@ } } + void loadOrderingConfig(const QString &activityTag) + { + if (!m_configFile) { + qDebug() << "Nothing to load - the client id is empty"; + return; + } + + m_orderingConfig = + KConfigGroup(m_configFile, + "ResultModel-OrderingFor-" + m_clientId + activityTag); + + if (m_orderingConfig.hasKey("kactivitiesLinkedItemsOrder")) { + // If we have the ordering defined, use it + m_fixedOrderedItems = m_orderingConfig.readEntry("kactivitiesLinkedItemsOrder", + QStringList()); + } else { + // Otherwise, copy the order from the previous activity to this one + m_orderingConfig.writeEntry("kactivitiesLinkedItemsOrder", m_fixedOrderedItems); + m_orderingConfig.sync(); + + } + } + private: ResultModelPrivate *const d; @@ -198,9 +226,9 @@ int m_countLimit; QString m_clientId; - std::unique_ptr<KConfig> m_configFile; - KConfigGroup m_config; - QStringList m_fixedItems; + KSharedConfig::Ptr m_configFile; + KConfigGroup m_orderingConfig; + QStringList m_fixedOrderedItems; friend QDebug operator<< (QDebug out, const Cache &cache) { @@ -212,9 +240,9 @@ } public: - inline const QStringList &fixedItems() const + inline const QStringList &fixedOrderedItems() const { - return m_fixedItems; + return m_fixedOrderedItems; } //_ Fancy iterator, find, lowerBound @@ -244,16 +272,6 @@ { return &(*iterator); } - - // const ResultSet::Result &operator*() const - // { - // return *iterator; - // } - // - // const ResultSet::Result *operator->() const - // { - // return &(*iterator); - // } }; inline FindCacheResult find(const QString &resource) @@ -266,28 +284,44 @@ == resource)); } - template <typename What, typename Predicate> - inline FindCacheResult lowerBound(What &&what, Predicate &&predicate) - { - return FindCacheResult( - this, boost::lower_bound(m_items, std::forward<What>(what), - std::forward<Predicate>(predicate))); - } - template <typename Predicate> - inline FindCacheResult lowerBound(Predicate &&predicate) + inline FindCacheResult lowerBoundWithSkippedResource(Predicate &&lessThanPredicate) { using namespace kamd::utils::member_matcher; - return FindCacheResult( - this, boost::lower_bound(m_items, _, - std::forward<Predicate>(predicate))); - } - //^ + const int count = boost::count_if(m_items, + [&] (const ResultSet::Result &result) { + return lessThanPredicate(result, _); + }); - inline int indexOf(const FindCacheResult &result) - { - return std::distance(m_items.begin(), result.iterator); + return FindCacheResult(this, m_items.begin() + count); + + + // using namespace kamd::utils::member_matcher; + // + // const auto position = + // std::lower_bound(m_items.begin(), m_items.end(), + // _, std::forward<Predicate>(lessThanPredicate)); + // + // // We seem to have found the position for the item. + // // The problem is that we might have found the same position + // // we were previously at. Since this function is usually used + // // to reposition the result, we might not be in a completely + // // sorted collection, so the next item(s) could be less than us. + // // We could do this with count_if, but it would be slower + // + // if (position >= m_items.cend() - 1) { + // return FindCacheResult(this, position); + // + // } else if (lessThanPredicate(_, *(position + 1))) { + // return FindCacheResult(this, position); + // + // } else { + // return FindCacheResult( + // this, std::lower_bound(position + 1, m_items.end(), + // _, std::forward<Predicate>(lessThanPredicate))); + // } } + //^ inline void insertAt(const FindCacheResult &at, const ResultSet::Result &result) @@ -507,35 +541,39 @@ { } - bool compare (const QString &leftResource, const QString &rightResource) const + bool lessThan(const QString &leftResource, const QString &rightResource) const { - const bool hasLeft = cache.fixedItems().contains(leftResource); - const bool hasRight = cache.fixedItems().contains(rightResource); + const auto fixedOrderedItems = cache.fixedOrderedItems(); + + const auto indexLeft = fixedOrderedItems.indexOf(leftResource); + const auto indexRight = fixedOrderedItems.indexOf(rightResource); + + const bool hasLeft = indexLeft != -1; + const bool hasRight = indexRight != -1; return ( hasLeft && !hasRight) ? true : (!hasLeft && hasRight) ? false : - ( hasLeft && hasRight) ? cache.fixedItems().indexOf(leftResource) < - cache.fixedItems().indexOf(rightResource) : - false; + ( hasLeft && hasRight) ? indexLeft < indexRight : + leftResource < rightResource; } template <typename T> bool operator() (const T &left, placeholder) const { - return compare(left.resource(), matchResource); + return lessThan(left.resource(), matchResource); } template <typename T> bool operator() (placeholder, const T &right) const { - return compare(matchResource, right.resource()); + return lessThan(matchResource, right.resource()); } template <typename T, typename V> bool operator() (const T &left, const V &right) const { - return compare(left.resource(), right.resource()); + return lessThan(left.resource(), right.resource()); } const Cache &cache; @@ -557,11 +595,13 @@ #define ORDER_BY(Field) member(&ResultSet::Result::Field) > Field #define ORDER_BY_FULL(Field) \ (query.selection() == Terms::AllResources ? \ - cache.lowerBound(FixedItemsLessThan(cache, resource) \ + cache.lowerBoundWithSkippedResource( \ + FixedItemsLessThan(cache, resource) \ && ORDER_BY(linkStatus) \ && ORDER_BY(Field) \ && ORDER_BY(resource)) : \ - cache.lowerBound(FixedItemsLessThan(cache, resource) \ + cache.lowerBoundWithSkippedResource( \ + FixedItemsLessThan(cache, resource) \ && ORDER_BY(Field) \ && ORDER_BY(resource)) \ ) @@ -592,19 +632,26 @@ inline void repositionResult(const Cache::FindCacheResult &result, const Cache::FindCacheResult &destination) { - using kamd::utils::slide_one; - // We already have the resource in the cache // So, it is the time for a reshuffle - const int currentIndex = result.index; + const int oldPosition = result.index; + int position = destination.index; + + q->dataChanged(q->index(oldPosition), q->index(oldPosition)); + + if (oldPosition == position) { + return; + } - q->dataChanged(q->index(currentIndex), q->index(currentIndex)); + if (position > oldPosition) { + position++; + } bool moving - = q->beginMoveRows(QModelIndex(), currentIndex, currentIndex, - QModelIndex(), destination.index); + = q->beginMoveRows(QModelIndex(), oldPosition, oldPosition, + QModelIndex(), position); - slide_one(result.iterator, destination.iterator); + kamd::utils::move_one(result.iterator, destination.iterator); if (moving) { q->endMoveRows(); @@ -695,6 +742,13 @@ // and loading all from scratch cache.clear(); + const QString activityTag = + query.activities().contains(CURRENT_ACTIVITY_TAG) + ? ("-ForActivity-" + activities.currentActivity()) + : "-ForAllActivities"; + + cache.loadOrderingConfig(activityTag); + fetch(0, MAX_CHUNK_LOAD_SIZE); } else if (mode == FetchReload) { @@ -719,8 +773,6 @@ void onResultScoreUpdated(const QString &resource, double score, uint lastUpdate, uint firstUpdate) { - using boost::lower_bound; - QDBG << "ResultModelPrivate::onResultScoreUpdated " << "result added:" << resource << "score:" << score @@ -750,9 +802,7 @@ item.setLastUpdate(lastUpdate); item.setFirstUpdate(firstUpdate); - const auto destination = destinationFor(item); - - repositionResult(result, destination); + repositionResult(result, destinationFor(item)); } else { // We do not have the resource in the cache, @@ -883,9 +933,12 @@ private: ResultModel *const q; + static QList<ResultModelPrivate*> s_privates; }; +QList<ResultModelPrivate*> ResultModelPrivate::s_privates; + ResultModel::ResultModel(Query query, QObject *parent) : QAbstractListModel(parent) , d(new ResultModelPrivate(query, QString(), this)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/src/utils/slide.h new/kactivities-stats-5.33.0/src/utils/slide.h --- old/kactivities-stats-5.32.0/src/utils/slide.h 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/src/utils/slide.h 2017-04-01 11:07:27.000000000 +0200 @@ -43,6 +43,25 @@ slide(f, f + 1, p); } +template <typename Iterator> +void move_one(Iterator from, Iterator to) +{ + if (from < to) { + while (from != to) { + using std::swap; + swap(*from, *(from + 1)); + ++from; + } + } else { + while (from != to) { + using std::swap; + swap(*from, *(from - 1)); + --from; + } + + } +} + } // namespace utils } // namespace kamd diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/tests/model/CMakeLists.txt new/kactivities-stats-5.33.0/tests/model/CMakeLists.txt --- old/kactivities-stats-5.32.0/tests/model/CMakeLists.txt 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/tests/model/CMakeLists.txt 2017-04-01 11:07:27.000000000 +0200 @@ -41,6 +41,7 @@ Qt5::Test Qt5::Quick Qt5::QuickWidgets + KF5::Activities KF5::ActivitiesStats ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/tests/model/modeltest.cpp new/kactivities-stats-5.33.0/tests/model/modeltest.cpp --- old/kactivities-stats-5.32.0/tests/model/modeltest.cpp 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/tests/model/modeltest.cpp 2017-04-01 11:07:27.000000000 +0200 @@ -451,7 +451,7 @@ // Check that the alignment is one we know about QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole ); if ( textAlignmentVariant.isValid() ) { - int alignment = textAlignmentVariant.toInt(); + const auto alignment = textAlignmentVariant.toUInt(); QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) ); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/tests/model/window.cpp new/kactivities-stats-5.33.0/tests/model/window.cpp --- old/kactivities-stats-5.32.0/tests/model/window.cpp 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/tests/model/window.cpp 2017-04-01 11:07:27.000000000 +0200 @@ -33,8 +33,6 @@ #include <QQmlComponent> #include <QQuickItem> -#include <resultset.h> -#include <resultmodel.h> #include <KActivities/Consumer> #include <boost/range/numeric.hpp> @@ -166,12 +164,119 @@ } } + auto redisplayAction = new QAction(this); + addAction(redisplayAction); + redisplayAction->setShortcut(Qt::Key_F5); + connect(redisplayAction, SIGNAL(triggered()), + this, SLOT(updateResults())); + + // loading the presets + + const auto recentQueryBase + = UsedResources + | RecentlyUsedFirst + | Agent::any() + | Type::any() + | Activity::current(); + + const auto popularQueryBase + = UsedResources + | HighScoredFirst + | Agent::any() + | Type::any() + | Activity::current(); + + presets = { + { "kicker-favorites", + LinkedResources + | Agent { + "org.kde.plasma.favorites.applications", + "org.kde.plasma.favorites.contacts" + } + | Type::any() + | Activity::current() + | Activity::global() + | Limit(15) + }, + { "kicker-recent-apps-n-docs", + recentQueryBase | Url::startsWith("applications:") | Url::file() | Limit(30) + }, + { "kicker-recent-apps", + recentQueryBase | Url::startsWith("applications:") | Limit(15) + }, + { "kicker-recent-docs", + recentQueryBase | Url::file() | Limit(15) + }, + { "kicker-popular-apps-n-docs", + popularQueryBase | Url::startsWith("applications:") | Url::file() | Limit(30) + }, + { "kicker-popular-apps", + popularQueryBase | Url::startsWith("applications:") | Limit(15) + }, + { "kicker-popular-docs", + popularQueryBase | Url::file() | Limit(15) + } + }; + + ui->comboPreset->addItem("Choose a preset", QVariant()); + for (const auto& presetId: presets.keys()) { + ui->comboPreset->addItem(presetId, presetId); + } + + connect(ui->comboPreset, SIGNAL(activated(int)), + this, SLOT(selectPreset())); } Window::~Window() { } +void Window::selectPreset() +{ + const auto id = ui->comboPreset->currentData().toString(); + + if (id.isEmpty()) return; + + const auto &query = presets[id]; + qDebug() << "Id: " << id; + qDebug() << "Query: " << query; + + // Selection + qDebug() << "\tSelection:" << query.selection(); + ui->radioSelectUsedResources->setChecked(query.selection() == UsedResources); + ui->radioSelectLinkedResources->setChecked(query.selection() == LinkedResources); + ui->radioSelectAllResources->setChecked(query.selection() == AllResources); + + // Ordering + qDebug() << "\tOrdering:" << query.ordering(); + ui->radioOrderHighScoredFirst->setChecked(query.ordering() == HighScoredFirst); + ui->radioOrderRecentlyUsedFirst->setChecked(query.ordering() == RecentlyUsedFirst); + ui->radioOrderRecentlyCreatedFirst->setChecked(query.ordering() == RecentlyCreatedFirst); + ui->radioOrderByUrl->setChecked(query.ordering() == OrderByUrl); + ui->radioOrderByTitle->setChecked(query.ordering() == OrderByTitle); + + // Agents + qDebug() << "\tAgents:" << query.agents(); + ui->textAgent->setText(query.agents().join(',')); + + // Types + qDebug() << "\tTypes:" << query.types(); + ui->textMimetype->setText(query.types().join(',')); + + // Activities + qDebug() << "\tActivities:" << query.activities(); + ui->comboActivity->setEditText(query.activities().join(',')); + + // Url filters + qDebug() << "\tUrl filters:" << query.urlFilters(); + ui->textUrl->setText(query.urlFilters().join(',')); + + // Limit + ui->spinLimitCount->setValue(query.limit()); + + updateResults(); +} + void Window::updateRowCount() { ui->labelRowCount->setText(QString::number( @@ -179,13 +284,44 @@ )); } -void Window::updateResults() +void Window::setQuery(const KActivities::Stats::Query &query) { qDebug() << "Updating the results"; ui->viewResults->setModel(nullptr); - auto query = + // Log results + using boost::accumulate; + + ui->textLog->setText( + accumulate(ResultSet(query), QString(), + [] (const QString &acc, const ResultSet::Result &result) { + return acc + result.title() + " (" + result.resource() + ")\n"; + }) + ); + + model.reset(new ResultModel(query)); + + // modelTest.reset(); + // modelTest.reset(new ModelTest(new ResultModel(query))); + + ui->viewResults->setModel(model.get()); + + // QML + + auto context = ui->viewResultsQML->rootContext(); + ui->viewResultsQML->setResizeMode(QQuickWidget::SizeRootObjectToView); + + context->setContextProperty("kamdmodel", model.get()); + + ui->viewResultsQML->setSource(QUrl("qrc:/main.qml")); +} + +void Window::updateResults() +{ + qDebug() << "Updating the results"; + + setQuery( // What should we get ( ui->radioSelectUsedResources->isChecked() ? UsedResources : @@ -211,35 +347,11 @@ // Which activities? Activity(ui->comboActivity->currentText().split(',')) | + // And URL filters + Url(ui->textUrl->text().split(',', QString::SkipEmptyParts)) | + // And how many items Limit(ui->spinLimitCount->value()) - - ; - - // Log results - using boost::accumulate; - - ui->textLog->setText( - accumulate(ResultSet(query), QString(), - [] (const QString &acc, const ResultSet::Result &result) { - return acc + result.title() + " (" + result.resource() + ")\n"; - }) - ); - - model.reset(new ResultModel(query)); - - // modelTest.reset(); - // modelTest.reset(new ModelTest(new ResultModel(query))); - - ui->viewResults->setModel(model.get()); - - // QML - - auto context = ui->viewResultsQML->rootContext(); - ui->viewResultsQML->setResizeMode(QQuickWidget::SizeRootObjectToView); - - context->setContextProperty("kamdmodel", model.get()); - - ui->viewResultsQML->setSource(QUrl("qrc:/main.qml")); + ); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/tests/model/window.h new/kactivities-stats-5.33.0/tests/model/window.h --- old/kactivities-stats-5.32.0/tests/model/window.h 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/tests/model/window.h 2017-04-01 11:07:27.000000000 +0200 @@ -20,6 +20,10 @@ #pragma once #include <QMainWindow> + +#include <resultset.h> +#include <resultmodel.h> + #include <memory> class ModelTest; @@ -44,11 +48,16 @@ private Q_SLOTS: void updateResults(); void updateRowCount(); + void selectPreset(); private: + void setQuery(const KActivities::Stats::Query &query); + std::unique_ptr<Ui::MainWindow> ui; std::unique_ptr<KActivities::Stats::ResultModel> model; std::unique_ptr<ModelTest> modelTest; std::unique_ptr<KActivities::Consumer> activities; + + QMap<QString, KActivities::Stats::Query> presets; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-stats-5.32.0/tests/model/window.ui new/kactivities-stats-5.33.0/tests/model/window.ui --- old/kactivities-stats-5.32.0/tests/model/window.ui 2017-03-03 13:40:54.000000000 +0100 +++ new/kactivities-stats-5.33.0/tests/model/window.ui 2017-04-01 11:07:27.000000000 +0200 @@ -54,6 +54,36 @@ </attribute> <layout class="QVBoxLayout" name="verticalLayout_3"> <item> + <widget class="QGroupBox" name="groupPreset"> + <property name="title"> + <string>Presets</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <property name="checkable"> + <bool>false</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout_6"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <widget class="QComboBox" name="comboPreset"/> + </item> + </layout> + </widget> + </item> + <item> <widget class="QGroupBox" name="groupWhat"> <property name="title"> <string>What</string> @@ -62,6 +92,18 @@ <bool>true</bool> </property> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> <item> <widget class="QRadioButton" name="radioSelectLinkedResources"> <property name="text"> @@ -101,6 +143,18 @@ <bool>true</bool> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> <item> <widget class="QRadioButton" name="radioOrderHighScoredFirst"> <property name="text"> @@ -131,7 +185,7 @@ <item> <widget class="QRadioButton" name="radioOrderByUrl"> <property name="text"> - <string>By url</string> + <string>&By url</string> </property> </widget> </item> @@ -146,6 +200,13 @@ </widget> </item> <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> <layout class="QFormLayout" name="formLayout"> <property name="fieldGrowthPolicy"> <enum>QFormLayout::AllNonFixedFieldsGrow</enum> @@ -198,20 +259,30 @@ </property> </widget> </item> - <item row="3" column="0"> + <item row="4" column="0"> <widget class="QLabel" name="labelLimitCount"> <property name="text"> <string>Count</string> </property> </widget> </item> - <item row="3" column="1"> + <item row="4" column="1"> <widget class="QSpinBox" name="spinLimitCount"> <property name="value"> <number>10</number> </property> </widget> </item> + <item row="3" column="0"> + <widget class="QLabel" name="labelUrl"> + <property name="text"> + <string>Url</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="textUrl"/> + </item> </layout> </item> <item> @@ -257,8 +328,7 @@ </property> <property name="icon"> <iconset theme="view-refresh"> - <normaloff/> - </iconset> + <normaloff>.</normaloff>.</iconset> </property> </widget> </item> @@ -388,7 +458,7 @@ <customwidget> <class>QQuickWidget</class> <extends>QWidget</extends> - <header>QQuickWidget</header> + <header>QtQuickWidgets/QQuickWidget</header> </customwidget> </customwidgets> <resources/>
