#include "Qtx.h"
-#include <qdir.h>
-#include <qbitmap.h>
-#include <qstring.h>
-#include <qwidget.h>
-#include <qlayout.h>
-#include <qpainter.h>
-#include <qtoolbar.h>
-#include <qgroupbox.h>
-#include <qfileinfo.h>
-#include <qpopupmenu.h>
-#include <qobjectlist.h>
-#include <qwidgetlist.h>
-#include <qapplication.h>
+#include <QtCore/qdir.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qfileinfo.h>
+
+#include <QtGui/qmenu.h>
+#include <QtGui/qbitmap.h>
+#include <QtGui/qwidget.h>
+#include <QtGui/qlayout.h>
+#include <QtGui/qpainter.h>
+#include <QtGui/qtoolbar.h>
+#include <QtGui/qapplication.h>
+#include <QtGui/qdesktopwidget.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+QString Qtx::toQString( const char* str, const int len )
+{
+ return toQString( (unsigned char*)str, len );
+}
+
+QString Qtx::toQString( const short* str, const int len )
+{
+ return toQString( (unsigned short*)str, len );
+}
+
+QString Qtx::toQString( const unsigned char* str, const int len )
+{
+ QString res;
+ int l = len;
+ const unsigned char* s = str;
+ while ( len < 0 || res.length() < len )
+ {
+ if ( *s == '\0' )
+ break;
+
+ res.append( QChar( *s ) );
+ s++;
+ }
+ return res;
+}
+
+QString Qtx::toQString( const unsigned short* str, const int len )
+{
+ QString res;
+ int l = len;
+ const unsigned short* s = str;
+ while ( len < 0 || res.length() < len )
+ {
+ if ( *s == '\0' )
+ break;
+
+ res.append( QChar( *s ) );
+ s++;
+ }
+ return res;
+}
+
/*!
Name: setTabOrder [static public]
Desc: Set tab order for specified list of widgets. Last parameter should be null pointer.
return;
QWidget* prev = 0;
- for ( QWidgetListIt it( widgets ); it.current(); ++it )
+ for ( QWidgetList::const_iterator it = widgets.begin(); it!= widgets.end(); ++it )
{
- QWidget* next = it.current();
+ QWidget* next = *it;
if ( prev && next )
QWidget::setTabOrder( prev, next );
prev = next;
if ( desk && y + srcHei + border > desk->height() )
y = desk->height() - srcHei - border;
- x = QMAX( x, 0 );
- y = QMAX( y, 0 );
+ x = qMax( x, 0 );
+ y = qMax( y, 0 );
src->move( x, y );
}
Name: simplifySeparators [static public]
Desc: Checks toolbar for unnecessary separators and removes them
*/
+/*
void Qtx::simplifySeparators( QToolBar* toolbar )
{
if ( !toolbar )
return;
- const QObjectList* objList = toolbar->children();
- if ( !objList )
- return;
+ const QObjectList& objList = toolbar->children();
QObjectList delList;
bool isPrevSep = true;
- for ( QObjectListIt it( *objList ); it.current(); ++it )
+ QObject* lastVis = 0; // last visible
+ for ( QObjectList::const_iterator it = objList.begin(); it != objList.end(); ++it )
{
- bool isSep = it.current()->isA( "QToolBarSeparator" );
+ QObject* obj = *it;
+ if ( !obj || !obj->isWidgetType() )
+ continue;
+ bool isSep = obj->inherits( "QToolBarSeparator" );
+ if ( !isSep && !((QWidget*)obj)->isVisibleTo( toolbar ) )
+ continue;
if ( isPrevSep && isSep )
- delList.append( it.current() );
- isPrevSep = isSep;
+ delList.append( obj );
+ else
+ {
+ isPrevSep = isSep;
+ lastVis = obj;
+ }
}
+ // remove last visible separator
+ if ( lastVis && lastVis->inherits( "QToolBarSeparator" ) )
+ delList.append( lastVis );
- for ( QObjectListIt itr( delList ); itr.current(); ++itr )
- delete itr.current();
-
- if ( toolbar->children() && !toolbar->children()->isEmpty() &&
- toolbar->children()->getFirst()->isA( "QToolBarSeparator" ) )
- delete toolbar->children()->getFirst();
-
- if ( toolbar->children() && !toolbar->children()->isEmpty() &&
- toolbar->children()->getLast()->isA( "QToolBarSeparator" ) )
- delete toolbar->children()->getLast();
+ for ( QObjectList::iterator itr = delList.begin(); itr != delList.end(); ++itr )
+ delete *itr;
}
+*/
/*!
Name: simplifySeparators [static public]
Desc: Checks popup menu recursively for unnecessary separators and removes them
*/
-void Qtx::simplifySeparators( QPopupMenu* popup, const bool recursive )
+void Qtx::simplifySeparators( QWidget* wid, const bool recursive )
{
- if ( !popup || !popup->count() )
+ if ( !wid )
+ return;
+
+ QList<QAction*> items = wid->actions();
+ if ( items.isEmpty() )
return;
- QIntList idRemove;
- for ( uint i = 1; i < popup->count(); i++ )
+ QList<QAction*> toRemove;
+ for ( uint i = 1; i < items.count(); i++ )
{
- if ( popup->findItem( popup->idAt( i ) )->isSeparator() &&
- popup->findItem( popup->idAt( i - 1 ) )->isSeparator() )
- idRemove.append( popup->idAt( i ) );
+ if ( items[i]->isSeparator() && items[i - 1]->isSeparator() )
+ toRemove.append( items[i] );
- if ( recursive )
- simplifySeparators( popup->findItem( popup->idAt( i ) )->popup() );
+ if ( recursive && items[i]->menu() )
+ simplifySeparators( items[i]->menu(), recursive );
}
- for ( QIntList::const_iterator it = idRemove.begin(); it != idRemove.end(); ++it )
- popup->removeItem( *it );
+ for ( QList<QAction*>::iterator it = toRemove.begin(); it != toRemove.end(); ++it )
+ wid->removeAction( *it );
- if ( popup->count() > 0 && popup->findItem( popup->idAt( 0 ) )->isSeparator() )
- popup->removeItem( popup->idAt( 0 ) );
+ items = wid->actions();
+ if ( !items.isEmpty() && items[0]->isSeparator() )
+ wid->removeAction( items[0] );
- if ( popup->count() > 0 && popup->findItem( popup->idAt( popup->count() - 1 ) )->isSeparator() )
- popup->removeItem( popup->idAt( popup->count() - 1 ) );
+ items = wid->actions();
+ if ( !items.isEmpty() && items[items.count() - 1]->isSeparator() )
+ wid->removeAction( items[items.count() - 1] );
}
/*!
*/
QString Qtx::dir( const QString& path, const bool abs )
{
- QString dirPath = QFileInfo( path ).dirPath( abs );
+ QDir aDir = QFileInfo( path ).dir();
+ QString dirPath = abs ? aDir.absolutePath() : aDir.path();
if ( dirPath == QString( "." ) )
dirPath = QString::null;
return dirPath;
Name: extension [static public]
Desc: Returns the file extension only or null string.
*/
-QString Qtx::extension( const QString& path )
+QString Qtx::extension( const QString& path, const bool full )
{
- return QFileInfo( path ).extension(false); // after the last dot
+ return full ? QFileInfo( path ).completeSuffix() : QFileInfo( path ).suffix();
}
/*!
QString libExt( "so" );
#endif
- if ( ext.lower() != QString( "so" ) && ext.lower() != QString( "dll" ) )
+ if ( ext.toLower() != QString( "so" ) && ext.toLower() != QString( "dll" ) )
{
if ( !name.isEmpty() && !ext.isEmpty() )
name += QString( "." );
*/
bool Qtx::mkDir( const QString& dirPath )
{
- QString path = QDir::convertSeparators( dirPath );
-
-#ifdef WIN32
- while ( !path.isEmpty() && path.at( path.length() - 1 ) == QDir::separator() )
- path.remove( path.length() - 1, 1 );
-
- if ( path.at( path.length() - 1 ) == ':' )
- return QFileInfo( path ).exists();
-#endif
-
- QFileInfo fInfo( path );
- if ( fInfo.exists() )
- return fInfo.isDir();
-
- if ( !mkDir( fInfo.dirPath() ) )
- return false;
-
- return QDir( fInfo.dirPath() ).mkdir( fInfo.fileName() );
+ return QDir().mkpath( dirPath );
}
/*!
else if ( fi.isDir() )
{
QDir aDir( thePath );
- const QFileInfoList* anEntries = aDir.entryInfoList();
- if ( anEntries )
+ QFileInfoList anEntries = aDir.entryInfoList();
+ for ( QFileInfoList::iterator it = anEntries.begin(); it != anEntries.end(); ++it )
{
- for ( QPtrListIterator<QFileInfo> it( *anEntries ); it.current(); ++it )
- {
- if ( it.current()->fileName() == "." || it.current()->fileName() == ".." )
+ QFileInfo inf = *it;
+ if ( inf.fileName() == "." || inf.fileName() == ".." )
continue;
- stat = stat && rmDir( it.current()->absFilePath() );
- }
+ stat = stat && rmDir( inf.absoluteFilePath() );
}
stat = stat && aDir.rmdir( thePath );
}
*/
bool Qtx::dos2unix( const QString& absName )
{
- FILE* src = ::fopen( absName, "rb" );
+ FILE* src = ::fopen( absName.toLatin1(), "rb" );
if ( !src )
return false;
/* we'll use temporary file */
char temp[512] = { '\0' };
QString dir = Qtx::dir( absName );
- FILE* tgt = ::fopen( strcpy( temp, ::tempnam( dir, "__x" ) ), "wb" );
+ FILE* tgt = ::fopen( strcpy( temp, ::tempnam( dir.toLatin1(), "__x" ) ), "wb" );
if ( !tgt )
return false;
Name: rgbSet [static public]
Desc: Unpack the specified integer RGB set into the color.
*/
-void Qtx::rgbSet( const int rgb, QColor& c )
+QColor Qtx::rgbSet( const int rgb )
{
int r, g, b;
rgbSet( rgb, r, g, b );
- c = QColor( r, g, b );
+ return QColor( r, g, b );
}
/*!
}
}
- return QColor( hue, 255, 255, QColor::Hsv );
+ return QColor::fromHsv( hue, 255, 255 );
}
/*!
Name: scaleColors [static public]
Desc: Returns the 'num' number of colors from blue to red.
*/
-void Qtx::scaleColors( const int num, QValueList<QColor>& lst )
+void Qtx::scaleColors( const int num, QList<QColor>& lst )
{
lst.clear();
for ( int i = 0; i < num; i++ )
QPixmap Qtx::grayscale( const QPixmap& pix )
{
QPixmap res;
- res.convertFromImage( grayscale( pix.convertToImage() ) );
+ res.fromImage( grayscale( pix.toImage() ) );
return res;
}
*/
QImage Qtx::transparentImage( const int w, const int h, const int d )
{
- QImage img;
- if ( img.create( w, h, d < 0 ? QPixmap::defaultDepth() : d ) )
+ QImage::Format fmt;
+ switch ( d )
+ {
+ case 1:
+ fmt = QImage::Format_Mono;
+ break;
+ case 8:
+ fmt = QImage::Format_Indexed8;
+ break;
+ case 16:
+ case 24:
+ case 32:
+ default:
+ fmt = QImage::Format_ARGB32;
+ break;
+ }
+
+ QImage img( w, h, fmt );
+ if ( !img.isNull() )
{
- img.setAlphaBuffer( true );
+// img.setAlphaBuffer( true );
for ( int i = 0; i < img.height(); i++ )
for ( int j = 0; j < img.width(); j++ )
img.setPixel( j, i, qRgba( 0, 0, 0, 0 ) );
QPixmap pix;
QImage img = transparentImage( w, h, d );
if ( !img.isNull() )
- pix.convertFromImage( img );
+ pix.fromImage( img );
return pix;
}
if ( pix.isNull() )
return dest;
- int width = QMAX( pix.width() + x, dest.width() );
- int height = QMAX( pix.height() + y, dest.height() );
+ int width = qMax( pix.width() + x, dest.width() );
+ int height = qMax( pix.height() + y, dest.height() );
QPixmap res( width, height );
QImage img = transparentImage( width, height, 32 );
QPainter p;
p.begin( &res );
- p.fillRect( 0, 0, width, height, QBrush( white ) );
+ p.fillRect( 0, 0, width, height, QBrush( Qt::white ) );
if ( !dest.isNull() )
{
p.drawPixmap( 0, 0, dest );
- QImage temp = dest.convertToImage();
+ QImage temp = dest.toImage();
for ( int i = 0; i < temp.width() && i < img.width(); i++ )
{
for ( int j = 0; j < temp.height() && j < img.height(); j++ )
{
- if ( temp.hasAlphaBuffer() )
+ if ( temp.hasAlphaChannel() )
img.setPixel( i, j, temp.pixel( i, j ) );
else
{
}
p.drawPixmap( x, y, pix );
- QImage temp = pix.convertToImage();
+ QImage temp = pix.toImage();
for ( int c = x; c < temp.width() + x && c < img.width(); c++ )
{
for ( int r = y; r < temp.height() + y && r < img.height(); r++ )
}
QBitmap bmp( width, height );
- bmp.convertFromImage( img, Qt::ColorMode_Mask | Qt::ThresholdDither );
+ bmp.fromImage( img, Qt::ColorMode_Mask | Qt::ThresholdDither );
res.setMask( bmp );
return res;
#define true 1
#endif
-#ifndef INCLUDE_MENUITEM_DEF
-#define INCLUDE_MENUITEM_DEF
-#endif
+#define QT_VER 4
-#include <qnamespace.h>
+#include <Qt/qnamespace.h>
-#ifndef QT_VERSION
-#define QT_VER 0
-#else
-#if QT_VERSION >= 0x30000
-#define QT_VER 3
-#else
-#if QT_VERSION >= 300
-#define QT_VER 3
-#else
-#if QT_VERSION >= 200
-#define QT_VER 2
-#else
-#if QT_VERSION >= 100
-#define QT_VER 1
-#endif
-#endif
-#endif
-#endif
-#endif
-
-#include <qimage.h>
-#include <qpixmap.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qpixmap.h>
+class QMenu;
class QObject;
class QString;
class QWidget;
class QToolBar;
-class QGroupBox;
-class QPopupMenu;
-class QWidgetList;
-template <class> class QValueList;
-
-#if QT_VER < 3
-#define QPtrList QList
-#define QPtrListIterator QListIterator
-#endif
+template <class> class QList;
-typedef QValueList<int> QIntList;
-typedef QValueList<short> QShortList;
-typedef QValueList<double> QDoubleList;
+typedef QList<int> QIntList;
+typedef QList<short> QShortList;
+typedef QList<double> QDoubleList;
/*!
\class Qtx
\brief Set of auxiliary static methods
*/
+
+#ifndef QT_MOC_RUN
+class QTX_EXPORT Qtx
+#else
class QTX_EXPORT Qtx : public Qt
+#endif
{
public:
enum AlignmentFlags
{
- AlignOutLeft = AlignVCenter << 2,
+ AlignLeft = Qt::AlignLeft,
+ AlignLeading = Qt::AlignLeading,
+ AlignRight = Qt::AlignRight,
+ AlignTrailing = Qt::AlignTrailing,
+ AlignHCenter = Qt::AlignHCenter,
+ AlignJustify = Qt::AlignJustify,
+ AlignAbsolute = Qt::AlignAbsolute,
+ AlignHorizontal_Mask = Qt::AlignHorizontal_Mask,
+
+ AlignTop = Qt::AlignTop,
+ AlignBottom = Qt::AlignBottom,
+ AlignVCenter = Qt::AlignVCenter,
+ AlignVertical_Mask = Qt::AlignVertical_Mask,
+
+ AlignCenter = Qt::AlignCenter,
+
+ AlignOutLeft = Qt::AlignVCenter << 2,
AlignOutRight = AlignOutLeft << 2,
AlignOutTop = AlignOutRight << 2,
AlignOutBottom = AlignOutTop << 2
};
+ static QString toQString( const char*, const int = -1 );
+ static QString toQString( const short*, const int = -1 );
+ static QString toQString( const unsigned char*, const int = -1 );
+ static QString toQString( const unsigned short*, const int = -1 );
+
static void setTabOrder( QWidget*, ... );
static void setTabOrder( const QWidgetList& );
static void alignWidget( QWidget*, const QWidget*, const int );
- static void simplifySeparators( QToolBar* );
- static void simplifySeparators( QPopupMenu*, const bool = true );
+// static void simplifySeparators( QToolBar* );
+ static void simplifySeparators( QWidget*, const bool = true );
static bool isParent( QObject*, QObject* );
- static QString extension( const QString& );
static QString dir( const QString&, const bool = true );
static QString file( const QString&, const bool = true );
+ static QString extension( const QString&, const bool = false );
static QString library( const QString& );
static int rgbSet( const QColor& );
static int rgbSet( const int, const int, const int );
- static void rgbSet( const int, QColor& );
+ static QColor rgbSet( const int );
static void rgbSet( const int, int&, int&, int& );
static QColor scaleColor( const int, const int, const int );
- static void scaleColors( const int, QValueList<QColor>& );
+ static void scaleColors( const int, QList<QColor>& );
static QImage grayscale( const QImage& );
static QPixmap grayscale( const QPixmap& );
#include "QtxAction.h"
-#include <qpopupmenu.h>
-#include <qmenubar.h>
+#include <QtGui/qmenu.h>
+#include <QtGui/qmenubar.h>
/*!
Name: QtxAction [public]
*/
QtxAction::QtxAction( QObject* parent, const char* name, bool toggle )
- : QAction( parent, name, toggle )
+: QAction( parent )
{
+ setCheckable( toggle );
}
/*!
be a command action.
*/
-QtxAction::QtxAction( const QString& text, const QIconSet& icon,
+QtxAction::QtxAction( const QString& text, const QIcon& icon,
const QString& menuText, int accel,
QObject* parent, const char* name, bool toggle )
- : QAction( text, icon, menuText, accel, parent, name, toggle )
+: QAction( icon, menuText, parent )
{
+ setToolTip( text );
+ setShortcut( accel );
+ setCheckable( toggle );
}
/*!
QtxAction::QtxAction( const QString& text, const QString& menuText, int accel,
QObject* parent, const char* name, bool toggle )
- : QAction( text, menuText, accel, parent, name, toggle )
+: QAction( menuText, parent )
{
+ setToolTip( text );
+ setShortcut( accel );
+ setCheckable( toggle );
}
/*!
bool QtxAction::addTo( QWidget* w )
{
- if ( w->inherits( "QMenuBar" ) ) {
- // --- Add action to the QMenuBar ---
- // n.b. currently for the actions inserted to the menu bar
- // the following properties are not supported:
- // * tooltips
- // * what's this info
- // * toggle mode
- QMenuBar* mb = (QMenuBar*)w;
- if ( myMenuIds.find( w ) != myMenuIds.end() )
- return false; // already added
- if ( name() == "qt_separator_action" ) // separator
- myMenuIds[ w ] = mb->insertSeparator();
- else if ( iconSet().isNull() ) // has no icon
- myMenuIds[ w ] = mb->insertItem( menuText(), this, SIGNAL( activated() ), accel() );
- else // has icon
- myMenuIds[ w ] = mb->insertItem( iconSet(), menuText(), this, SIGNAL( activated() ), accel() );
- mb->setItemEnabled( myMenuIds[ w ], isEnabled() );
- mb->setItemVisible( myMenuIds[ w ], isVisible() );
- return true;
- }
- return QAction::addTo( w );
+ if ( !w )
+ return false;
+
+ w->addAction( this );
+ return true;
}
/*!
bool QtxAction::addTo( QWidget* w, const int index )
{
- if ( !addTo( w ) )
+ if ( !w )
return false;
- if ( w->inherits( "QPopupMenu" ) ) {
- // --- Add action to the QPopupMenu ---
- QPopupMenu* popup = (QPopupMenu*)w;
- if ( index >= 0 && index < (int)popup->count() - 1 ) {
- int id = popup->idAt( popup->count() - 1 );
- if ( id != -1 ) {
- QMenuItem* item = popup->findItem( id );
- if ( item && item->isSeparator() ) {
- popup->removeItem( id );
- popup->insertSeparator( index );
- }
- else {
- QPopupMenu* p = item ? item->popup() : 0;
- int accel = popup->accel( id );
- bool isOn = popup->isItemEnabled( id );
- bool isVisible = popup->isItemVisible( id );
- bool isChecked = popup->isItemChecked( id );
- QString text = popup->text( id );
- QIconSet icon;
- if ( popup->iconSet( id ) )
- icon = *popup->iconSet( id );
- popup->removeItem( id );
- int pos;
- if ( icon.isNull() )
- if ( p )
- pos = popup->indexOf( popup->insertItem( text, p, id, index ) );
- else
- pos = popup->indexOf( popup->insertItem( text, id, index ) );
- else
- if ( p )
- pos = popup->indexOf( popup->insertItem( icon, text, p, id, index ) );
- else
- pos = popup->indexOf( popup->insertItem( icon, text, p, id, index ) );
- popup->setId( pos, id );
- popup->setAccel( accel, id );
- popup->setItemEnabled( id, isOn );
- popup->setItemVisible( id, isVisible );
- popup->setItemChecked( id, isChecked );
- if ( !whatsThis().isEmpty() )
- popup->setWhatsThis( id, whatsThis() );
- if ( !p )
- popup->connectItem( id, this, SLOT( internalActivation() ) );
- }
- }
- }
- }
- else if ( w->inherits( "QMenuBar" ) ) {
- // --- Add action to the QMenuBar ---
- QMenuBar* mb = (QMenuBar*)w;
- if ( index >= 0 && index < (int)mb->count() - 1 ) {
- int id = mb->idAt( mb->count() - 1 );
- if ( id != -1 ) {
- QMenuItem* item = mb->findItem( id );
- if ( item && item->isSeparator() ) {
- mb->removeItem( id );
- mb->insertSeparator( index );
- }
- else {
- QPopupMenu* p = item ? item->popup() : 0;
- int accel = mb->accel( id );
- bool isOn = mb->isItemEnabled( id );
- bool isVisible = mb->isItemVisible( id );
- QString text = mb->text( id );
- QIconSet icon;
- if ( mb->iconSet( id ) )
- icon = *mb->iconSet( id );
- mb->removeItem( id );
- int pos;
- if ( icon.isNull() )
- if ( p )
- pos = mb->indexOf( mb->insertItem( text, p, id, index ) );
- else
- pos = mb->indexOf( mb->insertItem( text, id, index ) );
- else
- if ( p )
- pos = mb->indexOf( mb->insertItem( icon, text, p, id, index ) );
- else
- pos = mb->indexOf( mb->insertItem( icon, text, p, id, index ) );
- mb->setId( pos, id );
- mb->setAccel( accel, id );
- mb->setItemEnabled( id, isOn );
- mb->setItemVisible( id, isVisible );
- if ( !p )
- mb->connectItem( id, this, SIGNAL( activated() ) );
- }
- }
- }
- }
+ QAction* b = 0;
+ if ( 0 <= index && index < w->actions().count() )
+ b = w->actions().at( index );
+
+ w->insertAction( b, this );
+
return true;
}
bool QtxAction::removeFrom( QWidget* w )
{
- // check if widget is QMenuBar
- if ( w->inherits( "QMenuBar" ) ) {
- QMenuBar* mb = (QMenuBar*)w;
- if ( myMenuIds.find( w ) == myMenuIds.end() )
- return false; // not yet added
- mb->removeItem( myMenuIds[ w ] );
- myMenuIds.remove( w );
- return true;
- }
- return QAction::removeFrom( w );
+ if ( !w )
+ return false;
+
+ w->removeAction( this );
+ return true;
}
/*!
Desc: Set or unset the sub popup menu for item with specified id in the given popup.
*/
-void QtxAction::setPopup( QWidget* w, const int id, QPopupMenu* subPopup ) const
+void QtxAction::setPopup( QWidget* w, const int id, QMenu* subPopup ) const
{
+/*
if ( !w )
return;
pmd->removeItem( id );
// add new item
- if ( w->inherits( "QPopupMenu" ) ) {
+ if ( w->inherits( "QPopupMenu" ) )
+ {
// --- QPopupMenu ---
QPopupMenu* popup = (QPopupMenu*)w;
if ( icon.isNull() )
pos = popup->indexOf( subPopup ? popup->insertItem( text, subPopup, id, pos ) :
- popup->insertItem( text, id, pos ) );
+ popup->insertItem( text, id, pos ) );
else
pos = popup->indexOf( subPopup ? popup->insertItem( icon, text, subPopup, id, pos ) :
- popup->insertItem( icon, text, id, pos ) );
+ popup->insertItem( icon, text, id, pos ) );
}
- else {
+ else
+ {
// --- QMenuBar ---
QMenuBar* mb = (QMenuBar*)w;
if ( icon.isNull() )
pos = mb->indexOf( subPopup ? mb->insertItem( text, subPopup, id, pos ) :
- mb->insertItem( text, id, pos ) );
+ mb->insertItem( text, id, pos ) );
else
pos = mb->indexOf( subPopup ? mb->insertItem( icon, text, subPopup, id, pos ) :
- mb->insertItem( icon, text, id, pos ) );
+ mb->insertItem( icon, text, id, pos ) );
}
// restore properties
// delete old popup
delete oldPopup;
+*/
}
-
#include "Qtx.h"
-#include <qaction.h>
-#include <qmap.h>
+#include <QtCore/qmap.h>
+#include <QtGui/qicon.h>
+#include <QtGui/qaction.h>
#ifdef WIN32
#pragma warning ( disable:4251 )
#endif
+class QMenu;
+
class QTX_EXPORT QtxAction : public QAction
{
Q_OBJECT
public:
QtxAction( QObject* = 0, const char* = 0, bool = false );
QtxAction( const QString&, const QString&, int, QObject*, const char* = 0, bool = false );
- QtxAction( const QString&, const QIconSet&, const QString&, int, QObject*, const char* = 0, bool = false );
+ QtxAction( const QString&, const QIcon&, const QString&, int, QObject*, const char* = 0, bool = false );
virtual ~QtxAction();
virtual bool addTo( QWidget* );
virtual bool addTo( QWidget*, const int );
+
virtual bool removeFrom( QWidget* );
protected:
- void setPopup( QWidget*, const int, QPopupMenu* ) const;
+ void setPopup( QWidget*, const int, QMenu* ) const;
private:
QMap<QWidget*,int> myMenuIds;
#include "QtxAction.h"
-#include <qwidget.h>
-#include <qmenubar.h>
-#include <qpopupmenu.h>
-#include <qwidgetlist.h>
-#include <qobjectlist.h>
-#include <qmainwindow.h>
-#include <qfile.h>
-#include <qdom.h>
-#include <qvaluelist.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qfile.h>
+
+#include <QtGui/qmenu.h>
+#include <QtGui/qwidget.h>
+#include <QtGui/qmenubar.h>
+#include <QtGui/qmainwindow.h>
+
+#include <QtXml/qdom.h>
// VSR: Uncomment this #define in order to allow dynamic menus support
// (emit signals when popup menu is pre-activated)
Level: Internal
*/
namespace {
- QValueList<int> prepareIds( const QWidget* w )
+/*
+ QList<int> prepareIds( const QWidget* w )
{
- QValueList<int> l;
+ QList<int> l;
const QMenuData* md = 0;
if ( w->inherits( "QMenuBar" ) )
md = ::qt_cast<QMenuBar*>( w );
else if ( w->inherits( "QPopupMenu" ) )
md = ::qt_cast<QPopupMenu*>( w );
- if ( md ) {
+ if ( md )
+ {
for ( uint i = 0; i < md->count(); i++ )
l.append( md->idAt( i ) );
}
printf( "%d: %d: %s\n", i, md->idAt( i ), md->text( md->idAt( i ) ).latin1() );
printf( "<<< end dump menu (%s) <<<\n", before ? "before" : "after" );
}
+*/
};
/*!
MenuAction( const QString&, const QString&, QObject*, const int = -1, const bool = false );
virtual ~MenuAction();
- virtual bool addTo( QWidget* );
-
- virtual bool removeFrom( QWidget* );
-
- QPopupMenu* popup() const;
-
private:
- int myId;
- QPopupMenu* myPopup;
- bool myEmptyEnabled;
- QMap<QWidget*,int> myIds;
+ int myId;
+ bool myEmptyEnabled;
};
-
/*!
Constructor for menu action
\param text - description text
\param id - integer identificator of action
\param allowEmpty - if it is true, it makes possible to add this action with empty popup to menu
*/
-
-QtxActionMenuMgr::MenuAction::MenuAction( const QString& text,
- const QString& menuText,
- QObject* parent,
- const int id,
- const bool allowEmpty )
+/*
+QtxActionMenuMgr::MenuAction::MenuAction( const QString& text, const QString& menuText,
+ QObject* parent, const int id, const bool allowEmpty )
: QtxAction( text, menuText, 0, parent ),
- myId( id ),
- myPopup( 0 ),
- myEmptyEnabled( allowEmpty )
+myId( id ),
+myPopup( 0 ),
+myEmptyEnabled( allowEmpty )
{
- myPopup = new QPopupMenu();
+ myPopup = new QMenu();
}
-
+*/
/*!
Destructor: deletes internal popup
*/
+/*
QtxActionMenuMgr::MenuAction::~MenuAction()
{
delete myPopup;
}
-
+*/
/*!
Adds action to widget, for example, to popup menu or menu bar
*/
+/*
bool QtxActionMenuMgr::MenuAction::addTo( QWidget* w )
{
if ( !w )
if ( !myPopup )
return false; // bad own popup menu
- if ( !myEmptyEnabled && !myPopup->count() )
+ if ( !myEmptyEnabled && !myPopup->actions().count() )
return false; // not allowed empty menu
- if ( w->inherits( "QPopupMenu" ) ) {
+ if ( w->inherits( "QPopupMenu" ) )
+ {
QValueList<int> l = prepareIds( w );
int idx;
- if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 ) {
+ if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 )
+ {
QPopupMenu* pm = (QPopupMenu*)w;
myIds[ w ] = pm->idAt( idx );
if ( myId != -1 )
- pm->setId( idx, myId );
+ pm->setId( idx, myId );
setPopup( pm, myId != -1 ? myId : myIds[ w ], myPopup );
}
}
- else if ( w->inherits( "QMenuBar" ) ) {
+ else if ( w->inherits( "QMenuBar" ) )
+ {
QValueList<int> l = prepareIds( w );
int idx;
- if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 ) {
+ if ( QtxAction::addTo( w ) && ( idx = getNewId( w, l, false ) ) != -1 )
+ {
QMenuBar* mb = (QMenuBar*)w;
myIds[ w ] = mb->idAt( idx );
if ( myId != -1 )
- mb->setId( idx, myId );
+ mb->setId( idx, myId );
setPopup( mb, myId != -1 ? myId : myIds[ w ], myPopup );
}
+
}
else
return false;
return true;
}
+*/
/*!
Removes action from widget, for example, from popup menu or menu bar
*/
+/*
bool QtxActionMenuMgr::MenuAction::removeFrom( QWidget* w )
{
if ( !w )
if ( myIds.find( w ) == myIds.end() )
return false; // not yet added
- if ( w->inherits( "QPopupMenu" ) ) {
- if ( myId != -1 ) {
+ if ( w->inherits( "QPopupMenu" ) )
+ {
+ if ( myId != -1 )
+ {
QPopupMenu* pm = (QPopupMenu*)w;
int idx = pm->indexOf( myId );
- if ( idx != -1 ) pm->setId( idx, myIds[ w ] );
+ if ( idx != -1 )
+ pm->setId( idx, myIds[ w ] );
}
myIds.remove( w );
return QtxAction::removeFrom( w );;
}
else if ( w->inherits( "QMenuBar" ) )
{
- if ( myId != -1 ) {
+ if ( myId != -1 )
+ {
QMenuBar* mb = (QMenuBar*)w;
int idx = mb->indexOf( myId );
- if ( idx != -1 ) mb->setId( idx, myIds[ w ] );
+ if ( idx != -1 )
+ mb->setId( idx, myIds[ w ] );
}
myIds.remove( w );
return QtxAction::removeFrom( w );
}
return false;
}
+*/
/*!
\return internal popup of action
*/
-QPopupMenu* QtxActionMenuMgr::MenuAction::popup() const
+/*
+QMenu* QtxActionMenuMgr::MenuAction::popup() const
{
return myPopup;
}
+*/
/*!
Class: QtxActionMenuMgr
*/
QtxActionMenuMgr::QtxActionMenuMgr( QMainWindow* p )
: QtxActionMgr( p ),
- myMenu( p ? p->menuBar() : 0 )
+myMenu( p ? p->menuBar() : 0 )
{
myRoot.id = -1;
myRoot.group = -1;
*/
QtxActionMenuMgr::QtxActionMenuMgr( QWidget* mw, QObject* p )
: QtxActionMgr( p ),
- myMenu( mw )
+myMenu( mw )
{
myRoot.id = -1;
myRoot.group = -1;
*/
QtxActionMenuMgr::~QtxActionMenuMgr()
{
- for ( NodeListIterator it( myRoot.children ); it.current() && myMenu; ++it )
+ for ( NodeList::iterator it = myRoot.children.begin(); it != myRoot.children.end() && myMenu; ++it )
{
- QAction* a = itemAction( it.current()->id );
+ QAction* a = itemAction( (*it)->id );
if ( !a )
- a = menuAction( it.current()->id );
+ a = menuAction( (*it)->id );
- if ( a )
- a->removeFrom( myMenu );
+// if ( a )
+// a->removeFrom( myMenu );
}
for ( MenuMap::Iterator itr = myMenus.begin(); itr != myMenus.end(); ++itr )
- delete itr.data();
+ delete itr.value();
}
/*!
*/
int QtxActionMenuMgr::insert( const int id, const QString& menus, const int group, const int idx )
{
- return insert( id, QStringList::split( "|", menus ), group, idx );
+ return insert( id, menus.split( "|", QString::SkipEmptyParts ), group, idx );
}
/*!
*/
int QtxActionMenuMgr::insert( QAction* a, const QString& menus, const int group, const int idx )
{
- return insert( a, QStringList::split( "|", menus ), group, idx );
+ return insert( a, menus.split( "|", QString::SkipEmptyParts ), group, idx );
}
/*!
pNode->children.append( node );
- updateMenu( pNode, false );
+ triggerUpdate( pNode->id, false );
+
return node->id;
}
MenuNode* eNode = id == -1 ? 0 : find( id );
int fid = -1;
- for ( NodeListIterator it( pNode->children ); it.current() && fid == -1; ++it )
+ for ( NodeList::iterator it = pNode->children.begin(); it != pNode->children.end() && fid == -1; ++it )
{
- if ( myMenus.contains( it.current()->id ) &&
- clearTitle( myMenus[it.current()->id]->menuText() ) == clearTitle( title ) )
- fid = it.current()->id;
+ if ( myMenus.contains( (*it)->id ) &&
+ clearTitle( myMenus[(*it)->id]->text() ) == clearTitle( title ) )
+ fid = (*it)->id;
}
if ( fid != -1 )
int gid = (id == -1 || eNode ) ? generateId() : id;
- MenuAction* ma = new MenuAction( clearTitle( title ), title, this, gid, allowEmpty );
+ QAction* ma = new QAction( title, this );
+ ma->setMenu( new QMenu( myMenu ) );
#ifdef ENABLE_DYNAMIC_MENU
- connect( ma->popup(), SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) );
+ connect( ma->menu(), SIGNAL( highlighted( int ) ), this, SLOT( onHighlighted( int ) ) );
#endif
MenuNode* node = new MenuNode( pNode );
pNode->children.append( node );
- updateMenu( pNode, false );
+ triggerUpdate( pNode->id, false );
return node->id;
}
*/
int QtxActionMenuMgr::insert( const QString& title, const QString& menus, const int group, const int id, const int idx, const bool allowEmpty )
{
- return insert( title, QStringList::split( "|", menus ), group, id, idx, allowEmpty );
+ return insert( title, menus.split( "|", QString::SkipEmptyParts ), group, id, idx, allowEmpty );
}
/*!
return;
NodeList delNodes;
- for ( NodeListIterator it( pNode->children ); it.current(); ++it )
+ for ( NodeList::iterator it = pNode->children.begin(); it != pNode->children.end(); ++it )
{
- if ( it.current()->id == id && ( it.current()->group == group || group == -1 ) )
- delNodes.append( it.current() );
+ if ( (*it)->id == id && ( (*it)->group == group || group == -1 ) )
+ delNodes.append( *it );
}
- for ( NodeListIterator itr( delNodes ); itr.current(); ++itr )
- pNode->children.remove( itr.current() );
+ for ( NodeList::iterator itr = delNodes.begin(); itr != delNodes.end(); ++itr )
+ pNode->children.removeAll( *itr );
- updateMenu( pNode, false );
+ triggerUpdate( pNode->id, false );
}
/*!
NodeList aNodes;
find( id, aNodes );
- QMap<MenuNode*, int> updMap;
- for ( NodeListIterator it( aNodes ); it.current(); ++it )
+ for ( NodeList::iterator it = aNodes.begin(); it != aNodes.end(); ++it )
{
- if ( it.current()->visible != on )
+ if ( (*it)->visible != on )
{
- it.current()->visible = on;
- updMap.insert( it.current()->parent, 0 );
+ (*it)->visible = on;
+ triggerUpdate( (*it)->parent ? (*it)->parent->id : myRoot.id, false );
}
}
+}
- for ( QMap<MenuNode*, int>::ConstIterator itr = updMap.begin(); itr != updMap.end(); ++itr )
- updateMenu( itr.key(), false );
+/*!
+ Changes the specified menu title
+*/
+void QtxActionMenuMgr::change( const int id, const QString& title )
+{
+ QAction* a = menuAction( id );
+ if ( a )
+ a->setText( title );
}
/*!
int pid = 0, realId;
if ( myMenu && snd == myMenu )
pid = -1;
- else {
- for ( MenuMap::Iterator itr = myMenus.begin(); itr != myMenus.end(); ++itr ) {
- if ( itr.data()->popup() && itr.data()->popup() == snd )
- pid = itr.key();
+ else
+ {
+ for ( MenuMap::Iterator itr = myMenus.begin(); itr != myMenus.end(); ++itr )
+ {
+ if ( itr.value()->menu() && itr.value()->menu() == snd )
+ pid = itr.key();
}
}
- if ( pid ) {
+ if ( pid )
+ {
realId = findId( id, pid );
- if ( realId != -1 ) {
- bool updatesEnabled = isUpdatesEnabled();
- setUpdatesEnabled( false );
+ if ( realId != -1 )
+ {
emit menuHighlighted( pid, realId );
- setUpdatesEnabled( updatesEnabled );
- updateMenu( find( realId ) );
+ triggerUpdate( realId );
}
}
}
{
MenuNode* node = 0;
MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot;
- for ( NodeListIterator it( start->children ); it.current() && !node; ++it )
+ for ( NodeList::iterator it = start->children.begin(); it != start->children.end() && !node; ++it )
{
- if ( it.current()->id == id )
- node = it.current();
+ if ( (*it)->id == id )
+ node = *it;
else if ( rec )
- node = find( id, it.current(), rec );
+ node = find( id, *it, rec );
}
return node;
}
bool QtxActionMenuMgr::find( const int id, NodeList& lst, MenuNode* startNode ) const
{
MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot;
- for ( NodeListIterator it( start->children ); it.current(); ++it )
+ for ( NodeList::iterator it = start->children.begin(); it != start->children.end(); ++it )
{
- if ( it.current()->id == id )
- lst.prepend( it.current() );
+ MenuNode* node = *it;
+ if ( node->id == id )
+ lst.prepend( node );
- find( id, lst, it.current() );
+ find( id, lst, node );
}
return !lst.isEmpty();
}
bool QtxActionMenuMgr::find( const QString& title, NodeList& lst, MenuNode* startNode ) const
{
MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot;
- for ( NodeListIterator it( start->children ); it.current(); ++it )
+ for ( NodeList::iterator it = start->children.begin(); it != start->children.end(); ++it )
{
- QAction* a = itemAction( it.current()->id );
+ QAction* a = itemAction( (*it)->id );
if ( !a )
- a = menuAction( it.current()->id );
- if ( a && clearTitle( a->menuText() ) == clearTitle( title ) )
- lst.prepend( it.current() );
+ a = menuAction( (*it)->id );
+ if ( a && clearTitle( a->text() ) == clearTitle( title ) )
+ lst.prepend( *it );
- find( title, lst, it.current() );
+ find( title, lst, *it );
}
return !lst.isEmpty();
}
{
MenuNode* node = 0;
MenuNode* start = startNode ? startNode : (MenuNode*)&myRoot;
- for ( NodeListIterator it( start->children ); it.current() && !node; ++it )
+ for ( NodeList::iterator it = start->children.begin(); it != start->children.end() && !node; ++it )
{
- QAction* a = itemAction( it.current()->id );
+ QAction* a = itemAction( (*it)->id );
if ( !a )
- a = menuAction( it.current()->id );
- if ( a && clearTitle( a->menuText() ) == clearTitle( title ) )
- node = it.current();
+ a = menuAction( (*it)->id );
+ if ( a && clearTitle( a->text() ) == clearTitle( title ) )
+ node = *it;
if ( !node && rec )
- node = find( title, it.current(), rec );
+ node = find( title, *it, rec );
}
return node;
}
int QtxActionMenuMgr::findId( const int id, const int pid ) const
{
MenuNode* start = pid != -1 ? find( pid ) : (MenuNode*)&myRoot;
- if ( start ) {
- for ( NodeListIterator it( start->children ); it.current(); ++it ) {
- if ( it.current()->id == id ) return id;
+ if ( start )
+ {
+ for ( NodeList::iterator it = start->children.begin(); it != start->children.end(); ++it )
+ {
+ if ( (*it)->id == id )
+ return id;
}
}
return -1;
void QtxActionMenuMgr::removeMenu( const int id, MenuNode* startNode )
{
MenuNode* start = startNode ? startNode : &myRoot;
- for ( NodeListIterator it( start->children ); it.current(); ++it )
+ for ( NodeList::iterator it = start->children.begin(); it != start->children.end(); ++it )
{
- if ( it.current()->id == id )
- start->children.remove( it.current() );
+ if ( (*it)->id == id )
+ start->children.removeAll( *it );
else
- removeMenu( id, it.current() );
+ removeMenu( id, *it );
}
}
\return menu action by id
\param id - id of action
*/
-QtxActionMenuMgr::MenuAction* QtxActionMenuMgr::menuAction( const int id ) const
+QAction* QtxActionMenuMgr::menuAction( const int id ) const
{
- MenuAction* a = 0;
+ QAction* a = 0;
if ( myMenus.contains( id ) )
a = myMenus[id];
bool filled = checkWidget( mw );
- for ( NodeListIterator it1( node->children ); it1.current(); ++it1 )
+ for ( NodeList::iterator it1 = node->children.begin(); it1 != node->children.end(); ++it1 )
{
- QAction* a = itemAction( it1.current()->id );
+ QAction* a = itemAction( (*it1)->id );
if ( !a )
- a = menuAction( it1.current()->id );
+ a = menuAction( (*it1)->id );
- if ( a )
- a->removeFrom( mw );
+ mw->removeAction( a );
+// if ( a )
+// a->removeFrom( mw );
}
- /* VSR: commented to allow direct creating of menus by calling insertItem() methods
- if ( mw->inherits( "QMenuBar" ) )
- ((QMenuBar*)mw)->clear();
- else if ( mw->inherits( "QPopupMenu" ) )
- ((QPopupMenu*)mw)->clear();
- */
+
QMap<int, NodeList> idMap;
- for ( NodeListIterator it2( node->children ); it2.current(); ++it2 )
+ for ( NodeList::iterator it2 = node->children.begin(); it2 != node->children.end(); ++it2 )
{
- NodeList& lst = idMap[it2.current()->group];
- int idx = it2.current()->idx;
+ NodeList& lst = idMap[(*it2)->group];
+ int idx = (*it2)->idx;
if ( idx < 0 || idx >= (int)lst.count() )
- lst.append( it2.current() );
+ lst.append( *it2 );
else
- lst.insert( idx, it2.current() );
+ lst.insert( idx, *it2 );
}
QIntList groups = idMap.keys();
- qHeapSort( groups );
+ qSort( groups );
- groups.remove( -1 );
+ groups.removeAll( -1 );
groups.append( -1 );
for ( QIntList::const_iterator gIt = groups.begin(); gIt != groups.end(); ++gIt )
continue;
const NodeList& lst = idMap[*gIt];
- for ( NodeListIterator iter( lst ); iter.current(); ++iter )
+ for ( NodeList::const_iterator iter = lst.begin(); iter != lst.end(); ++iter )
{
- MenuNode* par = iter.current()->parent;
- if ( !isVisible( iter.current()->id, par ? par->id : -1 ) )
- continue;
+ MenuNode* node = *iter;
if ( rec )
- updateMenu( iter.current(), rec, false );
+ updateMenu( node, rec, false );
+
+ MenuNode* par = node->parent;
+ if ( !isVisible( node->id, par ? par->id : -1 ) )
+ continue;
- QAction* a = itemAction( iter.current()->id );
+ QAction* a = itemAction( node->id );
if ( !a )
- a = menuAction( iter.current()->id );
- if ( a )
- a->addTo( mw );
+ a = menuAction( node->id );
+
+ if ( !a->menu() || !a->menu()->isEmpty() )
+ mw->addAction( a );
}
}
*/
void QtxActionMenuMgr::internalUpdate()
{
- if ( isUpdatesEnabled() )
- updateMenu();
+ if ( !isUpdatesEnabled() )
+ return;
+
+ updateMenu();
+ myUpdateIds.clear();
}
/*!
if ( !wid )
return false;
- QMenuData* md = 0;
- if ( wid->inherits( "QPopupMenu" ) )
- md = (QPopupMenu*)wid;
- else if ( wid->inherits( "QMenuBar" ) )
- md = (QMenuBar*)wid;
-
- return md ? md->count() : false;
+ return !wid->actions().isEmpty();
}
/*!
if ( !myMenus.contains( node->id ) || !myMenus[node->id] )
return 0;
- return myMenus[node->id]->popup();
+ return myMenus[node->id]->menu();
}
/*!
*/
void QtxActionMenuMgr::simplifySeparators( QWidget* wid )
{
- if ( wid && wid->inherits( "QPopupMenu" ) )
- Qtx::simplifySeparators( (QPopupMenu*)wid, false );
+ Qtx::simplifySeparators( wid, false );
}
/*!
QStringList sl( lst );
- QString title = sl.last().stripWhiteSpace();
- sl.remove( sl.fromLast() );
+ QString title = sl.last().trimmed();
+ sl.removeLast();
int parentId = sl.isEmpty() ? pId : createMenu( sl, pId );
return (bool)find( id, pid, false );
}
+/*!
+ \Sets trigger for delayed update
+*/
+void QtxActionMenuMgr::triggerUpdate( const int id, const bool rec )
+{
+ bool isRec = rec;
+ if ( myUpdateIds.contains( id ) )
+ isRec = isRec || myUpdateIds[ id ];
+ myUpdateIds.insert( id, isRec );
+
+ QtxActionMgr::triggerUpdate();
+}
+
+/*!
+ \Sets trigger for delayed update
+*/
+void QtxActionMenuMgr::updateContent()
+{
+ // Warning: For correct updating it is necessary to update the most enclosed submenu firstly
+ // because not updated empty submenu will be skipped. Now the submenu are iterated in
+ // ascending order their identifiers. For a submenu with automatically generated identifiers
+ // will work correctly as the uppermost submenu have the biggest number (identifiers generated
+ // reduction from -1). Generally when any submenu will have positive identifiers are obviously
+ // appropriated can to work not truly. In this case it is required to improve the given method
+ // and to add preliminary sorting a submenu on depth of an enclosure.
+ for ( QMap<int, bool>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
+ {
+ MenuNode* node = it.key() == -1 ? &myRoot : find( it.key() );
+ if ( node )
+ updateMenu( node, it.value() );
+ }
+ myUpdateIds.clear();
+}
/*!
Constructor
\param r - menu reader
\param mgr - menu manager
*/
-QtxActionMenuMgr::MenuCreator::MenuCreator( QtxActionMgr::Reader* r,
- QtxActionMenuMgr* mgr )
+QtxActionMenuMgr::MenuCreator::MenuCreator( QtxActionMgr::Reader* r, QtxActionMenuMgr* mgr )
: QtxActionMgr::Creator( r ),
- myMgr( mgr )
+myMgr( mgr )
{
}
res = myMgr->insert( separator(), pId, intValue( attr, group, 0 ), intValue( attr, pos, -1 ) );
else
{
- QPixmap pix; QIconSet set;
+ QIcon set;
+ QPixmap pix;
QString name = strValue( attr, icon );
if( !name.isEmpty() && loadPixmap( name, pix ) )
- set = QIconSet( pix );
+ set = QIcon( pix );
QtxAction* newAct = new QtxAction( strValue( attr, tooltip ), set,
strValue( attr, label ),
myMgr );
newAct->setToolTip( strValue( attr, tooltip ) );
QString toggleact = strValue( attr, toggle );
- newAct->setToggleAction( !toggleact.isEmpty() );
- newAct->setOn( toggleact.lower()=="true" );
+ newAct->setCheckable( !toggleact.isEmpty() );
+ newAct->setChecked( toggleact.toLower() == "true" );
connect( newAct );
int aid = myMgr->registerAction( newAct, actId );
#include "Qtx.h"
#include "QtxActionMgr.h"
-#include <qptrlist.h>
-#include <qstringlist.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qstringlist.h>
class QPopupMenu;
class QMainWindow;
class MenuNode;
- typedef QPtrList<MenuNode> NodeList;
- typedef QPtrListIterator<MenuNode> NodeListIterator;
+ typedef QList<MenuNode*> NodeList;
/*!
\class MenuNode
class MenuNode
{
public:
- MenuNode() : parent( 0 ), visible( true ) { children.setAutoDelete( true ); };
- MenuNode( MenuNode* p ) : parent( p ), visible( true ) { children.setAutoDelete( true ); };
+ MenuNode() : parent( 0 ), visible( true ) {};
+ MenuNode( MenuNode* p ) : parent( p ), visible( true ) {};
+ ~MenuNode()
+ {
+ for ( NodeList::iterator it = children.begin(); it != children.end(); ++it )
+ delete *it;
+ }
int id;
int idx;
bool isShown( const int ) const;
void setShown( const int, const bool );
+ virtual void change( const int, const QString& );
+
virtual bool load( const QString&, QtxActionMgr::Reader& );
bool containsMenu( const QString&, const int ) const;
void removeMenu( const int, MenuNode* );
QAction* itemAction( const int ) const;
- MenuAction* menuAction( const int ) const;
+ QAction* menuAction( const int ) const;
void updateMenu( MenuNode* = 0, const bool = true, const bool = true );
virtual void internalUpdate();
+ virtual void updateContent();
private:
bool checkWidget( QWidget* ) const;
QString clearTitle( const QString& ) const;
int createMenu( const QStringList&, const int );
+ void triggerUpdate( const int, const bool rec = true );
+
private:
- typedef QMap<int, MenuAction*> MenuMap;
+ typedef QMap<int, QAction*> MenuMap;
private:
MenuNode myRoot;
QWidget* myMenu;
MenuMap myMenus;
+ QMap<int, bool> myUpdateIds;
};
/*!
#include "QtxActionMgr.h"
#include "QtxAction.h"
-#include <qwidget.h>
-#include <qtoolbar.h>
-#include <qpopupmenu.h>
-#include <qwidgetlist.h>
-#include <qobjectlist.h>
-#include <qfile.h>
-#include <qdom.h>
+#include <QtCore/qfile.h>
+#include <QtCore/qtimer.h>
-static QAction* qtx_separator_action = 0;
+#include <QtGui/qmenu.h>
+#include <QtGui/qwidget.h>
+#include <QtGui/qtoolbar.h>
+#include <QtGui/qapplication.h>
+
+#include <QtXml/qdom.h>
+
+typedef QList< QPointer<QAction> > qtx_actionlist;
+static qtx_actionlist qtx_separator_actions;
void qtxSeparatorActionCleanup()
{
- delete qtx_separator_action;
- qtx_separator_action = 0;
+ for ( qtx_actionlist::iterator it = qtx_separator_actions.begin(); it != qtx_separator_actions.end(); ++it )
+ delete *it;
}
/*!
public:
SeparatorAction( QObject* = 0 );
virtual ~SeparatorAction();
-
- virtual bool addTo( QWidget* );
- virtual bool removeFrom( QWidget* );
-
-private:
- QMap<QPopupMenu*, QIntList> myMenus;
- QMap<QToolBar*, QWidgetList> myTools;
};
/*!
QtxActionMgr::SeparatorAction::SeparatorAction( QObject* parent )
: QtxAction( parent )
{
+ setSeparator( true );
}
/*!
{
}
-/*!
- Adds action to widget
- \param wid - widget
-*/
-bool QtxActionMgr::SeparatorAction::addTo( QWidget* wid )
-{
- if ( !wid )
- return false;
-
- bool res = true;
- if ( wid->inherits( "QPopupMenu" ) )
- {
- QPopupMenu* popup = (QPopupMenu*)wid;
- myMenus[popup].append( popup->insertSeparator() );
- }
- else if ( wid->inherits( "QToolBar" ) )
- {
- QToolBar* tb = (QToolBar*)wid;
- tb->addSeparator();
- myTools[tb].append( (QWidget*)tb->children()->getLast() );
- }
- else
- res = false;
-
- return res;
-}
-
-/*!
- Removes action from widget
- \param wid - widget
-*/
-bool QtxActionMgr::SeparatorAction::removeFrom( QWidget* wid )
-{
- if ( !wid )
- return false;
-
- bool res = true;
- if ( wid->inherits( "QPopupMenu" ) )
- {
- QPopupMenu* popup = (QPopupMenu*)wid;
- if ( myMenus.contains( popup ) )
- {
- const QIntList& list = myMenus[popup];
- for ( QIntList::const_iterator it = list.begin(); it != list.end(); ++it )
- popup->removeItem( *it );
-
- myMenus.remove( popup );
- }
- }
- else if ( wid->inherits( "QToolBar" ) )
- {
- QToolBar* tb = (QToolBar*)wid;
- if ( myTools.contains( tb ) )
- {
- QMap<QObject*, int> childMap;
- if ( tb->children() )
- {
- for ( QObjectListIt it( *tb->children() ); it.current(); ++it )
- childMap.insert( it.current(), 0 );
- }
- const QWidgetList& list = myTools[tb];
- for ( QWidgetListIt it( list ); it.current(); ++it )
- {
- if ( childMap.contains( it.current() ) )
- delete it.current();
- }
-
- myTools.remove( tb );
- }
- }
- else
- res = false;
-
- return res;
-}
-
/*!
Class: QtxActionMgr
Level: Public
*/
QtxActionMgr::QtxActionMgr( QObject* parent )
: QObject( parent ),
-myUpdate( true )
+myUpdate( true ),
+myUpdTimer( 0 )
{
}
int theId = -1;
for ( ActionMap::ConstIterator it = myActions.begin(); it != myActions.end() && theId == -1; ++it )
{
- if ( it.data() == a )
+ if ( it.value() == a )
theId = it.key();
}
*/
void QtxActionMgr::update()
{
- if ( isUpdatesEnabled() )
- internalUpdate();
+ if ( !isUpdatesEnabled() )
+ return;
+
+ internalUpdate();
+ if ( myUpdTimer )
+ myUpdTimer->stop();
}
/*!
if ( individual )
return new SeparatorAction();
- if ( !qtx_separator_action )
- {
- qtx_separator_action = new SeparatorAction();
+ if ( qtx_separator_actions.isEmpty() )
qAddPostRoutine( qtxSeparatorActionCleanup );
+
+ SeparatorAction* a = new SeparatorAction();
+ qtx_separator_actions.append( a );
+
+ return a;
+}
+
+/*!
+ \initialise timer for delayed update
+*/
+void QtxActionMgr::triggerUpdate()
+{
+ if ( !isUpdatesEnabled() )
+ return;
+
+ if ( !myUpdTimer )
+ {
+ myUpdTimer = new QTimer( this );
+ myUpdTimer->setSingleShot( true );
+ connect( myUpdTimer, SIGNAL( timeout() ), this, SLOT( onUpdateContent() ) );
}
- return qtx_separator_action;
+ myUpdTimer->stop();
+ // add timer event to event list
+ myUpdTimer->start( 0 );
+}
+
+/*!
+ \perform delayed update
+ \default implementation is empty
+*/
+void QtxActionMgr::updateContent()
+{}
+
+/*!
+ \perform delayed update
+ \default implementation is empty
+*/
+void QtxActionMgr::onUpdateContent()
+{
+ updateContent();
}
/*!
/*!
- Constructor
+ Class: QtxActionMgr::XMLReader
+ Level: Public
*/
QtxActionMgr::XMLReader::XMLReader( const QString& root,
const QString& item,
#ifndef QT_NO_DOM
QFile file( fname );
- if ( !file.open( IO_ReadOnly ) )
+ if ( !file.open( QFile::ReadOnly ) )
return res;
QDomDocument doc;
if( parent_node.isNull() )
return;
- QStringList items = QStringList::split( "|", option( QString( "menu_item" ) ) );
+ QStringList items = option( "menu_item" ).split( "|", QString::SkipEmptyParts );
const QDomNodeList& children = parent_node.childNodes();
for( int i=0, n=children.count(); i<n; i++ )
}
+/*!
+ Class: QtxActionMgr::Creator
+ Level: Public
+*/
+
/*!
\return integer value by attributes
\param attrs - attributes
if( !reader() )
return false;
- QStringList dirlist = QStringList::split( ";", reader()->option( "icons_dir", "." ) );
+ QStringList dirlist = reader()->option( "icons_dir", "." ).split( ";", QString::SkipEmptyParts );
QStringList::const_iterator anIt = dirlist.begin(),
aLast = dirlist.end();
bool res = false;
#include "Qtx.h"
-#include <qmap.h>
-#include <qobject.h>
-#include <qguardedptr.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qpointer.h>
+class QTimer;
class QAction;
class QDomNode;
-
#ifdef WIN32
#pragma warning( disable:4251 )
#endif
virtual void internalUpdate();
int generateId() const;
+ //! initialise timer for delayed update
+ void triggerUpdate();
+ virtual void updateContent();
+
+private slots:
+ void onUpdateContent();
+
private:
- typedef QGuardedPtr<QAction> ActionPtr;
+ typedef QPointer<QAction> ActionPtr;
typedef QMap<int, ActionPtr> ActionMap;
private:
bool myUpdate;
ActionMap myActions;
+ QTimer* myUpdTimer;
};
#include "QtxAction.h"
#include "QtxToolBar.h"
-#include <qmainwindow.h>
-#include <qobjectlist.h>
+#include <QtGui/qmainwindow.h>
/*!
Constructor
int tbId = -1;
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && tbId == -1; ++it )
{
- if ( it.data().toolBar->label().lower() == name.lower() )
+ if ( it.value().toolBar->windowTitle().toLower() == name.toLower() )
tbId = it.key();
}
if ( !tb )
{
tb = new QtxToolBar( true, mainWindow() );
- tb->setLabel( name );
+ mainWindow()->addToolBar( tb );
+ tb->setWindowTitle( name );
}
tInfo.toolBar = tb;
if ( !mw )
return 0;
- QString pattern = label.lower();
+ QString pattern = label.toLower();
QToolBar* res = 0;
- QPtrList<QDockWindow> lst = mw->dockWindows();
- for ( QPtrListIterator<QDockWindow> it( lst ); it.current() && !res; ++it )
+ QList<QToolBar*> toolbars = qFindChildren<QToolBar*>( mw );
+ for ( QList<QToolBar*>::iterator it = toolbars.begin(); it != toolbars.end() && !res; ++it )
{
- if ( !it.current()->inherits( "QToolBar" ) )
- continue;
-
- QToolBar* cur = (QToolBar*)it.current();
- if ( cur->label().lower() == pattern )
- res = cur;
+ if ( (*it)->windowTitle().toLower() == pattern )
+ res = *it;
}
return res;
}
{
if ( !contains( id ) || !hasToolBar( tid ) )
return -1;
-
+/*
if ( containsAction( id, tid ) )
remove( id, tid );
-
+*/
ToolNode node;
node.id = id;
NodeList& list = myToolBars[tid].nodes;
- int index = idx < 0 ? list.count() : QMIN( idx, (int)list.count() );
- list.insert( list.at( index ), node );
- updateToolBar( tid );
+ int index = idx < 0 ? list.count() : qMin( idx, (int)list.count() );
+ list.insert( index, node );
+ triggerUpdate( tid );
return id;
}
myToolBars[tid].nodes = newList;
- updateToolBar( tid );
+ triggerUpdate( tid );
}
/*!
{
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end(); ++it )
{
- if ( tid == -1 || it.key() == tid ) {
- const NodeList& list = it.data().nodes;
+ if ( tid == -1 || it.key() == tid )
+ {
+ const NodeList& list = it.value().nodes;
for ( NodeList::const_iterator nit = list.begin(); nit != list.end(); ++nit )
if ( (*nit).id == id )
return true;
int id = -1;
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && id == -1; ++it )
{
- if ( it.data().toolBar->label() == tname )
+ if ( it.value().toolBar->windowTitle() == tname )
id = it.key();
}
return id;
int id = -1;
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end() && id == -1; ++it )
{
- if ( it.data().toolBar == t )
+ if ( it.value().toolBar == t )
id = it.key();
}
return id;
for ( NodeList::const_iterator it = list.begin(); it != list.end(); ++it )
{
QAction* a = action( (*it).id );
- if ( a )
- a->removeFrom( tb );
+ tb->removeAction( a );
+// if ( a )
+// a->removeFrom( tb );
}
tb->clear();
continue;
QAction* a = action( (*itr).id );
- if ( a )
- a->addTo( tb );
+ tb->addAction( a );
+// if ( a )
+// a->addTo( tb );
}
simplifySeparators( tb );
*/
void QtxActionToolMgr::internalUpdate()
{
+ if ( !isUpdatesEnabled() )
+ return;
+
for ( ToolBarMap::ConstIterator it1 = myToolBars.begin(); it1 != myToolBars.end(); ++it1 )
updateToolBar( it1.key() );
+
+ myUpdateIds.clear();
}
/*!
*/
void QtxActionToolMgr::simplifySeparators( QToolBar* t )
{
- if ( t )
- Qtx::simplifySeparators( t );
+ Qtx::simplifySeparators( t );
}
/*!
*/
bool QtxActionToolMgr::isShown( const int id ) const
{
- QPtrList<ToolNode> nodes;
+ QList<const ToolNode*> nodes;
for ( ToolBarMap::ConstIterator it = myToolBars.begin(); it != myToolBars.end(); ++it )
{
- const NodeList& nl = it.data().nodes;
+ const NodeList& nl = it.value().nodes;
for ( NodeList::const_iterator itr = nl.begin(); itr != nl.end(); ++itr )
{
const ToolNode& node = *itr;
return false;
bool vis = true;
- for ( QPtrListIterator<ToolNode> itr( nodes ); itr.current() && vis; ++itr )
- vis = itr.current()->visible;
+ for ( QList<const ToolNode*>::iterator itr = nodes.begin(); itr != nodes.end() && vis; ++itr )
+ vis = (*itr)->visible;
return vis;
}
}
if ( changed )
- updateToolBar( tId );
+ triggerUpdate( tId );
}
/*!
return r.read( fname, cr );
}
+/*!
+ \Perform delayed update
+*/
+void QtxActionToolMgr::updateContent()
+{
+ if ( !isUpdatesEnabled() )
+ return;
+
+ for ( QMap<int,int>::const_iterator it = myUpdateIds.constBegin(); it != myUpdateIds.constEnd(); ++it )
+ updateToolBar( it.key() );
+ myUpdateIds.clear();
+}
/*!
- Constructor
+ \ Sets trigger to update
+*/
+void QtxActionToolMgr::triggerUpdate( const int id )
+{
+ myUpdateIds.insert( id, 0 );
+ QtxActionMgr::triggerUpdate();
+}
+
+/*!
+ Class: QtxActionToolMgr::ToolCreator
+ Level: Public
*/
QtxActionToolMgr::ToolCreator::ToolCreator( QtxActionMgr::Reader* r,
QtxActionToolMgr* mgr )
res = myMgr->insert( separator(), tId, intValue( attr, pos, -1 ) );
else
{
- QPixmap pix; QIconSet set;
+ QIcon set;
+ QPixmap pix;
QString name = strValue( attr, icon );
if( !name.isEmpty() && loadPixmap( name, pix ) )
- set = QIconSet( pix );
+ set = QIcon( pix );
- QtxAction* newAct = new QtxAction( strValue( attr, tooltip ), set,
- strValue( attr, label ),
- QKeySequence( strValue( attr, accel ) ),
- myMgr );
+ QtxAction* newAct = new QtxAction( strValue( attr, tooltip ), set, strValue( attr, label ),
+ QKeySequence( strValue( attr, accel ) ), myMgr );
QString toggleact = strValue( attr, toggle );
- newAct->setToggleAction( !toggleact.isEmpty() );
- newAct->setOn( toggleact.lower()=="true" );
+ newAct->setCheckable( !toggleact.isEmpty() );
+ newAct->setChecked( toggleact.toLower() == "true" );
connect( newAct );
int aid = myMgr->registerAction( newAct, actId );
return res;
}
-
-
#include "Qtx.h"
-#include <qaction.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qlist.h>
+
+#include <QtGui/qaction.h>
#include "QtxActionMgr.h"
bool visible;
};
- typedef QValueList<ToolNode> NodeList;
+ typedef QList<ToolNode> NodeList;
protected:
class ToolCreator;
virtual void internalUpdate();
void updateToolBar( const int );
+ virtual void updateContent();
+
private:
void simplifySeparators( QToolBar* );
+ void triggerUpdate( const int );
private:
typedef struct { NodeList nodes; QToolBar* toolBar; } ToolBarInfo;
private:
ToolBarMap myToolBars;
QMainWindow* myMainWindow;
+ QMap<int,int> myUpdateIds;
};
/*!
#include "QtxColorScale.h"
-#include <qmap.h>
-#include <qimage.h>
-#include <qregexp.h>
-#include <qpixmap.h>
-#include <qbitmap.h>
-#include <qpainter.h>
-#include <qmainwindow.h>
-#include <qstringlist.h>
-#include <qstylesheet.h>
-#include <qsimplerichtext.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qregexp.h>
+#include <QtCore/qstringlist.h>
+
+#include <QtGui/qimage.h>
+#include <QtGui/qpixmap.h>
+#include <QtGui/qbitmap.h>
+#include <QtGui/qpainter.h>
+#include <QtGui/qtextdocument.h>
#include <math.h>
/*!
Constructor
*/
-QtxColorScale::QtxColorScale( QWidget* parent, const char* name, WFlags f )
-: QFrame( parent, name, f | WResizeNoErase | WRepaintNoErase ),
-myDock( 0 ),
+QtxColorScale::QtxColorScale( QWidget* parent, Qt::WindowFlags f )
+: QFrame( parent, f ),
myMin( 0.0 ),
myMax( 1.0 ),
myTitle( "" ),
myInterval( 10 ),
-myStyleSheet( 0 ),
myFormat( "%.4g" ),
myColorMode( Auto ),
myLabelMode( Auto ),
myDumpMode( NoDump ),
myFlags( AtBorder | WrapTitle )
{
- setCaption( tr ( "Color scale" ) );
+ setWindowTitle( tr ( "Color scale" ) );
}
/*!
Constructor
*/
-QtxColorScale::QtxColorScale( const int num, QWidget* parent, const char* name, WFlags f )
-: QFrame( parent, name, f | WResizeNoErase | WRepaintNoErase ),
-myDock( 0 ),
+QtxColorScale::QtxColorScale( const int num, QWidget* parent, Qt::WindowFlags f )
+: QFrame( parent, f ),
myMin( 0.0 ),
myMax( 1.0 ),
myTitle( "" ),
myInterval( num ),
-myStyleSheet( 0 ),
myFormat( "%.4g" ),
myColorMode( Auto ),
myLabelMode( Auto ),
myDumpMode( NoDump ),
myFlags( AtBorder | WrapTitle )
{
- setCaption( tr ( "Color scale" ) );
+ setWindowTitle( tr ( "Color scale" ) );
}
-#if QT_VER == 3
-
-/*!
- Constructor
-*/
-QtxColorScale::QtxColorScale( Dock* dock, const char* name, WFlags f )
-: QFrame( dock, name, f | WResizeNoErase | WRepaintNoErase ),
-myMin( 0.0 ),
-myMax( 1.0 ),
-myTitle( "" ),
-myDock( dock ),
-myInterval( 10 ),
-myStyleSheet( 0 ),
-myFormat( "%.4g" ),
-myColorMode( Auto ),
-myLabelMode( Auto ),
-myLabelPos( Right ),
-myTitlePos( Center ),
-myDumpMode( NoDump ),
-myFlags( AtBorder | WrapTitle )
-{
- setCaption( tr ( "Color scale" ) );
-}
-
-#endif
-
/*!
Destructor
*/
{
QString res;
if ( idx >= 0 && idx < (int)myLabels.count() )
- res = *myLabels.at( idx );
+ res = myLabels[idx];
return res;
}
{
QColor res;
if ( idx >= 0 && idx < (int)myColors.count() )
- res = *myColors.at( idx );
+ res = myColors[idx];
return res;
}
/*!
\return the user color.
*/
-void QtxColorScale::colors( QValueList<QColor>& list ) const
+void QtxColorScale::colors( QList<QColor>& list ) const
{
list = myColors;
}
uint i = idx < 0 ? myLabels.count() : idx;
if ( i < myLabels.count() )
{
- changed = *myLabels.at( i ) != txt;
+ changed = myLabels[i] != txt;
myLabels[i] = txt;
}
else
uint i = idx < 0 ? myColors.count() : idx;
if ( i < myColors.count() )
{
- changed = *myColors.at( i ) != clr;
+ changed = myColors[i] != clr;
myColors[i] = clr;
}
else
/*!
Replace the all user colors with specified list.
*/
-void QtxColorScale::setColors( const QValueList<QColor>& list )
+void QtxColorScale::setColors( const QList<QColor>& list )
{
if ( list.isEmpty() )
return;
QString fmt = that->myFormat;
for ( int idx = 0; idx < num; idx++ )
- textWidth = QMAX( textWidth, fontMetrics().width( getLabel( idx ) ) );
+ textWidth = qMax( textWidth, fontMetrics().width( getLabel( idx ) ) );
if ( !min )
that->myFormat = that->myFormat.replace( QRegExp( "g" ), "f" );
for ( int index = 0; index < num; index++ )
- textWidth = QMAX( textWidth, fontMetrics().width( getLabel( index ) ) );
+ textWidth = qMax( textWidth, fontMetrics().width( getLabel( index ) ) );
that->myFormat = fmt;
}
{
scaleWidth = colorWidth + textWidth + ( textWidth ? 3 : 2 ) * spacer;
if ( min )
- scaleHeight = QMAX( 2 * num, 3 * textHeight );
+ scaleHeight = qMax( 2 * num, 3 * textHeight );
else
scaleHeight = (int)( 1.5 * ( num + 1 ) * textHeight );
}
if ( title )
{
- QSimpleRichText* srt = simpleRichText( flags );
+ QTextDocument* srt = textDocument( flags );
if ( srt )
{
- QPainter p( this );
+ QPainter p( (QtxColorScale*)this );
if ( scaleWidth )
- srt->setWidth( &p, scaleWidth );
+ srt->setTextWidth( scaleWidth );
- titleHeight = srt->height() + spacer;
- titleWidth = srt->widthUsed() + 10;
+ titleHeight = srt->size().height() + spacer;
+ titleWidth = srt->size().width() + 10;
- delete srt;
}
+ delete srt;
}
- int W = QMAX( titleWidth, scaleWidth ) + width() - contentsRect().width();
+ int W = qMax( titleWidth, scaleWidth ) + width() - contentsRect().width();
int H = scaleHeight + titleHeight + height() - contentsRect().height();
return QSize( W, H );
labelPosition() != None;
bool title = ( myDumpMode == TitleDump || myDumpMode == FullDump ) &&
titlePosition() != None;
-
-#if QT_VER < 3
- QColor bgc = backgroundColor();
-#else
- QColor bgc = paletteBackgroundColor();
-#endif
+ QColor bgc = palette().color( backgroundRole() );
QPainter p;
p.begin( &aPix );
p.fillRect( 0, 0, aPix.width(), aPix.height(), bgc );
*/
QPixmap QtxColorScale::dump( const int w, const int h ) const
{
-#if QT_VER < 3
- return dump( backgroundColor(), w, h );
-#else
- return dump( paletteBackgroundColor(), w, h );
-#endif
+ return dump( palette().color( backgroundRole() ), w, h );
}
/*!
*/
void QtxColorScale::show()
{
-#if QT_VER == 3
- if ( myDock )
- myDock->activate();
- else
-#endif
QFrame::show();
}
*/
void QtxColorScale::hide()
{
-#if QT_VER == 3
- if ( myDock )
- myDock->deactivate();
- else
-#endif
QFrame::hide();
}
*/
void QtxColorScale::drawContents( QPainter* p )
{
- if ( !isUpdatesEnabled() )
+ if ( !updatesEnabled() )
return;
QRect aDrawRect = contentsRect();
QPixmap cache( W, H );
QPainter cp( &cache );
-#if QT_VER < 3
- drawScale( &cp, backgroundColor(), transp, 0, 0, W, H, title, label, scale );
-#else
- drawScale( &cp, paletteBackgroundColor(), transp, 0, 0, W, H, title, label, scale );
-#endif
+ drawScale( &cp, palette().color( backgroundRole() ), transp, 0, 0, W, H, title, label, scale );
cp.end();
p->drawPixmap( X, Y, cache );
if ( qGray( bg.rgb() ) < 128 )
p->setPen( QColor( 255, 255, 255 ) );
else
- p->setPen( QColor( 0, 0, 0 ) );
+ p->setPen( QColor( 0, 0, 0 ) );
// Draw title
if ( drawTitle )
{
- QSimpleRichText* srt = simpleRichText( myFlags );
+ QTextDocument* srt = textDocument( myFlags );
if ( srt )
{
- srt->setWidth( p, W - 10 );
- titleHeight = srt->height() + spacer;
- titleWidth = srt->widthUsed();
- QColorGroup cg = colorGroup();
- cg.setColor( QColorGroup::Text, p->pen().color() );
- srt->draw( p, X + 5, Y, QRect( 0, 0, srt->width(), srt->height() ), cg );
-
- delete srt;
+ srt->setTextWidth( W - 10 );
+ titleHeight = srt->size().height() + spacer;
+ titleWidth = srt->size().width();
+ p->save();
+ p->translate( X + 5, Y );
+ srt->drawContents( p );
+ p->restore();
}
+ delete srt;
}
bool reverse = testFlags( Reverse );
- QValueList<QColor> colors;
- QValueList<QString> labels;
+ QList<QColor> colors;
+ QList<QString> labels;
for ( int idx = 0; idx < num; idx++ )
{
if ( reverse )
else
labels.prepend( getLabel( num ) );
if ( drawLabel )
- textWidth = QMAX( textWidth, p->fontMetrics().width( labels.last() ) );
+ textWidth = qMax( textWidth, p->fontMetrics().width( labels.last() ) );
}
if ( drawLabel )
{
const QFontMetrics& fm = p->fontMetrics();
for ( QStringList::ConstIterator it = labels.begin(); it != labels.end(); ++it )
- textWidth = QMAX( textWidth, fm.width( *it) );
+ textWidth = qMax( textWidth, fm.width( *it) );
}
int lab = labels.count();
- double spc = ( H - ( ( QMIN( lab, 2 ) + QABS( lab - num - 1 ) ) * textHeight ) - titleHeight );
- double val = spc != 0 ? 1.0 * ( lab - QMIN( lab, 2 ) ) * textHeight / spc : 0;
+ double spc = ( H - ( ( qMin( lab, 2 ) + qAbs( lab - num - 1 ) ) * textHeight ) - titleHeight );
+ double val = spc != 0 ? 1.0 * ( lab - qMin( lab, 2 ) ) * textHeight / spc : 0;
double iPart;
double fPart = modf( val, &iPart );
int filter = (int)iPart + ( fPart != 0 ? 1 : 0 );
- filter = QMAX( filter, 1 );
+ filter = qMax( filter, 1 );
- double step = 1.0 * ( H - ( lab - num + QABS( lab - num - 1 ) ) * textHeight - titleHeight ) / num;
+ double step = 1.0 * ( H - ( lab - num + qAbs( lab - num - 1 ) ) * textHeight - titleHeight ) / num;
int ascent = p->fontMetrics().ascent();
- int colorWidth = QMAX( 5, QMIN( 20, W - textWidth - 3 * spacer ) );
+ int colorWidth = qMax( 5, qMin( 20, W - textWidth - 3 * spacer ) );
if ( labPos == Center || !drawLabel )
colorWidth = W - 2 * spacer;
break;
}
- double offset = 1.0 * textHeight / 2 * ( lab - num + QABS( lab - num - 1 ) ) + titleHeight;
- QValueList<QColor>::Iterator cit = colors.begin();
+ double offset = 1.0 * textHeight / 2 * ( lab - num + qAbs( lab - num - 1 ) ) + titleHeight;
+ QList<QColor>::Iterator cit = colors.begin();
uint ci = 0;
for ( ci = 0; cit != colors.end() && drawColors; ++cit, ci++ )
{
p->drawRect( int( x - 1 ), int( Y + offset - 1 ), int( colorWidth + 2 ), int( ci * step + 2 ) );
// Draw labels
- offset = 1.0 * QABS( lab - num - 1 ) * ( step - textHeight ) / 2 +
- 1.0 * QABS( lab - num - 1 ) * textHeight / 2;
+ offset = 1.0 * qAbs( lab - num - 1 ) * ( step - textHeight ) / 2 +
+ 1.0 * qAbs( lab - num - 1 ) * textHeight / 2;
offset += titleHeight;
if ( drawLabel && !labels.isEmpty() )
{
int pos2 = lab - 1 - i2;
if ( filter && !( pos1 % filter ) )
{
- p->drawText( x, (int)( Y + i1 * step + ascent + offset ), *labels.at( i1 ) );
+ p->drawText( x, (int)( Y + i1 * step + ascent + offset ), labels[i1] );
last1 = i1;
}
if ( filter && !( pos2 % filter ) )
{
- p->drawText( x, (int)( Y + i2 * step + ascent + offset ), *labels.at( i2 ) );
+ p->drawText( x, (int)( Y + i2 * step + ascent + offset ), labels[i2] );
last2 = i2;
}
i1++;
while ( pos <= i2 && i0 == -1 )
{
if ( filter && !( pos % filter ) &&
- QABS( pos - last1 ) >= filter && QABS( pos - last2 ) >= filter )
+ qAbs( pos - last1 ) >= filter && qAbs( pos - last2 ) >= filter )
i0 = pos;
pos++;
}
if ( i0 != -1 )
- p->drawText( x, (int)( Y + i0 * step + ascent + offset ), *labels.at( i0 ) );
+ p->drawText( x, (int)( Y + i0 * step + ascent + offset ), labels[i0] );
}
}
if ( !myPrecise.isEmpty() )
return myPrecise;
- if ( aFormat.find( QRegExp( "^(%[0-9]*.?[0-9]*[fegFEG])$" ) ) != 0 )
+ if ( !aFormat.contains( QRegExp( "^(%[0-9]*.?[0-9]*[fegFEG])$" ) ) )
return aFormat;
- int pos1 = aFormat.find( '.' );
- int pos2 = aFormat.find( QRegExp( "[fegFEG]") );
+ int pos1 = aFormat.indexOf( '.' );
+ int pos2 = aFormat.indexOf( QRegExp( "[fegFEG]") );
QString aLocFormat;
int precision = 1;
for ( int idx = 0; idx < intervalsNumber() && !isHasTwinz; idx++ )
{
double val = getNumber( idx );
- QString tmpname = QString().sprintf( aTmpFormat, val );
+ QString tmpname = QString().sprintf( aTmpFormat.toLatin1(), val );
isHasTwinz = map.contains( tmpname );
map.insert( tmpname, 1 );
}
{
double val = 0;
if ( intervalsNumber() > 0 )
- val = minimum() + idx * ( QABS( maximum() - minimum() ) / intervalsNumber() );
+ val = minimum() + idx * ( qAbs( maximum() - minimum() ) / intervalsNumber() );
return val;
}
else
{
double val = getNumber( idx );
- res = QString().sprintf( getFormat(), testFlags( Integer ) ? (int)val : val );
+ res = QString().sprintf( getFormat().toLatin1(), testFlags( Integer ) ? (int)val : val );
}
return res;
}
not defined (empty string) then return null pointer.
Object should be deleted by caller function.
*/
-QSimpleRichText* QtxColorScale::simpleRichText( const int flags ) const
+QTextDocument* QtxColorScale::textDocument( const int flags ) const
{
- QSimpleRichText* srt = 0;
+ QTextDocument* doc = 0;
QString aTitle;
switch ( titlePosition() )
if ( !aTitle.isEmpty() && !title().isEmpty() )
{
+ /*
if ( !myStyleSheet )
{
QtxColorScale* that = (QtxColorScale*)this;
item->setWhiteSpaceMode( flags & WrapTitle ? QStyleSheetItem::WhiteSpaceNormal :
QStyleSheetItem::WhiteSpaceNoWrap );
}
-
- aTitle = aTitle.arg( title() );
- srt = new QSimpleRichText( aTitle, font(), QString::null, myStyleSheet );
- }
-
- return srt;
-}
-
-#if QT_VER == 3
-
-/*!
- \class QtxColorScale::Dock
- Dockable window contains the color scale.
-*/
-
-/*!
- Constructor
-*/
-QtxColorScale::Dock::Dock( Place p, QWidget* parent, const char* name, WFlags f )
-: QDockWindow( p, parent, name, f ),
-myBlockShow( false ),
-myBlockResize( false )
-{
- myScale = new QtxColorScale( this );
-
- setWidget( myScale );
-
- setCloseMode( Always );
- setMovingEnabled( true );
- setResizeEnabled( true );
- setHorizontalStretchable( false );
-
- setCaption( tr ( "Color scale" ) );
-}
-
-/*!
- Destructor.
-*/
-QtxColorScale::Dock::~Dock()
-{
-}
-
-/*!
- \return color scale widget.
-*/
-QtxColorScale* QtxColorScale::Dock::colorScale() const
-{
- return myScale;
-}
-
-/*!
- Set the dockable window is visible for main window.
-*/
-void QtxColorScale::Dock::activate()
-{
- if ( myBlockShow )
- return;
-
- QMainWindow* mw = 0;
- QWidget* p = parentWidget();
- while ( !mw && p )
- {
- if ( p->inherits( "QMainWindow" ) )
- mw = (QMainWindow*)p;
- p = p->parentWidget();
- }
- if ( mw )
- mw->setAppropriate( this, true );
-}
-
-/*!
- Set the dockable window is hidden for main window.
*/
-void QtxColorScale::Dock::deactivate()
-{
- if ( myBlockShow )
- return;
-
- QMainWindow* mw = 0;
- QWidget* p = parentWidget();
- while ( !mw && p )
- {
- if ( p->inherits( "QMainWindow" ) )
- mw = (QMainWindow*)p;
- p = p->parentWidget();
+ aTitle = aTitle.arg( title() );
+ doc = new QTextDocument( aTitle );
}
- if ( mw )
- mw->setAppropriate( this, false );
-}
-/*!
- \return true if the dockable window is visible.
-*/
-bool QtxColorScale::Dock::isActive() const
-{
- QMainWindow* mw = 0;
- QWidget* p = parentWidget();
- while ( !mw && p )
- {
- if ( p->inherits( "QMainWindow" ) )
- mw = (QMainWindow*)p;
- p = p->parentWidget();
- }
- if ( mw )
- return mw->appropriate( (QDockWindow*)this );
- else
- return false;
+ return doc;
}
-
-/*!
- Redefined show
-*/
-void QtxColorScale::Dock::show()
-{
- bool f = myBlockShow;
- myBlockShow = true;
- QDockWindow::show();
- myBlockShow = f;
-}
-
-/*!
- Redefined hide
-*/
-void QtxColorScale::Dock::hide()
-{
- bool f = myBlockShow;
- myBlockShow = false;
- QDockWindow::hide();
- myBlockShow = f;
-}
-
-/*!
- Make extent width as maximum value of widget width.
-*/
-void QtxColorScale::Dock::resize( int w, int h )
-{
- QDockWindow::resize( w, h );
-
- if ( myBlockResize )
- return;
-
- if ( orientation() == Qt::Vertical )
- setFixedExtentWidth( QMAX( fixedExtent().width(), w ) );
- else if ( orientation() == Qt::Horizontal )
- setFixedExtentHeight( QMAX( fixedExtent().height(), h ) );
-}
-
-/*!
- Set orientation
- \param o - new orientation
-*/
-void QtxColorScale::Dock::setOrientation( Orientation o )
-{
- bool b = myBlockResize;
- myBlockResize = true;
- QDockWindow::setOrientation( o );
- myBlockResize = b;
-}
-
-#endif
#include "Qtx.h"
-#include <qframe.h>
-#include <qvaluelist.h>
+#include <QtGui/qframe.h>
+#include <QtCore/qlist.h>
-#if QT_VER == 3
-#include <qdockwindow.h>
-#endif
-
-class QStyleSheet;
-class QSimpleRichText;
+class QTextDocument;
#ifdef WIN32
#pragma warning( disable:4251 )
*/
class QTX_EXPORT QtxColorScale : public QFrame
{
- Q_OBJECT
+ Q_OBJECT
public:
- typedef enum { Auto, User } Mode;
- typedef enum { None, Left, Right, Center } Position;
- typedef enum { NoDump, TitleDump, ScaleDump, FullDump } DumpMode;
- typedef enum { AtBorder = 0x001, Reverse = 0x002, Integer = 0x004,
- WrapTitle = 0x008, PreciseFormat = 0x010, Transparent = 0x020 } Flags;
-
-#if QT_VER == 3
- class Dock : public QDockWindow
- {
- public:
- Dock( Place = InDock, QWidget* = 0, const char* = 0, WFlags = 0 );
- virtual ~Dock();
-
- QtxColorScale* colorScale() const;
-
- void activate();
- void deactivate();
-
- bool isActive() const;
-
- virtual void show();
- virtual void hide();
-
- virtual void resize( int, int );
- virtual void setOrientation( Orientation );
-
- private:
- QtxColorScale* myScale;
- bool myBlockShow;
- bool myBlockResize;
- };
-
-private:
- QtxColorScale( Dock*, const char* = 0, WFlags = 0 );
-#endif
+ typedef enum { Auto, User } Mode;
+ typedef enum { None, Left, Right, Center } Position;
+ typedef enum { NoDump, TitleDump, ScaleDump, FullDump } DumpMode;
+ typedef enum { AtBorder = 0x001, Reverse = 0x002, Integer = 0x004,
+ WrapTitle = 0x008, PreciseFormat = 0x010, Transparent = 0x020 } Flags;
public:
- QtxColorScale( QWidget* = 0, const char* = 0, WFlags = 0 );
- QtxColorScale( const int, QWidget* = 0, const char* = 0, WFlags = 0 );
- virtual ~QtxColorScale();
-
- double minimum() const;
- double maximum() const;
- void range( double&, double& ) const;
- int dumpMode() const;
- int labelMode() const;
- int colorMode() const;
- int intervalsNumber() const;
-
- QString title() const;
- QString format() const;
- QString label( const int ) const;
- QColor color( const int ) const;
- void labels( QStringList& ) const;
- void colors( QValueList<QColor>& ) const;
-
- int labelPosition() const;
- int titlePosition() const;
-
- void setMinimum( const double );
- void setMaximum( const double );
- void setRange( const double, const double );
- void setDumpMode( const int );
- void setColorMode( const int );
- void setLabelMode( const int );
- void setIntervalsNumber( const int );
-
- void setTitle( const QString& );
- void setFormat( const QString& );
- void setLabel( const QString&, const int = -1 );
- void setColor( const QColor&, const int = -1 );
- void setLabels( const QStringList& );
- void setColors( const QValueList<QColor>& );
-
- void setLabelPosition( const int );
- void setTitlePosition( const int );
-
- void setFlags( const int );
- bool testFlags( const int ) const;
- void clearFlags( const int );
-
- QPixmap dump() const;
- QPixmap dump( const int = -1, const int = -1 ) const;
- QPixmap dump( const QColor&, const int = -1, const int = -1 ) const;
-
- virtual QSize minimumSizeHint() const;
- virtual QSize sizeHint() const;
-
- virtual void show();
- virtual void hide();
+ QtxColorScale( QWidget* = 0, Qt::WindowFlags = 0 );
+ QtxColorScale( const int, QWidget* = 0, Qt::WindowFlags = 0 );
+ virtual ~QtxColorScale();
+
+ double minimum() const;
+ double maximum() const;
+ void range( double&, double& ) const;
+ int dumpMode() const;
+ int labelMode() const;
+ int colorMode() const;
+ int intervalsNumber() const;
+
+ QString title() const;
+ QString format() const;
+ QString label( const int ) const;
+ QColor color( const int ) const;
+ void labels( QStringList& ) const;
+ void colors( QList<QColor>& ) const;
+
+ int labelPosition() const;
+ int titlePosition() const;
+
+ void setMinimum( const double );
+ void setMaximum( const double );
+ void setRange( const double, const double );
+ void setDumpMode( const int );
+ void setColorMode( const int );
+ void setLabelMode( const int );
+ void setIntervalsNumber( const int );
+
+ void setTitle( const QString& );
+ void setFormat( const QString& );
+ void setLabel( const QString&, const int = -1 );
+ void setColor( const QColor&, const int = -1 );
+ void setLabels( const QStringList& );
+ void setColors( const QList<QColor>& );
+
+ void setLabelPosition( const int );
+ void setTitlePosition( const int );
+
+ void setFlags( const int );
+ bool testFlags( const int ) const;
+ void clearFlags( const int );
+
+ QPixmap dump() const;
+ QPixmap dump( const int = -1, const int = -1 ) const;
+ QPixmap dump( const QColor&, const int = -1, const int = -1 ) const;
+
+ virtual QSize minimumSizeHint() const;
+ virtual QSize sizeHint() const;
+
+ virtual void show();
+ virtual void hide();
protected:
- virtual void drawContents( QPainter* );
+ virtual void drawContents( QPainter* );
private:
- void updateScale();
- QString getFormat() const;
- QString getLabel( const int ) const;
- QColor getColor( const int ) const;
- double getNumber( const int ) const;
- QSimpleRichText* simpleRichText( const int ) const;
- void drawScale( QPainter*, const bool, const int, const int,
- const int, const int, const bool, const bool, const bool ) const;
- void drawScale( QPainter*, const QColor&, const bool,
- const int, const int, const int, const int,
- const bool, const bool, const bool ) const;
- QSize calculateSize( const bool, const int,
- const bool, const bool, const bool ) const;
-
-#if QT_VER == 3
- friend class QtxColorScale::Dock;
-#endif
+ void updateScale();
+ QString getFormat() const;
+ QString getLabel( const int ) const;
+ QColor getColor( const int ) const;
+ double getNumber( const int ) const;
+ QTextDocument* textDocument( const int ) const;
+ void drawScale( QPainter*, const bool, const int, const int,
+ const int, const int, const bool, const bool, const bool ) const;
+ void drawScale( QPainter*, const QColor&, const bool,
+ const int, const int, const int, const int,
+ const bool, const bool, const bool ) const;
+ QSize calculateSize( const bool, const int,
+ const bool, const bool, const bool ) const;
private:
- double myMin;
- double myMax;
- QString myTitle;
- QString myFormat;
- QString myPrecise;
- int myInterval;
- int myDumpMode;
- int myColorMode;
- int myLabelMode;
-
- QValueList<QColor> myColors;
- QValueList<QString> myLabels;
-
- Dock* myDock;
- int myFlags;
- int myLabelPos;
- int myTitlePos;
- QStyleSheet* myStyleSheet;
+ double myMin;
+ double myMax;
+ QString myTitle;
+ QString myFormat;
+ QString myPrecise;
+ int myInterval;
+ int myDumpMode;
+ int myColorMode;
+ int myLabelMode;
+
+ QList<QColor> myColors;
+ QList<QString> myLabels;
+
+ int myFlags;
+ int myLabelPos;
+ int myTitlePos;
};
#ifdef WIN32
#include "QtxComboBox.h"
-#include <qpixmap.h>
-#include <qlineedit.h>
-#include <qvaluelist.h>
+#include <QtCore/qlist.h>
+#include <QtGui/qpixmap.h>
+#include <QtGui/qlineedit.h>
/*!
Constructor
*/
-QtxComboBox::QtxComboBox( QWidget* parent, const char* name )
-: QComboBox( parent, name ),
-myCleared( false )
-{
- connect( this, SIGNAL( activated( int ) ), this, SLOT( onActivated( int ) ) );
- connect( this, SIGNAL( activated( const QString& ) ), this, SLOT( onActivated( const QString& ) ) );
-}
-
-/*!
- Constructor
-*/
-QtxComboBox::QtxComboBox( bool rw, QWidget* parent, const char* name )
-: QComboBox( rw, parent, name ),
+QtxComboBox::QtxComboBox( QWidget* parent )
+: QComboBox( parent ),
myCleared( false )
{
connect( this, SIGNAL( activated( int ) ), this, SLOT( onActivated( int ) ) );
*/
bool QtxComboBox::isCleared() const
{
- return myCleared;
+ return myCleared;
}
/*!
*/
void QtxComboBox::setCleared( const bool isClear )
{
- if ( myCleared == isClear )
- return;
+ if ( myCleared == isClear )
+ return;
- myCleared = isClear;
+ myCleared = isClear;
- if ( editable() )
- {
- if ( myCleared )
- lineEdit()->setText( "" );
- else
- lineEdit()->setText( text( currentItem() ) );
- }
+ if ( isEditable() )
+ {
+ if ( myCleared )
+ lineEdit()->setText( "" );
+ else
+ lineEdit()->setText( itemText( currentIndex() ) );
+ }
- update();
+ update();
}
/*!
Sets currently selected item
\param idx - index of item
*/
-void QtxComboBox::setCurrentItem( int idx )
+void QtxComboBox::setCurrentIndex( int idx )
{
- if ( idx < 0 || idx >= count() )
- return;
+ if ( idx < 0 || idx >= count() )
+ return;
- myCleared = false;
- QComboBox::setCurrentItem( idx );
-}
-
-/*!
- Sets current text
- \param txt - new current text
-*/
-void QtxComboBox::setCurrentText( const QString& txt )
-{
- myCleared = false;
-#if QT_VER < 3
- int i = -1;
- for ( int j = 0; j < count() && i == -1; j++ )
- if ( text( j ) == txt )
- i = j;
- if ( i >= 0 && i < count() )
- setCurrentItem( i );
- else if ( editable() )
- lineEdit()->setText( txt );
- else
- changeItem( txt, currentItem() );
-#else
- QComboBox::setCurrentText( txt );
-#endif
+ myCleared = false;
+ QComboBox::setCurrentIndex( idx );
}
/*!
*/
int QtxComboBox::currentId() const
{
- return id( currentItem() );
+ return id( currentIndex() );
}
/*!
*/
void QtxComboBox::setCurrentId( int num )
{
- setCurrentItem( index( num ) );
+ setCurrentIndex( index( num ) );
}
/*!
*/
void QtxComboBox::paintEvent( QPaintEvent* e )
{
- if ( !count() || !myCleared || editable() )
- QComboBox::paintEvent( e );
- else
- paintClear( e );
+ if ( !count() || !myCleared || isEditable() )
+ QComboBox::paintEvent( e );
+ else
+ paintClear( e );
}
/*!
*/
void QtxComboBox::onActivated( int idx )
{
- resetClear();
-
- if ( myIndexId.contains( idx ) )
- emit activatedId( myIndexId[idx] );
+ resetClear();
}
/*!
*/
void QtxComboBox::paintClear( QPaintEvent* e )
{
- int curIndex = currentItem();
- QString curText = text( curIndex );
-
- QPixmap curPix;
- if ( pixmap( curIndex ) )
- curPix = *pixmap( curIndex );
+ int curIndex = currentIndex();
+ QString curText = itemText( curIndex );
+ QIcon curIcon = itemIcon( curIndex );
- bool upd = isUpdatesEnabled();
- setUpdatesEnabled( false );
+ bool upd = updatesEnabled();
+ setUpdatesEnabled( false );
- changeItem( "", curIndex );
- QComboBox::paintEvent( e );
+ setItemIcon( curIndex, QIcon() );
+ setItemText( curIndex, QString::null );
+
+ QComboBox::paintEvent( e );
- if ( curPix.isNull() )
- changeItem( curText, curIndex );
- else
- changeItem( curPix, curText, curIndex );
+ setItemText( curIndex, curText );
+ setItemIcon( curIndex, curIcon );
- setUpdatesEnabled( upd );
+ setUpdatesEnabled( upd );
}
/*!
*/
int QtxComboBox::id( const int idx ) const
{
- int id = -1;
- if ( myIndexId.contains( idx ) )
- id = myIndexId[idx];
- return id;
+ int id = -1;
+ if ( myIndexId.contains( idx ) )
+ id = myIndexId[idx];
+ return id;
}
/*!
*/
int QtxComboBox::index( const int id ) const
{
- int idx = -1;
- for ( IndexIdMap::ConstIterator it = myIndexId.begin();
- it != myIndexId.end() && idx == -1; ++it )
- if ( it.data() == id )
- idx = it.key();
- return idx;
+ int idx = -1;
+ for ( IndexIdMap::ConstIterator it = myIndexId.begin(); it != myIndexId.end() && idx == -1; ++it )
+ {
+ if ( it.value() == id )
+ idx = it.key();
+ }
+ return idx;
}
#include "Qtx.h"
-#include <qmap.h>
-#include <qcombobox.h>
+#include <QtCore/qmap.h>
+#include <QtGui/qcombobox.h>
#ifdef WIN32
#pragma warning( disable:4251 )
class QTX_EXPORT QtxComboBox : public QComboBox
{
- Q_OBJECT
+ Q_OBJECT
- typedef QMap<int, int> IndexIdMap;
+ typedef QMap<int, int> IndexIdMap;
public:
- QtxComboBox( QWidget* = 0, const char* = 0 );
- QtxComboBox( bool, QWidget* = 0, const char* = 0 );
- virtual ~QtxComboBox();
+ QtxComboBox( QWidget* = 0 );
+ virtual ~QtxComboBox();
- bool isCleared() const;
- void setCleared( const bool );
+ bool isCleared() const;
+ void setCleared( const bool );
- virtual void setCurrentItem( int );
- virtual void setCurrentText( const QString& );
+ virtual void setCurrentIndex( int );
- int currentId() const;
- void setCurrentId( int );
+ int currentId() const;
+ void setCurrentId( int );
-signals:
- void activatedId( int );
- void highlightedId( int );
+Q_SIGNALS:
+ void activatedId( int );
+ void highlightedId( int );
-private slots:
- void onActivated( int );
- void onActivated( const QString& );
+private Q_SLOTS:
+ void onActivated( int );
+ void onActivated( const QString& );
protected:
- virtual void paintEvent( QPaintEvent* );
+ virtual void paintEvent( QPaintEvent* );
private:
- int id( const int ) const;
- int index( const int ) const;
+ int id( const int ) const;
+ int index( const int ) const;
- void resetClear();
- void paintClear( QPaintEvent* );
+ void resetClear();
+ void paintClear( QPaintEvent* );
private:
- bool myCleared;
- IndexIdMap myIndexId;
+ bool myCleared;
+ IndexIdMap myIndexId;
};
#ifdef WIN32
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxDockWidget.cxx
+// Author: Sergey TELKOV
+
+#include "QtxDockWidget.h"
+
+#include <QtGui/qlayout.h>
+#include <QtGui/qaction.h>
+#include <QtGui/qapplication.h>
+
+/*!
+ \class QtxDockWidget::Watcher [Internal]
+ Internal object with event filter.
+*/
+class QtxDockWidget::Watcher : public QObject
+{
+public:
+ Watcher( QtxDockWidget* );
+
+ void shown( QtxDockWidget* );
+ void hided( QtxDockWidget* );
+
+ virtual bool eventFilter( QObject*, QEvent* );
+
+protected:
+ virtual void customEvent( QEvent* );
+
+private:
+ void installFilters();
+
+ void showContainer();
+ void hideContainer();
+
+ void updateIcon();
+ void updateCaption();
+ void updateVisibility();
+
+private:
+ QtxDockWidget* myCont;
+ bool myState;
+ bool myEmpty;
+ bool myVisible;
+};
+
+/*!
+ Constructor
+*/
+QtxDockWidget::Watcher::Watcher( QtxDockWidget* cont )
+: QObject( cont ), myCont( cont ),
+myState( true ),
+myEmpty( true )
+{
+ myCont->installEventFilter( this );
+ myVisible = myCont->isVisibleTo( myCont->parentWidget() );
+
+ installFilters();
+}
+
+/*!
+ Custom event filter
+*/
+bool QtxDockWidget::Watcher::eventFilter( QObject* o, QEvent* e )
+{
+ if ( o == myCont && ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent ||
+ e->type() == QEvent::Hide || e->type() == QEvent::HideToParent ||
+ e->type() == QEvent::ChildAdded ) )
+ QApplication::postEvent( this, new QEvent( QEvent::User ) );
+
+ if ( o != myCont && e->type() == QEvent::WindowIconChange )
+ updateIcon();
+
+ if ( o != myCont && e->type() == QEvent::WindowTitleChange )
+ updateCaption();
+
+ if ( ( o != myCont && ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent ) ) ||
+ ( o == myCont && ( e->type() == QEvent::ChildRemoved ) ) ||
+ ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent ) )
+ updateVisibility();
+
+ return false;
+}
+
+/*!
+ Sets internal status to shown
+*/
+void QtxDockWidget::Watcher::shown( QtxDockWidget* dw )
+{
+ if ( dw != myCont )
+ return;
+
+ myVisible = true;
+}
+
+/*!
+ Sets internal status to hidden
+*/
+void QtxDockWidget::Watcher::hided( QtxDockWidget* dw )
+{
+ if ( dw != myCont )
+ return;
+
+ myVisible = false;
+}
+
+/*!
+ Shows corresponding dock window
+*/
+void QtxDockWidget::Watcher::showContainer()
+{
+ if ( !myCont )
+ return;
+
+ QtxDockWidget* cont = myCont;
+ myCont = 0;
+ cont->show();
+ myCont = cont;
+}
+
+/*!
+ Hides corresponding dock window
+*/
+void QtxDockWidget::Watcher::hideContainer()
+{
+ if ( !myCont )
+ return;
+
+ QtxDockWidget* cont = myCont;
+ myCont = 0;
+ cont->hide();
+ myCont = cont;
+}
+
+/*!
+ Event filter of custom events
+*/
+void QtxDockWidget::Watcher::customEvent( QEvent* e )
+{
+ installFilters();
+
+ updateIcon();
+ updateCaption();
+ updateVisibility();
+}
+
+/*!
+ Installs this object as event filter to all widgets inside corresponding main window
+*/
+void QtxDockWidget::Watcher::installFilters()
+{
+ if ( !myCont )
+ return;
+
+ QLayout* l = myCont->layout();
+ if ( !l )
+ return;
+
+ for ( uint i = 0; i < l->count(); i++ )
+ {
+ if ( l->itemAt( i ) && l->itemAt( i )->widget() )
+ l->itemAt( i )->widget()->installEventFilter( this );
+ }
+}
+
+/*!
+ Updates visibility of all widgets inside corresponding main window
+*/
+void QtxDockWidget::Watcher::updateVisibility()
+{
+ if ( !myCont )
+ return;
+
+ QLayout* l = myCont->layout();
+ if ( !l )
+ return;
+
+ bool vis = false;
+ for ( uint i = 0; i < l->count() && !vis; i++ )
+ vis = l->itemAt( i ) && l->itemAt( i )->widget() && l->itemAt( i )->widget()->isVisibleTo( myCont );
+
+ if ( myEmpty == vis )
+ {
+ myEmpty = !vis;
+ if ( !myEmpty )
+ myCont->toggleViewAction()->setVisible( myState );
+ else
+ {
+ myState = myCont->toggleViewAction()->isVisible();
+ myCont->toggleViewAction()->setVisible( false );
+ }
+ }
+
+ vis = !myEmpty && myVisible;
+ if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) )
+ vis ? showContainer() : hideContainer();
+}
+
+/*!
+ Updates icon of corresponding main window
+*/
+void QtxDockWidget::Watcher::updateIcon()
+{
+ if ( !myCont || !myCont->widget() )
+ return;
+
+ myCont->setWindowIcon( myCont->widget()->windowIcon() );
+}
+
+/*!
+ Updates caption of corresponding main window
+*/
+void QtxDockWidget::Watcher::updateCaption()
+{
+ if ( myCont && myCont->widget() && !myCont->widget()->windowTitle().isNull() )
+ myCont->setWindowTitle( myCont->widget()->windowTitle() );
+}
+
+/*!
+ Constructor
+*/
+QtxDockWidget::QtxDockWidget( const QString& title, QWidget* parent, Qt::WindowFlags f )
+: QDockWidget( title, parent, f ),
+myWatcher( 0 )
+{
+}
+
+/*!
+ Constructor
+*/
+QtxDockWidget::QtxDockWidget( const bool watch, QWidget* parent, Qt::WindowFlags f )
+: QDockWidget( parent, f ),
+myWatcher( 0 )
+{
+ if ( watch )
+ myWatcher = new Watcher( this );
+}
+
+/*!
+ Constructor
+*/
+QtxDockWidget::QtxDockWidget( QWidget* parent, Qt::WindowFlags f )
+: QDockWidget( parent, f ),
+myWatcher( 0 )
+{
+}
+
+/*!
+ Destructor
+*/
+QtxDockWidget::~QtxDockWidget()
+{
+}
+
+/*!
+ \return the recommended size for the widget
+*/
+QSize QtxDockWidget::sizeHint() const
+{
+ QSize sz = QDockWidget::sizeHint();
+/*
+ if ( place() == InDock && isStretchable() && area() )
+ {
+ if ( orientation() == Horizontal )
+ sz.setWidth( area()->width() );
+ else
+ sz.setHeight( area()->height() );
+ }
+*/
+ return sz;
+}
+
+/*!
+ \return the recommended minimum size for the widget
+*/
+QSize QtxDockWidget::minimumSizeHint() const
+{
+ QSize sz = QDockWidget::minimumSizeHint();
+/*
+ if ( orientation() == Horizontal )
+ sz = QSize( 0, QDockWidget::minimumSizeHint().height() );
+ else
+ sz = QSize( QDockWidget::minimumSizeHint().width(), 0 );
+
+ if ( place() == InDock && isStretchable() && area() )
+ {
+ if ( orientation() == Horizontal )
+ sz.setWidth( area()->width() );
+ else
+ sz.setHeight( area()->height() );
+ }
+*/
+ return sz;
+}
+
+/*!
+ Shows/hides the window
+*/
+void QtxDockWidget::setVisible( bool on )
+{
+ if ( myWatcher )
+ {
+ if ( on )
+ myWatcher->shown( this );
+ else
+ myWatcher->hided( this );
+ }
+
+ QDockWidget::setVisible( on );
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File: QtxDockWidget.h
+// Author: Sergey TELKOV
+
+#include "Qtx.h"
+
+#include <QtGui/qdockwidget.h>
+
+class QTX_EXPORT QtxDockWidget : public QDockWidget
+{
+ Q_OBJECT
+
+ class Watcher;
+
+public:
+ QtxDockWidget( const QString&, QWidget* = 0, Qt::WindowFlags = 0 );
+ QtxDockWidget( const bool, QWidget* = 0, Qt::WindowFlags = 0 );
+ QtxDockWidget( QWidget*, Qt::WindowFlags = 0 );
+ virtual ~QtxDockWidget();
+
+ virtual QSize sizeHint() const;
+ virtual QSize minimumSizeHint() const;
+
+public slots:
+ virtual void setVisible( bool );
+
+private:
+ Watcher* myWatcher;
+};
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: QtxDockWindow.cxx
-// Author: Sergey TELKOV
-
-#include "QtxDockWindow.h"
-
-#include <qlayout.h>
-#include <qpixmap.h>
-#include <qdockarea.h>
-#include <qmainwindow.h>
-#include <qapplication.h>
-
-/*!
- \class QtxDockWindow::Watcher [Internal]
- Internal object with event filter.
-*/
-class QtxDockWindow::Watcher : public QObject
-{
-public:
- Watcher( QtxDockWindow* );
-
- void shown( QtxDockWindow* );
- void hided( QtxDockWindow* );
-
- virtual bool eventFilter( QObject*, QEvent* );
-
-protected:
- virtual void customEvent( QCustomEvent* );
-
-private:
- void installFilters();
-
- void showContainer();
- void hideContainer();
-
- void updateIcon();
- void updateCaption();
- void updateVisibility();
-
-private:
- QtxDockWindow* myCont;
- bool myState;
- bool myEmpty;
- bool myVisible;
-};
-
-/*!
- Constructor
-*/
-QtxDockWindow::Watcher::Watcher( QtxDockWindow* cont )
-: QObject( cont ), myCont( cont ),
-myState( true ),
-myEmpty( true )
-{
- if ( myCont->mainWindow() )
- myState = myCont->mainWindow()->appropriate( myCont );
-
- myCont->installEventFilter( this );
- myVisible = myCont->isVisibleTo( myCont->parentWidget() );
-
- installFilters();
-}
-
-/*!
- Custom event filter
-*/
-bool QtxDockWindow::Watcher::eventFilter( QObject* o, QEvent* e )
-{
- if ( o == myCont &&
- ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent ||
- e->type() == QEvent::Hide || e->type() == QEvent::HideToParent ||
- e->type() == QEvent::ChildInserted ) )
- QApplication::postEvent( this, new QCustomEvent( QEvent::User ) );
-
- if ( o != myCont && e->type() == QEvent::IconChange )
- updateIcon();
-
- if ( o != myCont && e->type() == QEvent::CaptionChange )
- updateCaption();
-
- if ( ( o != myCont && ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent ) ) ||
- ( o == myCont && ( e->type() == QEvent::ChildRemoved ) ) ||
- ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent ) )
- updateVisibility();
-
- return false;
-}
-
-/*!
- Sets internal status to shown
-*/
-void QtxDockWindow::Watcher::shown( QtxDockWindow* dw )
-{
- if ( dw != myCont )
- return;
-
- myVisible = true;
-}
-
-/*!
- Sets internal status to hidden
-*/
-void QtxDockWindow::Watcher::hided( QtxDockWindow* dw )
-{
- if ( dw != myCont )
- return;
-
- myVisible = false;
-}
-
-/*!
- Shows corresponding dock window
-*/
-void QtxDockWindow::Watcher::showContainer()
-{
- if ( !myCont )
- return;
-
- QtxDockWindow* cont = myCont;
- myCont = 0;
- cont->show();
- myCont = cont;
-}
-
-/*!
- Hides corresponding dock window
-*/
-void QtxDockWindow::Watcher::hideContainer()
-{
- if ( !myCont )
- return;
-
- QtxDockWindow* cont = myCont;
- myCont = 0;
- cont->hide();
- myCont = cont;
-}
-
-/*!
- Event filter of custom events
-*/
-void QtxDockWindow::Watcher::customEvent( QCustomEvent* e )
-{
- installFilters();
-
- updateIcon();
- updateCaption();
- updateVisibility();
-}
-
-/*!
- Installs this object as event filter to all widgets inside corresponding main window
-*/
-void QtxDockWindow::Watcher::installFilters()
-{
- if ( !myCont )
- return;
-
- QBoxLayout* bl = myCont->boxLayout();
- if ( !bl )
- return;
-
- for ( QLayoutIterator it = bl->iterator(); it.current(); ++it )
- {
- if ( it.current()->widget() )
- it.current()->widget()->installEventFilter( this );
- }
-}
-
-/*!
- Updates visibility of all widgets inside corresponding main window
-*/
-void QtxDockWindow::Watcher::updateVisibility()
-{
- if ( !myCont )
- return;
-
- QBoxLayout* bl = myCont->boxLayout();
- if ( !bl )
- return;
-
- bool vis = false;
- for ( QLayoutIterator it = bl->iterator(); it.current() && !vis; ++it )
- vis = it.current()->widget() && it.current()->widget()->isVisibleTo( myCont );
-
- QMainWindow* mw = myCont->mainWindow();
- if ( mw && myEmpty == vis )
- {
- myEmpty = !vis;
- if ( !myEmpty )
- mw->setAppropriate( myCont, myState );
- else
- {
- myState = mw->appropriate( myCont );
- mw->setAppropriate( myCont, false );
- }
- }
-
- vis = !myEmpty && myVisible;
- if ( vis != myCont->isVisibleTo( myCont->parentWidget() ) )
- vis ? showContainer() : hideContainer();
-}
-
-/*!
- Updates icon of corresponding main window
-*/
-void QtxDockWindow::Watcher::updateIcon()
-{
- if ( !myCont || !myCont->widget() )
- return;
-
- const QPixmap* ico = myCont->widget()->icon();
- myCont->setIcon( ico ? *ico : QPixmap() );
-}
-
-/*!
- Updates caption of corresponding main window
-*/
-void QtxDockWindow::Watcher::updateCaption()
-{
- if ( myCont && myCont->widget() && !myCont->widget()->caption().isNull() )
- myCont->setCaption( myCont->widget()->caption() );
-}
-
-/*!
- Constructor
-*/
-QtxDockWindow::QtxDockWindow( Place p, QWidget* parent, const char* name, WFlags f )
-: QDockWindow( p, parent, name, f ),
-myWatcher( 0 ),
-myStretch( false )
-{
-}
-
-/*!
- Constructor
-*/
-QtxDockWindow::QtxDockWindow( const bool watch, QWidget* parent, const char* name, WFlags f )
-: QDockWindow( InDock, parent, name, f ),
-myWatcher( 0 ),
-myStretch( false )
-{
- if ( watch )
- myWatcher = new Watcher( this );
-}
-
-/*!
- Constructor
-*/
-QtxDockWindow::QtxDockWindow( QWidget* parent, const char* name, WFlags f )
-: QDockWindow( InDock, parent, name, f ),
-myWatcher( 0 ),
-myStretch( false )
-{
-}
-
-/*!
- Destructor
-*/
-QtxDockWindow::~QtxDockWindow()
-{
-}
-
-/*!
- Sets the dock window's main widget
- \param wid - new main widget
-*/
-void QtxDockWindow::setWidget( QWidget* wid )
-{
- if ( wid )
- {
- if ( wid->parentWidget() != this )
- wid->reparent( this, QPoint( 0, 0 ), wid->isVisibleTo( wid->parentWidget() ) );
- if ( myWatcher )
- {
- setCaption( wid->caption() );
- if ( wid->icon() )
- setIcon( *wid->icon() );
- }
- }
-
- QDockWindow::setWidget( wid );
-}
-
-/*!
- \return true if the dock window is stretchable
-*/
-bool QtxDockWindow::isStretchable() const
-{
- return myStretch;
-}
-
-/*!
- Sets the dock window "stretchable" state
- \param on - new state
-*/
-void QtxDockWindow::setStretchable( const bool on )
-{
- if ( myStretch == on )
- return;
-
- myStretch = on;
-
- boxLayout()->setStretchFactor( widget(), myStretch ? 1 : 0 );
-
- if ( myStretch != isHorizontalStretchable() ||
- myStretch != isVerticalStretchable() )
- {
- if ( orientation() == Horizontal )
- setHorizontalStretchable( myStretch );
- else
- setVerticalStretchable( myStretch );
- }
-}
-
-/*!
- \return the recommended size for the widget
-*/
-QSize QtxDockWindow::sizeHint() const
-{
- QSize sz = QDockWindow::sizeHint();
-
- if ( place() == InDock && isStretchable() && area() )
- {
- if ( orientation() == Horizontal )
- sz.setWidth( area()->width() );
- else
- sz.setHeight( area()->height() );
- }
-
- return sz;
-}
-
-/*!
- \return the recommended minimum size for the widget
-*/
-QSize QtxDockWindow::minimumSizeHint() const
-{
- QSize sz = QDockWindow::minimumSizeHint();
-
- if ( orientation() == Horizontal )
- sz = QSize( 0, QDockWindow::minimumSizeHint().height() );
- else
- sz = QSize( QDockWindow::minimumSizeHint().width(), 0 );
-
- if ( place() == InDock && isStretchable() && area() )
- {
- if ( orientation() == Horizontal )
- sz.setWidth( area()->width() );
- else
- sz.setHeight( area()->height() );
- }
-
- return sz;
-}
-
-/*!
- \return corresponding main window
-*/
-QMainWindow* QtxDockWindow::mainWindow() const
-{
- QMainWindow* mw = 0;
-
- QWidget* wid = parentWidget();
- while ( !mw && wid )
- {
- if ( wid->inherits( "QMainWindow" ) )
- mw = (QMainWindow*)wid;
- wid = wid->parentWidget();
- }
-
- return mw;
-}
-
-/*!
- Shows window
-*/
-void QtxDockWindow::show()
-{
- if ( myWatcher )
- myWatcher->shown( this );
-
- QDockWindow::show();
-}
-
-/*!
- Hides window
-*/
-void QtxDockWindow::hide()
-{
- if ( myWatcher )
- myWatcher->hided( this );
-
- QDockWindow::hide();
-}
+++ /dev/null
-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-// File: QtxDockWindow.h
-// Author: Sergey TELKOV
-
-#include "Qtx.h"
-
-#include <qdockwindow.h>
-
-class QTX_EXPORT QtxDockWindow : public QDockWindow
-{
- Q_OBJECT
-
- class Watcher;
-
-public:
- QtxDockWindow( Place = InDock, QWidget* = 0, const char* = 0, WFlags = 0 );
- QtxDockWindow( const bool, QWidget*, const char* = 0, WFlags = 0 );
- QtxDockWindow( QWidget*, const char* = 0, WFlags = 0 );
- virtual ~QtxDockWindow();
-
- virtual void setWidget( QWidget* );
-
- bool isStretchable() const;
- virtual void setStretchable( const bool );
-
- virtual QSize sizeHint() const;
- virtual QSize minimumSizeHint() const;
-
- QMainWindow* mainWindow() const;
-
-public slots:
- virtual void show();
- virtual void hide();
-
-private:
- Watcher* myWatcher;
- bool myStretch;
-};