forked from qt-creator/qt-creator
Device support: Move processes dialog creation to settings widget.
With the process list model being publicly available from the IDevice interface, there's no longer a need to force all subclasses to create the dialog themselves via opaque handles. Since clients can now check whether a device offers a process list, the base process list model has been made abstract. Change-Id: If4a0aa68a95b221862c287ad8397ebabe9be5909 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -207,7 +207,7 @@ void StartGdbServerDialog::attachToDevice()
|
||||
{
|
||||
IDevice::ConstPtr device = d->currentDevice();
|
||||
// TODO: display error on non-matching device.
|
||||
if (!device)
|
||||
if (!device || !device->canCreateProcessModel())
|
||||
return;
|
||||
delete d->processList;
|
||||
d->processList = device->createProcessListModel();
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include "maddedevicetester.h"
|
||||
#include "maemoconstants.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
|
||||
#include <projectexplorer/devicesupport/deviceprocesslist.h>
|
||||
#include <remotelinux/linuxdevicetestdialog.h>
|
||||
#include <remotelinux/publickeydeploymentdialog.h>
|
||||
#include <remotelinux/remotelinux_constants.h>
|
||||
@@ -45,7 +43,6 @@ using namespace RemoteLinux;
|
||||
namespace Madde {
|
||||
namespace Internal {
|
||||
const char MaddeDeviceTestActionId[] = "Madde.DeviceTestAction";
|
||||
const char MaddeRemoteProcessesActionId[] = "Madde.RemoteProcessesAction";
|
||||
|
||||
MaddeDevice::Ptr MaddeDevice::create()
|
||||
{
|
||||
@@ -85,8 +82,7 @@ QString MaddeDevice::displayType() const
|
||||
QList<Core::Id> MaddeDevice::actionIds() const
|
||||
{
|
||||
return QList<Core::Id>() << Core::Id(MaddeDeviceTestActionId)
|
||||
<< Core::Id(Constants::GenericDeployKeyToDeviceActionId)
|
||||
<< Core::Id(MaddeRemoteProcessesActionId);
|
||||
<< Core::Id(Constants::GenericDeployKeyToDeviceActionId);
|
||||
}
|
||||
|
||||
QString MaddeDevice::displayNameForActionId(Core::Id actionId) const
|
||||
@@ -95,8 +91,6 @@ QString MaddeDevice::displayNameForActionId(Core::Id actionId) const
|
||||
|
||||
if (actionId == Core::Id(MaddeDeviceTestActionId))
|
||||
return tr("Test");
|
||||
if (actionId == Core::Id(MaddeRemoteProcessesActionId))
|
||||
return tr("Remote Processes...");
|
||||
if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
|
||||
return tr("Deploy Public Key...");
|
||||
return QString(); // Can't happen.
|
||||
@@ -110,8 +104,6 @@ void MaddeDevice::executeAction(Core::Id actionId, QWidget *parent) const
|
||||
const IDevice::ConstPtr device = sharedFromThis();
|
||||
if (actionId == Core::Id(MaddeDeviceTestActionId))
|
||||
d = new LinuxDeviceTestDialog(device, new MaddeDeviceTester, parent);
|
||||
else if (actionId == Core::Id(MaddeRemoteProcessesActionId))
|
||||
d = new DeviceProcessesDialog(createProcessListModel(parent));
|
||||
else if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
|
||||
d = PublicKeyDeploymentDialog::createDialog(device, parent);
|
||||
if (d)
|
||||
|
||||
@@ -40,7 +40,7 @@ class DeviceProcessList;
|
||||
|
||||
namespace Internal { class DeviceProcessesDialogPrivate; }
|
||||
|
||||
class PROJECTEXPLORER_EXPORT DeviceProcessesDialog : public QDialog
|
||||
class DeviceProcessesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -77,11 +77,6 @@ void DeviceProcessList::update()
|
||||
doUpdate();
|
||||
}
|
||||
|
||||
void DeviceProcessList::doUpdate()
|
||||
{
|
||||
reportProcessListUpdated(QList<DeviceProcess>());
|
||||
}
|
||||
|
||||
void DeviceProcessList::reportProcessListUpdated(const QList<DeviceProcess> &processes)
|
||||
{
|
||||
QTC_ASSERT(d->state == Listing, return);
|
||||
@@ -104,11 +99,6 @@ void DeviceProcessList::killProcess(int row)
|
||||
doKillProcess(d->remoteProcesses.at(row));
|
||||
}
|
||||
|
||||
void DeviceProcessList::doKillProcess(const DeviceProcess &)
|
||||
{
|
||||
QTC_ASSERT(false, qDebug("Process list should be empty"); return);
|
||||
}
|
||||
|
||||
void DeviceProcessList::reportProcessKilled()
|
||||
{
|
||||
QTC_ASSERT(d->state == Killing, return);
|
||||
|
||||
@@ -82,9 +82,8 @@ private:
|
||||
int role = Qt::DisplayRole) const;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
|
||||
// No-op implementations for devices without process listing abilities.
|
||||
virtual void doUpdate();
|
||||
virtual void doKillProcess(const DeviceProcess &process);
|
||||
virtual void doUpdate() = 0;
|
||||
virtual void doKillProcess(const DeviceProcess &process) = 0;
|
||||
|
||||
void setFinished();
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "devicefactoryselectiondialog.h"
|
||||
#include "devicemanager.h"
|
||||
#include "devicemanagermodel.h"
|
||||
#include "deviceprocessesdialog.h"
|
||||
#include "deviceprocesslist.h"
|
||||
#include "idevice.h"
|
||||
#include "idevicefactory.h"
|
||||
#include "idevicewidget.h"
|
||||
@@ -288,9 +290,18 @@ void DeviceSettingsWidget::currentDeviceChanged(int index)
|
||||
m_ui->removeConfigButton->setEnabled(false);
|
||||
clearDetails();
|
||||
m_ui->defaultDeviceButton->setEnabled(false);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
setDeviceInfoWidgetsEnabled(true);
|
||||
m_ui->removeConfigButton->setEnabled(true);
|
||||
|
||||
if (device->canCreateProcessModel()) {
|
||||
QPushButton * const button = new QPushButton(tr("Remote Processes"));
|
||||
m_additionalActionButtons << button;
|
||||
connect(button, SIGNAL(clicked()), SLOT(handleProcessListRequested()));
|
||||
m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button);
|
||||
}
|
||||
|
||||
foreach (const Core::Id actionId, device->actionIds()) {
|
||||
QPushButton * const button = new QPushButton(device->displayNameForActionId(actionId));
|
||||
m_additionalActionButtons << button;
|
||||
@@ -298,6 +309,7 @@ void DeviceSettingsWidget::currentDeviceChanged(int index)
|
||||
m_additionalActionsMapper->setMapping(button, actionId.uniqueIdentifier());
|
||||
m_ui->buttonsLayout->insertWidget(m_ui->buttonsLayout->count() - 1, button);
|
||||
}
|
||||
|
||||
if (!m_ui->osSpecificGroupBox->layout())
|
||||
new QVBoxLayout(m_ui->osSpecificGroupBox);
|
||||
m_configWidget = m_deviceManager->mutableDevice(device->id())->createWidget();
|
||||
@@ -305,7 +317,6 @@ void DeviceSettingsWidget::currentDeviceChanged(int index)
|
||||
m_ui->osSpecificGroupBox->layout()->addWidget(m_configWidget);
|
||||
displayCurrent();
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceSettingsWidget::clearDetails()
|
||||
{
|
||||
@@ -321,5 +332,12 @@ void DeviceSettingsWidget::handleAdditionalActionRequest(int actionId)
|
||||
device->executeAction(Core::Id::fromUniqueIdentifier(actionId), this);
|
||||
}
|
||||
|
||||
void DeviceSettingsWidget::handleProcessListRequested()
|
||||
{
|
||||
QTC_ASSERT(currentDevice()->canCreateProcessModel(), return);
|
||||
DeviceProcessesDialog d(currentDevice()->createProcessListModel());
|
||||
d.exec();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace ProjectExplorer
|
||||
|
||||
@@ -69,6 +69,7 @@ private slots:
|
||||
void deviceNameEditingFinished();
|
||||
void setDefaultDevice();
|
||||
void handleAdditionalActionRequest(int actionId);
|
||||
void handleProcessListRequested();
|
||||
|
||||
private:
|
||||
void initGui();
|
||||
|
||||
@@ -262,7 +262,9 @@ PortsGatheringMethod::Ptr IDevice::portsGatheringMethod() const
|
||||
|
||||
DeviceProcessList *IDevice::createProcessListModel(QObject *parent) const
|
||||
{
|
||||
return new DeviceProcessList(sharedFromThis(), parent);
|
||||
Q_UNUSED(parent);
|
||||
QTC_ASSERT(false, qDebug("This should not have been called..."); return 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
IDevice::DeviceState IDevice::deviceState() const
|
||||
|
||||
@@ -114,6 +114,7 @@ public:
|
||||
|
||||
virtual DeviceProcessSupport::Ptr processSupport() const;
|
||||
virtual PortsGatheringMethod::Ptr portsGatheringMethod() const;
|
||||
virtual bool canCreateProcessModel() const { return false; }
|
||||
virtual DeviceProcessList *createProcessListModel(QObject *parent = 0) const;
|
||||
|
||||
enum DeviceState { DeviceReadyToUse, DeviceConnected, DeviceDisconnected, DeviceStateUnknown };
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
|
||||
ProjectExplorer::DeviceProcessSupport::Ptr processSupport() const;
|
||||
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const;
|
||||
bool canCreateProcessModel() const { return false; } // Override LinuxDevice implementation.
|
||||
|
||||
QString displayType() const;
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
|
||||
#include <projectexplorer/devicesupport/deviceprocessesdialog.h>
|
||||
#include <ssh/sshconnection.h>
|
||||
#include <utils/portlist.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -197,8 +196,7 @@ ProjectExplorer::IDeviceWidget *LinuxDevice::createWidget()
|
||||
QList<Core::Id> LinuxDevice::actionIds() const
|
||||
{
|
||||
return QList<Core::Id>() << Core::Id(Constants::GenericTestDeviceActionId)
|
||||
<< Core::Id(Constants::GenericDeployKeyToDeviceActionId)
|
||||
<< Core::Id(Constants::GenericRemoteProcessesActionId);
|
||||
<< Core::Id(Constants::GenericDeployKeyToDeviceActionId);
|
||||
}
|
||||
|
||||
QString LinuxDevice::displayNameForActionId(Core::Id actionId) const
|
||||
@@ -207,8 +205,6 @@ QString LinuxDevice::displayNameForActionId(Core::Id actionId) const
|
||||
|
||||
if (actionId == Core::Id(Constants::GenericTestDeviceActionId))
|
||||
return tr("Test");
|
||||
if (actionId == Core::Id(Constants::GenericRemoteProcessesActionId))
|
||||
return tr("Remote Processes...");
|
||||
if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
|
||||
return tr("Deploy Public Key...");
|
||||
return QString(); // Can't happen.
|
||||
@@ -222,8 +218,6 @@ void LinuxDevice::executeAction(Core::Id actionId, QWidget *parent) const
|
||||
const LinuxDevice::ConstPtr device = sharedFromThis().staticCast<const LinuxDevice>();
|
||||
if (actionId == Core::Id(Constants::GenericTestDeviceActionId))
|
||||
d = new LinuxDeviceTestDialog(device, new GenericLinuxDeviceTester, parent);
|
||||
else if (actionId == Core::Id(Constants::GenericRemoteProcessesActionId))
|
||||
d = new DeviceProcessesDialog(createProcessListModel(parent));
|
||||
else if (actionId == Core::Id(Constants::GenericDeployKeyToDeviceActionId))
|
||||
d = PublicKeyDeploymentDialog::createDialog(device, parent);
|
||||
if (d)
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
|
||||
ProjectExplorer::DeviceProcessSupport::Ptr processSupport() const;
|
||||
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const;
|
||||
bool canCreateProcessModel() const { return true; }
|
||||
ProjectExplorer::DeviceProcessList *createProcessListModel(QObject *parent) const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -37,7 +37,6 @@ const char GenericLinuxOsType[] = "GenericLinuxOsType";
|
||||
|
||||
const char GenericTestDeviceActionId[] = "RemoteLinux.GenericTestDeviceAction";
|
||||
const char GenericDeployKeyToDeviceActionId[] = "RemoteLinux.GenericDeployKeyToDeviceAction";
|
||||
const char GenericRemoteProcessesActionId[] = "RemoteLinux.GenericRemoteProcessesAction";
|
||||
|
||||
const char EMBEDDED_LINUX_QT[] = "RemoteLinux.EmbeddedLinuxQt";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user