rock_widget_collection  0.1
Public Slots | Public Member Functions | List of all members
MultiViewPlugin Class Reference

#include <MultiViewPlugin.h>

Inherits QObject, and QDesignerCustomWidgetInterface.

Public Slots

void manageWidget (QWidget *widget)
 
void selectionChanged ()
 
void activeFormWindowChanged (QDesignerFormWindowInterface *formWindow)
 

Public Member Functions

 MultiViewPlugin (QObject *parent)
 
virtual ~MultiViewPlugin ()
 
bool isContainer () const
 
bool isInitialized () const
 
QIcon icon () const
 
QString domXml () const
 
QString group () const
 
QString includeFile () const
 
QString name () const
 
QString toolTip () const
 
QString whatsThis () const
 
QWidget * createWidget (QWidget *parent)
 
void initialize (QDesignerFormEditorInterface *core)
 

Detailed Description

Simple qt designer plugin class. Only thing to note that the multi view widget is used as a container widget. It handles the adding of widgets for the MultiViewWidget in a QTDesigner specific way. No preview will be shown as QT Designer can not handle widgets which will be taken care of by the MultiViewWidget.

Definition at line 25 of file MultiViewPlugin.h.

Constructor & Destructor Documentation

◆ MultiViewPlugin()

MultiViewPlugin::MultiViewPlugin ( QObject *  parent)

Simple constructor

Parameters
parentparent widget

Definition at line 12 of file MultiViewPlugin.cc.

12  : QObject(parent)
13 {
14  widget = NULL;
15  initialized = false;
16  designerMode = false;
17 }

◆ ~MultiViewPlugin()

MultiViewPlugin::~MultiViewPlugin ( )
virtual

Standard Destructor

Definition at line 19 of file MultiViewPlugin.cc.

20 {
21 }

Member Function Documentation

◆ activeFormWindowChanged

void MultiViewPlugin::activeFormWindowChanged ( QDesignerFormWindowInterface *  formWindow)
slot

Called when the active Form window was changed. Used when loading a ui file to know when the designer is ready to add teh already added widgets

Parameters
formWindowThe active form window

Definition at line 108 of file MultiViewPlugin.cc.

109 {
110  // needs to be done for reloading as widgets will be added before the
111  // active form window is set by the designer
112  if(formWindow != NULL && lastWidgets.size() > 0)
113  {
114  for(unsigned int i=0;i<lastWidgets.size();i++)
115  {
116  manageWidget(lastWidgets[i]);
117  }
118  lastWidgets.clear();
119  }
120 
121 }
void manageWidget(QWidget *widget)

◆ createWidget()

QWidget * MultiViewPlugin::createWidget ( QWidget *  parent)

Creates the widget which the plugin handles

Parameters
parentparent widget
Returns
the widget which the plugin shall handle

Definition at line 168 of file MultiViewPlugin.cc.

169 {
170  widget = new MultiViewWidget(parent);
171  widget->setDesignerMode(designerMode);
172  connect(widget, SIGNAL(widgetButtonAdded(QWidget*)), this, SLOT(manageWidget(QWidget*)));
173  return widget;
174 }
void setDesignerMode(bool designerMode)
void manageWidget(QWidget *widget)

◆ domXml()

QString MultiViewPlugin::domXml ( ) const

Returns an XML defining the plugins internals

Returns
an xml string

Definition at line 176 of file MultiViewPlugin.cc.

177 {
178  return "<widget class=\"MultiViewWidget\" name=\"MultiViewWidget\">\n"
179  " <property name=\"geometry\">\n"
180  " <rect>\n"
181  " <x>0</x>\n"
182  " <y>0</y>\n"
183  " <width>400</width>\n"
184  " <height>300</height>\n"
185  " </rect>\n"
186  " </property>\n"
187  " <property name=\"toolTip\" >\n"
188  " <string>MultiView</string>\n"
189  " </property>\n"
190  " <property name=\"whatsThis\" >\n"
191  " <string>Displays multiple widgets in a container.</string>\n"
192  " </property>\n"
193  "</widget>\n";
194 
195 }

◆ group()

QString MultiViewPlugin::group ( ) const

Returns a group name

Returns
a group name

Definition at line 38 of file MultiViewPlugin.cc.

39 {
40  return "Rock-Robotics";
41 }

◆ icon()

QIcon MultiViewPlugin::icon ( ) const

Returns teh icon of the plugin

Returns
the icon of the plugin

Definition at line 33 of file MultiViewPlugin.cc.

34 {
35  return QIcon();
36 }

◆ includeFile()

QString MultiViewPlugin::includeFile ( ) const

Returns the include File

Returns
the include file

Definition at line 43 of file MultiViewPlugin.cc.

44 {
45  return "MultiViewWidget.h";
46 }

◆ initialize()

void MultiViewPlugin::initialize ( QDesignerFormEditorInterface *  core)

Initializes the plugin

Parameters
coreInterface given by QT Designer

Definition at line 63 of file MultiViewPlugin.cc.

