Maemo: Improve remote mounts GUI.

Reviewed-by: kh1
This commit is contained in:
ck
2010-07-29 14:35:08 +02:00
parent 576642a76a
commit af57685ca8
4 changed files with 56 additions and 5 deletions

View File

@@ -86,6 +86,16 @@ void MaemoRemoteMountsModel::setLocalDir(int pos, const QString &localDir)
emit dataChanged(currentIndex, currentIndex); emit dataChanged(currentIndex, currentIndex);
} }
int MaemoRemoteMountsModel::validMountSpecificationCount() const
{
int count = 0;
foreach (const MountSpecification &m, m_mountSpecs) {
if (m.isValid())
++count;
}
return count;
}
bool MaemoRemoteMountsModel::hasValidMountSpecifications() const bool MaemoRemoteMountsModel::hasValidMountSpecifications() const
{ {
foreach (const MountSpecification &m, m_mountSpecs) { foreach (const MountSpecification &m, m_mountSpecs) {
@@ -168,7 +178,7 @@ QVariant MaemoRemoteMountsModel::data(const QModelIndex &index, int role) const
return mountSpec.remoteMountPoint; return mountSpec.remoteMountPoint;
break; break;
case PortRow: case PortRow:
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole || role == Qt::EditRole)
return mountSpec.port; return mountSpec.port;
break; break;
} }

View File

@@ -53,6 +53,7 @@ public:
explicit MaemoRemoteMountsModel(QObject *parent = 0); explicit MaemoRemoteMountsModel(QObject *parent = 0);
int mountSpecificationCount() const { return m_mountSpecs.count(); } int mountSpecificationCount() const { return m_mountSpecs.count(); }
int validMountSpecificationCount() const;
MountSpecification mountSpecificationAt(int pos) const { return m_mountSpecs.at(pos); } MountSpecification mountSpecificationAt(int pos) const { return m_mountSpecs.at(pos); }
bool hasValidMountSpecifications() const; bool hasValidMountSpecifications() const;

View File

@@ -43,6 +43,7 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <projectexplorer/environmenteditmodel.h> #include <projectexplorer/environmenteditmodel.h>
#include <utils/detailswidget.h>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QFileDialog> #include <QtGui/QFileDialog>
@@ -99,12 +100,13 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
formLayout->addRow(tr("Arguments:"), m_argsLineEdit); formLayout->addRow(tr("Arguments:"), m_argsLineEdit);
mainLayout->addSpacing(20); mainLayout->addSpacing(20);
QGroupBox *mountViewBox = new QGroupBox; m_detailsContainer = new Utils::DetailsWidget(this);
QWidget *mountViewWidget = new QWidget;
m_detailsContainer->setWidget(mountViewWidget);
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
mainLayout->addWidget(mountViewBox); mainLayout->addWidget(m_detailsContainer);
#endif #endif
mountViewBox->setTitle(tr("Local Directories to mount from device")); QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget);
QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewBox);
QHBoxLayout *hostAddressLayout = new QHBoxLayout; QHBoxLayout *hostAddressLayout = new QHBoxLayout;
mountViewLayout->addLayout(hostAddressLayout); mountViewLayout->addLayout(hostAddressLayout);
QLabel *hostNameLabel QLabel *hostNameLabel
@@ -160,6 +162,7 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
handleCurrentDeviceConfigChanged(); handleCurrentDeviceConfigChanged();
enableOrDisableRemoveButton(); enableOrDisableRemoveButton();
handleRemoteMountsChanged();
connect(m_configNameLineEdit, SIGNAL(textEdited(QString)), this, connect(m_configNameLineEdit, SIGNAL(textEdited(QString)), this,
SLOT(configNameEdited(QString))); SLOT(configNameEdited(QString)));
@@ -175,6 +178,7 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
SLOT(showSettingsDialog(QString))); SLOT(showSettingsDialog(QString)));
connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this, connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this,
SLOT(showSettingsDialog(QString))); SLOT(showSettingsDialog(QString)));
connect(addMountButton, SIGNAL(clicked()), this, SLOT(addMount())); connect(addMountButton, SIGNAL(clicked()), this, SLOT(addMount()));
connect(m_removeMountButton, SIGNAL(clicked()), this, SLOT(removeMount())); connect(m_removeMountButton, SIGNAL(clicked()), this, SLOT(removeMount()));
connect(m_mountView, SIGNAL(doubleClicked(QModelIndex)), this, connect(m_mountView, SIGNAL(doubleClicked(QModelIndex)), this,
@@ -182,6 +186,17 @@ MaemoRunConfigurationWidget::MaemoRunConfigurationWidget(
connect(m_mountView->selectionModel(), connect(m_mountView->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
SLOT(enableOrDisableRemoveButton())); SLOT(enableOrDisableRemoveButton()));
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()));
connect(m_environmentWidget, SIGNAL(userChangesChanged()), this, connect(m_environmentWidget, SIGNAL(userChangesChanged()), this,
SLOT(userChangesEdited())); SLOT(userChangesEdited()));
@@ -335,5 +350,26 @@ void MaemoRunConfigurationWidget::userEnvironmentChangesChanged(const QList<Proj
m_environmentWidget->setUserChanges(userChanges); m_environmentWidget->setUserChanges(userChanges);
} }
void MaemoRunConfigurationWidget::handleRemoteMountsChanged()
{
const int mountCount
= m_runConfiguration->remoteMounts()->validMountSpecificationCount();
QString text;
switch (mountCount) {
case 0:
text = tr("No local directories to be mounted from the device.");
break;
case 1:
text = tr("One local directory to be mounted from the device.");
break;
default:
text = tr("%1 local directories to be mounted from the device.")
.arg(mountCount);
break;
}
m_detailsContainer->setSummaryText(QLatin1String("<b>") + text
+ QLatin1String("</b>"));
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager

View File

@@ -52,6 +52,8 @@ namespace ProjectExplorer {
class EnvironmentWidget; class EnvironmentWidget;
} }
namespace Utils { class DetailsWidget; }
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
@@ -84,6 +86,7 @@ private slots:
void baseEnvironmentChanged(); void baseEnvironmentChanged();
void systemEnvironmentChanged(); void systemEnvironmentChanged();
void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges); void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges);
void handleRemoteMountsChanged();
private: private:
QLineEdit *m_configNameLineEdit; QLineEdit *m_configNameLineEdit;
@@ -93,6 +96,7 @@ private:
QLineEdit *m_hostAddressLineEdit; QLineEdit *m_hostAddressLineEdit;
QTableView *m_mountView; QTableView *m_mountView;
QToolButton *m_removeMountButton; QToolButton *m_removeMountButton;
Utils::DetailsWidget *m_detailsContainer;
MaemoRunConfiguration *m_runConfiguration; MaemoRunConfiguration *m_runConfiguration;
bool m_ignoreChange; bool m_ignoreChange;