forked from qt-creator/qt-creator
Maemo: Make package contents user-editable.
Reviewed-by: kh1
This commit is contained in:
@@ -50,6 +50,27 @@ MaemoPackageContents::Deployable MaemoPackageContents::deployableAt(int row) con
|
|||||||
: m_deployables.at(row - 1);
|
: m_deployables.at(row - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MaemoPackageContents::addDeployable(const Deployable &deployable)
|
||||||
|
{
|
||||||
|
if (m_deployables.contains(deployable))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
beginInsertRows(QModelIndex(), rowCount(), rowCount());
|
||||||
|
m_deployables << deployable;
|
||||||
|
endInsertRows();
|
||||||
|
m_modified = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoPackageContents::removeDeployableAt(int row)
|
||||||
|
{
|
||||||
|
Q_ASSERT(row > 0 && row < rowCount());
|
||||||
|
beginRemoveRows(QModelIndex(), row, row);
|
||||||
|
m_deployables.removeAt(row);
|
||||||
|
endRemoveRows();
|
||||||
|
m_modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
int MaemoPackageContents::rowCount(const QModelIndex &parent) const
|
int MaemoPackageContents::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
return parent.isValid() ? 0 : m_deployables.count() + 1;
|
return parent.isValid() ? 0 : m_deployables.count() + 1;
|
||||||
|
|||||||
@@ -47,15 +47,24 @@ public:
|
|||||||
{
|
{
|
||||||
Deployable(const QString &localFilePath, const QString &remoteFilePath)
|
Deployable(const QString &localFilePath, const QString &remoteFilePath)
|
||||||
: localFilePath(localFilePath), remoteFilePath(remoteFilePath) {}
|
: localFilePath(localFilePath), remoteFilePath(remoteFilePath) {}
|
||||||
|
|
||||||
|
bool operator==(const Deployable &other) const
|
||||||
|
{
|
||||||
|
return localFilePath == other.localFilePath
|
||||||
|
&& remoteFilePath == other.remoteFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
QString localFilePath;
|
QString localFilePath;
|
||||||
QString remoteFilePath;
|
QString remoteFilePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
||||||
|
|
||||||
MaemoPackageContents(MaemoPackageCreationStep *packageStep);
|
MaemoPackageContents(MaemoPackageCreationStep *packageStep);
|
||||||
|
|
||||||
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
|
||||||
Deployable deployableAt(int row) const;
|
Deployable deployableAt(int row) const;
|
||||||
|
bool addDeployable(const Deployable &deployable);
|
||||||
|
void removeDeployableAt(int row);
|
||||||
bool isModified() const { return m_modified; }
|
bool isModified() const { return m_modified; }
|
||||||
void setUnModified() { m_modified = false; }
|
void setUnModified() { m_modified = false; }
|
||||||
|
|
||||||
|
|||||||
@@ -123,8 +123,8 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
env.insert(key, path % QLatin1String("madbin") % colon % env.value(key));
|
env.insert(key, path % QLatin1String("madbin") % colon % env.value(key));
|
||||||
env.insert(QLatin1String("PERL5LIB"), path % QLatin1String("madlib/perl5"));
|
env.insert(QLatin1String("PERL5LIB"), path % QLatin1String("madlib/perl5"));
|
||||||
|
|
||||||
const QString projectDir = QFileInfo(localExecutableFilePath()).absolutePath();
|
const QString buildDir = QFileInfo(localExecutableFilePath()).absolutePath();
|
||||||
env.insert(QLatin1String("PWD"), projectDir);
|
env.insert(QLatin1String("PWD"), buildDir);
|
||||||
|
|
||||||
const QRegExp envPattern(QLatin1String("([^=]+)=[\"']?([^;\"']+)[\"']? ;.*"));
|
const QRegExp envPattern(QLatin1String("([^=]+)=[\"']?([^;\"']+)[\"']? ;.*"));
|
||||||
QByteArray line;
|
QByteArray line;
|
||||||
@@ -136,14 +136,14 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
|
|
||||||
QProcess buildProc;
|
QProcess buildProc;
|
||||||
buildProc.setProcessEnvironment(env);
|
buildProc.setProcessEnvironment(env);
|
||||||
buildProc.setWorkingDirectory(projectDir);
|
buildProc.setWorkingDirectory(buildDir);
|
||||||
|
|
||||||
if (!QFileInfo(projectDir + QLatin1String("/debian")).exists()) {
|
if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) {
|
||||||
const QString command = QLatin1String("dh_make -s -n -p ")
|
const QString command = QLatin1String("dh_make -s -n -p ")
|
||||||
% executableFileName().toLower() % versionString();
|
% executableFileName().toLower() % versionString();
|
||||||
if (!runCommand(buildProc, command))
|
if (!runCommand(buildProc, command))
|
||||||
return false;
|
return false;
|
||||||
QFile rulesFile(projectDir + QLatin1String("/debian/rules"));
|
QFile rulesFile(buildDir + QLatin1String("/debian/rules"));
|
||||||
if (!rulesFile.open(QIODevice::ReadWrite)) {
|
if (!rulesFile.open(QIODevice::ReadWrite)) {
|
||||||
raiseError(tr("Packaging Error: Cannot open file '%1'.")
|
raiseError(tr("Packaging Error: Cannot open file '%1'.")
|
||||||
.arg(nativePath(rulesFile)));
|
.arg(nativePath(rulesFile)));
|
||||||
@@ -164,20 +164,32 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
if (!runCommand(buildProc, QLatin1String("dh_installdirs")))
|
if (!runCommand(buildProc, QLatin1String("dh_installdirs")))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString targetFile(projectDir % QLatin1String("/debian/")
|
const QDir debianRoot = QDir(buildDir % QLatin1String("/debian/")
|
||||||
% executableFileName().toLower() % remoteExecutableFilePath());
|
% executableFileName().toLower());
|
||||||
if (QFile::exists(targetFile)) {
|
for (int i = 0; i < m_packageContents->rowCount(); ++i) {
|
||||||
if (!QFile::remove(targetFile)) {
|
const MaemoPackageContents::Deployable &d
|
||||||
|
= m_packageContents->deployableAt(i);
|
||||||
|
const QString targetFile = debianRoot.path() + '/' + d.remoteFilePath;
|
||||||
|
const QString absTargetDir = QFileInfo(targetFile).dir().path();
|
||||||
|
const QString relTargetDir = debianRoot.relativeFilePath(absTargetDir);
|
||||||
|
if (!debianRoot.exists(relTargetDir)
|
||||||
|
&& !debianRoot.mkpath(relTargetDir)) {
|
||||||
|
raiseError(tr("Packaging Error: Could not create directory '%1'.")
|
||||||
|
.arg(QDir::toNativeSeparators(absTargetDir)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (QFile::exists(targetFile) && !QFile::remove(targetFile)) {
|
||||||
raiseError(tr("Packaging Error: Could not replace file '%1'.")
|
raiseError(tr("Packaging Error: Could not replace file '%1'.")
|
||||||
.arg(QDir::toNativeSeparators(targetFile)));
|
.arg(QDir::toNativeSeparators(targetFile)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!QFile::copy(localExecutableFilePath(), targetFile)) {
|
if (!QFile::copy(d.localFilePath, targetFile)) {
|
||||||
raiseError(tr("Packaging Error: Could not copy '%1' to '%2'.")
|
raiseError(tr("Packaging Error: Could not copy '%1' to '%2'.")
|
||||||
.arg(QDir::toNativeSeparators(localExecutableFilePath()))
|
.arg(QDir::toNativeSeparators(d.localFilePath))
|
||||||
.arg(QDir::toNativeSeparators(targetFile)));
|
.arg(QDir::toNativeSeparators(targetFile)));
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList commands = QStringList() << QLatin1String("dh_link")
|
const QStringList commands = QStringList() << QLatin1String("dh_link")
|
||||||
@@ -280,7 +292,7 @@ QString MaemoPackageCreationStep::packageFilePath() const
|
|||||||
|
|
||||||
QString MaemoPackageCreationStep::remoteExecutableFilePath() const
|
QString MaemoPackageCreationStep::remoteExecutableFilePath() const
|
||||||
{
|
{
|
||||||
return QLatin1String("/usr/bin/") % executableFileName();
|
return QLatin1String("/usr/local/bin/") % executableFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaemoPackageCreationStep::versionString() const
|
QString MaemoPackageCreationStep::versionString() const
|
||||||
|
|||||||
@@ -44,6 +44,16 @@
|
|||||||
|
|
||||||
#include "maemopackagecontents.h"
|
#include "maemopackagecontents.h"
|
||||||
#include "maemopackagecreationstep.h"
|
#include "maemopackagecreationstep.h"
|
||||||
|
#include "maemotoolchain.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
#include <qt4projectmanager/qt4buildconfiguration.h>
|
||||||
|
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -60,8 +70,12 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep
|
|||||||
m_ui->packageContentsView, SLOT(resizeColumnsToContents()));
|
m_ui->packageContentsView, SLOT(resizeColumnsToContents()));
|
||||||
connect(step->packageContents(), SIGNAL(rowsInserted(QModelIndex, int, int)),
|
connect(step->packageContents(), SIGNAL(rowsInserted(QModelIndex, int, int)),
|
||||||
m_ui->packageContentsView, SLOT(resizeColumnsToContents()));
|
m_ui->packageContentsView, SLOT(resizeColumnsToContents()));
|
||||||
|
connect(m_ui->packageContentsView->selectionModel(),
|
||||||
|
SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this,
|
||||||
|
SLOT(enableOrDisableRemoveButton()));
|
||||||
m_ui->packageContentsView->resizeColumnsToContents();
|
m_ui->packageContentsView->resizeColumnsToContents();
|
||||||
m_ui->packageContentsView->horizontalHeader()->setStretchLastSection(true);
|
m_ui->packageContentsView->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
enableOrDisableRemoveButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoPackageCreationWidget::init()
|
void MaemoPackageCreationWidget::init()
|
||||||
@@ -78,5 +92,68 @@ QString MaemoPackageCreationWidget::displayName() const
|
|||||||
return m_step->displayName();
|
return m_step->displayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MaemoPackageCreationWidget::addFile()
|
||||||
|
{
|
||||||
|
const Qt4BuildConfiguration * const bc
|
||||||
|
= static_cast<Qt4BuildConfiguration *>(m_step->buildConfiguration());
|
||||||
|
QTC_ASSERT(bc, return);
|
||||||
|
QString title = tr("Choose a local file");
|
||||||
|
QString baseDir = bc->target()->project()->projectDirectory();
|
||||||
|
const QString localFile = QFileDialog::getOpenFileName(this, title, baseDir);
|
||||||
|
if (localFile.isEmpty())
|
||||||
|
return;
|
||||||
|
title = tr("Choose a remote file path");
|
||||||
|
QTC_ASSERT(bc->toolChainType() == ProjectExplorer::ToolChain::GCC_MAEMO, return);
|
||||||
|
baseDir = static_cast<MaemoToolChain *>(bc->toolChain())->sysrootRoot();
|
||||||
|
QString remoteFile;
|
||||||
|
const QString canonicalSysRoot = QFileInfo(baseDir).canonicalFilePath();
|
||||||
|
do {
|
||||||
|
QFileDialog d(this, title, baseDir);
|
||||||
|
d.setFileMode(QFileDialog::AnyFile);
|
||||||
|
d.selectFile(QFileInfo(localFile).fileName());
|
||||||
|
if (!d.exec())
|
||||||
|
return;
|
||||||
|
remoteFile = d.selectedFiles().first();
|
||||||
|
if (remoteFile.isEmpty())
|
||||||
|
return;
|
||||||
|
const QFileInfo remoteFileInfo(remoteFile);
|
||||||
|
QString remoteDir = remoteFileInfo.dir().canonicalPath();
|
||||||
|
if (!remoteDir.startsWith(canonicalSysRoot)) {
|
||||||
|
QMessageBox::warning(this, tr("Invalid path"),
|
||||||
|
tr("Please choose a location inside your sysroot directory."));
|
||||||
|
remoteFile.clear();
|
||||||
|
} else {
|
||||||
|
remoteDir.remove(canonicalSysRoot);
|
||||||
|
remoteFile = remoteDir + '/' + remoteFileInfo.fileName();
|
||||||
|
}
|
||||||
|
} while (remoteFile.isEmpty());
|
||||||
|
|
||||||
|
const MaemoPackageContents::Deployable
|
||||||
|
deployable(QFileInfo(localFile).absoluteFilePath(), remoteFile);
|
||||||
|
if (!m_step->packageContents()->addDeployable(deployable)) {
|
||||||
|
QMessageBox::information(this, tr("File already in package"),
|
||||||
|
tr("You have already added this file."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoPackageCreationWidget::removeFile()
|
||||||
|
{
|
||||||
|
const QModelIndexList selectedRows
|
||||||
|
= m_ui->packageContentsView->selectionModel()->selectedRows();
|
||||||
|
if (selectedRows.isEmpty())
|
||||||
|
return;
|
||||||
|
const int row = selectedRows.first().row();
|
||||||
|
if (row != 0)
|
||||||
|
m_step->packageContents()->removeDeployableAt(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaemoPackageCreationWidget::enableOrDisableRemoveButton()
|
||||||
|
{
|
||||||
|
const QModelIndexList selectedRows
|
||||||
|
= m_ui->packageContentsView->selectionModel()->selectedRows();
|
||||||
|
m_ui->removeFileButton->setEnabled(!selectedRows.isEmpty()
|
||||||
|
&& selectedRows.first().row() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -62,6 +62,12 @@ public:
|
|||||||
virtual void init();
|
virtual void init();
|
||||||
virtual QString summaryText() const;
|
virtual QString summaryText() const;
|
||||||
virtual QString displayName() const;
|
virtual QString displayName() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void addFile();
|
||||||
|
void removeFile();
|
||||||
|
void enableOrDisableRemoveButton();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaemoPackageCreationStep * const m_step;
|
MaemoPackageCreationStep * const m_step;
|
||||||
Ui::MaemoPackageCreationWidget * const m_ui;
|
Ui::MaemoPackageCreationWidget * const m_ui;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<verstretch>1</verstretch>
|
<verstretch>1</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="contentsLabel">
|
<widget class="QLabel" name="contentsLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
@@ -31,32 +31,123 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="packageContentsView">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<widget class="QTableView" name="packageContentsView">
|
||||||
<horstretch>1</horstretch>
|
<property name="sizePolicy">
|
||||||
<verstretch>1</verstretch>
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
</sizepolicy>
|
<horstretch>1</horstretch>
|
||||||
</property>
|
<verstretch>1</verstretch>
|
||||||
<property name="selectionBehavior">
|
</sizepolicy>
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
</property>
|
||||||
</property>
|
<property name="selectionMode">
|
||||||
<property name="showGrid">
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
<bool>false</bool>
|
</property>
|
||||||
</property>
|
<property name="selectionBehavior">
|
||||||
<attribute name="horizontalHeaderVisible">
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</attribute>
|
<property name="showGrid">
|
||||||
<attribute name="horizontalHeaderCascadingSectionResizes">
|
<bool>false</bool>
|
||||||
<bool>false</bool>
|
</property>
|
||||||
</attribute>
|
<attribute name="horizontalHeaderVisible">
|
||||||
<attribute name="verticalHeaderVisible">
|
<bool>true</bool>
|
||||||
<bool>false</bool>
|
</attribute>
|
||||||
</attribute>
|
<attribute name="horizontalHeaderCascadingSectionResizes">
|
||||||
</widget>
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="addFileButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Add File to Package</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../coreplugin/core.qrc">
|
||||||
|
<normaloff>:/core/images/plus.png</normaloff>:/core/images/plus.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="removeFileButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Remove File from Package</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../coreplugin/core.qrc">
|
||||||
|
<normaloff>:/core/images/minus.png</normaloff>:/core/images/minus.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
<connections/>
|
<include location="../../coreplugin/core.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>addFileButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>MaemoPackageCreationWidget</receiver>
|
||||||
|
<slot>addFile()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>712</x>
|
||||||
|
<y>44</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>732</x>
|
||||||
|
<y>525</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>removeFileButton</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>MaemoPackageCreationWidget</receiver>
|
||||||
|
<slot>removeFile()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>723</x>
|
||||||
|
<y>77</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>735</x>
|
||||||
|
<y>145</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<slots>
|
||||||
|
<slot>addFile()</slot>
|
||||||
|
<slot>removeFile()</slot>
|
||||||
|
</slots>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user