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

Maemo: Don't create desktop files, ask before updating project files.

Also don't waste performance by repeatedly reacting to the same
project file change.
This is relevant for bigger projects to which a Maemo target might
have been added by mistake.

Task-number: QTCREATORBUG-2647
Reviewed-by: kh1
parent a48139b8
......@@ -41,12 +41,14 @@ namespace Qt4ProjectManager {
namespace Internal {
MaemoDeployableListModel::MaemoDeployableListModel(const Qt4ProFileNode *proFileNode,
const QSharedPointer<ProFileOption> &proFileOption, QObject *parent)
const QSharedPointer<ProFileOption> &proFileOption,
ProFileUpdateSetting updateSetting, QObject *parent)
: QAbstractTableModel(parent),
m_proFileNode(proFileNode),
m_modified(false),
m_proFileWrapper(new MaemoProFileWrapper(m_proFileNode->path(),
m_proFileNode->buildDir(), proFileOption))
m_proFileNode->buildDir(), proFileOption)),
m_proFileUpdateSetting(updateSetting), m_hasTargetPath(false)
{
buildModel();
}
......@@ -58,7 +60,8 @@ bool MaemoDeployableListModel::buildModel()
m_deployables.clear();
const MaemoProFileWrapper::InstallsList &installs = m_proFileWrapper->installs();
if (installs.targetPath.isEmpty()) {
m_hasTargetPath = !installs.targetPath.isEmpty();
if (!m_hasTargetPath && m_proFileUpdateSetting == UpdateProFile) {
const QString remoteDirSuffix
= QLatin1String(m_proFileNode->projectType() == LibraryTemplate
? "/lib" : "/bin");
......@@ -223,8 +226,10 @@ QString MaemoDeployableListModel::localExecutableFilePath() const
QString MaemoDeployableListModel::remoteExecutableFilePath() const
{
return deployableAt(0).remoteDir + '/'
+ QFileInfo(localExecutableFilePath()).fileName();
return m_hasTargetPath
? deployableAt(0).remoteDir + '/'
+ QFileInfo(localExecutableFilePath()).fileName()
: QString();
}
QString MaemoDeployableListModel::projectName() const
......@@ -237,5 +242,12 @@ QString MaemoDeployableListModel::projectDir() const
return QFileInfo(m_proFileNode->path()).dir().path();
}
void MaemoDeployableListModel::setProFileUpdateSetting(ProFileUpdateSetting updateSetting)
{
m_proFileUpdateSetting = updateSetting;
if (updateSetting == UpdateProFile)
buildModel();
}
} // namespace Qt4ProjectManager
} // namespace Internal
......@@ -52,8 +52,13 @@ class MaemoDeployableListModel : public QAbstractTableModel
{
Q_OBJECT
public:
enum ProFileUpdateSetting {
UpdateProFile, DontUpdateProFile, AskToUpdateProFile
};
MaemoDeployableListModel(const Qt4ProFileNode *proFileNode,
const QSharedPointer<ProFileOption> &proFileOption, QObject *parent);
const QSharedPointer<ProFileOption> &proFileOption,
ProFileUpdateSetting updateSetting, QObject *parent);
~MaemoDeployableListModel();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
......@@ -68,6 +73,11 @@ public:
QString projectName() const;
QString projectDir() const;
const Qt4ProFileNode *proFileNode() const { return m_proFileNode; }
bool hasTargetPath() const { return m_hasTargetPath; }
ProFileUpdateSetting proFileUpdateSetting() const {
return m_proFileUpdateSetting;
}
void setProFileUpdateSetting(ProFileUpdateSetting updateSetting);
private:
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
......@@ -85,6 +95,8 @@ private:
QList<MaemoDeployable> m_deployables;
mutable bool m_modified;
const QScopedPointer<MaemoProFileWrapper> m_proFileWrapper;
ProFileUpdateSetting m_proFileUpdateSetting;
bool m_hasTargetPath;
};
} // namespace Qt4ProjectManager
......
......@@ -72,6 +72,7 @@ MaemoDeployableListWidget::MaemoDeployableListWidget(QWidget *parent,
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
SLOT(enableOrDisableRemoveButton()));
m_ui->deployablesView->resizeColumnsToContents();
m_ui->deployablesView->resizeRowsToContents();
m_ui->deployablesView->horizontalHeader()->setStretchLastSection(true);
enableOrDisableRemoveButton();
}
......
......@@ -61,6 +61,7 @@ class MaemoDeployableListWidget : public QWidget
public:
MaemoDeployableListWidget(QWidget *parent, MaemoDeployableListModel *model);
~MaemoDeployableListWidget();
MaemoDeployableListModel *model() const { return m_model; }
private slots:
void addFile();
......
......@@ -41,10 +41,11 @@
#include "maemodeployables.h"
#include "maemodeployablelistmodel.h"
#include "maemoprofilesupdatedialog.h"
#include <profileevaluator.h>
#include <projectexplorer/buildstep.h>
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include <qt4projectmanager/qt4buildconfiguration.h>
#include <qt4projectmanager/qt4project.h>
#include <qt4projectmanager/qt4target.h>
......@@ -55,46 +56,91 @@ namespace Qt4ProjectManager {
namespace Internal {
MaemoDeployables::MaemoDeployables(const ProjectExplorer::BuildStep *buildStep)
: m_buildStep(buildStep)
: m_buildStep(buildStep), m_updateTimer(new QTimer(this))
{
QTimer::singleShot(0, this, SLOT(init()));
m_updateTimer->setInterval(1500);
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(createModels()));
}
MaemoDeployables::~MaemoDeployables() {}
void MaemoDeployables::init()
{
createModels();
connect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
this, SLOT(createModels()));
m_updateTimer, SLOT(start()));
createModels();
}
void MaemoDeployables::createModels()
{
qDeleteAll(m_listModels);
m_listModels.clear();
if (!qt4BuildConfiguration() || !qt4BuildConfiguration()->qt4Target()
|| qt4BuildConfiguration()->qt4Target()->project()->activeTarget()->id()
!= QLatin1String(Qt4ProjectManager::Constants::MAEMO_DEVICE_TARGET_ID))
return;
disconnect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
m_updateTimer, SLOT(start()));
m_updateTimer->stop();
m_proFileOption = QSharedPointer<ProFileOption>(new ProFileOption);
m_proFileOption->properties
= qt4BuildConfiguration()->qtVersion()->versionInfo();
m_proFileOption->target_mode = ProFileOption::TARG_UNIX_MODE;
createModels(qt4BuildConfiguration()->qt4Target()->qt4Project()
->rootProjectNode());
const Qt4ProFileNode *const rootNode
= qt4BuildConfiguration()->qt4Target()->qt4Project()->rootProjectNode();
if (!rootNode) // Happens on project creation by wizard.
return;
qDeleteAll(m_listModels);
m_listModels.clear();
createModels(rootNode);
QList<MaemoDeployableListModel *> modelsWithoutTargetPath;
foreach (MaemoDeployableListModel *const model, m_listModels) {
if (!model->hasTargetPath()) {
if (model->proFileUpdateSetting() == MaemoDeployableListModel::AskToUpdateProFile)
modelsWithoutTargetPath << model;
}
}
if (!modelsWithoutTargetPath.isEmpty()) {
MaemoProFilesUpdateDialog dialog(modelsWithoutTargetPath);
dialog.exec();
const QList<MaemoProFilesUpdateDialog::UpdateSetting> &settings
= dialog.getUpdateSettings();
foreach (const MaemoProFilesUpdateDialog::UpdateSetting &setting, settings) {
const MaemoDeployableListModel::ProFileUpdateSetting updateSetting
= setting.second
? MaemoDeployableListModel::UpdateProFile
: MaemoDeployableListModel::DontUpdateProFile;
m_updateSettings.insert(setting.first->proFileNode()->path(),
updateSetting);
setting.first->setProFileUpdateSetting(updateSetting);
}
}
emit modelsCreated();
connect(qt4BuildConfiguration()->qt4Target()->qt4Project(),
SIGNAL(proFileUpdated(Qt4ProjectManager::Internal::Qt4ProFileNode*)),
m_updateTimer, SLOT(start()));
}
void MaemoDeployables::createModels(const Qt4ProFileNode *proFileNode)
{
if (!proFileNode) // Happens on project creation by wizard.
return;
const Qt4ProjectType type = proFileNode->projectType() ;
switch (type) {
switch (proFileNode->projectType()) {
case ApplicationTemplate:
case LibraryTemplate:
case ScriptTemplate:
m_listModels
<< new MaemoDeployableListModel(proFileNode, m_proFileOption, this);
case ScriptTemplate: {
UpdateSettingsMap::ConstIterator it
= m_updateSettings.find(proFileNode->path());
const MaemoDeployableListModel::ProFileUpdateSetting updateSetting
= it != m_updateSettings.end()
? it.value() : MaemoDeployableListModel::AskToUpdateProFile;
MaemoDeployableListModel *const newModel
= new MaemoDeployableListModel(proFileNode, m_proFileOption,
updateSetting, this);
m_listModels << newModel;
break;
}
case SubDirsTemplate: {
const QList<ProjectExplorer::ProjectNode *> &subProjects
= proFileNode->subProjectNodes();
......@@ -160,7 +206,6 @@ const Qt4BuildConfiguration *MaemoDeployables::qt4BuildConfiguration() const
{
const Qt4BuildConfiguration * const bc
= qobject_cast<Qt4BuildConfiguration *>(m_buildStep->target()->activeBuildConfiguration());
Q_ASSERT(bc);
return bc;
}
......
......@@ -43,21 +43,21 @@
#define MAEMODEPLOYABLES_H
#include "maemodeployable.h"
#include "maemodeployablelistmodel.h"
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
struct ProFileOption;
QT_END_NAMESPACE
QT_FORWARD_DECLARE_CLASS(QTimer);
QT_FORWARD_DECLARE_STRUCT(ProFileOption)
namespace ProjectExplorer { class BuildStep; }
namespace Qt4ProjectManager {
namespace Internal {
class MaemoDeployableListModel;
class Qt4BuildConfiguration;
class Qt4ProFileNode;
......@@ -80,6 +80,8 @@ signals:
void modelsCreated();
private:
typedef QHash<QString, MaemoDeployableListModel::ProFileUpdateSetting> UpdateSettingsMap;
Q_SLOT void createModels();
Q_SLOT void init();
void createModels(const Qt4ProFileNode *proFileNode);
......@@ -87,7 +89,9 @@ private:
QList<MaemoDeployableListModel *> m_listModels;
QSharedPointer<ProFileOption> m_proFileOption;
UpdateSettingsMap m_updateSettings;
const ProjectExplorer::BuildStep * const m_buildStep;
QTimer *const m_updateTimer;
};
} // namespace Qt4ProjectManager
......
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "maemoprofilesupdatedialog.h"
#include "ui_maemoprofilesupdatedialog.h"
#include "maemodeployablelistmodel.h"
#include <qt4projectmanager/qt4nodes.h>
#include <QtGui/QTableWidgetItem>
namespace Qt4ProjectManager {
namespace Internal {
MaemoProFilesUpdateDialog::MaemoProFilesUpdateDialog(const QList<MaemoDeployableListModel *> &models,
QWidget *parent)
: QDialog(parent),
m_models(models),
ui(new Ui::MaemoProFilesUpdateDialog)
{
ui->setupUi(this);
ui->tableWidget->setRowCount(models.count());
ui->tableWidget->setHorizontalHeaderItem(0,
new QTableWidgetItem(tr("Updateable Project Files")));
for (int row = 0; row < models.count(); ++row) {
QTableWidgetItem *const item
= new QTableWidgetItem(models.at(row)->proFileNode()->path());
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item->setCheckState(Qt::Unchecked);
ui->tableWidget->setItem(row, 0, item);
}
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget->resizeRowsToContents();
connect(ui->checkAllButton, SIGNAL(clicked()), this, SLOT(checkAll()));
connect(ui->uncheckAllButton, SIGNAL(clicked()), this, SLOT(uncheckAll()));
}
MaemoProFilesUpdateDialog::~MaemoProFilesUpdateDialog()
{
delete ui;
}
void MaemoProFilesUpdateDialog::checkAll()
{
setCheckStateForAll(Qt::Checked);
}
void MaemoProFilesUpdateDialog::uncheckAll()
{
setCheckStateForAll(Qt::Unchecked);
}
void MaemoProFilesUpdateDialog::setCheckStateForAll(Qt::CheckState checkState)
{
for (int row = 0; row < ui->tableWidget->rowCount(); ++row) {
ui->tableWidget->item(row, 0)->setCheckState(checkState);
}
}
QList<MaemoProFilesUpdateDialog::UpdateSetting>
MaemoProFilesUpdateDialog::getUpdateSettings() const
{
QList<UpdateSetting> settings;
for (int row = 0; row < m_models.count(); ++row) {
const bool doUpdate = result() != Rejected
&& ui->tableWidget->item(row, 0)->checkState() == Qt::Checked;
settings << UpdateSetting(m_models.at(row), doUpdate);
}
return settings;
}
} // namespace Qt4ProjectManager
} // namespace Internal
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef MAEMOPROFILESUPDATEDIALOG_H
#define MAEMOPROFILESUPDATEDIALOG_H
#include <QtCore/QList>
#include <QtCore/QPair>
#include <QtCore/QString>
#include <QtGui/QDialog>
QT_BEGIN_NAMESPACE
namespace Ui {
class MaemoProFilesUpdateDialog;
}
QT_END_NAMESPACE
namespace Qt4ProjectManager {
namespace Internal {
class MaemoDeployableListModel;
class MaemoProFilesUpdateDialog : public QDialog
{
Q_OBJECT
public:
typedef QPair<MaemoDeployableListModel *, bool> UpdateSetting;
explicit MaemoProFilesUpdateDialog(const QList<MaemoDeployableListModel *> &models,
QWidget *parent = 0);
~MaemoProFilesUpdateDialog();
QList<UpdateSetting> getUpdateSettings() const;
private:
Q_SLOT void checkAll();
Q_SLOT void uncheckAll();
void setCheckStateForAll(Qt::CheckState checkState);
const QList<MaemoDeployableListModel *> m_models;
Ui::MaemoProFilesUpdateDialog *ui;
};
} // namespace Qt4ProjectManager
} // namespace Internal
#endif // MAEMOPROFILESUPDATEDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MaemoProFilesUpdateDialog</class>
<widget class="QDialog" name="MaemoProFilesUpdateDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>659</width>
<height>494</height>
</rect>
</property>
<property name="windowTitle">
<string>Maemo Deployment Issue</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="infoLabel">
<property name="text">
<string>The project files listed below do not contain Maemo deployment information, which means the respective targets cannot be deployed to and/or run on a device. Qt Creator can add the missing information to these files. </string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="checkAllButton">
<property name="text">
<string>Check all</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="uncheckAllButton">
<property name="text">
<string>Uncheck All</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<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>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="showGrid">
<bool>false</bool>
</property>
<property name="columnCount">
<number>1</number>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column/>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>MaemoProFilesUpdateDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>MaemoProFilesUpdateDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -222,6 +222,8 @@ QString MaemoProFileWrapper::absFilePath(const QString &relFilePath) const
void MaemoProFileWrapper::parseProFile(ParseType type) const
{