1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
/*
* Copyright 2013 Canonical Ltd.
*
* This program 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; version 3.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Michael Zanetti <michael.zanetti@canonical.com>
*/
#ifndef LOMIRI_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
#define LOMIRI_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
#include <lomiri/SymbolExport.h>
#include <lomiri/shell/application/ApplicationManagerInterface.h>
#include <QtCore/QAbstractListModel>
namespace lomiri
{
namespace shell
{
namespace launcher
{
class LauncherItemInterface;
/**
* @brief A list of launcher items to be displayed
*
* This model exposes all the launcher items that should be shown in the launcher.
*/
class LOMIRI_API LauncherModelInterface: public QAbstractListModel
{
Q_OBJECT
/**
* @brief The ApplicationManager instance the launcher should be connected to
*
* The Launcher will display applications contained in the ApplicationManager as
* running/recent apps and adjust the currently focused app highlight according
* to this.
*/
Q_PROPERTY(lomiri::shell::application::ApplicationManagerInterface* applicationManager
READ applicationManager WRITE setApplicationManager NOTIFY applicationManagerChanged)
/**
* @brief Only show pinned apps, hiding the unpinned running/recent ones.
*/
Q_PROPERTY(bool onlyPinned READ onlyPinned WRITE setOnlyPinned NOTIFY onlyPinnedChanged)
protected:
/// @cond
LauncherModelInterface(QObject *parent = 0): QAbstractListModel(parent) {
m_roleNames.insert(RoleAppId, "appId");
m_roleNames.insert(RoleName, "name");
m_roleNames.insert(RoleIcon, "icon");
m_roleNames.insert(RolePinned, "pinned");
m_roleNames.insert(RoleRunning, "running");
m_roleNames.insert(RoleRecent, "recent");
m_roleNames.insert(RoleProgress, "progress");
m_roleNames.insert(RoleCount, "count");
m_roleNames.insert(RoleCountVisible, "countVisible");
m_roleNames.insert(RoleFocused, "focused");
m_roleNames.insert(RoleAlerting, "alerting");
m_roleNames.insert(RoleSurfaceCount, "surfaceCount");
}
/// @endcond
public:
/**
* @brief The Roles supported by the model
*
* See LauncherItemInterface properties for details.
*/
enum Roles {
RoleAppId = Qt::UserRole,
RoleName,
RoleIcon,
RolePinned,
RoleRunning,
RoleRecent,
RoleProgress,
RoleCount,
RoleCountVisible,
RoleFocused,
RoleAlerting,
RoleSurfaceCount
};
virtual ~LauncherModelInterface() {}
/**
* @brief Move an item in the model.
*
* @param oldIndex The current (old) index of the item to be moved.
* @param newIndex The new index where the item should be moved to.
*/
Q_INVOKABLE virtual void move(int oldIndex, int newIndex) = 0;
/**
* @brief Get a launcher item.
*
* Note: QML requires the full namespace in the return value.
*
* @param index the index of the item to get
* @returns The item.
*/
Q_INVOKABLE virtual lomiri::shell::launcher::LauncherItemInterface *get(int index) const = 0;
/**
* @brief Pin an item to the launcher.
*
* Recent and running applications will eventually disappear from the model
* as the application is closed or new recent items appear. Pinning an item
* to the launcher makes it persist until remove is called on it.
*
* @param appId The appId of the item to be pinned.
* @param index The index where the item should be pinned to. This parameter is optional
* and if not supplied, the item will be pinned to the current position.
* Note: If an item is not contained in the launcher yet, calling this without an index
* will pin the item to the end of the list.
*/
Q_INVOKABLE virtual void pin(const QString &appId, int index = -1) = 0;
/**
* @brief Request removal of an item from the model.
*
* Note: The actual removal of the item might be delayed in certain circumstances.
*
* @param appId The appId of the item to be removed.
*/
Q_INVOKABLE virtual void requestRemove(const QString &appId) = 0;
/**
* @brief Trigger an action from the QuickList
*
* @param appId The appId of the LauncherItem.
* @param actionIndex The index of the triggered entry in the QuickListModel.
*/
Q_INVOKABLE virtual void quickListActionInvoked(const QString &appId, int actionIndex) = 0;
/**
* @brief Set the user for which the launcher should display items.
*
* @param username The user for which the launcher should display items.
*/
Q_INVOKABLE virtual void setUser(const QString &username) = 0;
/// @cond
virtual lomiri::shell::application::ApplicationManagerInterface *applicationManager() const = 0;
virtual void setApplicationManager(lomiri::shell::application::ApplicationManagerInterface *applicationManager) = 0;
virtual bool onlyPinned() const = 0;
virtual void setOnlyPinned(bool onlyPinned) = 0;
QHash<int, QByteArray> roleNames() const override
{
return m_roleNames;
}
/// @endcond
Q_SIGNALS:
/// @cond
void applicationManagerChanged();
void onlyPinnedChanged();
/// @endcond
/**
* @brief Emitted when the launcher should hint itself to the user, e.g. to indicate a
* change the user should be made aware of.
*/
void hint();
protected:
/// @cond
QHash<int, QByteArray> m_roleNames;
/// @endcond
};
} // namespace launcher
} // namespace shell
} // namespace lomiri
#endif // LOMIRI_SHELL_LAUNCHER_LAUNCHERMODELINTERFACE_H
|