OSDN Git Service

Allow the user to set the version number used for the build deb package.
authorkh1 <qt-info@nokia.com>
Mon, 28 Jun 2010 09:59:36 +0000 (11:59 +0200)
committerkh1 <qt-info@nokia.com>
Mon, 28 Jun 2010 10:37:47 +0000 (12:37 +0200)
Task-number: QTCREATORBUG-1670
Reviewed-by: ck
src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.cpp
src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationstep.h
src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.cpp
src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.h
src/plugins/qt4projectmanager/qt-maemo/maemopackagecreationwidget.ui

index fdd0ad0..53b0af7 100644 (file)
 #include <QtCore/QStringBuilder>
 #include <QtGui/QWidget>
 
-namespace { const QLatin1String PackagingEnabledKey("Packaging Enabled"); }
+namespace {
+    const QLatin1String PackagingEnabledKey("Packaging Enabled");
+    const QLatin1String DefaultVersionNumber("0.0.1");
+    const QLatin1String VersionNumberKey("Version Number");
+}
 
 using namespace ProjectExplorer::Constants;
 using ProjectExplorer::BuildConfiguration;
@@ -72,7 +76,8 @@ namespace Internal {
 MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConfig)
     : ProjectExplorer::BuildStep(buildConfig, CreatePackageId),
       m_packageContents(new MaemoPackageContents(this)),
-      m_packagingEnabled(true)
+      m_packagingEnabled(true),
+      m_versionString(DefaultVersionNumber)
 {
 }
 
@@ -80,10 +85,9 @@ MaemoPackageCreationStep::MaemoPackageCreationStep(BuildConfiguration *buildConf
     MaemoPackageCreationStep *other)
     : BuildStep(buildConfig, other),
       m_packageContents(new MaemoPackageContents(this)),
-      m_packagingEnabled(other->m_packagingEnabled)
-
+      m_packagingEnabled(other->m_packagingEnabled),
+      m_versionString(other->m_versionString)
 {
-
 }
 
 bool MaemoPackageCreationStep::init()
@@ -95,6 +99,7 @@ QVariantMap MaemoPackageCreationStep::toMap() const
 {
     QVariantMap map(ProjectExplorer::BuildStep::toMap());
     map.insert(PackagingEnabledKey, m_packagingEnabled);
+    map.insert(VersionNumberKey, m_versionString);
     return map.unite(m_packageContents->toMap());
 }
 
@@ -102,6 +107,7 @@ bool MaemoPackageCreationStep::fromMap(const QVariantMap &map)
 {
     m_packageContents->fromMap(map);
     m_packagingEnabled = map.value(PackagingEnabledKey, true).toBool();
+    m_versionString = map.value(VersionNumberKey, DefaultVersionNumber).toString();
     return ProjectExplorer::BuildStep::fromMap(map);
 }
 
@@ -159,9 +165,10 @@ bool MaemoPackageCreationStep::createPackage()
 
     if (!QFileInfo(buildDir + QLatin1String("/debian")).exists()) {
         const QString command = QLatin1String("dh_make -s -n -p ")
-            % executableFileName().toLower() % versionString();
+            % executableFileName().toLower() % QLatin1Char('_') % versionString();
         if (!runCommand(buildProc, command))
             return false;
+
         QFile rulesFile(buildDir + QLatin1String("/debian/rules"));
         if (!rulesFile.open(QIODevice::ReadWrite)) {
             raiseError(tr("Packaging Error: Cannot open file '%1'.")
@@ -180,6 +187,17 @@ bool MaemoPackageCreationStep::createPackage()
         }
     }
 
+    {
+        QFile changeLog(buildDir + QLatin1String("/debian/changelog"));
+        if (changeLog.open(QIODevice::ReadWrite)) {
+            QString content = QString::fromUtf8(changeLog.readAll());
+            content.replace(QRegExp("\\([a-zA-Z0-9_\\.]+\\)"),
+                QLatin1Char('(') % versionString() % QLatin1Char(')'));
+            changeLog.resize(0);
+            changeLog.write(content.toUtf8());
+        }
+    }
+
     if (!runCommand(buildProc, QLatin1String("dh_installdirs")))
         return false;
     
@@ -310,12 +328,17 @@ QString MaemoPackageCreationStep::packageFilePath() const
 {
     QFileInfo execInfo(localExecutableFilePath());
     return execInfo.path() % QDir::separator() % execInfo.fileName().toLower()
-        % versionString() % QLatin1String("_armel.deb");
+        % QLatin1Char('_') % versionString() % QLatin1String("_armel.deb");
 }
 
 QString MaemoPackageCreationStep::versionString() const
 {
-    return QLatin1String("_0.1");
+    return m_versionString;
+}
+
+void MaemoPackageCreationStep::setVersionString(const QString &version)
+{
+    m_versionString = version;
 }
 
 QString MaemoPackageCreationStep::nativePath(const QFile &file) const
index 255fb1d..8a250aa 100644 (file)
@@ -71,6 +71,9 @@ public:
     bool isPackagingEnabled() const { return m_packagingEnabled; }
     void setPackagingEnabled(bool enabled) { m_packagingEnabled = enabled; }
 
+    QString versionString() const;
+    void setVersionString(const QString &version);
+
 private:
     MaemoPackageCreationStep(ProjectExplorer::BuildConfiguration *buildConfig,
                              MaemoPackageCreationStep *other);
@@ -90,7 +93,6 @@ private:
     QString targetRoot() const;
     QString nativePath(const QFile &file) const;
     bool packagingNeeded() const;
-    QString versionString() const;
     void raiseError(const QString &shortMsg,
                     const QString &detailedMsg = QString());
 
@@ -98,6 +100,7 @@ private:
 
     MaemoPackageContents *const m_packageContents;
     bool m_packagingEnabled;
+    QString m_versionString;
 };
 
 } // namespace Internal
