CMS 3D CMS Logo

IgQWidgetStackSite.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "Iguana/Studio/interface/IgQWidgetStackSite.h"
00004 #include "Iguana/Framework/interface/IgDocumentDataRoot.h"
00005 #include <qwidgetstack.h>
00006 #include <qlayout.h>
00007 #include <qvbox.h>
00008 #include <qcombobox.h>
00009 
00010 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00011 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00012 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00013 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00014 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00015 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00016 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00017 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00018 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00019 
00020 // FIXME: the way widgets embeds into this site should be handled in a
00021 // better way although I've no idea how....
00022 
00023 IgQWidgetStackSite::IgQWidgetStackSite (IgState */*state*/, IgSite *parent)
00024     :m_box (new QVBox (hostFrom (parent))),
00025      m_combo (new QComboBox (m_box)),
00026      m_widget (new QWidgetStack (m_box)),
00027      m_layout (new QGridLayout (m_widget)),
00028      m_currentName (IgDocumentDataRoot::getCurrentRoot()),
00029      m_parent(parent)
00030 {
00031     QObject::connect (m_combo,
00032                       SIGNAL (activated (int)), 
00033                       this, 
00034                       SLOT (switchToWidget (int)));    
00035     IgQtSite::host (parent, m_box);
00036     hostFrom (m_parent)->hide();
00037 }
00038 
00039 const char *
00040 IgQWidgetStackSite::catalogLabel (void)
00041 { return "QWidgetStack"; }
00042 
00043 QWidget *
00044 IgQWidgetStackSite::self (void)
00045 {
00046     return m_widget;
00047 }
00048 
00049 QWidget *
00050 IgQWidgetStackSite::host (void)
00051 {
00052     return m_widget;
00053 }
00054 
00055 
00056 IgSite *
00057 IgQWidgetStackSite::hostWithName (const std::string &name)
00058 {
00059     m_currentName = name;
00060     return this;
00061 }
00062 
00063 void
00064 IgQWidgetStackSite::host (QWidget *child)
00065 {
00066     QWidget *previousWidget = m_widget->visibleWidget ();
00067     if (previousWidget)
00068     {
00069         m_layout->remove (previousWidget);      
00070     }
00071     
00072     int currentWidget = m_widget->addWidget (child);    
00073     m_layout->add (child);
00074     m_widget->raiseWidget (currentWidget);
00075     m_combo->insertItem (m_currentName);
00076     m_combo->setCurrentItem (m_combo->count () - 1);
00077     
00078     m_currentName = IgDocumentDataRoot::getCurrentRoot();
00079     m_comboIndexToWidgetID[m_combo->count () - 1] = currentWidget;
00080     hostFrom (m_parent)->show();
00081 }
00082 
00083 void
00084 IgQWidgetStackSite::switchToWidget (int id)
00085 {
00086     QWidget *previousWidget = m_widget->visibleWidget ();
00087     if (previousWidget)
00088     {
00089         m_layout->remove (previousWidget);      
00090     }
00091     m_layout->add (m_widget->widget (m_comboIndexToWidgetID[id]));
00092     m_widget->raiseWidget (m_comboIndexToWidgetID[id]);
00093     IgDocumentDataRoot::currentRoot(m_combo->text(id));
00094     m_currentName = IgDocumentDataRoot::getCurrentRoot ();
00095 }
00096 
00097 void
00098 IgQWidgetStackSite::tile (void)
00099 {    
00100 }
00101 
00102 void
00103 IgQWidgetStackSite::cascade (void)
00104 {
00105 }

Generated on Tue Jun 9 17:38:50 2009 for CMSSW by  doxygen 1.5.4