forked from qt-creator/qt-creator
Maemo: Implement GUI for per-device port specification.
Currently hidden.
This commit is contained in:
@@ -57,6 +57,7 @@ namespace {
|
||||
const QLatin1String HostKey("Host");
|
||||
const QLatin1String SshPortKey("SshPort");
|
||||
const QLatin1String DebuggingPortKey("GdbServerPort");
|
||||
const QLatin1String PortsSpecKey("FreePortsSpec");
|
||||
const QLatin1String UserNameKey("Uname");
|
||||
const QLatin1String AuthKey("Authentication");
|
||||
const QLatin1String KeyFileKey("KeyFile");
|
||||
@@ -107,7 +108,7 @@ public:
|
||||
* ElemList -> Elem [ ',' ElemList ]
|
||||
* Elem -> Port [ '-' Port ]
|
||||
*/
|
||||
QList<int> parse()
|
||||
MaemoPortList parse()
|
||||
{
|
||||
try {
|
||||
if (!atEnd())
|
||||
@@ -115,7 +116,7 @@ public:
|
||||
} catch (ParseException &e) {
|
||||
qWarning("Malformed ports specification: %s", e.error);
|
||||
}
|
||||
return m_ports;
|
||||
return m_portList;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -138,15 +139,14 @@ private:
|
||||
{
|
||||
const int startPort = parsePort();
|
||||
if (atEnd() || nextChar() != '-') {
|
||||
m_ports << startPort;
|
||||
m_portList.addRange(MaemoPortList::Range(startPort, startPort));
|
||||
return;
|
||||
}
|
||||
++m_pos;
|
||||
const int endPort = parsePort();
|
||||
if (endPort < startPort)
|
||||
throw ParseException("Invalid range (end < start).");
|
||||
for (int port = startPort; port <= endPort; ++port)
|
||||
m_ports << port;
|
||||
m_portList.addRange(MaemoPortList::Range(startPort, endPort));
|
||||
}
|
||||
|
||||
int parsePort()
|
||||
@@ -154,12 +154,13 @@ private:
|
||||
if (atEnd())
|
||||
throw ParseException("Empty port string.");
|
||||
int port = 0;
|
||||
char next = nextChar();
|
||||
while (!atEnd() && std::isdigit(next)) {
|
||||
do {
|
||||
const char next = nextChar();
|
||||
if (!std::isdigit(next))
|
||||
break;
|
||||
port = 10*port + next - '0';
|
||||
++m_pos;
|
||||
next = nextChar();
|
||||
}
|
||||
} while (!atEnd());
|
||||
if (port == 0 || port >= 2 << 16)
|
||||
throw ParseException("Invalid port value.");
|
||||
return port;
|
||||
@@ -168,7 +169,7 @@ private:
|
||||
bool atEnd() const { return m_pos == m_portsSpec.length(); }
|
||||
char nextChar() const { return m_portsSpec.at(m_pos).toAscii(); }
|
||||
|
||||
QList<int> m_ports;
|
||||
MaemoPortList m_portList;
|
||||
int m_pos;
|
||||
const QString &m_portsSpec;
|
||||
};
|
||||
@@ -177,6 +178,7 @@ MaemoDeviceConfig::MaemoDeviceConfig(const QString &name, MaemoDeviceConfig::Dev
|
||||
: name(name),
|
||||
type(devType),
|
||||
debuggingPort(defaultDebuggingPort(type)),
|
||||
portsSpec(defaultPortsSpec(type)),
|
||||
internalId(MaemoDeviceConfigurations::instance().m_nextId++)
|
||||
{
|
||||
server.host = defaultHost(type);
|
||||
@@ -192,6 +194,7 @@ MaemoDeviceConfig::MaemoDeviceConfig(const QSettings &settings,
|
||||
: name(settings.value(NameKey).toString()),
|
||||
type(static_cast<DeviceType>(settings.value(TypeKey, DefaultDeviceType).toInt())),
|
||||
debuggingPort(settings.value(DebuggingPortKey, defaultDebuggingPort(type)).toInt()),
|
||||
portsSpec(settings.value(PortsSpecKey, defaultPortsSpec(type)).toString()),
|
||||
internalId(settings.value(InternalIdKey, nextId).toULongLong())
|
||||
{
|
||||
if (internalId == nextId)
|
||||
@@ -230,6 +233,11 @@ int MaemoDeviceConfig::defaultDebuggingPort(DeviceType type) const
|
||||
return type == Physical ? DefaultGdbServerPortHW : DefaultGdbServerPortSim;
|
||||
}
|
||||
|
||||
QString MaemoDeviceConfig::defaultPortsSpec(DeviceType type) const
|
||||
{
|
||||
return QLatin1String(type == Physical ? "10000-10100" : "13219,14168");
|
||||
}
|
||||
|
||||
QString MaemoDeviceConfig::defaultHost(DeviceType type) const
|
||||
{
|
||||
return type == Physical ? DefaultHostNameHW : DefaultHostNameSim;
|
||||
@@ -240,7 +248,7 @@ bool MaemoDeviceConfig::isValid() const
|
||||
return internalId != InvalidId;
|
||||
}
|
||||
|
||||
QList<int> MaemoDeviceConfig::freePorts() const
|
||||
MaemoPortList MaemoDeviceConfig::freePorts() const
|
||||
{
|
||||
return PortsSpecParser(portsSpec).parse();
|
||||
}
|
||||
@@ -252,6 +260,7 @@ void MaemoDeviceConfig::save(QSettings &settings) const
|
||||
settings.setValue(HostKey, server.host);
|
||||
settings.setValue(SshPortKey, server.port);
|
||||
settings.setValue(DebuggingPortKey, debuggingPort);
|
||||
settings.setValue(PortsSpecKey, portsSpec);
|
||||
settings.setValue(UserNameKey, server.uname);
|
||||
settings.setValue(AuthKey, server.authType);
|
||||
settings.setValue(PasswordKey, server.pwd);
|
||||
|
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -48,6 +49,31 @@ QT_END_NAMESPACE
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class MaemoPortList
|
||||
{
|
||||
public:
|
||||
typedef QPair<int, int> Range;
|
||||
void addRange(const Range &range) { m_ranges << range; }
|
||||
bool hasMore() const { return !m_ranges.isEmpty(); }
|
||||
int count() const {
|
||||
int n = 0;
|
||||
foreach (const Range &r, m_ranges)
|
||||
n += r.second - r.first + 1;
|
||||
return n;
|
||||
}
|
||||
int getNext() {
|
||||
Q_ASSERT(!m_ranges.isEmpty());
|
||||
Range &firstRange = m_ranges.first();
|
||||
const int next = firstRange.first++;
|
||||
if (firstRange.first > firstRange.second)
|
||||
m_ranges.removeFirst();
|
||||
return next;
|
||||
}
|
||||
|
||||
private:
|
||||
QList<Range> m_ranges;
|
||||
};
|
||||
|
||||
class MaemoDeviceConfig
|
||||
{
|
||||
public:
|
||||
@@ -57,7 +83,7 @@ public:
|
||||
MaemoDeviceConfig(const QSettings &settings, quint64 &nextId);
|
||||
void save(QSettings &settings) const;
|
||||
bool isValid() const;
|
||||
QList<int> freePorts() const;
|
||||
MaemoPortList freePorts() const;
|
||||
static QString portsRegExpr();
|
||||
|
||||
static const quint64 InvalidId = 0;
|
||||
@@ -72,6 +98,7 @@ public:
|
||||
private:
|
||||
int defaultSshPort(DeviceType type) const;
|
||||
int defaultDebuggingPort(DeviceType type) const;
|
||||
QString defaultPortsSpec(DeviceType type) const;
|
||||
QString defaultHost(DeviceType type) const;
|
||||
|
||||
};
|
||||
|
@@ -145,6 +145,13 @@ void MaemoSettingsWidget::initGui()
|
||||
m_ui->setupUi(this);
|
||||
m_ui->nameLineEdit->setValidator(m_nameValidator);
|
||||
m_ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File);
|
||||
QRegExpValidator * const portsValidator
|
||||
= new QRegExpValidator(QRegExp(MaemoDeviceConfig::portsRegExpr()), this);
|
||||
m_ui->portsLineEdit->setValidator(portsValidator);
|
||||
#if 1
|
||||
m_ui->freePortsLabel->hide();
|
||||
m_ui->portsLineEdit->hide();
|
||||
#endif
|
||||
|
||||
foreach (const MaemoDeviceConfig &devConf, m_devConfs)
|
||||
m_ui->configurationComboBox->addItem(devConf.name);
|
||||
@@ -217,6 +224,7 @@ void MaemoSettingsWidget::fillInValues()
|
||||
m_ui->hostLineEdit->setText(currentConfig().server.host);
|
||||
m_ui->sshPortSpinBox->setValue(currentConfig().server.port);
|
||||
m_ui->gdbServerPortSpinBox->setValue(currentConfig().debuggingPort);
|
||||
m_ui->portsLineEdit->setText(currentConfig().portsSpec);
|
||||
m_ui->timeoutSpinBox->setValue(currentConfig().server.timeout);
|
||||
m_ui->userLineEdit->setText(currentConfig().server.uname);
|
||||
m_ui->pwdLineEdit->setText(currentConfig().server.pwd);
|
||||
@@ -302,6 +310,11 @@ void MaemoSettingsWidget::gdbServerPortEditingFinished()
|
||||
currentConfig().debuggingPort = m_ui->gdbServerPortSpinBox->value();
|
||||
}
|
||||
|
||||
void MaemoSettingsWidget::handleFreePortsChanged()
|
||||
{
|
||||
currentConfig().portsSpec = m_ui->portsLineEdit->text();
|
||||
}
|
||||
|
||||
void MaemoSettingsWidget::timeoutEditingFinished()
|
||||
{
|
||||
currentConfig().server.timeout = m_ui->timeoutSpinBox->value();
|
||||
|
@@ -84,6 +84,7 @@ private slots:
|
||||
void passwordEditingFinished();
|
||||
void keyFileEditingFinished();
|
||||
void showPassword(bool showClearText);
|
||||
void handleFreePortsChanged();
|
||||
|
||||
// For configuration testing.
|
||||
void testConfig();
|
||||
|
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>596</width>
|
||||
<height>354</height>
|
||||
<width>602</width>
|
||||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -209,13 +209,44 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="freePortsLabel">
|
||||
<property name="text">
|
||||
<string>Free ports:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="portsLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>You can enter lists and ranges like this: 1024,1026-1028,1030</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="connectionTimeoutLabel">
|
||||
<property name="text">
|
||||
<string>Connection timeout:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="timeoutSpinBox">
|
||||
@@ -248,24 +279,24 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="userNameLabel">
|
||||
<property name="text">
|
||||
<string>Username:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="userLineEdit"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="pwdLineEdit">
|
||||
@@ -283,14 +314,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="keyLabel">
|
||||
<property name="text">
|
||||
<string>Private key file:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="Utils::PathChooser" name="keyFileLineEdit" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -420,8 +451,8 @@
|
||||
<slot>userNameEditingFinished()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>419</x>
|
||||
<y>268</y>
|
||||
<x>425</x>
|
||||
<y>302</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>422</x>
|
||||
@@ -436,8 +467,8 @@
|
||||
<slot>passwordEditingFinished()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>291</x>
|
||||
<y>299</y>
|
||||
<x>297</x>
|
||||
<y>334</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>423</x>
|
||||
@@ -516,8 +547,8 @@
|
||||
<slot>keyFileEditingFinished()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>419</x>
|
||||
<y>321</y>
|
||||
<x>425</x>
|
||||
<y>356</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>257</x>
|
||||
@@ -532,8 +563,8 @@
|
||||
<slot>keyFileEditingFinished()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>419</x>
|
||||
<y>321</y>
|
||||
<x>425</x>
|
||||
<y>356</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>257</x>
|
||||
@@ -628,8 +659,8 @@
|
||||
<slot>timeoutEditingFinished()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>199</x>
|
||||
<y>227</y>
|
||||
<x>237</x>
|
||||
<y>270</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>6</x>
|
||||
@@ -644,8 +675,8 @@
|
||||
<slot>timeoutEditingFinished()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>178</x>
|
||||
<y>224</y>
|
||||
<x>237</x>
|
||||
<y>270</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>0</x>
|
||||
@@ -724,8 +755,8 @@
|
||||
<slot>showPassword(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>290</y>
|
||||
<x>424</x>
|
||||
<y>332</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>3</x>
|
||||
@@ -733,6 +764,22 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>portsLineEdit</sender>
|
||||
<signal>editingFinished()</signal>
|
||||
<receiver>MaemoSettingsWidget</receiver>
|
||||
<slot>handleFreePortsChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>184</x>
|
||||
<y>225</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>0</x>
|
||||
<y>393</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>configNameEditingFinished()</slot>
|
||||
@@ -753,5 +800,6 @@
|
||||
<slot>currentConfigChanged(int)</slot>
|
||||
<slot>showGenerateSshKeyDialog()</slot>
|
||||
<slot>showPassword(bool)</slot>
|
||||
<slot>handleFreePortsChanged()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
Reference in New Issue
Block a user