Commit 6aa00e7d authored by Christian Kandeler's avatar Christian Kandeler
Browse files

Maemo: Manage project's display name for package manager.

Task-number: QTCREATORBUG-3063
parent 084a51fb
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
#include <QtGui/QImageReader> #include <QtGui/QImageReader>
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
using namespace ProjectExplorer;
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
...@@ -82,11 +84,9 @@ void MaemoPackageCreationWidget::init() ...@@ -82,11 +84,9 @@ void MaemoPackageCreationWidget::init()
void MaemoPackageCreationWidget::initGui() void MaemoPackageCreationWidget::initGui()
{ {
const ProjectExplorer::Project * const project updateDebianFileList(thisProject());
= m_step->buildConfiguration()->target()->project(); updateVersionInfo(thisProject());
updateDebianFileList(project); handleControlFileUpdate(thisProject());
updateVersionInfo(project);
updatePackageManagerIcon(project);
connect(m_step, SIGNAL(packageFilePathChanged()), this, connect(m_step, SIGNAL(packageFilePathChanged()), this,
SIGNAL(updateSummary())); SIGNAL(updateSummary()));
connect(m_step, SIGNAL(qtVersionChanged()), this, connect(m_step, SIGNAL(qtVersionChanged()), this,
...@@ -101,14 +101,13 @@ void MaemoPackageCreationWidget::initGui() ...@@ -101,14 +101,13 @@ void MaemoPackageCreationWidget::initGui()
SLOT(updateVersionInfo(const ProjectExplorer::Project*))); SLOT(updateVersionInfo(const ProjectExplorer::Project*)));
connect(MaemoTemplatesManager::instance(), connect(MaemoTemplatesManager::instance(),
SIGNAL(controlChanged(const ProjectExplorer::Project*)), this, SIGNAL(controlChanged(const ProjectExplorer::Project*)), this,
SLOT(updatePackageManagerIcon(const ProjectExplorer::Project*))); SLOT(handleControlFileUpdate(const ProjectExplorer::Project*)));
connect(m_ui->nameLineEdit, SIGNAL(editingFinished()), SLOT(setName()));
} }
void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Project *project) void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Project *project)
{ {
const ProjectExplorer::Project * const ourProject if (thisProject() == project)
= m_step->buildConfiguration()->target()->project();
if (ourProject == project)
m_ui->debianFilesComboBox->clear(); m_ui->debianFilesComboBox->clear();
const QStringList &debianFiles = MaemoTemplatesManager::instance() const QStringList &debianFiles = MaemoTemplatesManager::instance()
->debianFiles(project); ->debianFiles(project);
...@@ -120,7 +119,7 @@ void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Pro ...@@ -120,7 +119,7 @@ void MaemoPackageCreationWidget::updateDebianFileList(const ProjectExplorer::Pro
void MaemoPackageCreationWidget::updateVersionInfo(const ProjectExplorer::Project *project) void MaemoPackageCreationWidget::updateVersionInfo(const ProjectExplorer::Project *project)
{ {
if (project != m_step->buildConfiguration()->target()->project()) if (project != thisProject())
return; return;
QString error; QString error;
...@@ -136,11 +135,17 @@ void MaemoPackageCreationWidget::updateVersionInfo(const ProjectExplorer::Projec ...@@ -136,11 +135,17 @@ void MaemoPackageCreationWidget::updateVersionInfo(const ProjectExplorer::Projec
m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt()); m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt());
} }
void MaemoPackageCreationWidget::updatePackageManagerIcon(const ProjectExplorer::Project *project) void MaemoPackageCreationWidget::handleControlFileUpdate(const Project *project)
{ {
if (project != m_step->buildConfiguration()->target()->project()) if (project != thisProject())
return; return;
updatePackageManagerIcon(project);
updateName(project);
updateShortDescription(project);
}
void MaemoPackageCreationWidget::updatePackageManagerIcon(const Project *project)
{
QString error; QString error;
const QIcon &icon const QIcon &icon
= MaemoTemplatesManager::instance()->packageManagerIcon(project, &error); = MaemoTemplatesManager::instance()->packageManagerIcon(project, &error);
...@@ -152,6 +157,17 @@ void MaemoPackageCreationWidget::updatePackageManagerIcon(const ProjectExplorer: ...@@ -152,6 +157,17 @@ void MaemoPackageCreationWidget::updatePackageManagerIcon(const ProjectExplorer:
} }
} }
void MaemoPackageCreationWidget::updateName(const Project *project)
{
m_ui->nameLineEdit->setText(MaemoTemplatesManager::instance()->name(project));
}
void MaemoPackageCreationWidget::updateShortDescription(const Project *project)
{
// TODO: Implment
Q_UNUSED(project);
}
void MaemoPackageCreationWidget::setPackageManagerIcon() void MaemoPackageCreationWidget::setPackageManagerIcon()
{ {
QString imageFilter = tr("Images") + QLatin1String("( "); QString imageFilter = tr("Images") + QLatin1String("( ");
...@@ -164,12 +180,26 @@ void MaemoPackageCreationWidget::setPackageManagerIcon() ...@@ -164,12 +180,26 @@ void MaemoPackageCreationWidget::setPackageManagerIcon()
QString(), imageFilter); QString(), imageFilter);
if (!iconFileName.isEmpty()) { if (!iconFileName.isEmpty()) {
QString error; QString error;
if (!MaemoTemplatesManager::instance()->setPackageManagerIcon(m_step-> if (!MaemoTemplatesManager::instance()->setPackageManagerIcon(thisProject(),
buildConfiguration()->target()->project(), iconFileName, &error)) iconFileName, &error))
QMessageBox::critical(this, tr("Could Not Set New Icon"), error); QMessageBox::critical(this, tr("Could Not Set New Icon"), error);
} }
} }
void MaemoPackageCreationWidget::setName()
{
if (!MaemoTemplatesManager::instance()->setName(thisProject(),
m_ui->nameLineEdit->text())) {
QMessageBox::critical(this, tr("File Error"),
tr("Could not set project name."));
}
}
void MaemoPackageCreationWidget::setShortDescription()
{
}
void MaemoPackageCreationWidget::handleToolchainChanged() void MaemoPackageCreationWidget::handleToolchainChanged()
{ {
if (!m_step->maemoToolChain()) if (!m_step->maemoToolChain())
...@@ -217,13 +247,18 @@ void MaemoPackageCreationWidget::versionInfoChanged() ...@@ -217,13 +247,18 @@ void MaemoPackageCreationWidget::versionInfoChanged()
void MaemoPackageCreationWidget::editDebianFile() void MaemoPackageCreationWidget::editDebianFile()
{ {
const QString debianFilePath = MaemoTemplatesManager::instance() const QString debianFilePath
->debianDirPath(m_step->buildConfiguration()->target()->project()) = MaemoTemplatesManager::instance()->debianDirPath(thisProject())
+ QLatin1Char('/') + m_ui->debianFilesComboBox->currentText(); + QLatin1Char('/') + m_ui->debianFilesComboBox->currentText();
Core::EditorManager::instance()->openEditor(debianFilePath, Core::EditorManager::instance()->openEditor(debianFilePath,
QString(), QString(),
Core::EditorManager::ModeSwitch); Core::EditorManager::ModeSwitch);
} }
Project *MaemoPackageCreationWidget::thisProject() const
{
return m_step->buildConfiguration()->target()->project();
}
} // namespace Internal } // namespace Internal
} // namespace Qt4ProjectManager } // namespace Qt4ProjectManager
...@@ -68,13 +68,20 @@ private slots: ...@@ -68,13 +68,20 @@ private slots:
void editDebianFile(); void editDebianFile();
void versionInfoChanged(); void versionInfoChanged();
void initGui(); void initGui();
void updateDebianFileList(const ProjectExplorer::Project *project); void updateDebianFileList(const ProjectExplorer::Project *thisProject);
void updateVersionInfo(const ProjectExplorer::Project *project); void updateVersionInfo(const ProjectExplorer::Project *thisProject);
void updatePackageManagerIcon(const ProjectExplorer::Project *project); void handleControlFileUpdate(const ProjectExplorer::Project *thisProject);
void setPackageManagerIcon(); void setPackageManagerIcon();
void setName();
void setShortDescription();
void handleToolchainChanged(); void handleToolchainChanged();
private: private:
void updatePackageManagerIcon(const ProjectExplorer::Project *thisProject);
void updateName(const ProjectExplorer::Project *thisProject);
void updateShortDescription(const ProjectExplorer::Project *thisProject);
ProjectExplorer::Project *thisProject() const;
MaemoPackageCreationStep * const m_step; MaemoPackageCreationStep * const m_step;
Ui::MaemoPackageCreationWidget * const m_ui; Ui::MaemoPackageCreationWidget * const m_ui;
}; };
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>505</width> <width>505</width>
<height>162</height> <height>189</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -157,26 +157,19 @@ ...@@ -157,26 +157,19 @@
</layout> </layout>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="editDebianFileLabel"> <widget class="QLabel" name="nameLabel">
<property name="text"> <property name="text">
<string>&lt;b&gt;Adapt Debian file:&lt;/b&gt;</string> <string>&lt;b&gt;Name for Package Manager:&lt;/b&gt;</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QComboBox" name="debianFilesComboBox"/>
</item>
<item> <item>
<widget class="QPushButton" name="editDebianFileButton"> <widget class="QLineEdit" name="nameLineEdit"/>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
...@@ -242,6 +235,40 @@ ...@@ -242,6 +235,40 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="editDebianFileLabel">
<property name="text">
<string>&lt;b&gt;Adapt Debian file:&lt;/b&gt;</string>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="debianFilesComboBox"/>
</item>
<item>
<widget class="QPushButton" name="editDebianFileButton">
<property name="text">
<string>Edit</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>
</layout> </layout>
</item> </item>
</layout> </layout>
......
...@@ -62,6 +62,7 @@ namespace Internal { ...@@ -62,6 +62,7 @@ namespace Internal {
namespace { namespace {
const QByteArray IconFieldName("XB-Maemo-Icon-26:"); const QByteArray IconFieldName("XB-Maemo-Icon-26:");
const QByteArray DescriptionFieldName("XB-Maemo-Display-Name");
const QLatin1String PackagingDirName("qtc_packaging"); const QLatin1String PackagingDirName("qtc_packaging");
const QLatin1String DebianDirNameFremantle("debian_fremantle"); const QLatin1String DebianDirNameFremantle("debian_fremantle");
} // anonymous namespace } // anonymous namespace
...@@ -260,6 +261,8 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project) ...@@ -260,6 +261,8 @@ bool MaemoTemplatesManager::adaptControlFile(const Project *project)
adaptControlFileField(controlContents, "Section", "user/hidden"); adaptControlFileField(controlContents, "Section", "user/hidden");
adaptControlFileField(controlContents, "Priority", "optional"); adaptControlFileField(controlContents, "Priority", "optional");
adaptControlFileField(controlContents, DescriptionFieldName,
project->displayName().toUtf8());
const int buildDependsOffset = controlContents.indexOf("Build-Depends:"); const int buildDependsOffset = controlContents.indexOf("Build-Depends:");
if (buildDependsOffset == -1) { if (buildDependsOffset == -1) {
qDebug("Unexpected: no Build-Depends field in debian control file."); qDebug("Unexpected: no Build-Depends field in debian control file.");
...@@ -566,6 +569,24 @@ bool MaemoTemplatesManager::setPackageManagerIcon(const Project *project, ...@@ -566,6 +569,24 @@ bool MaemoTemplatesManager::setPackageManagerIcon(const Project *project,
return true; return true;
} }
QString MaemoTemplatesManager::name(const Project *project) const
{
return controlFileFieldValue(project, DescriptionFieldName);
}
bool MaemoTemplatesManager::setName(const Project *project,
const QString &description)
{
QFile controlFile(controlFilePath(project));
if (!controlFile.open(QIODevice::ReadWrite))
return false;
QByteArray contents = controlFile.readAll();
adaptControlFileField(contents, DescriptionFieldName, description.toUtf8());
controlFile.resize(0);
controlFile.write(contents);
return true;
}
QStringList MaemoTemplatesManager::debianFiles(const Project *project) const QStringList MaemoTemplatesManager::debianFiles(const Project *project) const
{ {
return QDir(debianDirPath(project)) return QDir(debianDirPath(project))
...@@ -603,7 +624,7 @@ QString MaemoTemplatesManager::controlFileFieldValue(const Project *project, ...@@ -603,7 +624,7 @@ QString MaemoTemplatesManager::controlFileFieldValue(const Project *project,
if (valueEndPos == -1) if (valueEndPos == -1)
valueEndPos = contents.count(); valueEndPos = contents.count();
return QString::fromUtf8(contents.mid(valueStartPos, return QString::fromUtf8(contents.mid(valueStartPos,
valueEndPos - valueStartPos)); valueEndPos - valueStartPos)).trimmed();
} }
void MaemoTemplatesManager::raiseError(const QString &reason) void MaemoTemplatesManager::raiseError(const QString &reason)
......
...@@ -71,6 +71,10 @@ public: ...@@ -71,6 +71,10 @@ public:
bool setPackageManagerIcon(const ProjectExplorer::Project *project, bool setPackageManagerIcon(const ProjectExplorer::Project *project,
const QString &iconFilePath, QString *error) const; const QString &iconFilePath, QString *error) const;
QString name(const ProjectExplorer::Project *project) const;
bool setName(const ProjectExplorer::Project *project,
const QString &description);
QString controlFileFieldValue(const ProjectExplorer::Project *project, QString controlFileFieldValue(const ProjectExplorer::Project *project,
const QString &key) const; const QString &key) const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment