Commit e00c24eb authored by Christian Kandeler's avatar Christian Kandeler
Browse files

RemoteLinux: Refactor the way the enabled state is updated.

Until now, the widget had some of the knowledge and passed it on to the
run configuration. Now the flow of information is strictly the other way
around.

Change-Id: I7489910d8c48ad8aa63921ec861e429ea0d2949f
Reviewed-on: http://codereview.qt.nokia.com/294

Reviewed-by: default avatarChristian Kandeler <christian.kandeler@nokia.com>
parent 4b393e70
......@@ -183,10 +183,8 @@ void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
SLOT(handleDebuggingTypeChanged()));
connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
SLOT(updateTargetInformation()));
connect(m_runConfiguration->target(),
SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
SLOT(handleActiveDeployConfigurationChanged()));
handleActiveDeployConfigurationChanged();
connect(m_runConfiguration, SIGNAL(deploySpecsChanged()), SLOT(handleDeploySpecsChanged()));
handleDeploySpecsChanged();
}
void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
......@@ -248,18 +246,8 @@ void MaemoRunConfigurationWidget::addMountWidgets(QVBoxLayout *mainLayout)
connect(m_mountView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
SLOT(enableOrDisableRemoveMountSpecButton()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(rowsInserted(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(),
SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_runConfiguration->remoteMounts(), SIGNAL(modelReset()), this,
SLOT(handleRemoteMountsChanged()));
enableOrDisableRemoveMountSpecButton();
connect(m_runConfiguration, SIGNAL(remoteMountsChanged()), SLOT(handleRemoteMountsChanged()));
handleRemoteMountsChanged();
}
......@@ -314,25 +302,9 @@ void MaemoRunConfigurationWidget::updateTargetInformation()
->setText(QDir::toNativeSeparators(m_runConfiguration->localExecutableFilePath()));
}
void MaemoRunConfigurationWidget::handleActiveDeployConfigurationChanged()
{
if (m_deployablesConnected)
return;
connect(m_runConfiguration->deployConfig()->deployables().data(),
SIGNAL(modelReset()), SLOT(handleDeploySpecsChanged()));
handleDeploySpecsChanged();
m_deployablesConnected = true;
disconnect(m_runConfiguration->target(),
SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
this,
SLOT(handleActiveDeployConfigurationChanged()));
}
void MaemoRunConfigurationWidget::handleDeploySpecsChanged()
{
m_remoteExecutableLabel->setText(m_runConfiguration->remoteExecutableFilePath());
m_runConfiguration->updateFactoryState();
}
void MaemoRunConfigurationWidget::showDeviceConfigurationsDialog(const QString &link)
......@@ -535,7 +507,6 @@ void MaemoRunConfigurationWidget::updateMountWarning()
m_mountWarningLabel->show();
m_mountDetailsContainer->setState(Utils::DetailsWidget::Expanded);
}
m_runConfiguration->updateFactoryState();
}
} // namespace Internal
......
......@@ -95,7 +95,6 @@ private slots:
void handleRemoteMountsChanged();
void handleDebuggingTypeChanged();
void handleDeploySpecsChanged();
void handleActiveDeployConfigurationChanged();
private:
void addGenericWidgets(QVBoxLayout *mainLayout);
......
......@@ -138,6 +138,14 @@ void RemoteLinuxRunConfiguration::init()
this, SLOT(proFileUpdate(Qt4ProjectManager::Qt4ProFileNode*,bool)));
connect(pro, SIGNAL(proFileInvalidated(Qt4ProjectManager::Qt4ProFileNode *)),
this, SLOT(proFileInvalidated(Qt4ProjectManager::Qt4ProFileNode*)));
connect(this, SIGNAL(debuggersChanged()), SLOT(updateEnabledState()));
connect(m_d->remoteMounts, SIGNAL(rowsInserted(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_d->remoteMounts, SIGNAL(rowsRemoved(QModelIndex, int, int)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_d->remoteMounts, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this,
SLOT(handleRemoteMountsChanged()));
connect(m_d->remoteMounts, SIGNAL(modelReset()), SLOT(handleRemoteMountsChanged()));
}
RemoteLinuxRunConfiguration::~RemoteLinuxRunConfiguration()
......@@ -199,9 +207,8 @@ void RemoteLinuxRunConfiguration::handleParseState(bool success)
{
bool enabled = isEnabled();
m_d->validParse = success;
if (enabled != isEnabled()) {
emit isEnabledChanged(!enabled);
}
if (enabled != isEnabled())
updateEnabledState();
}
void RemoteLinuxRunConfiguration::proFileInvalidated(Qt4ProjectManager::Qt4ProFileNode *pro)
......@@ -407,8 +414,6 @@ bool RemoteLinuxRunConfiguration::hasEnoughFreePorts(const QString &mode) const
const AbstractQt4MaemoTarget * const maemoTarget
= qobject_cast<AbstractQt4MaemoTarget *>(target());
const bool remoteMountsAllowed = maemoTarget && maemoTarget->allowsRemoteMounts();
if (remoteMountsAllowed && freePortCount == 0)
return false;
const int mountDirCount = remoteMountsAllowed
? remoteMounts()->validMountSpecificationCount() : 0;
if (mode == Debugger::Constants::DEBUGMODE)
......@@ -421,13 +426,15 @@ bool RemoteLinuxRunConfiguration::hasEnoughFreePorts(const QString &mode) const
void RemoteLinuxRunConfiguration::updateDeviceConfigurations()
{
emit deviceConfigurationChanged(target());
updateEnabledState();
}
void RemoteLinuxRunConfiguration::handleDeployConfigChanged()
{
DeployConfiguration * const activeDeployConf
= target()->activeDeployConfiguration();
Qt4MaemoDeployConfiguration * const activeDeployConf = deployConfig();
if (activeDeployConf) {
connect(activeDeployConf->deployables().data(), SIGNAL(modelReset()),
SLOT(handleDeployablesUpdated()), Qt::UniqueConnection);
connect(activeDeployConf->stepList(), SIGNAL(stepInserted(int)),
SLOT(handleDeployConfigChanged()), Qt::UniqueConnection);
connect(activeDeployConf->stepList(), SIGNAL(stepInserted(int)),
......@@ -445,7 +452,19 @@ void RemoteLinuxRunConfiguration::handleDeployConfigChanged()
}
updateDeviceConfigurations();
updateFactoryState();
updateEnabledState();
}
void RemoteLinuxRunConfiguration::handleDeployablesUpdated()
{
emit deploySpecsChanged();
updateEnabledState();
}
void RemoteLinuxRunConfiguration::handleRemoteMountsChanged()
{
emit remoteMountsChanged();
updateEnabledState();
}
QString RemoteLinuxRunConfiguration::baseEnvironmentText() const
......
......@@ -101,7 +101,6 @@ public:
QSharedPointer<const LinuxDeviceConfiguration> deviceConfig() const;
PortList freePorts() const;
bool useRemoteGdb() const;
void updateFactoryState() { emit isEnabledChanged(isEnabled()); }
DebuggingType debuggingType() const;
QString gdbCmd() const;
......@@ -124,10 +123,12 @@ public:
signals:
void deviceConfigurationChanged(ProjectExplorer::Target *target);
void deploySpecsChanged();
void targetInformationChanged() const;
void baseEnvironmentChanged();
void systemEnvironmentChanged();
void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &diff);
void remoteMountsChanged();
protected:
RemoteLinuxRunConfiguration(Qt4ProjectManager::Qt4BaseTarget *parent,
......@@ -140,6 +141,9 @@ private slots:
void proFileInvalidated(Qt4ProjectManager::Qt4ProFileNode *pro);
void updateDeviceConfigurations();
void handleDeployConfigChanged();
void handleDeployablesUpdated();
void handleRemoteMountsChanged();
void updateEnabledState() { emit isEnabledChanged(isEnabled()); }
private:
void init();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment