[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/lib/kofficeui
From:       Thorsten Zachmann <t.zachmann () zagge ! de>
Date:       2005-11-10 13:51:19
Message-ID: 1131630679.499027.7818.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 479425 by zachmann:

o Added dialog for adding guide line



 M  +83 -1     koGuideLineDia.cpp  
 M  +35 -1     koGuideLineDia.h  
 M  +1 -0      koGuides.cpp  


--- trunk/koffice/lib/kofficeui/koGuideLineDia.cpp #479424:479425
@@ -21,17 +21,22 @@
 
 #include "koGuideLineDia.h"
 
+#include <qbuttongroup.h>
 #include <qhbox.h>
+#include <qvbox.h>
 #include <qlabel.h>
 #include <qlayout.h>
+#include <qradiobutton.h>
 
 #include <klocale.h>
 #include <koUnitWidgets.h>
 
 
 KoGuideLineDia::KoGuideLineDia( QWidget *parent, double pos, double minPos, double \
                maxPos,
-                               KoUnit::Unit unit, const char *name )
+                                KoUnit::Unit unit, const char *name )
 : KDialogBase( parent, name , true, "", Ok | Cancel, Ok, true )
+, m_hButton( 0 )
+, m_vButton( 0 )
 {
     setCaption( i18n("Set Guide Line Position") );
     QHBox *page = makeHBoxMainWidget();
@@ -40,10 +45,87 @@
     m_position->setFocus();
 }
 
+
+KoGuideLineDia::KoGuideLineDia( QWidget *parent, KoPoint &pos, KoRect &rect,
+                                KoUnit::Unit unit, const char *name )
+: KDialogBase( parent, name , true, "", Ok | Cancel, Ok, true )
+, m_rect( rect )
+, m_pos( pos )
+, m_positionChanged( false )
+, m_hButton( 0 )
+, m_vButton( 0 )
+{
+    setCaption( i18n("Add Guide Line") );
+    QVBox * vbox = makeVBoxMainWidget();
+
+    QButtonGroup *group = new QButtonGroup( 1, QGroupBox::Horizontal, i18n( \
"Orientation" ), vbox ); +    group->setRadioButtonExclusive( true );
+    //group->layout();
+    m_hButton = new QRadioButton( i18n( "Horizontal" ), group );
+    m_vButton = new QRadioButton( i18n( "Vertical" ), group );
+
+    connect( group, SIGNAL( clicked( int ) ), this, SLOT( slotOrientationChanged() ) \
); +
+    m_vButton->setChecked( true );;
+
+    QHBox *hbox = new QHBox( vbox );
+    QLabel *label = new QLabel( i18n( "&Position:" ), hbox );
+    m_position= new KoUnitDoubleSpinBox( hbox, QMAX( 0.0, m_rect.left() ), QMAX( \
0.0, m_rect.right() ), 1, QMAX( 0.0, pos.x() ), unit ); +    m_position->setFocus();
+    label->setBuddy( m_position );
+
+    connect( m_position, SIGNAL( valueChanged( double ) ), this, SLOT( \
slotPositionChanged() ) ); +}
+
+
 double KoGuideLineDia::pos() const
 {
     return m_position->value();
 }
 
 
+Qt::Orientation KoGuideLineDia::orientation() const
+{
+    Qt::Orientation o = Qt::Horizontal;
+    if ( m_vButton && m_vButton->isChecked() )
+    {
+        o = Qt::Vertical;
+    }
+    return o;
+}
+
+
+void KoGuideLineDia::slotOrientationChanged()
+{
+    if ( m_hButton && m_vButton )
+    {
+        if ( m_hButton->isChecked() )
+        {
+            m_position->setMinValue( QMAX( 0.0, m_rect.top() ) );
+            m_position->setMaxValue( QMAX( 0.0, m_rect.bottom() ) );
+            if ( ! m_positionChanged )
+            {
+                disconnect( m_position, SIGNAL( valueChanged( double ) ), this, \
SLOT( slotPositionChanged() ) ); +                m_position->changeValue( m_pos.y() \
); +                connect( m_position, SIGNAL( valueChanged( double ) ), this, \
SLOT( slotPositionChanged() ) ); +            }
+        }
+        else if ( m_vButton->isChecked() )
+        {
+            m_position->setMinValue( QMAX( 0.0, m_rect.left() ) );
+            m_position->setMaxValue( QMAX( 0.0, m_rect.right() ) );
+            if ( ! m_positionChanged )
+            {
+                disconnect( m_position, SIGNAL( valueChanged( double ) ), this, \
SLOT( slotPositionChanged() ) ); +                m_position->changeValue( m_pos.x() \
); +                connect( m_position, SIGNAL( valueChanged( double ) ), this, \
SLOT( slotPositionChanged() ) ); +            }
+        }
+    }
+}
+
+void KoGuideLineDia::slotPositionChanged()
+{
+    m_positionChanged = true;
+}
 #include "koGuideLineDia.moc"
--- trunk/koffice/lib/kofficeui/koGuideLineDia.h #479424:479425
@@ -24,9 +24,12 @@
 
 #include <kdialogbase.h>
 #include <koUnit.h>
+#include "koRect.h"
+#include "koPoint.h"
 
 
 class KoUnitDoubleSpinBox;
+class QRadioButton;
 
 /**
  * @brief Class for setting a guide line position.
@@ -49,13 +52,44 @@
                     KoUnit::Unit unit, const char *name = 0L );
 
     /**
+     * @brief Constructor
+     *
+     * This shows a dialog to add a guide line. As long the position is not changed 
+     * and the orientation of the guide line is changed the value will be set to \
pos.x() +     * or pos.y() according to the orientation.
+     *
+     * @param parent the parent widget
+     * @param pos the actual position of cursor
+     * @param rect the rect in where the guide can be placed
+     * @param unit the unit used in the document
+     * @param name the name is send to the QObject constructor
+     */
+    KoGuideLineDia( QWidget *parent, KoPoint &pos, KoRect &rect,
+                    KoUnit::Unit unit, const char *name = 0L );
+    /**
      * @brief the position
      *
-     * @return The value of the position input
+     * @return the value of the position input
      */
     double pos() const;
 
+    /**
+     * @brief the orientation
+     *
+     * @return the orientation of the added guide line
+     */
+    Qt::Orientation orientation() const;
+
+protected slots:
+    void slotOrientationChanged();
+    void slotPositionChanged();
+
 protected:
+    KoRect m_rect;
+    KoPoint m_pos;
+    bool m_positionChanged;
+    QRadioButton * m_hButton;
+    QRadioButton * m_vButton;
     KoUnitDoubleSpinBox* m_position;
 };
 
--- trunk/koffice/lib/kofficeui/koGuides.cpp #479424:479425
@@ -799,6 +799,7 @@
     {
         guideLine->position = dia.pos();
         paint();
+        emit guideLinesChanged( m_view );
     }
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic