From 63e63230a34dec08a695c0ed73777338cf0b9465 Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 20 Jul 2005 05:48:54 +0000 Subject: [PATCH] Comments moved into cxx-files. Method QtxWorkstack::onTop() removed. --- src/Qtx/QtxWorkstack.cxx | 167 +++++++++++++++++++++------------ src/Qtx/QtxWorkstack.h | 118 +++++------------------ src/Qtx/QtxWorkstackAction.cxx | 10 +- 3 files changed, 140 insertions(+), 155 deletions(-) diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 9169b4612..25358a51b 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -16,8 +16,6 @@ #include #include -#include - /*! Class: QtxWorkstack [Public] Descr: @@ -116,7 +114,12 @@ void QtxWorkstack::split( const int o ) curWid->setFocus(); } -// begin: jfa 06.07.2005 +/*! +* \brief Split workarea of the given widget on two parts. +* \param wid - widget, belonging to this workstack +* \param o - orientation of splitting (Qt::Horizontal or Qt::Vertical) +* \param type - type of splitting, see SplitType enumeration +*/ void QtxWorkstack::Split (QWidget* wid, const Qt::Orientation o, const SplitType type) { if (!wid) return; @@ -190,27 +193,48 @@ void QtxWorkstack::Split (QWidget* wid, const Qt::Orientation o, const SplitType distributeSpace(trg); } +/*! +* \brief Put given widget on top of its workarea +* \param wid - widget, belonging to this workstack +*/ +/* void QtxWorkstack::OnTop (QWidget* wid) { - if (!wid) return; + if ( !wid ) + return; // find area of the given widget - QtxWorkstackArea* area = NULL; + QtxWorkstackArea* area = 0; QPtrList allAreas; - areas(mySplit, allAreas, true); - QPtrListIterator it (allAreas); - for (; it.current() && !area; ++it) { - if (it.current()->contains(wid)) + areas( mySplit, allAreas, true ); + for ( QPtrListIterator it( allAreas ); it.current() && !area; ++it ) + { + if ( it.current()->contains( wid ) ) area = it.current(); } - if (!area) return; - area->setActiveWidget(wid); + if ( area ) + area->setActiveWidget( wid ); } +*/ -void QtxWorkstack::Attract (QWidget* wid1, QWidget* wid2, const bool all) +/*! +* \brief Move widget(s) from source workarea into target workarea +* or just reorder widgets inside one workarea. +* \param wid1 - widget from target workarea +* \param wid2 - widget from source workarea +* \param all - if this parameter is TRUE, all widgets from source workarea will +* be moved into the target one, else only the \a wid2 will be moved +* +* Move \a wid2 in target workarea. Put it right after \a wid1. +* If value of boolean argument is TRUE, all widgets from source workarea +* will be moved together with \a wid2, source workarea will be deleted. +* If \a wid1 and \a wid2 belongs to one workarea, simple reordering will take place. +*/ +void QtxWorkstack::Attract ( QWidget* wid1, QWidget* wid2, const bool all ) { - if (!wid1 || !wid2) return; + if ( !wid1 || !wid2 ) + return; // find area of the widgets QtxWorkstackArea *area1 = NULL, *area2 = NULL; @@ -268,24 +292,7 @@ void QtxWorkstack::Attract (QWidget* wid1, QWidget* wid2, const bool all) } } - /*area2->removeWidget(wid2); - area1->insertWidget(wid2); - - // Reorder widgets - QWidgetListIt itr( wids1 ); - for ( ; itr.current() && itr.current() != wid1; ++itr ) - { - } - ++itr; - for ( ; itr.current(); ++itr ) - { - if (itr.current() != wid2) { - area1->removeWidget( itr.current() ); - area1->insertWidget( itr.current() ); - } - }*/ - - area1->setActiveWidget(curWid); + area1->setActiveWidget( curWid ); } static void setSizes (QIntList& szList, const int item_ind, @@ -307,10 +314,18 @@ static void setSizes (QIntList& szList, const int item_ind, } } +/*! +* \brief Set position of the widget relatively its splitter. +* \param wid - widget to set position of +* \param pos - position relatively splitter. Value in range [0..1]. +* +* Orientation of positioning will correspond to the splitter orientation. +*/ void QtxWorkstack::SetRelativePositionInSplitter( QWidget* wid, const double position ) { if ( position < 0.0 || 1.0 < position) return; + if ( !wid ) return; @@ -356,37 +371,57 @@ void QtxWorkstack::SetRelativePositionInSplitter( QWidget* wid, const double pos split->setSizes(szList); } -void QtxWorkstack::SetRelativePosition (QWidget* wid, - const Qt::Orientation o, - const double position) +/*! +* \brief Set position of the widget relatively the entire workstack. +* \param wid - widget to set position of +* \param o - orientation of positioning (Qt::Horizontal or Qt::Vertical). +* If o = Qt::Horizontal, horizontal position of \a wid will be changed. +* If o = Qt::Vertical, vertical position of \a wid will be changed. +* \param pos - position relatively workstack. Value in range [0..1]. +*/ +void QtxWorkstack::SetRelativePosition( QWidget* wid, const Qt::Orientation o, + const double position ) { - if (position < 0.0 || 1.0 < position) + if ( position < 0.0 || 1.0 < position ) return; - if (!wid) + + if ( !wid ) return; - int splitter_size = (o == Horizontal ? mySplit->width() : mySplit->height()); - int need_pos = int(position * splitter_size); + int splitter_size = o == Horizontal ? mySplit->width() : mySplit->height(); + int need_pos = int( position * splitter_size ); int splitter_pos = 0; - if (setPosition(wid, mySplit, o, need_pos, splitter_pos) != 0) { + if ( setPosition( wid, mySplit, o, need_pos, splitter_pos ) != 0 ) + { // impossible to set required position } } - +/*! +* \brief Sets the action's accelerator key to accel. +* \param id - the key of the action in the actions map. +* \param accel - action's accelerator key. +*/ void QtxWorkstack::setAccel( const int id, const int accel ) { - if (!myActionsMap.contains(id)) + if ( !myActionsMap.contains( id ) ) return; - myActionsMap[id]->setAccel(accel); + + myActionsMap[id]->setAccel( accel ); } -int QtxWorkstack::accel (const int id) const +/*! +* \brief Returns the action's accelerator key. +* \param id - the key of the action in the actions map. +* \retval int - action's accelerator key. +*/ +int QtxWorkstack::accel( const int id ) const { - if (!myActionsMap.contains(id)) - return 0; - return myActionsMap[id]->accel(); + int res = 0; + if ( myActionsMap.contains( id ) ) + res = myActionsMap[id]->accel(); + return res; } static int positionSimple (QIntList& szList, const int nb, const int splitter_size, @@ -449,11 +484,25 @@ static int positionSimple (QIntList& szList, const int nb, const int splitter_si return delta; } -int QtxWorkstack::setPosition (QWidget* wid, QSplitter* split, - const Qt::Orientation o, const int need_pos, - const int splitter_pos) +/*! +* \brief Set position of given widget. +* \param wid - widget to be moved +* \param split - currently processed splitter (goes from more common +* to more particular splitter in recursion calls) +* \param o - orientation of positioning +* \param need_pos - required position of the given widget in pixels +* (from top/left side of workstack area) +* \param splitter_pos - position of the splitter \a split +* (from top/left side of workstack area) +* \retval int - returns difference between a required and a distinguished position. +* +* Internal method. Recursively calls itself. +* Is called from SetRelativePosition public method. +*/ +int QtxWorkstack::setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o, + const int need_pos, const int splitter_pos ) { - if (!wid || !split) + if ( !wid || !split ) return need_pos - splitter_pos; // Find corresponding sub-splitter. @@ -462,7 +511,7 @@ int QtxWorkstack::setPosition (QWidget* wid, QSplitter* split, bool isBottom = false, isFound = false; QSplitter* sub_split = NULL; const QObjectList* objs = split->children(); - if (objs) + if ( objs ) { for (QObjectListIt it (*objs); it.current() && !isFound; ++it) { @@ -631,7 +680,6 @@ int QtxWorkstack::setPosition (QWidget* wid, QSplitter* split, return 0; } -// end: jfa 06.07.2005 void QtxWorkstack::distributeSpace( QSplitter* split ) const { @@ -656,12 +704,6 @@ void QtxWorkstack::splitHorizontal() split( Qt::Horizontal ); } -void QtxWorkstack::onCloseWindow() -{ - if ( activeWindow() ) - activeWindow()->close(); -} - QSplitter* QtxWorkstack::wrapSplitter( QtxWorkstackArea* area ) { if ( !area ) @@ -723,6 +765,15 @@ void QtxWorkstack::insertWidget( QWidget* wid, QWidget* pWid, QWidget* after ) itr.current()->reparent( pWid, QPoint( 0, 0 ), map.contains( itr.current() ) ? map[itr.current()] : false ); } +/*! +* \brief Closes the active window. +*/ +void QtxWorkstack::onCloseWindow() +{ + if ( activeWindow() ) + activeWindow()->close(); +} + void QtxWorkstack::onDestroyed( QObject* obj ) { QtxWorkstackArea* area = (QtxWorkstackArea*)obj; diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index a48854bbb..ac71afdc2 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -23,12 +23,24 @@ class QtxWorkstackDrag; class QtxWorkstackChild; class QtxWorkstackTabBar; +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + class QTX_EXPORT QtxWorkstack : public QWidget { Q_OBJECT - + public: + enum { SplitVertical, SplitHorizontal, Close }; + + enum SplitType { + SPLIT_STAY, //!< given widget stays in its workarea, others are moved into a new one + SPLIT_AT, //!< widgets before a given widget stays in they workarea, others are moved into a new one + SPLIT_MOVE //!< given widget is moved into a new workarea, others stay in an old one + }; +public: QtxWorkstack( QWidget* = 0 ); virtual ~QtxWorkstack(); @@ -37,79 +49,18 @@ public: QWidget* activeWindow() const; + int accel( const int ) const; + void setAccel( const int, const int ); + void split( const int ); - enum { SplitVertical, SplitHorizontal, Close }; + // STV: Useless function. wid->setFocus() should be used instead. + // void OnTop( QWidget* wid); - // begin: jfa 06.07.2005 - enum SplitType { - SPLIT_STAY, //!< given widget stays in its workarea, others are moved into a new one - SPLIT_AT, //!< widgets before a given widget stays in they workarea, others are moved into a new one - SPLIT_MOVE //!< given widget is moved into a new workarea, others stay in an old one - }; - - /*! - * \brief Split workarea of the given widget on two parts. - * \param wid - widget, belonging to this workstack - * \param o - orientation of splitting (Qt::Horizontal or Qt::Vertical) - * \param type - type of splitting, see SplitType enumeration - */ - void Split( QWidget* wid, const Qt::Orientation o, const SplitType type); - - /*! - * \brief Put given widget on top of its workarea - * \param wid - widget, belonging to this workstack - */ - void OnTop( QWidget* wid); - - /*! - * \brief Move widget(s) from source workarea into target workarea - * or just reorder widgets inside one workarea. - * \param wid1 - widget from target workarea - * \param wid2 - widget from source workarea - * \param all - if this parameter is TRUE, all widgets from source workarea will - * be moved into the target one, else only the \a wid2 will be moved - * - * Move \a wid2 in target workarea. Put it right after \a wid1. - * If value of boolean argument is TRUE, all widgets from source workarea - * will be moved together with \a wid2, source workarea will be deleted. - * If \a wid1 and \a wid2 belongs to one workarea, simple reordering will take place. - */ + void Split( QWidget* wid, const Qt::Orientation o, const SplitType type ); void Attract( QWidget* wid1, QWidget* wid2, const bool all ); - - /*! - * \brief Set position of the widget relatively its splitter. - * \param wid - widget to set position of - * \param pos - position relatively splitter. Value in range [0..1]. - * - * Orientation of positioning will correspond to the splitter orientation. - */ - void SetRelativePositionInSplitter( QWidget* wid, const double pos ); - - /*! - * \brief Set position of the widget relatively the entire workstack. - * \param wid - widget to set position of - * \param o - orientation of positioning (Qt::Horizontal or Qt::Vertical). - * If o = Qt::Horizontal, horizontal position of \a wid will be changed. - * If o = Qt::Vertical, vertical position of \a wid will be changed. - * \param pos - position relatively workstack. Value in range [0..1]. - */ void SetRelativePosition( QWidget* wid, const Qt::Orientation o, const double pos ); - // end: jfa 06.07.2005 - - /*! - * \brief Sets the action's accelerator key to accel. - * \param id - the key of the action in the actions map. - * \param accel - action's accelerator key. - */ - void setAccel( const int id, const int accel ); - - /*! - * \brief Returns the action's accelerator key. - * \param id - the key of the action in the actions map. - * \retval int - action's accelerator key. - */ - int accel (const int id) const; + void SetRelativePositionInSplitter( QWidget* wid, const double pos ); signals: void windowActivated( QWidget* ); @@ -119,14 +70,11 @@ public slots: void splitHorizontal(); private slots: + void onCloseWindow(); void onDestroyed( QObject* ); void onWindowActivated( QWidget* ); void onContextMenuRequested( QPoint ); void onDeactivated( QtxWorkstackArea* ); - /*! - * \brief Closes the active window. - */ - void onCloseWindow(); protected: virtual void childEvent( QChildEvent* ); @@ -155,26 +103,8 @@ private: void updateState( QSplitter* ); void distributeSpace( QSplitter* ) const; - - // begin: jfa 06.07.2005 - /*! - * \brief Set position of given widget. - * \param wid - widget to be moved - * \param split - currently processed splitter (goes from more common - * to more particular splitter in recursion calls) - * \param o - orientation of positioning - * \param need_pos - required position of the given widget in pixels - * (from top/left side of workstack area) - * \param splitter_pos - position of the splitter \a split - * (from top/left side of workstack area) - * \retval int - returns difference between a required and a distinguished position. - * - * Internal method. Recursively calls itself. - * Is called from SetRelativePosition public method. - */ int setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o, - const int need_pos, const int splitter_pos); - // end: jfa 06.07.2005 + const int need_pos, const int splitter_pos ); private: QWidget* myWin; @@ -370,4 +300,8 @@ private: }; +#ifdef WIN32 +#pragma warning( default:4251 ) +#endif + #endif diff --git a/src/Qtx/QtxWorkstackAction.cxx b/src/Qtx/QtxWorkstackAction.cxx index 82058dabf..6773afdc2 100644 --- a/src/Qtx/QtxWorkstackAction.cxx +++ b/src/Qtx/QtxWorkstackAction.cxx @@ -169,11 +169,11 @@ void QtxWorkstackAction::onAboutToShow() return; QtxWorkstack* ws = workstack(); - if ( ws ) - { - myItem[VSplit]->setAccel(ws->accel(QtxWorkstack::SplitVertical)); - myItem[HSplit]->setAccel(ws->accel(QtxWorkstack::SplitHorizontal)); - } + if ( ws && myItem.contains( VSplit ) ) + myItem[VSplit]->setAccel( ws->accel( QtxWorkstack::SplitVertical ) ); + if ( ws && myItem.contains( HSplit ) ) + myItem[HSplit]->setAccel( ws->accel( QtxWorkstack::SplitHorizontal ) ); + updatePopup( (QPopupMenu*)obj ); } -- 2.39.2