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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jul 26 04:24:28 EDT 2008


Author: mhugent
Date: 2008-07-26 04:24:28 -0400 (Sat, 26 Jul 2008)
New Revision: 8913

Added:
   branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.h
   branches/advanced_printing_branch/src/ui/qgscomposerlegenditemdialogbase.ui
Modified:
   branches/advanced_printing_branch/src/app/CMakeLists.txt
   branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.h
   branches/advanced_printing_branch/src/ui/CMakeLists.txt
   branches/advanced_printing_branch/src/ui/qgscomposerlegendwidgetbase.ui
Log:
Added possibility to edit item text for composer legend

Modified: branches/advanced_printing_branch/src/app/CMakeLists.txt
===================================================================
--- branches/advanced_printing_branch/src/app/CMakeLists.txt	2008-07-26 07:26:02 UTC (rev 8912)
+++ branches/advanced_printing_branch/src/app/CMakeLists.txt	2008-07-26 08:24:28 UTC (rev 8913)
@@ -67,6 +67,7 @@
   composer/qgscomposerscalebarwidget.cpp
   composer/qgslegendmodel.cpp
   composer/qgscomposerlegend.cpp
+  composer/qgscomposerlegenditemdialog.cpp
   composer/qgscomposerlegendwidget.cpp
   composer/qgsscalebarstyle.cpp
   composer/qgsdoubleboxscalebarstyle.cpp

Added: branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.cpp	                        (rev 0)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.cpp	2008-07-26 08:24:28 UTC (rev 8913)
@@ -0,0 +1,44 @@
+/***************************************************************************
+                         qgscomposerlegenditemdialog.cpp 
+                         -------------------------------
+    begin                : July 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 "qgscomposerlegenditemdialog.h"
+#include <QStandardItem>
+
+QgsComposerLegendItemDialog::QgsComposerLegendItemDialog(const QStandardItem* item, QWidget* parent): QDialog(parent)
+{
+  setupUi(this);
+
+  if(item)
+    {
+      mItemTextLineEdit->setText(item->text());
+    }
+}
+
+QgsComposerLegendItemDialog::QgsComposerLegendItemDialog(): QDialog(0)
+{
+
+}
+
+QgsComposerLegendItemDialog::~QgsComposerLegendItemDialog()
+{
+
+}
+
+QString QgsComposerLegendItemDialog::itemText() const
+{
+  return mItemTextLineEdit->text();
+}

Added: branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.h	                        (rev 0)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerlegenditemdialog.h	2008-07-26 08:24:28 UTC (rev 8913)
@@ -0,0 +1,39 @@
+/***************************************************************************
+                         qgscomposerlegenditemdialog.h 
+                         -----------------------------
+    begin                : July 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 QGSCOMPOSERLEGENDITEMDIALOG_H
+#define QGSCOMPOSERLEGENDITEMDIALOG_H
+
+#include "ui_qgscomposerlegenditemdialogbase.h"
+
+class QStandardItem;
+
+/**A dialog to enter properties of composer legend items (currently only item text)*/
+class QgsComposerLegendItemDialog: private Ui::QgsComposerLegendItemDialogBase, public QDialog
+{
+ public:
+  QgsComposerLegendItemDialog(const QStandardItem* item, QWidget* parent = 0);
+  ~QgsComposerLegendItemDialog();
+
+  /**Returns the item text inserted by user*/
+  QString itemText() const;
+  
+ private:
+  QgsComposerLegendItemDialog(); //forbidden
+};
+
+#endif //QGSCOMPOSERLEGENDITEMDIALOG_H

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp	2008-07-26 07:26:02 UTC (rev 8912)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.cpp	2008-07-26 08:24:28 UTC (rev 8913)
@@ -17,6 +17,7 @@
 
 #include "qgscomposerlegendwidget.h"
 #include "qgscomposerlegend.h"
+#include "qgscomposerlegenditemdialog.h"
 #include <QFontDialog>
 
 QgsComposerLegendWidget::QgsComposerLegendWidget(QgsComposerLegend* legend): mLegend(legend)
@@ -325,3 +326,36 @@
       mLegend->update();
     }
 }
