File indexing completed on 2024-05-19 05:37:51

0001 /*
0002     SPDX-FileCopyrightText: 2008 Alex Merry <alex.merry@kdemail.net>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #include "placeservice.h"
0008 #include "jobs.h"
0009 
0010 #include <QDebug>
0011 
0012 PlaceService::PlaceService(QObject *parent, KFilePlacesModel *model)
0013     : Plasma5Support::Service(parent)
0014     , m_model(model)
0015 {
0016     setName(QStringLiteral("org.kde.places"));
0017 
0018     setDestination(QStringLiteral("places"));
0019     qDebug() << "Created a place service for" << destination();
0020 }
0021 
0022 Plasma5Support::ServiceJob *PlaceService::createJob(const QString &operation, QMap<QString, QVariant> &parameters)
0023 {
0024     QModelIndex index = m_model->index(parameters.value(QStringLiteral("placeIndex")).toInt(), 0);
0025 
0026     if (!index.isValid()) {
0027         return nullptr;
0028     }
0029 
0030     qDebug() << "Job" << operation << "with arguments" << parameters << "requested";
0031     if (operation == QLatin1String("Add")) {
0032         return new AddEditPlaceJob(m_model, index, parameters, this);
0033     } else if (operation == QLatin1String("Edit")) {
0034         return new AddEditPlaceJob(m_model, QModelIndex(), parameters, this);
0035     } else if (operation == QLatin1String("Remove")) {
0036         return new RemovePlaceJob(m_model, index, this);
0037     } else if (operation == QLatin1String("Hide")) {
0038         return new ShowPlaceJob(m_model, index, false, this);
0039     } else if (operation == QLatin1String("Show")) {
0040         return new ShowPlaceJob(m_model, index, true, this);
0041     } else if (operation == QLatin1String("Setup Device")) {
0042         return new SetupDeviceJob(m_model, index, this);
0043     } else if (operation == QLatin1String("Teardown Device")) {
0044         return new TeardownDeviceJob(m_model, index, this);
0045     } else {
0046         // FIXME: BAD!  No!
0047         return nullptr;
0048     }
0049 }
0050 
0051 // vim: sw=4 sts=4 et tw=100