25 #define YUILogComponent "qt-ui"
26 #include <yui/YUILog.h>
30 #include <yui/YEvent.h>
31 #include "YQWidgetFactory.h"
32 #include "YQOptionalWidgetFactory.h"
33 #include "YQPartitionSplitter.h"
34 #include "YQLayoutBox.h"
35 #include "YQBarGraph.h"
36 #include "YQIntField.h"
38 #include "YQSignalBlocker.h"
49 const string & usedLabel,
50 const string & freeLabel,
51 const string & newPartLabel,
52 const string & freeFieldLabel,
53 const string & newPartFieldLabel )
54 : QWidget( (QWidget *) parent->widgetRep() )
55 , YPartitionSplitter( parent,
69 , _freeSizeSlider( 0 )
75 setChildrenManager(
new YSingleWidgetChildManager(
this ) );
81 _vbox = YUI::widgetFactory()->createVBox(
this );
82 _barGraph =
dynamic_cast<YQBarGraph *
> ( YUI::optionalWidgetFactory()->createBarGraph( _vbox ) );
83 YUI_CHECK_PTR( _barGraph );
85 int freeSize = totalFreeSize - newPartSize;
88 YBarGraphMultiUpdate multiUpdate( _barGraph );
90 _barGraph->addSegment( YBarGraphSegment( usedSize, usedLabel ) );
91 _barGraph->addSegment( YBarGraphSegment( freeSize, freeLabel ) );
92 _barGraph->addSegment( YBarGraphSegment( newPartSize, newPartLabel) );
95 _hbox = YUI::widgetFactory()->createHBox( _vbox );
97 _freeSizeSlider =
new YQSlider( _hbox, freeFieldLabel,
98 minFreeSize, maxFreeSize(), freeSize,
100 YUI_CHECK_PTR( _freeSizeSlider );
101 _freeSizeSlider->setStretchable( YD_HORIZ,
true );
103 _newPartField =
new YQIntField( _hbox, newPartFieldLabel,
104 minNewSize, maxNewPartSize(), newPartSize );
105 YUI_CHECK_PTR( _newPartField );
106 _newPartField->setStretchable( YD_HORIZ,
false );
111 connect( _newPartField, &pclass(_newPartField)::valueChanged,
114 connect( _freeSizeSlider, &pclass(_freeSizeSlider)::valueChanged,
130 YWidget::setEnabled( enabled );
136 return _vbox->preferredWidth();
142 return _vbox->preferredHeight();
148 QWidget::resize( newWidth, newHeight );
149 _vbox->setSize ( newWidth, newHeight );
155 YUI_CHECK_PTR( _newPartField );
157 return _newPartField->
value();
163 YUI_CHECK_PTR( _barGraph );
164 YUI_CHECK_PTR( _freeSizeSlider );
165 YUI_CHECK_PTR( _newPartField );
171 _newPartField->setValue( newValue );
173 int freeSize = totalFreeSize() - newValue;
174 _freeSizeSlider->setValue( freeSize );
176 YBarGraphMultiUpdate multiUpdate( _barGraph );
178 _barGraph->setValue( freeSegment, freeSize );
179 _barGraph->setValue( newPartSegment, newValue );
186 int newPartSize = totalFreeSize() - newFreeSize;
virtual void setEnabled(bool enabled)
Sets the widget's enabled state.
virtual int value()
Get the current value (the number entered by the user or set from the outside) of this IntField.
virtual bool setKeyboardFocus()
Accept the keyboard focus.
virtual bool setKeyboardFocus()
Accept the keyboard focus.
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
virtual void setSize(int newWidth, int newHeight)
Set the new size of the widget.
void setFreeSizeSlot(int newFreeSize)
Slot for setting the free size.
YQPartitionSplitter(YWidget *parent, int usedSize, int freeSize, int newPartSize, int minNewPartSize, int minFreeSize, const std::string &usedLabel, const std::string &freeLabel, const std::string &newPartLabel, const std::string &freeFieldLabel, const std::string &newPartFieldLabel)
Constructor.
virtual int value()
Return the value (the size of the new partition).
void setNewPartSizeSlot(int newNewSize)
Slot for setting the new size.
~YQPartitionSplitter()
Destructor.
virtual void setValue(int newValue)
Set the value (the size of the new partition).
virtual int preferredHeight()
Preferred height of the widget.
virtual int preferredWidth()
Preferred width of the widget.
Helper class to block Qt signals for QWidgets or QObjects as long as this object exists.
virtual void setEnabled(bool enabled)
Set enabled/disabled state.
static YQUI * ui()
Access the global Qt-UI.
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...