+
+void QgsComposerLegendWidget::on_mEditPushButton_clicked()
+{
+  QStandardItemModel* itemModel = dynamic_cast<QStandardItemModel*>(mItemTreeView->model());
+  if(!itemModel)
+    {
+      return;
+    }
+
+  //get current item
+  QModelIndex currentIndex = mItemTreeView->currentIndex();
+  if(!currentIndex.isValid())
+    {
+      return;
+    }
+
+  QStandardItem* currentItem = itemModel->itemFromIndex(currentIndex);
+  if(!currentItem)
+    {
+      return;
+    }
+
+  QgsComposerLegendItemDialog itemDialog(currentItem);
+  if(itemDialog.exec() == QDialog::Accepted)
+    {
+      currentItem->setText(itemDialog.itemText());
+    } 
+  if(mLegend)
+    {
+      mLegend->adjustBoxSize();
+      mLegend->update();
+    }
+}

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.h	2008-07-26 07:26:02 UTC (rev 8912)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerlegendwidget.h	2008-07-26 08:24:28 UTC (rev 8913)
@@ -49,6 +49,7 @@
   void on_mMoveDownPushButton_clicked();
   void on_mMoveUpPushButton_clicked();
   void on_mRemovePushButton_clicked();
+  void on_mEditPushButton_clicked();
 
  private:
   QgsComposerLegendWidget();

Modified: branches/advanced_printing_branch/src/ui/CMakeLists.txt
===================================================================
--- branches/advanced_printing_branch/src/ui/CMakeLists.txt	2008-07-26 07:26:02 UTC (rev 8912)
+++ branches/advanced_printing_branch/src/ui/CMakeLists.txt	2008-07-26 08:24:28 UTC (rev 8913)
@@ -8,6 +8,7 @@
   qgsbookmarksbase.ui
   qgscomposerbase.ui
   qgscomposerlabelwidgetbase.ui
+  qgscomposerlegenditemdialogbase.ui
   qgscomposerlegendwidgetbase.ui
   qgscomposermapwidgetbase.ui
   qgscomposerpicturebase.ui

Added: branches/advanced_printing_branch/src/ui/qgscomposerlegenditemdialogbase.ui
===================================================================
--- branches/advanced_printing_branch/src/ui/qgscomposerlegenditemdialogbase.ui	                        (rev 0)
+++ branches/advanced_printing_branch/src/ui/qgscomposerlegenditemdialogbase.ui	2008-07-26 08:24:28 UTC (rev 8913)
@@ -0,0 +1,73 @@
+<ui version="4.0" >
+ <class>QgsComposerLegendItemDialogBase</class>
+ <widget class="QDialog" name="QgsComposerLegendItemDialogBase" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>360</width>
+    <height>91</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>Legend item properties</string>
+  </property>
+  <layout class="QGridLayout" >
+   <item row="0" column="0" >
+    <widget class="QLabel" name="mItemTextLabel" >
+     <property name="text" >
+      <string>Item text:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1" >
+    <widget class="QLineEdit" name="mItemTextLineEdit" />
+   </item>
+   <item row="1" column="0" colspan="2" >
+    <widget class="QDialogButtonBox" name="buttonBox" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons" >
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>QgsComposerLegendItemDialogBase</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>QgsComposerLegendItemDialogBase</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel" >
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel" >
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

Modified: branches/advanced_printing_branch/src/ui/qgscomposerlegendwidgetbase.ui
===================================================================
--- branches/advanced_printing_branch/src/ui/qgscomposerlegendwidgetbase.ui	2008-07-26 07:26:02 UTC (rev 8912)
+++ branches/advanced_printing_branch/src/ui/qgscomposerlegendwidgetbase.ui	2008-07-26 08:24:28 UTC (rev 8913)
@@ -206,40 +206,33 @@
        </widget>
       </item>
       <item row="0" column="2" >
-       <widget class="QPushButton" name="mAddPushButton" >
-        <property name="text" >
-         <string>add...</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="3" >
        <widget class="QPushButton" name="mRemovePushButton" >
         <property name="text" >
          <string>remove</string>
         </property>
        </widget>
       </item>
-      <item row="0" column="4" >
+      <item row="0" column="3" >
        <widget class="QPushButton" name="mEditPushButton" >
         <property name="text" >
          <string>edit...</string>
         </property>
        </widget>
       </item>
-      <item row="0" column="5" >
+      <item row="0" column="4" >
        <spacer>
         <property name="orientation" >
          <enum>Qt::Horizontal</enum>
         </property>
         <property name="sizeHint" >
          <size>
-          <width>28</width>
-          <height>20</height>
+          <width>121</width>
+          <height>33</height>
          </size>
         </property>
        </spacer>
       </item>
-      <item row="1" column="0" colspan="6" >
+      <item row="1" column="0" colspan="5" >
        <widget class="QTreeView" name="mItemTreeView" >
         <property name="headerHidden" stdset="0" >
          <bool>true</bool>



More information about the QGIS-commit mailing list