Hello community, here is the log from the commit of package kactivities5 for openSUSE:Factory checked in at 2016-08-29 14:55:33 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kactivities5 (Old) and /work/SRC/openSUSE:Factory/.kactivities5.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kactivities5" Changes: -------- --- /work/SRC/openSUSE:Factory/kactivities5/kactivities5.changes 2016-07-15 12:31:48.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.kactivities5.new/kactivities5.changes 2016-08-29 14:56:08.000000000 +0200 @@ -1,0 +2,19 @@ +Sun Aug 7 21:50:11 UTC 2016 - [email protected] + +- Update to 5.25.0 + * Qt >= 5.5 is now required + * [KActivities-CLI] commands for starting and stopping an activity + * [KActivities-CLI] setting and getting activity name, + icon and description + * Added a CLI application for controlling activities + * Adding scripts to switch to previous and next activities + * Method for inserting into QFlatSet now returns index along + with the iterator (kde#365610) + * Adding ZSH functions for stopping and deleting + non-current activities + * Added isCurrent property to KActivities::Info + * Using constant iterators when searching for activity + * For more details please see: + https://www.kde.org/announcements/kde-frameworks-5.25.0.php + +------------------------------------------------------------------- Old: ---- kactivities-5.24.0.tar.xz New: ---- kactivities-5.25.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kactivities5.spec ++++++ --- /var/tmp/diff_new_pack.8JDeh7/_old 2016-08-29 14:56:09.000000000 +0200 +++ /var/tmp/diff_new_pack.8JDeh7/_new 2016-08-29 14:56:09.000000000 +0200 @@ -17,9 +17,9 @@ %define lname libKF5Activities5 -%define _tar_path 5.24 +%define _tar_path 5.25 Name: kactivities5 -Version: 5.24.0 +Version: 5.25.0 Release: 0 %define kf5_version %{version} Summary: KDE Plasma Activities support @@ -38,18 +38,26 @@ BuildRequires: cmake(KF5CoreAddons) >= %{_tar_path} BuildRequires: cmake(KF5KIO) >= %{_tar_path} BuildRequires: cmake(KF5WindowSystem) >= %{_tar_path} -BuildRequires: cmake(Qt5Core) >= 5.4.0 -BuildRequires: cmake(Qt5DBus) >= 5.4.0 -BuildRequires: cmake(Qt5Gui) >= 5.4.0 -BuildRequires: cmake(Qt5Qml) >= 5.4.0 -BuildRequires: cmake(Qt5Quick) >= 5.4.0 -BuildRequires: cmake(Qt5Sql) >= 5.4.0 -BuildRequires: cmake(Qt5Test) >= 5.4.0 +BuildRequires: cmake(Qt5Core) >= 5.5.0 +BuildRequires: cmake(Qt5DBus) >= 5.5.0 +BuildRequires: cmake(Qt5Gui) >= 5.5.0 +BuildRequires: cmake(Qt5Qml) >= 5.5.0 +BuildRequires: cmake(Qt5Quick) >= 5.5.0 +BuildRequires: cmake(Qt5Sql) >= 5.5.0 +BuildRequires: cmake(Qt5Test) >= 5.5.0 BuildRoot: %{_tmppath}/%{name}-%{version}-build %description Kactivities provides an API for using and interacting with the Plasma Activities Manager. +%package tools +Summary: Command-line tools for Plasma Activity management +Group: System/GUI/KDE +Requires: %lname = %{version} + +%description tools +This package provides command-line tools to manipulate Plasma Activities. + %package -n %lname Summary: Library for KDE's Plasma Activities support Group: System/GUI/KDE @@ -70,7 +78,7 @@ Group: Development/Libraries/KDE Requires: %lname = %{version} Requires: extra-cmake-modules >= 1.7.0 -Requires: cmake(Qt5Core) >= 5.4.0 +Requires: cmake(Qt5Core) >= 5.5.0 %description devel Kactivities provides an API for using and interacting with the Plasma Activities Manager. @@ -91,6 +99,10 @@ %postun -n %lname -p /sbin/ldconfig +%files tools +%defattr(-,root,root,-) +%{_bindir}/kactivities-cli + %files -n %lname %defattr(-,root,root,-) %{_kf5_libdir}/libKF5Activities.so.* ++++++ kactivities-5.24.0.tar.xz -> kactivities-5.25.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/CMakeLists.txt new/kactivities-5.25.0/CMakeLists.txt --- old/kactivities-5.24.0/CMakeLists.txt 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/CMakeLists.txt 2016-08-06 10:25:49.000000000 +0200 @@ -1,6 +1,6 @@ # vim:set softtabstop=3 shiftwidth=3 tabstop=3 expandtab: -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 2.8.12) project (KActivities) @@ -36,7 +36,7 @@ # Extra CMake stuff include(FeatureSummary) -find_package(ECM 5.24.0 NO_MODULE) +find_package(ECM 5.25.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) @@ -53,8 +53,8 @@ find_package (Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED COMPONENTS Core DBus) # KDE Frameworks -set(KF5_VERSION "5.24.0") # handled by release scripts -set(KF5_DEP_VERSION "5.24.0") # handled by release scripts +set(KF5_VERSION "5.25.0") # handled by release scripts +set(KF5_DEP_VERSION "5.25.0") # handled by release scripts # Basic includes include (CPack) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/contrib/bash/next-activity.sh new/kactivities-5.25.0/contrib/bash/next-activity.sh --- old/kactivities-5.24.0/contrib/bash/next-activity.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/kactivities-5.25.0/contrib/bash/next-activity.sh 2016-08-06 10:25:49.000000000 +0200 @@ -0,0 +1,30 @@ +#! /bin/bash +# +# next-activity.sh +# Copyright (C) 2016 Ivan Čukić <ivan.cukic(at)kde.org> +# +# Distributed under terms of the MIT license. +# + +current_activity=($(qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity)) +activities=($(qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities)) +found="0" + +for ((i=0; i < ${#activities[@]}; ++i)); do + if [ "$current_activity" = "${activities[$i]}" ]; then + found="1" + else + if [ "$found" == "1" ]; then + echo "Switching to ${activities[$i]}" + qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity ${activities[$i]} + found="0" + fi + fi +done + +if [ "$found" == "1" ]; then + echo "Switching to ${activities[0]}" + qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity ${activities[0]} +fi + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/contrib/bash/prev-activity.sh new/kactivities-5.25.0/contrib/bash/prev-activity.sh --- old/kactivities-5.24.0/contrib/bash/prev-activity.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/kactivities-5.25.0/contrib/bash/prev-activity.sh 2016-08-06 10:25:49.000000000 +0200 @@ -0,0 +1,30 @@ +#! /bin/bash +# +# next-activity.sh +# Copyright (C) 2016 Ivan Čukić <ivan.cukic(at)kde.org> +# +# Distributed under terms of the MIT license. +# + +current_activity=($(qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity)) +activities=($(qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities)) +found="0" + +previous_activity="" + +for ((i=0; i < ${#activities[@]}; ++i)); do + if [ "$current_activity" = "${activities[$i]}" ]; then + if [ "$previous_activity" != "" ]; then + echo "Switching to $previous_activity" + qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity $previous_activity + exit + else + echo "Switching to ${activities[-1]}" + qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity ${activities[-1]} + exit + fi + else + previous_activity="${activities[$i]}" + fi +done + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/contrib/zsh/kamd-functions new/kactivities-5.25.0/contrib/zsh/kamd-functions --- old/kactivities-5.24.0/contrib/zsh/kamd-functions 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/contrib/zsh/kamd-functions 2016-08-06 10:25:49.000000000 +0200 @@ -113,3 +113,29 @@ echo $CURRENT_ACTIVITY_NAME | tr '[:upper:] ' '[:lower:]-' } +# Returns the current activity ID +function kamd_STOP_ALL_BUT_CURRENT() { + CURRENT_ACTIVITY_ID=$(kamd_get_currentactivity_id) + + for activity in `qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities`; do + if [ "$activity" != "$CURRENT_ACTIVITY_ID" ]; then + echo "Stop: $activity" + qdbus org.kde.ActivityManager /ActivityManager/Activities StopActivity $activity + sleep 1 + fi + done +} + +# Returns the current activity ID +function kamd_REMOVE_ALL_BUT_CURRENT() { + CURRENT_ACTIVITY_ID=$(kamd_get_currentactivity_id) + + for activity in `qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities`; do + if [ "$activity" != "$CURRENT_ACTIVITY_ID" ]; then + echo "Remove: $activity" + qdbus org.kde.ActivityManager /ActivityManager/Activities RemoveActivity $activity + sleep 1 + fi + done +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/CMakeLists.txt new/kactivities-5.25.0/src/CMakeLists.txt --- old/kactivities-5.24.0/src/CMakeLists.txt 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/src/CMakeLists.txt 2016-08-06 10:25:49.000000000 +0200 @@ -36,3 +36,4 @@ add_subdirectory (imports) endif () +add_subdirectory (cli) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/cli/CMakeLists.txt new/kactivities-5.25.0/src/cli/CMakeLists.txt --- old/kactivities-5.24.0/src/cli/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/kactivities-5.25.0/src/cli/CMakeLists.txt 2016-08-06 10:25:49.000000000 +0200 @@ -0,0 +1,36 @@ +# vim:set softtabstop=3 shiftwidth=3 tabstop=3 expandtab: +project (KActivitiesCLI) + +find_package (Qt5 REQUIRED NO_MODULE COMPONENTS Core Gui Widgets) +find_package (Qt5 REQUIRED NO_MODULE COMPONENTS Core Gui Widgets) +find_package (KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS WindowSystem) + +include_directories ( + ${KACTIVITIES_CURRENT_ROOT_SOURCE_DIR}/src/ + ${KACTIVITIES_CURRENT_ROOT_SOURCE_DIR}/autotests/ + ) + +set ( + KActivitiesCLI_SRCS + main.cpp + ) + +qt5_wrap_ui( + KActivitiesCLI_SRCS + ) + +add_executable ( + kactivities-cli + ${KActivitiesCLI_SRCS} + ) + +target_link_libraries ( + kactivities-cli + Qt5::Core + KF5::Activities + ) + +install (TARGETS + kactivities-cli + ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} + ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/cli/main.cpp new/kactivities-5.25.0/src/cli/main.cpp --- old/kactivities-5.24.0/src/cli/main.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/kactivities-5.25.0/src/cli/main.cpp 2016-08-06 10:25:49.000000000 +0200 @@ -0,0 +1,297 @@ +/* + * Copyright (C) 2016 Ivan Cukic <ivan.cukic(at)kde.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * or (at your option) any later version, as published by the Free + * Software Foundation + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <QCoreApplication> +#include <QDebug> +#include <QTimer> + +#include <KActivities/Controller> + +#include "utils.h" + + +// Output modifiers + +DEFINE_COMMAND(bare, 0) +{ + flags.bare = true; + return 0; +} + +DEFINE_COMMAND(noBare, 0) +{ + flags.bare = false; + return 0; +} + +DEFINE_COMMAND(color, 0) +{ + flags.color = true; + return 0; +} + +DEFINE_COMMAND(noColor, 0) +{ + flags.color = false; + return 0; +} + +// Activity management + +DEFINE_COMMAND(createActivity, 1) +{ + auto result = awaitFuture(controller->addActivity(args(1))); + + qDebug().noquote() << result; + + return 1; +} + +DEFINE_COMMAND(removeActivity, 1) +{ + awaitFuture(controller->removeActivity(args(1))); + + return 1; +} + +DEFINE_COMMAND(startActivity, 1) +{ + awaitFuture(controller->startActivity(args(1))); + + return 1; +} + +DEFINE_COMMAND(stopActivity, 1) +{ + awaitFuture(controller->stopActivity(args(1))); + + return 1; +} + +DEFINE_COMMAND(listActivities, 0) +{ + for (const auto& activity: controller->activities()) { + printActivity(activity); + } + + return 0; +} + +DEFINE_COMMAND(currentActivity, 0) +{ + printActivity(controller->currentActivity()); + + return 0; +} + +DEFINE_COMMAND(setActivityProperty, 3) +{ + const auto what = args(1); + const auto id = args(2); + const auto value = args(3); + + awaitFuture( + what == "name" ? controller->setActivityName(id, value) : + what == "description" ? controller->setActivityDescription(id, value) : + what == "icon" ? controller->setActivityIcon(id, value) : + QFuture<void>() + ); + + return 3; +} + +DEFINE_COMMAND(activityProperty, 2) +{ + const auto what = args(1); + const auto id = args(2); + + KActivities::Info info(id); + + out << ( + what == "name" ? info.name() : + what == "description" ? info.description() : + what == "icon" ? info.icon() : + QString() + ) << "\n"; + + return 2; +} + +// Activity switching + +DEFINE_COMMAND(setCurrentActivity, 1) +{ + switchToActivity(args(1)); + + return 1; +} + +DEFINE_COMMAND(nextActivity, 0) +{ + const auto activities = controller->activities(); + const auto currentActivity = controller->currentActivity(); + bool found = false; + + for (int i = 0; i < activities.count() - 1; ++i) { + if (activities[i] == currentActivity) { + found = true; + switchToActivity(activities[i + 1]); + break; + } + } + + if (!found) { + switchToActivity(activities[0]); + } + + return 0; +} + +DEFINE_COMMAND(previousActivity, 0) +{ + const auto activities = controller->activities(); + const auto currentActivity = controller->currentActivity(); + bool found = false; + + for (int i = 1; i < activities.count(); ++i) { + if (activities[i] == currentActivity) { + found = true; + switchToActivity(activities[i - 1]); + break; + } + } + + if (!found) { + found = true; + switchToActivity(activities.last()); + } + + return 0; +} + +void printHelp() +{ + if (!flags.bare) { + qDebug() + << "\nModifiers (applied only to trailing commands):" + << "\n --bare, --no-bare - show minimal info vs show everything" + << "\n --color, --no-color - make the output pretty" + + << "\n\nCommands:" + << "\n --list-activities - lists all activities" + << "\n --create-activity Name - creates a new activity with the specified name" + << "\n --remove-activity ID - removes the activity with the specified id" + << "\n --start-activity ID - starts the specified activity" + << "\n --stop-activity ID - stops the specified activity" + + << "\n --current-activity - show the current activity" + << "\n --set-current-activity - sets the current activity" + << "\n --next-activity - switches to the next activity (in list-activities order)" + << "\n --previous-activity - switches to the previous activity (in list-activities order)" + + << "\n --activity-property What ID" + << "\n - gets activity name, icon or description" + << "\n --set-activity-property What ID Value" + << "\n - changes activity name, icon or description" + ; + + } else { + qDebug() + << "\n--bare" + << "\n--no-bare" + << "\n--color" + << "\n--no-color" + << "\n--list-activities" + << "\n--create-activitya NAME" + << "\n--remove-activity ID" + + << "\n--current-activity" + << "\n--set-current-activity" + << "\n--next-activity" + << "\n--previous-activity" + ; + + } + +} + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + + QTimer::singleShot(0, &app, [] { + + const auto args = QCoreApplication::arguments(); + + controller = new KActivities::Controller(); + + while (controller->serviceStatus() != KActivities::Controller::Running) { + QCoreApplication::processEvents(); + } + + #define MATCH_COMMAND(Command) \ + else if (args[argId] == QStringLiteral("--") + toDashes(#Command)) \ + { \ + argId += 1 + Command##_command({ args, argId })(); \ + } + + if (args.count() <= 1) { + printHelp(); + + } else for (int argId = 1; argId < args.count(); ) { + if (args[argId] == "--help") { + printHelp(); + argId++; + } + + MATCH_COMMAND(bare) + MATCH_COMMAND(noBare) + MATCH_COMMAND(color) + MATCH_COMMAND(noColor) + + MATCH_COMMAND(listActivities) + + MATCH_COMMAND(currentActivity) + MATCH_COMMAND(setCurrentActivity) + MATCH_COMMAND(activityProperty) + MATCH_COMMAND(setActivityProperty) + MATCH_COMMAND(nextActivity) + MATCH_COMMAND(previousActivity) + + MATCH_COMMAND(createActivity) + MATCH_COMMAND(removeActivity) + MATCH_COMMAND(startActivity) + MATCH_COMMAND(stopActivity) + + else { + qDebug() << "Skipping unknown argument" << args[argId]; + argId++; + } + + } + + delete controller; + + QCoreApplication::quit(); + + }); + + return app.exec(); +} + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/cli/utils.h new/kactivities-5.25.0/src/cli/utils.h --- old/kactivities-5.24.0/src/cli/utils.h 1970-01-01 01:00:00.000000000 +0100 +++ new/kactivities-5.25.0/src/cli/utils.h 2016-08-06 10:25:49.000000000 +0200 @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2016 Ivan Čukić <ivan.cukic(at)kde.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. + * If not, see <http://www.gnu.org/licenses/>. + */ + +QTextStream out(stdout); + +class StringListView { +public: + StringListView(const QStringList &list, int start, int end = -1) + : m_list(list) + , m_start(start) + , m_size((end == -1 ? list.count() : end) - start) + { + + } + + const QString &operator() (int index) const + { + return m_list[m_start + index]; + } + + int count() const + { + return m_size; + } + +private: + const QStringList &m_list; + int m_start; + int m_size; + +}; + +KActivities::Controller *controller = nullptr; + +class Flags { +public: + Flags() + : bare(false) + , color(true) + { + } + + bool bare; + bool color; + +} flags; + +QString toDashes(const QString &command) +{ + QString result(command); + + for (int i = 0; i < result.size() - 1; ++i) { + if (result[i].isLower() && + result[i+1].isUpper()) { + result[i+1] = result[i+1].toLower(); + result.insert(i+1, "-"); + } + } + + return result; +} + +void printActivity(const QString &id) +{ + if (flags.bare) { + out << id << "\n"; + + } else { + using namespace KActivities; + Info info(id); + + out + << ( + info.id() == controller->currentActivity() ? "[CURRENT] " : + info.state() == Info::Running ? "[RUNNING] " : + info.state() == Info::Stopped ? "[STOPPED] " : + info.state() == Info::Starting ? "[STARTING]" : + info.state() == Info::Stopping ? "[STOPPING]" : + "unknown " + ) + << info.id() + << " " + << info.name() + << " (" + << info.icon() + << ")\n" + ; + + if (info.id() == controller->currentActivity() + && info.state() != Info::Running) { + qWarning() + << "Activity is the current one, but its state is" + << ( + info.state() == Info::Running ? "running" : + info.state() == Info::Stopped ? "stopped" : + info.state() == Info::Starting ? "starting" : + info.state() == Info::Stopping ? "stopping" : + "unknown " + ); + } + } +} + +template <typename T> +T awaitFuture(const QFuture<T> &future) +{ + while (!future.isFinished()) { + QCoreApplication::processEvents(); + } + + return future.result(); +} + +void awaitFuture(const QFuture<void> &future) +{ + while (!future.isFinished()) { + QCoreApplication::processEvents(); + } +} + +void switchToActivity(const QString &id) +{ + auto result = awaitFuture(controller->setCurrentActivity(id)); + + if (!flags.bare) { + if (result) { + qDebug() << "Current activity is" << id; + } else { + qDebug() << "Failed to change the activity"; + } + } +} + + +#define DEFINE_COMMAND(Command, MinArgCount) \ + struct Command##_command { \ + const StringListView &args; \ + Command##_command(const StringListView &args) \ + : args(args) \ + { \ + if (args.count() < MinArgCount + 1) { \ + qFatal("not enough arguments for " #Command); \ + } \ + } \ + \ + int operator()(); \ + }; \ + \ + int Command##_command::operator()() + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/lib/activitiesmodel.cpp new/kactivities-5.25.0/src/lib/activitiesmodel.cpp --- old/kactivities-5.24.0/src/lib/activitiesmodel.cpp 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/src/lib/activitiesmodel.cpp 2016-08-06 10:25:49.000000000 +0200 @@ -297,16 +297,17 @@ return; } - auto activityInfoPtr = *(registeredPosition.iterator); + const auto activityInfoPtr = *(registeredPosition.iterator); - auto position = shownActivities.insert(activityInfoPtr); - - if (notifyClients) { - unsigned int index = - (position.second ? position.first : shownActivities.end()) - - shownActivities.begin(); + // In C++17, this would be: + // const auto [iterator, index, found] = shownActivities.insert(...); + const auto _result = shownActivities.insert(activityInfoPtr); + // const auto iterator = std::get<0>(_result); + const auto index = std::get<1>(_result); + const auto found = std::get<2>(_result); + if (notifyClients) { q->beginInsertRows(QModelIndex(), index, index); q->endInsertRows(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/lib/info.cpp new/kactivities-5.25.0/src/lib/info.cpp --- old/kactivities-5.24.0/src/lib/info.cpp 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/src/lib/info.cpp 2016-08-06 10:25:49.000000000 +0200 @@ -81,6 +81,23 @@ } } +void InfoPrivate::setCurrentActivity(const QString ¤tActivity) +{ + if (isCurrent) { + if (currentActivity != id) { + // We are no longer the current activity + isCurrent = false; + emit q->isCurrentChanged(false); + } + } else { + if (currentActivity == id) { + // We are the current activity + isCurrent = true; + emit q->isCurrentChanged(true); + } + } +} + // Info Info::Info(const QString &activity, QObject *parent) : QObject(parent) @@ -108,6 +125,10 @@ PASS_SIGNAL_HANDLER(activityIconChanged, iconChanged, QString); #undef PASS_SIGNAL_HANDLER + connect(d->cache.get(), SIGNAL(currentActivityChanged(QString)), + this, SLOT(setCurrentActivity(QString))); + + d->isCurrent = (d->cache.get()->m_currentActivity == activity); } Info::~Info() @@ -131,6 +152,11 @@ return d->id; } +bool Info::isCurrent() const +{ + return d->isCurrent; +} + Info::State Info::state() const { if (d->cache->m_status == Consumer::Unknown) return Info::Unknown; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/lib/info.h new/kactivities-5.25.0/src/lib/info.h --- old/kactivities-5.24.0/src/lib/info.h 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/src/lib/info.h 2016-08-06 10:25:49.000000000 +0200 @@ -76,6 +76,7 @@ Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString description READ description NOTIFY descriptionChanged) Q_PROPERTY(QString icon READ icon NOTIFY iconChanged) + Q_PROPERTY(bool isCurrent READ isCurrent NOTIFY isCurrentChanged) Q_PROPERTY(Info::State state READ state NOTIFY stateChanged) public: @@ -125,6 +126,11 @@ QString id() const; /** + * @returns whether this activity is the current one + */ + bool isCurrent() const; + + /** * @returns the name of the activity */ QString name() const; @@ -181,6 +187,12 @@ void nameChanged(const QString &name); /** + * Emitted when the activity becomes the current one, or when it stops + * being the current one + */ + void isCurrentChanged(bool current); + + /** * Emitted when the description is changed */ void descriptionChanged(const QString &description); @@ -229,6 +241,7 @@ Q_PRIVATE_SLOT(d, void descriptionChanged(const QString &, const QString &)) Q_PRIVATE_SLOT(d, void iconChanged(const QString &, const QString &)) Q_PRIVATE_SLOT(d, void setServiceStatus(Consumer::ServiceStatus)) + Q_PRIVATE_SLOT(d, void setCurrentActivity(const QString &)) friend class InfoPrivate; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/lib/info_p.h new/kactivities-5.25.0/src/lib/info_p.h --- old/kactivities-5.24.0/src/lib/info_p.h 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/src/lib/info_p.h 2016-08-06 10:25:49.000000000 +0200 @@ -45,9 +45,11 @@ void descriptionChanged(const QString &, const QString &) const; void iconChanged(const QString &, const QString &) const; void setServiceStatus(Consumer::ServiceStatus status) const; + void setCurrentActivity(const QString ¤tActivity); Info *const q; std::shared_ptr<ActivitiesCache> cache; + bool isCurrent; const QString id; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kactivities-5.24.0/src/utils/qflatset.h new/kactivities-5.25.0/src/utils/qflatset.h --- old/kactivities-5.24.0/src/utils/qflatset.h 2016-07-02 10:40:02.000000000 +0200 +++ new/kactivities-5.25.0/src/utils/qflatset.h 2016-08-06 10:25:49.000000000 +0200 @@ -24,44 +24,49 @@ #include <QVector> #include <QPair> +#include <QDebug> namespace KActivities { -template <typename T, typename Comparator> +template <typename T, typename LessThan> class QFlatSet: public QVector<T> { public: + QFlatSet() + { + } + inline - QPair<typename QVector<T>::iterator, bool> insert(const T &value) + // QPair<typename QVector<T>::iterator, bool> insert(const T &value) + std::tuple<typename QVector<T>::iterator, int, bool> insert(const T &value) { - auto comparator = Comparator(); - auto begin = this->begin(); - auto end = this->end(); + auto lessThan = LessThan(); + auto begin = this->begin(); + auto end = this->end(); if (begin == end) { QVector<T>::insert(0, value); - return { QVector<T>::begin(), true }; + return std::make_tuple(QVector<T>::begin(), 0, true); } else { - // We want small sets, so a binary search - // will be slower than a serial search - auto iterator = std::find_if(begin, end, - [&] (const T ¤t) { - return comparator(value, current); - }); + auto iterator = std::lower_bound(begin, end, value, lessThan); if (iterator != end) { - if (comparator(*iterator, value)) { + if (!lessThan(value, *iterator)) { // Already present - return { iterator, false }; + return std::make_tuple(iterator, iterator - begin, false); } } QVector<T>::insert(iterator, value); - return { iterator, true }; + return std::make_tuple(iterator, iterator - begin, true); } } + +private: + QFlatSet(const QFlatSet &original); // = delete + };
