bool sortMenuEnabled() const;
void addMenuAction( QAction* );
-
protected:
void contextMenuEvent( QContextMenuEvent* );
private:
typedef QMap<int, QAction*> ActionsMap;
- bool myEnableSortMenu;
+ bool myEnableSortMenu;
ActionsMap myActions;
};
h->addMenuAction( action );
}
+/*!
+ \brief Resizes the given column in order to enclose its contents.
+ The size will be changed only if it is smaller than the size of
+ contents.
+ \param column number of column
+*/
+void QtxTreeView::resizeColumnToEncloseContents( int column )
+{
+ if (column < 0 || column >= header()->count())
+ return;
+
+ int contentsSizeHint = sizeHintForColumn(column);
+ int headerSizeHint = header()->isHidden() ? 0 : header()->sectionSizeHint(column);
+ int sizeHint = qMax(contentsSizeHint, headerSizeHint);
+
+ int currentSize = columnWidth( column );
+ if (currentSize < sizeHint)
+ setColumnWidth( column, sizeHint );
+}
+
/*
\brief Called when the header section is clicked.
\param column header column index
emit drawedRow( index );
}
+/*!
+ \brief Called when rows are about to be removed.
+ \param parent model index
+ \param start first row to remove
+ \param end last row to remove
+*/
+void QtxTreeView::rowsAboutToBeRemoved( const QModelIndex& parent, int start, int end )
+{
+ setCurrentIndex( QModelIndex() );
+ QTreeView::rowsAboutToBeRemoved( parent, start, end );
+}
+
/*!
\brief Expand/collapse the specified item (recursively).
\param index model index
#include "QtxAction.h"
-#include <QRegExp>
#include <QMenu>
-#include <QFocusEvent>
-#include <QMouseEvent>
#include <QStyle>
+#include <QRegExp>
#include <QLayout>
+#include <QPainter>
#include <QSplitter>
+#include <QFocusEvent>
+#include <QMouseEvent>
#include <QRubberBand>
#include <QApplication>
+#include <QStyleOption>
#include <QInputDialog>
#include <QStackedWidget>
#include <QAbstractButton>
-#include <QPainter>
-#include <QStyleOption>
-
-#define DARK_COLOR_LIGHT 250
/*!
\class QtxWorkstackArea::WidgetEvent
connect( myActionsMap[Close], SIGNAL( triggered( bool ) ), this, SLOT( onCloseWindow() ) );
connect( myActionsMap[Rename], SIGNAL( triggered( bool ) ), this, SLOT( onRename() ) );
+ // Action shortcut will work when action added in any widget.
+ for ( QMap<int, QAction*>::iterator it = myActionsMap.begin(); it != myActionsMap.end(); ++it )
+ {
+ addAction( it.value() );
+ it.value()->setShortcutContext( Qt::ApplicationShortcut );
+ }
+
QVBoxLayout* base = new QVBoxLayout( this );
base->setMargin( 0 );
}
/*!
- \brief Get all child widgets in all workareas.
- \return list of widgets in all workareas
+ \brief Get list of all widgets in all areas or in specified area which given
+ widget belongs to
+ \param wid widget specifying area if it is equal to null when widgets of all
+ areas are retuned
+ \return list of widgets
*/
-QWidgetList QtxWorkstack::windowList() const
+QWidgetList QtxWorkstack::windowList( QWidget* wid ) const
{
QList<QtxWorkstackArea*> lst;
- areas( mySplit, lst, true );
+ if ( !wid )
+ {
+ areas( mySplit, lst, true );
+ }
+ else
+ {
+ QtxWorkstackArea* area = wgArea( wid );
+ if ( area )
+ lst.append( area );
+ }
QWidgetList widList;
for ( QList<QtxWorkstackArea*>::iterator it = lst.begin(); it != lst.end(); ++it )
if ( !split )
return;
- const QObjectList& objs = split->children();
+ /*const QObjectList& objs = */split->children(); // VSR: is it needed ???
QString sizesStr;
QList<int> sizes = split->sizes();
\brief Emitted when the workstack's child widget \w is activated.
\param w widget being activated
*/
+
+/*!
+ \brief Gets area containing given widget
+ \param wid widget
+ \return pointer to QtxWorkstackArea* object
+*/
+QtxWorkstackArea* QtxWorkstack::wgArea( QWidget* wid ) const
+{
+ QtxWorkstackArea* resArea = 0;
+
+ QList<QtxWorkstackArea*> areaList;
+ areas( mySplit, areaList, true );
+
+ QList<QtxWorkstackArea*>::ConstIterator it;
+ for ( it = areaList.begin(); it != areaList.end() && !resArea; ++it )
+ {
+ if ( (*it)->contains( wid ) )
+ resArea = *it;
+ }
+
+ return resArea;
+}
+
+/*!
+ \brief Moves the first widget to the same area which the second widget belongs to
+ \param wid widget to be moved
+ \param wid_to widget specified the destination area
+ \param before specifies whether the first widget has to be moved before or after
+ the second widget
+ \return TRUE if operation is completed successfully, FALSE otherwise
+*/
+bool QtxWorkstack::move( QWidget* wid, QWidget* wid_to, const bool before )
+{
+ if ( wid && wid_to )
+ {
+ QtxWorkstackArea* area_src = wgArea( wid );
+ QtxWorkstackArea* area_to = wgArea( wid_to );
+ if ( area_src && area_to )
+ {
+ // find index of the second widget
+ QWidgetList wgList = area_to->widgetList();
+ QWidgetList::ConstIterator it;
+ int idx = 0;
+ for ( it = wgList.begin(); it != wgList.begin(); ++it, idx++ )
+ {
+ if ( *it == wid_to )
+ break;
+ }
+
+ if ( idx < wgList.count() ) // paranoidal check
+ {
+ if ( !before )
+ idx++;
+ area_src->removeWidget( wid, true );
+ area_to->insertWidget( wid, idx );
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/*!
+ \brief Group all windows in one area
+ \return TRUE if operation is completed successfully, FALSE otherwise
+*/
+void QtxWorkstack::stack()
+{
+ QWidgetList wgList = windowList();
+ if ( !wgList.count() )
+ return; // nothing to do
+
+ QtxWorkstackArea* area_to = 0;
+ QWidgetList::ConstIterator it;
+ for ( it = wgList.begin(); it != wgList.end(); ++it )
+ {
+ QtxWorkstackArea* area_src = 0;
+ if ( !area_to )
+ {
+ area_to = wgArea( *it );
+ area_src = area_to;
+ }
+ else
+ area_src = wgArea( *it );
+
+ if ( area_src != area_to )
+ {
+ area_src->removeWidget( *it, true );
+ area_to->insertWidget( *it, -1 );
+ }
+ }
+}