index 6306e91..901c746 100644 (file)
@@ -77,6 +77,12 @@ MaemoPackageCreationWidget::MaemoPackageCreationWidget(MaemoPackageCreationStep
     m_ui->packageContentsView->resizeColumnsToContents();
     m_ui->packageContentsView->horizontalHeader()->setStretchLastSection(true);
     enableOrDisableRemoveButton();
+
+    const QStringList list = m_step->versionString().split(QLatin1Char('.'),
+        QString::SkipEmptyParts);
+    m_ui->major->setValue(list.value(0, QLatin1String("0")).toInt());
+    m_ui->minor->setValue(list.value(1, QLatin1String("0")).toInt());
+    m_ui->patch->setValue(list.value(2, QLatin1String("0")).toInt());
 }
 
 void MaemoPackageCreationWidget::init()
@@ -141,5 +147,12 @@ void MaemoPackageCreationWidget::handleSkipButtonToggled(bool checked)
     m_step->setPackagingEnabled(!checked);
 }
 
+void MaemoPackageCreationWidget::versionInfoChanged()
+{
+    m_step->setVersionString(m_ui->major->text() + QLatin1Char('.')
+        + m_ui->minor->text() + QLatin1Char('.') + m_ui->patch->text());
+    emit updateSummary();
+}
+
 } // namespace Internal
 } // namespace Qt4ProjectManager
index ead07fa..a341880 100644 (file)
@@ -68,6 +68,7 @@ private slots:
     void removeFile();
     void enableOrDisableRemoveButton();
     void handleSkipButtonToggled(bool checked);
+    void versionInfoChanged();
 
 private:
     MaemoPackageCreationStep * const m_step;
index 6d72b74..3b5101e 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>741</width>
-    <height>574</height>
+    <width>470</width>
+    <height>325</height>
    </rect>
   </property>
   <property name="sizePolicy">
     <verstretch>1</verstretch>
    </sizepolicy>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
-   <property name="spacing">
-    <number>6</number>
-   </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
    <item>
     <widget class="QCheckBox" name="skipCheckBox">
      <property name="toolTip">
     </widget>
    </item>
    <item>
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>5</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_2">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="font">
+        <font>
+         <weight>75</weight>
+         <bold>true</bold>
+        </font>
+       </property>
+       <property name="text">
+        <string>Version number:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout_2">
+       <item>
+        <spacer name="horizontalSpacer">
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
+         </property>
+         <property name="sizeType">
+          <enum>QSizePolicy::Fixed</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>13</width>
+           <height>13</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QLabel" name="label_2">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Major:</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSpinBox" name="major">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="maximum">
+          <number>99</number>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="label_3">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Minor:</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSpinBox" name="minor">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="maximum">
+          <number>99</number>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QLabel" name="label_4">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="text">
+          <string>Patch:</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QSpinBox" name="patch">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="maximum">
+          <number>99</number>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="horizontalSpacer_2">
+         <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>
+   </item>
+   <item>
     <widget class="QLabel" name="contentsLabel">
      <property name="font">
       <font>
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
+      <spacer name="horizontalSpacer_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>13</width>
+         <height>13</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
       <widget class="QTableView" name="packageContentsView">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
    <slot>addFile()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>729</x>
-     <y>88</y>
+     <x>458</x>
+     <y>134</y>
     </hint>
     <hint type="destinationlabel">
      <x>732</x>
    <slot>removeFile()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>729</x>
-     <y>124</y>
+     <x>458</x>
+     <y>162</y>
     </hint>
     <hint type="destinationlabel">
      <x>735</x>
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>major</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>MaemoPackageCreationWidget</receiver>
+   <slot>versionInfoChanged()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>83</x>
+     <y>73</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>461</x>
+     <y>32</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>minor</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>MaemoPackageCreationWidget</receiver>
+   <slot>versionInfoChanged()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>154</x>
+     <y>68</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>5</x>
+     <y>15</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>patch</sender>
+   <signal>valueChanged(int)</signal>
+   <receiver>MaemoPackageCreationWidget</receiver>
+   <slot>versionInfoChanged()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>249</x>
+     <y>68</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>466</x>
+     <y>-7</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>addFile()</slot>
   <slot>removeFile()</slot>
   <slot>handleSkipButtonToggled(bool)</slot>
+  <slot>versionInfoChanged()</slot>
  </slots>
 </ui>