[QGIS Commit] r8670 - in branches/advanced_printing_branch/src: app/composer ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Jun 22 11:00:52 EDT 2008


Author: mhugent
Date: 2008-06-22 11:00:52 -0400 (Sun, 22 Jun 2008)
New Revision: 8670

Added:
   branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.h
   branches/advanced_printing_branch/src/ui/qgscompositionwidget.h
Log:
Forgot to add some classes in the last commit

Added: branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.cpp	                        (rev 0)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.cpp	2008-06-22 15:00:52 UTC (rev 8670)
@@ -0,0 +1,175 @@
+/***************************************************************************
+                            qgscomposerscalebarwidget.cpp
+                            -----------------------------
+    begin                : 11 June 2008
+    copyright            : (C) 2008 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include "qgscomposerscalebarwidget.h"
+#include "qgscomposermap.h"
+#include "qgscomposerscalebar.h"
+#include <QWidget>
+
+QgsComposerScaleBarWidget::QgsComposerScaleBarWidget(QgsComposerScaleBar* scaleBar): QWidget(), mComposerScaleBar(scaleBar)
+{
+  setupUi(this);
+  setGuiElements(); //set the GUI elements to the state of scaleBar
+}
+
+QgsComposerScaleBarWidget::~QgsComposerScaleBarWidget()
+{
+
+}
+
+void QgsComposerScaleBarWidget::refreshMapComboBox()
+{
+  mMapComboBox->clear();
+
+  if(mComposerScaleBar)
+    {
+      //insert available maps into mMapComboBox
+      const QgsComposition* scaleBarComposition = mComposerScaleBar->composition();
+      if(scaleBarComposition)
+	{
+	  QList<const QgsComposerMap*> availableMaps = scaleBarComposition->composerMapItems();
+	  QList<const QgsComposerMap*>::const_iterator mapItemIt = availableMaps.constBegin();
+	  for(; mapItemIt != availableMaps.constEnd(); ++mapItemIt)
+	    {
+	      mMapComboBox->addItem(tr("Map ") + QString::number((*mapItemIt)->id()));
+	    } 
+	}
+    }
+}
+
+void QgsComposerScaleBarWidget::showEvent ( QShowEvent * event )
+{
+  refreshMapComboBox();
+  QWidget::showEvent(event);
+}
+
+void QgsComposerScaleBarWidget::on_mMapComboBox_activated(const QString& text)
+{
+  if(!mComposerScaleBar)
+    {
+      return;
+    }
+
+  const QgsComposition* comp = mComposerScaleBar->composition();
+  if(!comp)
+    {
+      return;
+    }
+
+  //extract id
+  int id;
+  bool conversionOk;
+  QString idString = text.split(" ").at(1);
+  id = idString.toInt(&conversionOk);
+
+  if(!conversionOk)
+    {
+      return;
+    }
+
+  //get QgsComposerMap object from composition
+  const QgsComposerMap* composerMap = comp->getComposerMapById(id);
+  if(!composerMap)
+    {
+      return;
+    }
+
+  //set it to scale bar
+  mComposerScaleBar->setComposerMap(composerMap);
+
+  //update scale bar
+  mComposerScaleBar->update();
+}
+
+void QgsComposerScaleBarWidget::setGuiElements()
+{
+  if(!mComposerScaleBar)
+    {
+      return;
+    }
+
+  blockSignals(true);
+  mNumberOfSegmentsSpinBox->setValue(mComposerScaleBar->numSegments());
+  mSegmentsLeftSpinBox->setValue(mComposerScaleBar->numSegmentsLeft());
+  mSegmentSizeSpinBox->setValue(mComposerScaleBar->numUnitsPerSegment());
+  mLineWidthSpinBox->setValue(mComposerScaleBar->pen().widthF());
+  mHeightSpinBox->setValue(mComposerScaleBar->height());
+
+  //map combo box
+  if(mComposerScaleBar->composerMap())
+    {
+      QString mapText = tr("Map ") + mComposerScaleBar->composerMap()->id();
+      int itemId = mMapComboBox->findText(mapText);
+      if(itemId > 0)
+	{
+	  mMapComboBox->setCurrentItem(itemId);
+	}
+    }
+
+  //Style //todo...
+  
+  
+  blockSignals(false);
+}
+
+//slots
+
+void QgsComposerScaleBarWidget::on_mLineWidthSpinBox_valueChanged(double d)
+{
+  if(!mComposerScaleBar)
+    {
+      return;
+    }
+
+  QPen newPen(QColor(0, 0, 0));
+  newPen.setWidthF(d);
+  mComposerScaleBar->setPen(newPen);
+  mComposerScaleBar->update();
+}
+
+void QgsComposerScaleBarWidget::on_mSegmentSizeSpinBox_valueChanged(double d)
+{
+  if(!mComposerScaleBar)
+    {
+      return;
+    }
+
+  mComposerScaleBar->setNumUnitsPerSegment(d);
+  mComposerScaleBar->update();
+}
+
+void QgsComposerScaleBarWidget::on_mSegmentsLeftSpinBox_valueChanged(int i)
+{
+  if(!mComposerScaleBar)
+    {
+      return;
+    }
+
+  mComposerScaleBar->setNumSegmentsLeft(i);
+  mComposerScaleBar->update();
+}
+
+void QgsComposerScaleBarWidget::on_mNumberOfSegmentsSpinBox_valueChanged(int i)
+{
+  if(!mComposerScaleBar)
+    {
+      return;
+    }
+
+  mComposerScaleBar->setNumSegments(i);
+  mComposerScaleBar->update();
+}
+

Added: branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.h	                        (rev 0)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerscalebarwidget.h	2008-06-22 15:00:52 UTC (rev 8670)
@@ -0,0 +1,49 @@
+/***************************************************************************
+                            qgscomposerscalebarwidget.h
+                            ---------------------------
+    begin                : 11 June 2008
+    copyright            : (C) 2008 by Marco Hugentobler
+    email                : marco dot hugentobler at karto dot baug dot ethz dot ch
+ ***************************************************************************/
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#ifndef QGSCOMPOSERSCALEBARWIDGET_H
+#define QGSCOMPOSERSCALEBARWIDGET_H
+
+#include "ui_qgscomposerscalebarwidgetbase.h"
+
+class QgsComposerScaleBar;
+
+class QgsComposerScaleBarWidget: public QWidget, private Ui::QgsComposerScaleBarWidgetBase
+{
+  Q_OBJECT
+
+ public:
+  QgsComposerScaleBarWidget(QgsComposerScaleBar* scaleBar);
+  ~QgsComposerScaleBarWidget();
+
+  public slots:
+  void on_mMapComboBox_activated(const QString& text);
+  void on_mLineWidthSpinBox_valueChanged(double d);
+  void on_mSegmentSizeSpinBox_valueChanged(double d);
+  void on_mSegmentsLeftSpinBox_valueChanged(int i);
+  void on_mNumberOfSegmentsSpinBox_valueChanged(int i);
+
+ protected:
+  void showEvent ( QShowEvent * event );
+ 
+ private:
+  QgsComposerScaleBar* mComposerScaleBar;
+
+  void refreshMapComboBox();
+  void setGuiElements();
+};
+
+#endif //QGSCOMPOSERSCALEBARWIDGET_H

