Make the maemo settings widget searchable.

Reviewed-by: ck
This commit is contained in:
kh1
2010-04-12 13:17:06 +02:00
parent c0e158f161
commit fac5b92194
5 changed files with 66 additions and 25 deletions

View File

@@ -87,9 +87,16 @@ QIcon MaemoSettingsPage::categoryIcon() const
return QIcon(QLatin1String(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON));
}
bool MaemoSettingsPage::matches(const QString &searchKeyWord) const
{
return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
}
QWidget *MaemoSettingsPage::createPage(QWidget *parent)
{
m_widget = new MaemoSettingsWidget(parent);
if (m_keywords.isEmpty())
m_keywords = m_widget->searchKeywords();
return m_widget;
}

View File

@@ -61,11 +61,13 @@ public:
virtual QString category() const;
virtual QString displayCategory() const;
virtual QIcon categoryIcon() const;
virtual bool matches(const QString &searchKeyWord) const;
virtual QWidget *createPage(QWidget *parent);
virtual void apply();
virtual void finish();
private:
QString m_keywords;
MaemoSettingsWidget *m_widget;
};

View File

@@ -41,6 +41,8 @@
#include "maemosshthread.h"
#include <QtCore/QRegExp>
#include <QtCore/QTextStream>
#include <QtCore/QFileInfo>
#include <QtGui/QFileDialog>
#include <QtGui/QMessageBox>
@@ -125,6 +127,33 @@ MaemoSettingsWidget::~MaemoSettingsWidget()
{
}
QString MaemoSettingsWidget::searchKeywords() const
{
QString rc;
QTextStream(&rc) << m_ui->configurationLabel->text()
<< ' ' << m_ui->gdbServerLabel->text()
<< ' ' << m_ui->sshPortLabel->text()
<< ' ' << m_ui->keyButton->text()
<< ' ' << m_ui->passwordButton->text()
<< ' ' << m_ui->authTypeLabel->text()
<< ' ' << m_ui->connectionTimeoutLabel->text()
<< ' ' << m_ui->deviceButton->text()
<< ' ' << m_ui->simulatorButton->text()
<< ' ' << m_ui->deviceTypeLabel->text()
<< ' ' << m_ui->deviceNameLabel->text()
<< ' ' << m_ui->hostNameLabel->text()
<< ' ' << m_ui->keyLabel->text()
<< ' ' << m_ui->nameLineEdit->text()
<< ' ' << m_ui->passwordLabel->text()
<< ' ' << m_ui->portsLabel->text()
<< ' ' << m_ui->pwdLineEdit->text()
<< ' ' << m_ui->timeoutLineEdit->text()
<< ' ' << m_ui->userLineEdit->text()
<< ' ' << m_ui->userNameLabel->text();
rc.remove(QLatin1Char('&'));
return rc;
}
void MaemoSettingsWidget::initGui()
{
m_ui->setupUi(this);
@@ -133,13 +162,15 @@ void MaemoSettingsWidget::initGui()
m_ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File);
foreach (const MaemoDeviceConfig &devConf, m_devConfs)
m_ui->configurationComboBox->addItem(devConf.name);
connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)), SLOT(currentConfigChanged(int)));
connect(m_ui->configurationComboBox, SIGNAL(currentIndexChanged(int)),
SLOT(currentConfigChanged(int)));
currentConfigChanged(m_ui->configurationComboBox->currentIndex());
}
void MaemoSettingsWidget::addConfig()
{
const QString prefix = tr("New Device Configuration %1", "Standard Configuration name with number");
const QString prefix = tr("New Device Configuration %1", "Standard "
"Configuration name with number");
int suffix = 1;
QString newName;
bool isUnique = false;
@@ -331,12 +362,9 @@ void MaemoSettingsWidget::deployKey()
return;
m_ui->deployKeyButton->disconnect();
SshDeploySpec deploySpec(keyFile,
homeDirOnDevice(currentConfig().uname)
+ QLatin1String("/.ssh/authorized_keys"),
true);
m_keyDeployer = new MaemoSshDeployer(currentConfig(),
QList<SshDeploySpec>() << deploySpec);
SshDeploySpec deploySpec(keyFile, homeDirOnDevice(currentConfig().uname)
+ QLatin1String("/.ssh/authorized_keys"), true);
m_keyDeployer = new MaemoSshDeployer(currentConfig(), QList<SshDeploySpec>() << deploySpec);
connect(m_keyDeployer, SIGNAL(finished()),
this, SLOT(handleDeployThreadFinished()));
m_ui->deployKeyButton->setText(tr("Stop deploying"));
@@ -350,11 +378,13 @@ void MaemoSettingsWidget::handleDeployThreadFinished()
if (!m_keyDeployer)
return;
if (m_keyDeployer->hasError())
QMessageBox::critical(this, tr("Deployment Failed"), tr("Key deployment failed: %1").arg(m_keyDeployer->error()));
else
QMessageBox::information(this, tr("Deployment Succeeded"), tr("Key was successfully deployed."));
if (m_keyDeployer->hasError()) {
QMessageBox::critical(this, tr("Deployment Failed"),
tr("Key deployment failed: %1").arg(m_keyDeployer->error()));
} else {
QMessageBox::information(this, tr("Deployment Succeeded"),
tr("Key was successfully deployed."));
}
stopDeploying();
}
@@ -368,8 +398,7 @@ void MaemoSettingsWidget::stopDeploying()
delete m_keyDeployer;
m_keyDeployer = 0;
m_ui->deployKeyButton->setText(tr("Deploy Key ..."));
connect(m_ui->deployKeyButton, SIGNAL(clicked()),
this, SLOT(deployKey()));
connect(m_ui->deployKeyButton, SIGNAL(clicked()), this, SLOT(deployKey()));
m_ui->deployKeyButton->setEnabled(buttonWasEnabled);
}
}

View File

@@ -60,7 +60,10 @@ class MaemoSettingsWidget : public QWidget
public:
MaemoSettingsWidget(QWidget *parent);
~MaemoSettingsWidget();
void saveSettings();
QString searchKeywords() const;
private slots:
void currentConfigChanged(int index);
void addConfig();

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>534</width>
<height>340</height>
<width>448</width>
<height>307</height>
</rect>
</property>
<property name="windowTitle">
@@ -17,7 +17,7 @@
<item row="0" column="0" colspan="2">
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="configurationLabel">
<property name="text">
<string>Configuration:</string>
</property>
@@ -114,7 +114,7 @@
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="deviceTypeLabel_2">
<widget class="QLabel" name="deviceNameLabel">
<property name="text">
<string>Name</string>
</property>
@@ -184,7 +184,7 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="hostNameLabel">
<property name="text">
<string>Host Name:</string>
</property>
@@ -198,7 +198,7 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="portsLabel">
<property name="text">
<string>Ports:</string>
</property>
@@ -207,7 +207,7 @@
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_7">
<widget class="QLabel" name="sshPortLabel">
<property name="text">
<string>SSH:</string>
</property>
@@ -227,7 +227,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="gdbServerLabel">
<property name="text">
<string>Gdb server:</string>
</property>
@@ -246,7 +246,7 @@
</layout>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="connectionTimeoutLabel">
<property name="text">
<string>Connection Timeout:</string>
</property>
@@ -260,7 +260,7 @@
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<widget class="QLabel" name="userNameLabel">
<property name="text">
<string>User Name:</string>
</property>