[QGIS Commit] r8605 - in branches/advanced_printing_branch: images/themes/default src/app/composer src/ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Jun 6 15:27:17 EDT 2008


Author: mhugent
Date: 2008-06-06 15:27:17 -0400 (Fri, 06 Jun 2008)
New Revision: 8605

Added:
   branches/advanced_printing_branch/images/themes/default/mActionGroupItems.png
   branches/advanced_printing_branch/images/themes/default/mActionUngroupItems.png
Modified:
   branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposer.h
   branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h
   branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.h
   branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp
   branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp
   branches/advanced_printing_branch/src/ui/qgscomposerbase.ui
Log:
Group/Ungroup composer items. Icons are not very beautiful yet

Added: branches/advanced_printing_branch/images/themes/default/mActionGroupItems.png
===================================================================
(Binary files differ)


Property changes on: branches/advanced_printing_branch/images/themes/default/mActionGroupItems.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/advanced_printing_branch/images/themes/default/mActionUngroupItems.png
===================================================================
(Binary files differ)


Property changes on: branches/advanced_printing_branch/images/themes/default/mActionUngroupItems.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposer.cpp	2008-06-06 19:27:17 UTC (rev 8605)
@@ -53,6 +53,16 @@
 {
   setupUi(this);
   setupTheme();
+
+  QString myIconPath = QgsApplication::themePath();
+  qWarning(QString(myIconPath +"mActionGroupItems.png").latin1() );
+
+  toolBar->addAction(QIcon(QPixmap(myIconPath+"mActionGroupItems.png")), tr("&Group Items"), this, SLOT(groupItems()));
+  toolBar->addAction(QIcon(QPixmap(myIconPath+"mActionUngroupItems.png")), tr("&Ungroup Items"), this, SLOT(ungroupItems()));
+
+ 
+  
+
   setWindowTitle(tr("QGIS - print composer"));
 
   // Template save and load is not yet implemented, so disable those actions
@@ -101,6 +111,8 @@
   }
   restoreWindowState();
   selectItem(); // Set selection tool
+
+  mView->setFocus();
 }
 
 QgsComposer::~QgsComposer()
@@ -878,7 +890,7 @@
   mView->setCursor(QCursor(cross_hair_cursor));
 }
  
-void QgsComposer::on_mActionGroupItems_activated(void)
+void QgsComposer::groupItems(void)
 {
   if(mComposition)
     {
@@ -886,7 +898,7 @@
     }
 }
 
-void QgsComposer::on_mActionUngroupItems_activated(void)
+void QgsComposer::ungroupItems(void)
 {
   if(mComposition)
     {

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposer.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposer.h	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposer.h	2008-06-06 19:27:17 UTC (rev 8605)
@@ -150,10 +150,10 @@
     void on_mActionAddImage_activated(void);
 
     //! Group selected items 
-    void on_mActionGroupItems_activated(void);
+    void groupItems(void);
 
     //! Ungroup selected item group
-    void on_mActionUngroupItems_activated(void);
+    void ungroupItems(void);
 
     //! read project
     void projectRead();
@@ -170,6 +170,9 @@
     //! Slot for when the close button is clicked
     void on_closePButton_clicked();
 
+ protected:
+    void mouseMoveEvent(QMouseEvent* e){qWarning("QgsComposer mouse move event");}
+
 private:
     //! Set teh pixmap / icons on the toolbar buttons
     void setupTheme();

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposeritem.cpp	2008-06-06 19:27:17 UTC (rev 8605)
@@ -286,15 +286,18 @@
 
 void QgsComposerItem::drawSelectionBoxes(QPainter* p)
 {
-  p->setPen(QPen(QColor(0, 0, 255)));
-  p->setBrush(QBrush(QColor(0, 0, 255)));
-
-  double s = 5;
-  
-  p->drawRect (QRectF(0, 0, s, s));
-  p->drawRect (QRectF(rect().width() -s, 0, s, s));
-  p->drawRect (QRectF(rect().width() -s, rect().height() -s, s, s));
-  p->drawRect (QRectF(0, rect().height() -s, s, s));
+  if(plotStyle() == QgsComposition::Preview)
+    {
+      p->setPen(QPen(QColor(0, 0, 255)));
+      p->setBrush(QBrush(QColor(0, 0, 255)));
+      
+      double s = 5;
+      
+      p->drawRect (QRectF(0, 0, s, s));
+      p->drawRect (QRectF(rect().width() -s, 0, s, s));
+      p->drawRect (QRectF(rect().width() -s, rect().height() -s, s, s));
+      p->drawRect (QRectF(0, rect().height() -s, s, s));
+    }
 }
 
 void QgsComposerItem::drawFrame(QPainter* p)
@@ -307,20 +310,13 @@
     }
 }
 
