Partially revert d2b461e

Caused runtime issues
This commit is contained in:
Jonah Brüchert 2020-03-21 02:59:49 +01:00
parent 6c66619bc6
commit 1e1b60a17d
No known key found for this signature in database
GPG key ID: A81E075ABEC80A7E
2 changed files with 14 additions and 19 deletions

View file

@ -157,9 +157,9 @@ void ApplicationListModel::loadApplications()
data.startupNotify = service->property(QStringLiteral("StartupNotify")).toBool(); data.startupNotify = service->property(QStringLiteral("StartupNotify")).toBool();
if (m_favorites.contains(data.storageId)) { if (m_favorites.contains(data.storageId)) {
data.location = ApplicationData::Favorites; data.location = Favorites;
} else if (m_desktopItems.contains(data.storageId)) { } else if (m_desktopItems.contains(data.storageId)) {
data.location = ApplicationData::Desktop; data.location = Desktop;
} }
auto it = m_appPositions.constFind(service->storageId()); auto it = m_appPositions.constFind(service->storageId());
@ -236,7 +236,7 @@ void ApplicationListModel::moveRow(const QModelIndex& /* sourceParent */, int so
moveItem(sourceRow, destinationChild); moveItem(sourceRow, destinationChild);
} }
void ApplicationListModel::setLocation(int row, ApplicationData::LauncherLocation location) void ApplicationListModel::setLocation(int row, LauncherLocation location)
{ {
if (row < 0 || row >= m_applicationList.length()) { if (row < 0 || row >= m_applicationList.length()) {
return; return;
@ -247,7 +247,7 @@ void ApplicationListModel::setLocation(int row, ApplicationData::LauncherLocatio
return; return;
} }
if (location == ApplicationData::Favorites) { if (location == Favorites) {
qWarning() << "favoriting" << row << data.name; qWarning() << "favoriting" << row << data.name;
// Deny favorites when full // Deny favorites when full
if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount) { if (row >= m_maxFavoriteCount || m_favorites.count() >= m_maxFavoriteCount) {
@ -260,19 +260,19 @@ void ApplicationListModel::setLocation(int row, ApplicationData::LauncherLocatio
emit favoriteCountChanged(); emit favoriteCountChanged();
// Out of favorites // Out of favorites
} else if (data.location == ApplicationData::Favorites) { } else if (data.location == Favorites) {
m_favorites.removeAll(data.storageId); m_favorites.removeAll(data.storageId);
m_homeScreen->config().writeEntry("Favorites", m_favorites); m_homeScreen->config().writeEntry("Favorites", m_favorites);
emit favoriteCountChanged(); emit favoriteCountChanged();
} }
// In Desktop // In Desktop
if (location == ApplicationData::Desktop) { if (location == Desktop) {
m_desktopItems.insert(data.storageId); m_desktopItems.insert(data.storageId);
m_homeScreen->config().writeEntry("DesktopItems", m_desktopItems.values()); m_homeScreen->config().writeEntry("DesktopItems", m_desktopItems.values());
// Out of Desktop // Out of Desktop
} else if (data.location == ApplicationData::Desktop) { } else if (data.location == Desktop) {
m_desktopItems.remove(data.storageId); m_desktopItems.remove(data.storageId);
m_homeScreen->config().writeEntry(QStringLiteral("DesktopItems"), m_desktopItems.values()); m_homeScreen->config().writeEntry(QStringLiteral("DesktopItems"), m_desktopItems.values());
} }
@ -348,8 +348,8 @@ void ApplicationListModel::setMaxFavoriteCount(int count)
int i = 0; int i = 0;
for (auto &app : m_applicationList) { for (auto &app : m_applicationList) {
if (i >= count && app.location == ApplicationData::Favorites) { if (i >= count && app.location == Favorites) {
app.location = ApplicationData::Grid; app.location = Grid;
emit dataChanged(index(i, 0), index(i, 0)); emit dataChanged(index(i, 0), index(i, 0));
} }
++i; ++i;

View file

@ -33,16 +33,11 @@ class QString;
class ApplicationListModel; class ApplicationListModel;
struct ApplicationData { struct ApplicationData {
enum LauncherLocation {
Grid = 0,
Favorites,
Desktop
};
QString name; QString name;
QString icon; QString icon;
QString storageId; QString storageId;
QString entryPath; QString entryPath;
LauncherLocation location = Grid; int location = 0; //FIXME
bool startupNotify = true; bool startupNotify = true;
}; };
@ -55,9 +50,9 @@ class ApplicationListModel : public QAbstractListModel {
public: public:
enum LauncherLocation { enum LauncherLocation {
Grid = ApplicationData::Grid, Grid = 0,
Favorites = ApplicationData::Favorites, Favorites,
Desktop = ApplicationData::Desktop Desktop
}; };
Q_ENUM(LauncherLocation) Q_ENUM(LauncherLocation)
@ -92,7 +87,7 @@ public:
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
Q_INVOKABLE void setLocation(int row, ApplicationData::LauncherLocation location); Q_INVOKABLE void setLocation(int row, LauncherLocation location);
Q_INVOKABLE void moveItem(int row, int destination); Q_INVOKABLE void moveItem(int row, int destination);