Added: branches/advanced_printing_branch/src/ui/qgscompositionwidget.h
===================================================================
--- branches/advanced_printing_branch/src/ui/qgscompositionwidget.h	                        (rev 0)
+++ branches/advanced_printing_branch/src/ui/qgscompositionwidget.h	2008-06-22 15:00:52 UTC (rev 8670)
@@ -0,0 +1,228 @@
+<ui version="4.0" >
+ <class>QgsCompositionBase</class>
+ <widget class="QWidget" name="QgsCompositionBase" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>243</width>
+    <height>422</height>
+   </rect>
+  </property>
+  <property name="sizePolicy" >
+   <sizepolicy>
+    <hsizetype>7</hsizetype>
+    <vsizetype>7</vsizetype>
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="windowTitle" >
+   <string>Composition</string>
+  </property>
+  <layout class="QGridLayout" >
+   <property name="margin" >
+    <number>9</number>
+   </property>
+   <property name="spacing" >
+    <number>6</number>
+   </property>
+   <item row="0" column="0" colspan="2" >
+    <widget class="QGroupBox" name="groupBox" >
+     <property name="title" >
+      <string>Paper</string>
+     </property>
+     <layout class="QGridLayout" >
+      <property name="margin" >
+       <number>9</number>
+      </property>
+      <property name="spacing" >
+       <number>6</number>
+      </property>
+      <item row="4" column="1" >
+       <widget class="QComboBox" name="mPaperOrientationComboBox" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>7</hsizetype>
+          <vsizetype>0</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="1" >
+       <widget class="QLineEdit" name="mPaperHeightLineEdit" />
+      </item>
+      <item row="2" column="1" >
+       <widget class="QLineEdit" name="mPaperWidthLineEdit" />
+      </item>
+      <item row="1" column="1" >
+       <widget class="QComboBox" name="mPaperUnitsComboBox" >
+        <property name="enabled" >
+         <bool>false</bool>
+        </property>
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>7</hsizetype>
+          <vsizetype>0</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" >
+       <widget class="QComboBox" name="mPaperSizeComboBox" >
+        <property name="enabled" >
+         <bool>true</bool>
+        </property>
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>7</hsizetype>
+          <vsizetype>0</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+       </widget>
+      </item>
+      <item row="4" column="0" >
+       <widget class="QLabel" name="textLabel7" >
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>5</hsizetype>
+          <vsizetype>5</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string>Orientation</string>
+        </property>
+        <property name="buddy" >
+         <cstring>mPaperOrientationComboBox</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0" >
+       <widget class="QLabel" name="textLabel6" >
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>5</hsizetype>
+          <vsizetype>5</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string>Height</string>
+        </property>
+        <property name="buddy" >
+         <cstring>mPaperHeightLineEdit</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="0" >
+       <widget class="QLabel" name="textLabel4" >
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>5</hsizetype>
+          <vsizetype>5</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string>Width</string>
+        </property>
+        <property name="buddy" >
+         <cstring>mPaperWidthLineEdit</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0" >
+       <widget class="QLabel" name="textLabel5" >
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>5</hsizetype>
+          <vsizetype>5</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string>Units</string>
+        </property>
+        <property name="buddy" >
+         <cstring>mPaperUnitsComboBox</cstring>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" >
+       <widget class="QLabel" name="textLabel3" >
+        <property name="sizePolicy" >
+         <sizepolicy>
+          <hsizetype>5</hsizetype>
+          <vsizetype>5</vsizetype>
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string>Size</string>
+        </property>
+        <property name="buddy" >
+         <cstring>mPaperSizeComboBox</cstring>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="2" column="0" colspan="2" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>223</width>
+       <height>41</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="1" column="0" >
+    <widget class="QLabel" name="textLabel1" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>5</hsizetype>
+       <vsizetype>5</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text" >
+      <string>Resolution (dpi)</string>
+     </property>
+     <property name="buddy" >
+      <cstring>mResolutionLineEdit</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1" >
+    <widget class="QLineEdit" name="mResolutionLineEdit" />
+   </item>
+  </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11" />
+ <resources/>
+ <connections/>
+</ui>



More information about the QGIS-commit mailing list