-void QgsComposerItem::resize(double dx, double dy)
+void QgsComposerItem::move(double dx, double dy)
 {
-  //default implementation just calls setSceneRect
-  QRectF newSceneRect(transform().dx(), transform().dy(), rect().width() + dx, rect().height() + dy);
+  QTransform t = transform();
+  QRectF newSceneRect(t.dx() + dx, t.dy() + dy, rect().width(), rect().height());
   setSceneRect(newSceneRect);
 }
 
-void QgsComposerItem::move(double dx, double dy)
-{
-  QTransform newTransform;
-  newTransform.translate(transform().dx() + dx, transform().dy() + dy);
-  setTransform(newTransform);
-}
-
 void QgsComposerItem::setSceneRect(const QRectF& rectangle)
 {
   //setRect in item coordinates

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposeritem.h	2008-06-06 19:27:17 UTC (rev 8605)
@@ -73,12 +73,9 @@
     /** delete settings from project file  */
     virtual bool removeSettings( void );
 
-    /** resizes an item in x- and y direction (scene coordinates)*/
-    virtual void resize(double dx, double dy);
+    /**Moves item in canvas coordinates*/
+    void move(double dx, double dy);
 
-    /** moves the whole item in scene coordinates*/
-    virtual void move(double dx, double dy);
-
     /**Sets this items bound in scene coordinates such that 1 item size units
      corresponds to 1 scene size unit*/
     virtual void setSceneRect(const QRectF& rectangle);

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.cpp	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.cpp	2008-06-06 19:27:17 UTC (rev 8605)
@@ -122,16 +122,6 @@
     }
 }
 
