From e83a6f6610620c5a8fa36c4c69e43be005ea4617 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 25 Nov 2020 14:24:55 +0100 Subject: [PATCH] Remove unused TypeSpecificDeviceConfigurationListModel class Change-Id: I658e447d49bfd78b76c32f635f284eba859a0e94 Reviewed-by: Christian Kandeler --- src/plugins/remotelinux/CMakeLists.txt | 1 - src/plugins/remotelinux/remotelinux.pro | 2 - src/plugins/remotelinux/remotelinux.qbs | 2 - ...pespecificdeviceconfigurationlistmodel.cpp | 134 ------------------ ...typespecificdeviceconfigurationlistmodel.h | 57 -------- 5 files changed, 196 deletions(-) delete mode 100644 src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp delete mode 100644 src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.h diff --git a/src/plugins/remotelinux/CMakeLists.txt b/src/plugins/remotelinux/CMakeLists.txt index f5b00e5ff8a..8c51e48ab6c 100644 --- a/src/plugins/remotelinux/CMakeLists.txt +++ b/src/plugins/remotelinux/CMakeLists.txt @@ -43,6 +43,5 @@ add_qtc_plugin(RemoteLinux rsyncdeploystep.cpp rsyncdeploystep.h sshkeydeployer.cpp sshkeydeployer.h tarpackagecreationstep.cpp tarpackagecreationstep.h - typespecificdeviceconfigurationlistmodel.cpp typespecificdeviceconfigurationlistmodel.h uploadandinstalltarpackagestep.cpp uploadandinstalltarpackagestep.h ) diff --git a/src/plugins/remotelinux/remotelinux.pro b/src/plugins/remotelinux/remotelinux.pro index 1e92e019cb4..c9c27a0f2d7 100644 --- a/src/plugins/remotelinux/remotelinux.pro +++ b/src/plugins/remotelinux/remotelinux.pro @@ -29,7 +29,6 @@ HEADERS += \ remotelinux_constants.h \ remotelinuxenvironmentreader.h \ sshkeydeployer.h \ - typespecificdeviceconfigurationlistmodel.h \ remotelinuxcustomcommanddeployservice.h \ remotelinuxcustomcommanddeploymentstep.h \ genericlinuxdeviceconfigurationwidget.h \ @@ -70,7 +69,6 @@ SOURCES += \ linuxdevicetester.cpp \ remotelinuxenvironmentreader.cpp \ sshkeydeployer.cpp \ - typespecificdeviceconfigurationlistmodel.cpp \ remotelinuxcustomcommanddeployservice.cpp \ remotelinuxcustomcommanddeploymentstep.cpp \ genericlinuxdeviceconfigurationwidget.cpp \ diff --git a/src/plugins/remotelinux/remotelinux.qbs b/src/plugins/remotelinux/remotelinux.qbs index 03d280735ba..f668e607dbd 100644 --- a/src/plugins/remotelinux/remotelinux.qbs +++ b/src/plugins/remotelinux/remotelinux.qbs @@ -95,8 +95,6 @@ Project { "sshkeydeployer.h", "tarpackagecreationstep.cpp", "tarpackagecreationstep.h", - "typespecificdeviceconfigurationlistmodel.cpp", - "typespecificdeviceconfigurationlistmodel.h", "uploadandinstalltarpackagestep.cpp", "uploadandinstalltarpackagestep.h", "images/embeddedtarget.png", diff --git a/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp b/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp deleted file mode 100644 index 315da09e023..00000000000 --- a/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "typespecificdeviceconfigurationlistmodel.h" - -#include -#include -#include -#include - -using namespace ProjectExplorer; - -namespace RemoteLinux { -namespace Internal { - -TypeSpecificDeviceConfigurationListModel::TypeSpecificDeviceConfigurationListModel(Target *target) - : QAbstractListModel(target) -{ - const DeviceManager * const devConfs = DeviceManager::instance(); - connect(devConfs, SIGNAL(updated()), this, SIGNAL(modelReset())); - connect(target, SIGNAL(kitChanged()), this, SIGNAL(modelReset())); -} - -int TypeSpecificDeviceConfigurationListModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - int count = 0; - const DeviceManager * const devConfs = DeviceManager::instance(); - const int devConfsCount = devConfs->deviceCount(); - for (int i = 0; i < devConfsCount; ++i) { - if (deviceMatches(devConfs->deviceAt(i))) - ++count; - } - return count; -} - -QVariant TypeSpecificDeviceConfigurationListModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.row() >= rowCount() || role != Qt::DisplayRole) - return QVariant(); - const IDevice::ConstPtr &device = deviceAt(index.row()); - Q_ASSERT(device); - QString displayedName = device->displayName(); - if (deviceMatches(device) - && DeviceManager::instance()->defaultDevice(device->type()) == device) { - displayedName = tr("%1 (default)").arg(displayedName); - } - return displayedName; -} - -IDevice::ConstPtr TypeSpecificDeviceConfigurationListModel::deviceAt(int idx) const -{ - int currentRow = -1; - const DeviceManager * const devConfs = DeviceManager::instance(); - const int devConfsCount = devConfs->deviceCount(); - for (int i = 0; i < devConfsCount; ++i) { - const IDevice::ConstPtr device = devConfs->deviceAt(i); - if (deviceMatches(device) && ++currentRow == idx) - return device; - } - QTC_CHECK(false); - return IDevice::ConstPtr(); -} - -IDevice::ConstPtr TypeSpecificDeviceConfigurationListModel::defaultDeviceConfig() const -{ - const DeviceManager * const deviceManager = DeviceManager::instance(); - const int deviceCount = deviceManager->deviceCount(); - for (int i = 0; i < deviceCount; ++i) { - const IDevice::ConstPtr device = deviceManager->deviceAt(i); - if (deviceMatches(device) - && deviceManager->defaultDevice(device->type()) == device) { - return device; - } - } - return IDevice::ConstPtr(); -} - -IDevice::ConstPtr TypeSpecificDeviceConfigurationListModel::find(Utils::Id id) const -{ - const IDevice::ConstPtr &device = DeviceManager::instance()->find(id); - if (deviceMatches(device)) - return device; - return defaultDeviceConfig(); -} - -int TypeSpecificDeviceConfigurationListModel::indexForId(Utils::Id id) const -{ - const int count = rowCount(); - for (int i = 0; i < count; ++i) { - if (deviceAt(i)->id() == id) - return i; - } - return -1; -} - -Target *TypeSpecificDeviceConfigurationListModel::target() const -{ - return qobject_cast(QObject::parent()); -} - -bool TypeSpecificDeviceConfigurationListModel::deviceMatches(IDevice::ConstPtr dev) const -{ - if (dev.isNull()) - return false; - Utils::Id typeId = DeviceTypeKitAspect::deviceTypeId(target()->kit()); - return dev->type() == typeId; -} - -} // namespace Internal -} // namespace RemoteLinux diff --git a/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.h b/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.h deleted file mode 100644 index 00e3168c775..00000000000 --- a/src/plugins/remotelinux/typespecificdeviceconfigurationlistmodel.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -#include - -namespace ProjectExplorer { class Target; } - -namespace RemoteLinux { -namespace Internal { - -class TypeSpecificDeviceConfigurationListModel : public QAbstractListModel -{ - Q_OBJECT - -public: - explicit TypeSpecificDeviceConfigurationListModel(ProjectExplorer::Target *target); - - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - -private: - int indexForId(Utils::Id id) const; - ProjectExplorer::IDevice::ConstPtr deviceAt(int idx) const; - ProjectExplorer::IDevice::ConstPtr defaultDeviceConfig() const; - ProjectExplorer::IDevice::ConstPtr find(Utils::Id id) const; - ProjectExplorer::Target *target() const; - bool deviceMatches(ProjectExplorer::IDevice::ConstPtr dev) const; -}; - -} // namespace Internal -} // namespace RemoteLinux