forked from qt-creator/qt-creator
Maemo deployment: Force remote file name to be same as local file name.
INSTALLS does not support an arbitrary target file name. Reviewed-by: kh1
This commit is contained in:
@@ -42,12 +42,12 @@
|
|||||||
namespace {
|
namespace {
|
||||||
const char * const MODIFIED_KEY
|
const char * const MODIFIED_KEY
|
||||||
= "Qt4ProjectManager.BuildStep.MaemoPackage.Modified";
|
= "Qt4ProjectManager.BuildStep.MaemoPackage.Modified";
|
||||||
const char * const REMOTE_EXE_KEY
|
const char * const REMOTE_EXE_DIR_KEY
|
||||||
= "Qt4ProjectManager.BuildStep.MaemoPackage.RemoteExe";
|
= "Qt4ProjectManager.BuildStep.MaemoPackage.RemoteExeDir";
|
||||||
const char * const LOCAL_FILES_KEY
|
const char * const LOCAL_FILES_KEY
|
||||||
= "Qt4ProjectManager.BuildStep.MaemoPackage.LocalFiles";
|
= "Qt4ProjectManager.BuildStep.MaemoPackage.LocalFiles";
|
||||||
const char * const REMOTE_FILES_KEY
|
const char * const REMOTE_DIRS_KEY
|
||||||
= "Qt4ProjectManager.BuildStep.MaemoPackage.RemoteFiles";
|
= "Qt4ProjectManager.BuildStep.MaemoPackage.RemoteDirs";
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
@@ -65,7 +65,7 @@ MaemoPackageContents::Deployable MaemoPackageContents::deployableAt(int row) con
|
|||||||
Q_ASSERT(row >= 0 && row < rowCount());
|
Q_ASSERT(row >= 0 && row < rowCount());
|
||||||
return row == 0
|
return row == 0
|
||||||
? Deployable(m_packageStep->localExecutableFilePath(),
|
? Deployable(m_packageStep->localExecutableFilePath(),
|
||||||
remoteExecutableFilePath())
|
remoteExecutableDir())
|
||||||
: m_deployables.at(row - 1);
|
: m_deployables.at(row - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ QVariant MaemoPackageContents::data(const QModelIndex &index, int role) const
|
|||||||
if (index.column() == 0 && role == Qt::DisplayRole)
|
if (index.column() == 0 && role == Qt::DisplayRole)
|
||||||
return d.localFilePath;
|
return d.localFilePath;
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||||
return d.remoteFilePath;
|
return d.remoteDir;
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,11 +128,11 @@ bool MaemoPackageContents::setData(const QModelIndex &index,
|
|||||||
|| role != Qt::EditRole)
|
|| role != Qt::EditRole)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const QString &remoteFilePath = value.toString();
|
const QString &remoteDir = value.toString();
|
||||||
if (index.row() == 0)
|
if (index.row() == 0)
|
||||||
m_remoteExecutableFilePath = remoteFilePath;
|
m_remoteExecutableDir = remoteDir;
|
||||||
else
|
else
|
||||||
m_deployables[index.row() - 1].remoteFilePath = remoteFilePath;
|
m_deployables[index.row() - 1].remoteDir = remoteDir;
|
||||||
m_modified = true;
|
m_modified = true;
|
||||||
emit dataChanged(index, index);
|
emit dataChanged(index, index);
|
||||||
return true;
|
return true;
|
||||||
@@ -143,57 +143,60 @@ QVariant MaemoPackageContents::headerData(int section,
|
|||||||
{
|
{
|
||||||
if (orientation == Qt::Vertical || role != Qt::DisplayRole)
|
if (orientation == Qt::Vertical || role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
return section == 0 ? tr("Local File Path") : tr("Remote File Path");
|
return section == 0 ? tr("Local File Path") : tr("Remote Directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap MaemoPackageContents::toMap() const
|
QVariantMap MaemoPackageContents::toMap() const
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map.insert(MODIFIED_KEY, m_modified);
|
map.insert(MODIFIED_KEY, m_modified);
|
||||||
map.insert(REMOTE_EXE_KEY, m_remoteExecutableFilePath);
|
map.insert(REMOTE_EXE_DIR_KEY, m_remoteExecutableDir);
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
QStringList localFiles;
|
QStringList localFiles;
|
||||||
QStringList remoteFiles;
|
QStringList remoteDirs;
|
||||||
foreach (const Deployable &p, m_deployables) {
|
foreach (const Deployable &p, m_deployables) {
|
||||||
localFiles << dir.fromNativeSeparators(p.localFilePath);
|
localFiles << dir.fromNativeSeparators(p.localFilePath);
|
||||||
remoteFiles << p.remoteFilePath;
|
remoteDirs << p.remoteDir;
|
||||||
}
|
}
|
||||||
map.insert(LOCAL_FILES_KEY, localFiles);
|
map.insert(LOCAL_FILES_KEY, localFiles);
|
||||||
map.insert(REMOTE_FILES_KEY, remoteFiles);
|
map.insert(REMOTE_DIRS_KEY, remoteDirs);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaemoPackageContents::fromMap(const QVariantMap &map)
|
void MaemoPackageContents::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
m_modified = map.value(MODIFIED_KEY).toBool();
|
m_modified = map.value(MODIFIED_KEY).toBool();
|
||||||
m_remoteExecutableFilePath = map.value(REMOTE_EXE_KEY).toString();
|
m_remoteExecutableDir = map.value(REMOTE_EXE_DIR_KEY).toString();
|
||||||
const QStringList localFiles = map.value(LOCAL_FILES_KEY).toStringList();
|
const QStringList localFiles = map.value(LOCAL_FILES_KEY).toStringList();
|
||||||
const QStringList remoteFiles = map.value(REMOTE_FILES_KEY).toStringList();
|
const QStringList remoteDirs = map.value(REMOTE_DIRS_KEY).toStringList();
|
||||||
if (localFiles.count() != remoteFiles.count())
|
if (localFiles.count() != remoteDirs.count())
|
||||||
qWarning("%s: serialized data inconsistent", Q_FUNC_INFO);
|
qWarning("%s: serialized data inconsistent", Q_FUNC_INFO);
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
const int count = qMin(localFiles.count(), remoteFiles.count());
|
const int count = qMin(localFiles.count(), remoteDirs.count());
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
m_deployables << Deployable(dir.toNativeSeparators(localFiles.at(i)),
|
m_deployables << Deployable(dir.toNativeSeparators(localFiles.at(i)),
|
||||||
remoteFiles.at(i));
|
remoteDirs.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MaemoPackageContents::remoteExecutableDir() const
|
||||||
|
{
|
||||||
|
if (m_remoteExecutableDir.isEmpty()) {
|
||||||
|
const Qt4ProjectType projectType
|
||||||
|
= m_packageStep->qt4BuildConfiguration()->qt4Target()->qt4Project()
|
||||||
|
->rootProjectNode()->projectType();
|
||||||
|
m_remoteExecutableDir = projectType == LibraryTemplate
|
||||||
|
? QLatin1String("/usr/local/lib")
|
||||||
|
: QLatin1String("/usr/local/bin");
|
||||||
|
}
|
||||||
|
return m_remoteExecutableDir;
|
||||||
|
}
|
||||||
|
|
||||||
QString MaemoPackageContents::remoteExecutableFilePath() const
|
QString MaemoPackageContents::remoteExecutableFilePath() const
|
||||||
{
|
{
|
||||||
if (m_remoteExecutableFilePath.isEmpty()) {
|
return remoteExecutableDir() + '/' + m_packageStep->executableFileName();
|
||||||
const Qt4ProjectType projectType
|
|
||||||
= m_packageStep->qt4BuildConfiguration()->qt4Target()->qt4Project()
|
|
||||||
->rootProjectNode()->projectType();
|
|
||||||
const QString remoteDir = projectType == LibraryTemplate
|
|
||||||
? QLatin1String("/usr/local/lib/")
|
|
||||||
: QLatin1String("/usr/local/bin/");
|
|
||||||
m_remoteExecutableFilePath
|
|
||||||
= remoteDir + m_packageStep->executableFileName();
|
|
||||||
}
|
|
||||||
return m_remoteExecutableFilePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -46,17 +46,17 @@ class MaemoPackageContents : public QAbstractTableModel
|
|||||||
public:
|
public:
|
||||||
struct Deployable
|
struct Deployable
|
||||||
{
|
{
|
||||||
Deployable(const QString &localFilePath, const QString &remoteFilePath)
|
Deployable(const QString &localFilePath, const QString &remoteDir)
|
||||||
: localFilePath(localFilePath), remoteFilePath(remoteFilePath) {}
|
: localFilePath(localFilePath), remoteDir(remoteDir) {}
|
||||||
|
|
||||||
bool operator==(const Deployable &other) const
|
bool operator==(const Deployable &other) const
|
||||||
{
|
{
|
||||||
return localFilePath == other.localFilePath
|
return localFilePath == other.localFilePath
|
||||||
&& remoteFilePath == other.remoteFilePath;
|
&& remoteDir == other.remoteDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString localFilePath;
|
QString localFilePath;
|
||||||
QString remoteFilePath;
|
QString remoteDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
MaemoPackageContents(MaemoPackageCreationStep *packageStep);
|
MaemoPackageContents(MaemoPackageCreationStep *packageStep);
|
||||||
@@ -83,11 +83,13 @@ private:
|
|||||||
virtual bool setData(const QModelIndex &index, const QVariant &value,
|
virtual bool setData(const QModelIndex &index, const QVariant &value,
|
||||||
int role = Qt::EditRole);
|
int role = Qt::EditRole);
|
||||||
|
|
||||||
|
QString remoteExecutableDir() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const MaemoPackageCreationStep * const m_packageStep;
|
const MaemoPackageCreationStep * const m_packageStep;
|
||||||
QList<Deployable> m_deployables;
|
QList<Deployable> m_deployables;
|
||||||
bool m_modified;
|
bool m_modified;
|
||||||
mutable QString m_remoteExecutableFilePath;
|
mutable QString m_remoteExecutableDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|||||||
@@ -181,8 +181,9 @@ bool MaemoPackageCreationStep::createPackage()
|
|||||||
for (int i = 0; i < m_packageContents->rowCount(); ++i) {
|
for (int i = 0; i < m_packageContents->rowCount(); ++i) {
|
||||||
const MaemoPackageContents::Deployable &d
|
const MaemoPackageContents::Deployable &d
|
||||||
= m_packageContents->deployableAt(i);
|
= m_packageContents->deployableAt(i);
|
||||||
const QString targetFile = debianRoot.path() + '/' + d.remoteFilePath;
|
const QString absTargetDir = debianRoot.path() + '/' + d.remoteDir;
|
||||||
const QString absTargetDir = QFileInfo(targetFile).dir().path();
|
const QString targetFile
|
||||||
|
= absTargetDir + '/' + QFileInfo(d.localFilePath).fileName();
|
||||||
const QString relTargetDir = debianRoot.relativeFilePath(absTargetDir);
|
const QString relTargetDir = debianRoot.relativeFilePath(absTargetDir);
|
||||||
if (!debianRoot.exists(relTargetDir)
|
if (!debianRoot.exists(relTargetDir)
|
||||||
&& !debianRoot.mkpath(relTargetDir)) {
|
&& !debianRoot.mkpath(relTargetDir)) {
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ void MaemoPackageCreationWidget::addFile()
|
|||||||
QTC_ASSERT(bc, return);
|
QTC_ASSERT(bc, return);
|
||||||
const QString title = tr("Choose a local file");
|
const QString title = tr("Choose a local file");
|
||||||
const QString baseDir = bc->target()->project()->projectDirectory();
|
const QString baseDir = bc->target()->project()->projectDirectory();
|
||||||
const QString localFile = QFileDialog::getOpenFileName(this, title, baseDir);
|
const QString localFile = QFileDialog::getOpenFileName(this, title, baseDir); // TODO: Support directories?
|
||||||
if (localFile.isEmpty())
|
if (localFile.isEmpty())
|
||||||
return;
|
return;
|
||||||
const MaemoPackageContents::Deployable
|
const MaemoPackageContents::Deployable
|
||||||
|
|||||||
Reference in New Issue
Block a user