64 {
65  // initialize will only be called wehn qt designer is used
66  // when loading via an ui file, this will not be called
67  designerMode = true;
68  if (initialized)
69  {
70  return;
71  }
72  formInterface = core;
73  connect(formInterface->formWindowManager(), SIGNAL(activeFormWindowChanged(QDesignerFormWindowInterface*)),
74  this, SLOT(activeFormWindowChanged(QDesignerFormWindowInterface*)));
75  initialized = true;
76 }
void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow)

◆ isContainer()

bool MultiViewPlugin::isContainer ( ) const

Returns whether this is a container widget

Returns
will always return true

Definition at line 23 of file MultiViewPlugin.cc.

24 {
25  return true;
26 }

◆ isInitialized()

bool MultiViewPlugin::isInitialized ( ) const

Returns whether the plugin is initialized

Returns
if the plugin is initialized

Definition at line 28 of file MultiViewPlugin.cc.

29 {
30  return initialized;
31 }

◆ manageWidget

void MultiViewPlugin::manageWidget ( QWidget *  widget)
slot

Called when a widget was added so it will be managed correctly in the active form

Parameters
widgetthe widgfet which shall be managed

Definition at line 78 of file MultiViewPlugin.cc.

79 {
80  if(!this->widget->isDesignerMode())
81  {
82  return;
83  }
84  // when designer loads a ui file it will call manage widget BEFORE
85  // setting the active Form Window, save what shall be added
86  // and wait for the activeFormWindow signal and add everything up
87  // to that point
88  if(formInterface->formWindowManager()->activeFormWindow() == NULL)
89  {
90  lastWidgets.push_back(widget);
91  return;
92  }
93  //formInterface->formWindowManager()->activeFormWindow()->manageWidget(widget);
94  WidgetButton* button = dynamic_cast<WidgetButton*>(widget);
95  if(button != NULL)
96  {
97  button->setIconAlternative(QIcon(), true);
98  printf("We have here an element in button: %s\n",typeid(*button->getWidget()).name());
99  printf("Adding this to: %s\n",typeid(*formInterface->formWindowManager()->activeFormWindow()).name());
100  printf("Filename for current one is: %s\n",formInterface->formWindowManager()->activeFormWindow()->fileName().toStdString().c_str());
101  formInterface->formWindowManager()->activeFormWindow()->manageWidget(button->getWidget());
102  }else{
103  printf("We have here an non-button: %s\n",typeid(*widget).name());
104  }
105  connect(formInterface->formWindowManager()->activeFormWindow(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
106 }
void setIconAlternative(const QIcon &icon, bool isAlternative=false)
QWidget * getWidget()
QString name() const

◆ name()

QString MultiViewPlugin::name ( ) const

Returns the name

Returns
the name

Definition at line 48 of file MultiViewPlugin.cc.

49 {
50  return "MultiViewWidget";
51 }

◆ selectionChanged

void MultiViewPlugin::selectionChanged ( )
slot

Called when a preview Button was selected to imitate clicks, which will normally be caught by designer to change the buttons name

Definition at line 123 of file MultiViewPlugin.cc.

124 {
125 
126  QWidget* selected = formInterface->formWindowManager()->activeFormWindow()->cursor()->selectedWidget(0);
127  WidgetButton* button = dynamic_cast<WidgetButton*>(selected);
128  if(button != NULL)
129  {
130  printf("It's an button selected with contains: %s\n",typeid(*button->getWidget()).name());
131  button->click();
132  }
133  else
134  {
135  if(selected != NULL)
136  {
137  button = widget->getButtonForWidget(selected);
138  if(button != NULL)
139  {
140  printf("It's an button selected with contains: %s\n",typeid(*button->getWidget()).name());
141  button->click();
142  }else{
143  printf("Cannot find Button for: %s\n",typeid(*selected).name());
144  }
145  }
146  }
147 
148  if(button != NULL)
149  {
150  QList<WidgetButton*> buttons = widget->getAllWidgetButtons();
151  for(int i=0;i<buttons.size();i++)
152  {
153  if(button != buttons[i])
154  {
155  buttons[i]->getWidget()->setMaximumSize(0, 0);
156  }
157  else
158  {
159  buttons[i]->getWidget()->setMaximumSize(1000000, 1000000);
160  }
161 
162  }
163  }
164 
165  //printf("Curent content: %s\n",formInterface->formWindowManager()->activeFormWindow()->contents().toStdString().c_str());
166 }
QList< WidgetButton * > getAllWidgetButtons()
QWidget * getWidget()
QString name() const
WidgetButton * getButtonForWidget(QWidget *widget)

◆ toolTip()

QString MultiViewPlugin::toolTip ( ) const

Returns the tooltip

Returns
the tooltip

Definition at line 53 of file MultiViewPlugin.cc.

54 {
55  return "Widget for displaying multiple widgets";
56 }

◆ whatsThis()

QString MultiViewPlugin::whatsThis ( ) const

Returns a whats this string

Returns
teh whatsthis string

Definition at line 58 of file MultiViewPlugin.cc.

59 {
60  return "Container widget for other widgets";
61 }

The documentation for this class was generated from the following files: