Plasma5Support

placeservice.cpp
1/*
2 SPDX-FileCopyrightText: 2008 Alex Merry <alex.merry@kdemail.net>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#include "placeservice.h"
8#include "jobs.h"
9
10#include <QDebug>
11
12PlaceService::PlaceService(QObject *parent, KFilePlacesModel *model)
13 : Plasma5Support::Service(parent)
14 , m_model(model)
15{
16 setName(QStringLiteral("org.kde.places"));
17
18 setDestination(QStringLiteral("places"));
19 qDebug() << "Created a place service for" << destination();
20}
21
22Plasma5Support::ServiceJob *PlaceService::createJob(const QString &operation, QMap<QString, QVariant> &parameters)
23{
24 QModelIndex index = m_model->index(parameters.value(QStringLiteral("placeIndex")).toInt(), 0);
25
26 if (!index.isValid()) {
27 return nullptr;
28 }
29
30 qDebug() << "Job" << operation << "with arguments" << parameters << "requested";
31 if (operation == QLatin1String("Add")) {
32 return new AddEditPlaceJob(m_model, index, parameters, this);
33 } else if (operation == QLatin1String("Edit")) {
34 return new AddEditPlaceJob(m_model, QModelIndex(), parameters, this);
35 } else if (operation == QLatin1String("Remove")) {
36 return new RemovePlaceJob(m_model, index, this);
37 } else if (operation == QLatin1String("Hide")) {
38 return new ShowPlaceJob(m_model, index, false, this);
39 } else if (operation == QLatin1String("Show")) {
40 return new ShowPlaceJob(m_model, index, true, this);
41 } else if (operation == QLatin1String("Setup Device")) {
42 return new SetupDeviceJob(m_model, index, this);
43 } else if (operation == QLatin1String("Teardown Device")) {
44 return new TeardownDeviceJob(m_model, index, this);
45 } else {
46 // FIXME: BAD! No!
47 return nullptr;
48 }
49}
50
51// vim: sw=4 sts=4 et tw=100
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
This class provides jobs for use with Plasma5Support::Service.
Definition servicejob.h:39
Namespace for everything in libplasma.
Definition datamodel.cpp:15
T value(const Key &key, const T &defaultValue) const const
bool isValid() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.