-void QgsComposerItemGroup::move(double dx, double dy)
-{
-  QSet<QgsComposerItem*>::iterator item_it = mItems.begin();
-  for(; item_it != mItems.end(); ++item_it)
-    {
-      (*item_it)->move(dx, dy);
-    }
-  QgsComposerItem::move(dx, dy);
-}
-
 void QgsComposerItemGroup::setSceneRect(const QRectF& rectangle)
 {
   //call resize and transform for every item
@@ -141,28 +131,30 @@
 
   double dx = rectangle.width() - rect().width();
   double dy = rectangle.height() - rect().height();
-  double widthRatio, heightRatio;
 
+  double itemWidthRatio, itemHeightRatio;
+  
+  double newItemWidth, newItemHeight;
+  QRectF newItemRect;
+
   QSet<QgsComposerItem*>::iterator item_it = mItems.begin();
   for(; item_it != mItems.end(); ++item_it)
-    {
-      (*item_it)->move(transformX, transformY);
-      widthRatio = (*item_it)->rect().width() / rect().width();
-      heightRatio = (*item_it)->rect().height() / rect().height();
-      (*item_it)->resize(dx * widthRatio, dy * heightRatio);
+    { 
+      itemWidthRatio = (*item_it)->rect().width()/ mSceneBoundingRectangle.width();
+      itemHeightRatio = (*item_it)->rect().height()/ mSceneBoundingRectangle.height();
+
+      newItemWidth = (*item_it)->rect().width() + dx * itemWidthRatio;
+      newItemHeight = (*item_it)->rect().height() + dy * itemHeightRatio;
+      newItemRect = QRectF((*item_it)->transform().dx() + transformX, (*item_it)->transform().dy() + transformY, newItemWidth, newItemHeight);  
+      (*item_it)->setSceneRect(newItemRect);
     }
 
   QgsComposerItem::setSceneRect(rectangle);
 }
 
-void QgsComposerItemGroup::resize(double dx, double dy)
-{
-  //soon...
-}
-
 void QgsComposerItemGroup::drawFrame(QPainter* p)
 {
-  if(mFrame)
+  if(mFrame && plotStyle() == QgsComposition::Preview)
     {
       QPen newPen(pen());
       newPen.setStyle(Qt::DashLine);

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.h	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposeritemgroup.h	2008-06-06 19:27:17 UTC (rev 8605)
@@ -31,8 +31,6 @@
   void removeItems();
   /**Draw outline and ev. selection handles*/
   void paint( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
-  /**Moves all contained items by dx/dy*/
-  void move(double dx, double dy);
   /**Sets this items bound in scene coordinates such that 1 item size units
      corresponds to 1 scene size unit*/
   void setSceneRect(const QRectF& rectangle);

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp	2008-06-06 19:27:17 UTC (rev 8605)
@@ -58,11 +58,11 @@
 void QgsComposerView::mouseMoveEvent(QMouseEvent* e)
 {
   qWarning("QgsComposerView::mouseMoveEvent");
-    mComposer->composition()->mouseMoveEvent(e);
-    if(mComposer->composition()->tool() == QgsComposition::Select)
-      {
-	QGraphicsView::mouseMoveEvent(e);
-      }
+  mComposer->composition()->mouseMoveEvent(e);
+  if(mComposer->composition()->tool() == QgsComposition::Select)
+    {
+      QGraphicsView::mouseMoveEvent(e);
+    }
 }
 
 void QgsComposerView::keyPressEvent ( QKeyEvent * e )

Modified: branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposition.cpp	2008-06-06 19:27:17 UTC (rev 8605)
@@ -442,7 +442,7 @@
   switch ( mTool ) {
     case AddMap: // mToolStep should be always 1 but rectangle can be 0 size
       {
-        double x = mRectangleItem->rect().x();//use doubles?
+        double x = mRectangleItem->rect().x();
         double y = mRectangleItem->rect().y();
         double w = mRectangleItem->rect().width();
         double h = mRectangleItem->rect().height();
@@ -458,8 +458,6 @@
 	    m = new QgsComposerMap ( this, mNextItemId++, x, y, w, h );
 	    QgsComposerMapWidget* w = new QgsComposerMapWidget(m);
 	    mComposer->addItem(m, w);
-
-	    //m->setUserExtent( mMapCanvas->extent());
 	    mItems.push_back(m);
 	    m->setSelected ( true );
 	    mCanvas->update();
@@ -849,6 +847,7 @@
 
   mComposer->addItem(itemGroup, 0);
   mCanvas->addItem(itemGroup);
+  mItems.push_back(itemGroup);
   itemGroup->setSelected(true);
   mComposer->showItemOptions(0);
 }

Modified: branches/advanced_printing_branch/src/ui/qgscomposerbase.ui
===================================================================
--- branches/advanced_printing_branch/src/ui/qgscomposerbase.ui	2008-06-06 15:46:26 UTC (rev 8604)
+++ branches/advanced_printing_branch/src/ui/qgscomposerbase.ui	2008-06-06 19:27:17 UTC (rev 8605)
@@ -9,10 +9,16 @@
     <height>609</height>
    </rect>
   </property>
+  <property name="mouseTracking" >
+   <bool>true</bool>
+  </property>
   <property name="windowTitle" >
    <string>MainWindow</string>
   </property>
   <widget class="QWidget" name="centralwidget" >
+   <property name="mouseTracking" >
+    <bool>true</bool>
+   </property>
    <layout class="QVBoxLayout" >
     <property name="spacing" >
      <number>6</number>
@@ -31,10 +37,16 @@
     </property>
     <item>
      <widget class="QSplitter" name="mSplitter" >
+      <property name="mouseTracking" >
+       <bool>true</bool>
+      </property>
       <property name="orientation" >
        <enum>Qt::Horizontal</enum>
       </property>
       <widget class="QFrame" name="mViewFrame" >
+       <property name="mouseTracking" >
+        <bool>true</bool>
+       </property>
        <property name="frameShape" >
         <enum>QFrame::StyledPanel</enum>
        </property>
@@ -234,8 +246,6 @@
    <addaction name="mActionAddNewVectLegend" />
    <addaction name="mActionAddNewScalebar" />
    <addaction name="mActionSelectMoveItem" />
-   <addaction name="mActionGroupItems" />
-   <addaction name="mActionUngroupItems" />
   </widget>
   <action name="mActionOpenTemplate" >
    <property name="icon" >
@@ -357,16 +367,6 @@
     <string>Add Image</string>
    </property>
   </action>
-  <action name="mActionGroupItems" >
-   <property name="text" >
-    <string>Group Items</string>
-   </property>
-  </action>
-  <action name="mActionUngroupItems" >
-   <property name="text" >
-    <string>Ungroup items</string>
-   </property>
-  </action>
  </widget>
  <tabstops>
   <tabstop>mOptionsTabWidget</tabstop>



More information about the QGIS-commit mailing list