Brief description of class still missing. More...
#include <ExpandTabWidget.h>
Signals | |
void | sizeChanged () |
Public Member Functions | |
void | addWidget (QString title, QWidget *w) |
ExpandTabWidget (QWidget *parent=0) | |
bool | isDocked (QWidget *w) |
uint | key () const |
void | restoreState (const QByteArray &state) |
QByteArray | saveState () const |
void | setTitlePrefix (QString p) |
void | takeWidget (QWidget *w) |
QList< QWidget * > | takeWidgets () |
~ExpandTabWidget () |
Brief description of class still missing.
Full description of class still missing
QGpGuiTools::ExpandTabWidget::ExpandTabWidget | ( | QWidget * | parent = 0 | ) |
void QGpGuiTools::ExpandTabWidget::addWidget | ( | QString | title, |
QWidget * | w | ||
) |
References QGpGuiTools::ExpandTabTitle::setContent(), QGpGuiTools::ExpandTabTitle::setTitle(), and TRACE.
Referenced by QGpGuiTools::PropertyCategory::setEditor().
{ TRACE; ExpandTabTitle * t=new ExpandTabTitle(this); t->setTitle(title); w->layout()->setContentsMargins(9, 9, 9 ,9); t->setContent(w); t->setObjectName(w->objectName()); connect(t, SIGNAL(moveUp()), this, SLOT(moveWidgetUp())); connect(t, SIGNAL(moveDown()), this, SLOT(moveWidgetDown())); connect(t, SIGNAL(dock()), this, SLOT(dockWidget())); connect(t, SIGNAL(addActions(QMenu *)), this, SLOT(addContextActions(QMenu *))); connect(t, SIGNAL(resize(int)), this, SLOT(resize(int))); _vboxLayout->addWidget(t); _vboxLayout->addWidget(w); // docked by default }
bool QGpGuiTools::ExpandTabWidget::isDocked | ( | QWidget * | w | ) |
References QGpGuiTools::ExpandTabTitle::docked().
Referenced by QGpGuiTools::PropertyCategory::removeTab().
{ int index; ExpandTabTitle * t=find(w, index); return t ? t->docked() : false; }
uint QGpGuiTools::ExpandTabWidget::key | ( | ) | const |
References QGpGuiTools::ExpandTabTitle::content(), QGpGuiTools::ExpandTabTitle::docked(), and DinverCore::qHash().
{ uint k=0; int n=_vboxLayout->count(); for(int i=0; i<n;i++) { ExpandTabTitle * t=qobject_cast<ExpandTabTitle *>(_vboxLayout->itemAt(i)->widget()); if(t) { QString name=t->content()->objectName(); k+=qHash(name); if(t->docked()) i++; } } return k; }
void QGpGuiTools::ExpandTabWidget::restoreState | ( | const QByteArray & | state | ) |
References QGpGuiTools::ExpandTabTitle::content(), QGpGuiTools::Settings::getRect(), QGpGuiTools::ExpandTabTitle::setDocked(), QGpGuiTools::ExpandTabTitle::setExpanded(), QGpGuiTools::ExpandTabTitle::title, and TRACE.
{ TRACE; QDataStream s(const_cast<QByteArray *>(&state), QIODevice::ReadOnly); int n; s >> n; if(n<=0) return; QList<ExpandTabTitle *> wList=findChildren<ExpandTabTitle *>(); // Tranfer to a Hash table to map from ObjectName to object pointers QHash<QString, ExpandTabTitle *> name2ptr; for(QList<ExpandTabTitle *>::iterator it=wList.begin(); it!=wList.end(); ++it) { name2ptr.insert((*it)->objectName(), *it); } // Reset layout to allow re-ordering of widgets delete _vboxLayout; _vboxLayout=new QVBoxLayout(this); _vboxLayout->setSpacing(0); _vboxLayout->setContentsMargins(0, 0, 0 ,0); for(int i=0; i<n; i++ ) { bool expanded, docked; int h; QString name; s >> expanded; s >> docked; s >> h; s >> name; if(name2ptr.contains(name)) { ExpandTabTitle * t=name2ptr[name]; _vboxLayout->addWidget(t); t->setExpanded(expanded); QWidget * w=t->content(); if(docked) { _vboxLayout->addWidget(t->content()); if(! (w->windowFlags() & Qt::Widget)) w->setWindowFlags(Qt::Widget); w->setMinimumSize(w->minimumSize().width(), h); t->setDocked(true); } else { QWidget * w=t->content(); w->setWindowTitle(_titlePrefix + t->title()); w->setParent(QApplication::activeWindow()); if(! (w->windowFlags() & Qt::Tool)) w->setWindowFlags(Qt::Tool); Settings::getRect(t->content(), objectName()+t->content()->objectName()); w->resize(w->width(), h); t->setDocked(false); t->setExpanded(true); } name2ptr.remove(name); } } // In case of error in widget list, there may be some remaining widgets, we add them at the end for(QHash<QString, ExpandTabTitle *>::iterator it=name2ptr.begin();it!=name2ptr.end(); ++it) { ExpandTabTitle * t=it.value(); _vboxLayout->addWidget(t); _vboxLayout->addWidget(t->content()); t->setExpanded(true); t->setDocked(true); } }
QByteArray QGpGuiTools::ExpandTabWidget::saveState | ( | ) | const |
References QGpGuiTools::ExpandTabTitle::content(), QGpGuiTools::ExpandTabTitle::docked(), QGpGuiTools::ExpandTabTitle::expanded, QGpGuiTools::Settings::setRect(), and TRACE.
{ TRACE; QByteArray state; QDataStream s(&state, QIODevice::WriteOnly); int n=_vboxLayout->count(); s << n; for(int i=0;i<n;i++) { ExpandTabTitle * t=qobject_cast<ExpandTabTitle *>(_vboxLayout->itemAt(i)->widget()); if(t) { s << t->expanded(); s << t->docked(); s << t->content()->height(); s << t->objectName(); if(t->docked()) { i++; } else { Settings::setRect(t->content(), objectName()+t->content()->objectName()); } } } return state; }
void QGpGuiTools::ExpandTabWidget::setTitlePrefix | ( | QString | p | ) | [inline] |
Referenced by QGpGuiTools::PropertyProxy::addCategory(), and QGpGuiTools::PropertyProxy::setEditor().
{_titlePrefix=p;}
void QGpGuiTools::ExpandTabWidget::sizeChanged | ( | ) | [signal] |
void QGpGuiTools::ExpandTabWidget::takeWidget | ( | QWidget * | w | ) |
References QGpGuiTools::ExpandTabTitle::content(), QGpGuiTools::ExpandTabTitle::docked(), and TRACE.
Referenced by QGpGuiTools::PropertyCategory::removeTab().
{ TRACE; int index; ExpandTabTitle * t=find(w, index); if(t) { if(t->docked()) delete _vboxLayout->takeAt(index+1); // Content: QLayoutItem deleted, widget remains delete _vboxLayout->takeAt(index); // Title item, widget still there t->content()->setParent(0); delete t; } }
QList< QWidget * > QGpGuiTools::ExpandTabWidget::takeWidgets | ( | ) |
References QGpGuiTools::ExpandTabTitle::content(), QGpGuiTools::ExpandTabTitle::docked(), and TRACE.
{ TRACE; QList<QWidget *> wList; while(!_vboxLayout->isEmpty()) { ExpandTabTitle * t=static_cast<ExpandTabTitle *>(_vboxLayout->itemAt(0)->widget()); if(t->docked()) delete _vboxLayout->takeAt(1); // Content: QLayoutItem deleted, widget remains delete _vboxLayout->takeAt(0); // Title item, widget still there wList.append(t->content()); t->content()->setParent(0); delete t; } return wList; }