Commit de667b3e authored by Isaak Lim's avatar Isaak Lim
Browse files

now the sidearea is not cleared everytime a toolbox is added, thus preventing...

now the sidearea is not cleared everytime a toolbox is added, thus preventing the loss of active states

refs #1015

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15472 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fda65e17
...@@ -69,19 +69,44 @@ SideArea::SideArea (QWidget *_parent) : ...@@ -69,19 +69,44 @@ SideArea::SideArea (QWidget *_parent) :
void SideArea::addItem (QWidget *_w, QString _name, QIcon *_icon) void SideArea::addItem (QWidget *_w, QString _name, QIcon *_icon)
{ {
bool contains = false;
QVector<SideElement*>::iterator it = items_.begin();
for(; it != items_.end(); ++it) {
if ((*it)->widget() == _w) {
contains = true;
break;
}
}
if (contains) {
return;
} else {
SideElement *e = new SideElement (this, _w, _name, _icon); SideElement *e = new SideElement (this, _w, _name, _icon);
layout_->addWidget (e); layout_->addWidget (e);
items_.push_back (e); items_.push_back (e);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void SideArea::addItem (QWidget *_w, QString _name) void SideArea::addItem (QWidget *_w, QString _name)
{ {
bool contains = false;
QVector<SideElement*>::iterator it = items_.begin();
for(; it != items_.end(); ++it) {
if ((*it)->widget() == _w) {
contains = true;
break;
}
}
if (contains) {
return;
} else {
SideElement *e = new SideElement (this, _w, _name); SideElement *e = new SideElement (this, _w, _name);
layout_->addWidget (e); layout_->addWidget (e);
items_.push_back (e); items_.push_back (e);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -164,9 +189,11 @@ void SideArea::setElementActive(QString _name, bool _active) ...@@ -164,9 +189,11 @@ void SideArea::setElementActive(QString _name, bool _active)
for (int i=0; i < items_.count(); i++) for (int i=0; i < items_.count(); i++)
if ( items_[i]->name() == _name ){ if ( items_[i]->name() == _name ){
items_[i]->setActive(_active); items_[i]->setActive(_active);
return; return;
} }
} }
//============================================================================= //=============================================================================
//============================================================================= //=============================================================================
...@@ -282,6 +282,12 @@ const QString& SideElement::name(){ ...@@ -282,6 +282,12 @@ const QString& SideElement::name(){
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QWidget const * SideElement::widget() {
return widget_;
}
//-----------------------------------------------------------------------------
SideElement::TopArea::TopArea (SideElement *_e) : SideElement::TopArea::TopArea (SideElement *_e) :
e_ (_e) e_ (_e)
{ {
......
...@@ -104,6 +104,9 @@ class SideElement : public QWidget ...@@ -104,6 +104,9 @@ class SideElement : public QWidget
/// return the name /// return the name
const QString& name(); const QString& name();
/// returns the pointer to the plugin tool widget
QWidget const * widget();
private: private:
/// Clickable area inside of the side element. /// Clickable area inside of the side element.
......
...@@ -360,16 +360,20 @@ void CoreWidget::slotChangeView(QString _mode, QStringList _toolboxWidgets, QStr ...@@ -360,16 +360,20 @@ void CoreWidget::slotChangeView(QString _mode, QStringList _toolboxWidgets, QStr
_contextmenus = viewModes_[i]->visibleContextMenus; _contextmenus = viewModes_[i]->visibleContextMenus;
} }
// Remove all toolbox entries
toolBox_->clear (); // Remove all toolbox entries if the view has changed
if (_mode != OpenFlipper::Options::currentViewMode())
toolBox_->clear();
//find all widgets that should be visible //find all widgets that should be visible
for (int i=0; i < _toolboxWidgets.size(); i++) for (int i=0; i < _toolboxWidgets.size(); i++)
for (uint p=0; p < plugins_.size(); p++){ for (uint p=0; p < plugins_.size(); p++){
for ( uint j = 0 ; j < plugins_[p].toolboxWidgets.size(); ++j ) for ( uint j = 0 ; j < plugins_[p].toolboxWidgets.size(); ++j )
if (_toolboxWidgets[i] == plugins_[p].toolboxWidgets[j].first ) if (_toolboxWidgets[i] == plugins_[p].toolboxWidgets[j].first ) {
toolBox_->addItem (plugins_[p].toolboxWidgets[j].second, plugins_[p].toolboxWidgets[j].first, plugins_[p].toolboxIcons[j] ); toolBox_->addItem (plugins_[p].toolboxWidgets[j].second, plugins_[p].toolboxWidgets[j].first, plugins_[p].toolboxIcons[j] );
} }
}
if (_expandAll) if (_expandAll)
toolBox_->expandAll(); toolBox_->expandAll();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment