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"
47 const std::string & usedLabel,
48 const std::string & freeLabel,
49 const std::string & newPartLabel,
50 const std::string & freeFieldLabel,
51 const std::string & newPartFieldLabel )
52 : QWidget( (QWidget *) parent->widgetRep() )
53 , YPartitionSplitter( parent,
67 , _freeSizeSlider( 0 )
73 setChildrenManager(
new YSingleWidgetChildManager(
this ) );
79 _vbox = YUI::widgetFactory()->createVBox(
this );
80 _barGraph =
dynamic_cast<YQBarGraph *
> ( YUI::optionalWidgetFactory()->createBarGraph( _vbox ) );
81 YUI_CHECK_PTR( _barGraph );
83 int freeSize = totalFreeSize - newPartSize;
86 YBarGraphMultiUpdate multiUpdate( _barGraph );
88 _barGraph->addSegment( YBarGraphSegment( usedSize, usedLabel ) );
89 _barGraph->addSegment( YBarGraphSegment( freeSize, freeLabel ) );
90 _barGraph->addSegment( YBarGraphSegment( newPartSize, newPartLabel) );
93 _hbox = YUI::widgetFactory()->createHBox( _vbox );
95 _freeSizeSlider =
new YQSlider( _hbox, freeFieldLabel,
96 minFreeSize, maxFreeSize(), freeSize,
98 YUI_CHECK_PTR( _freeSizeSlider );
99 _freeSizeSlider->setStretchable( YD_HORIZ,
true );
101 _newPartField =
new YQIntField( _hbox, newPartFieldLabel,
102 minNewSize, maxNewPartSize(), newPartSize );
103 YUI_CHECK_PTR( _newPartField );
104 _newPartField->setStretchable( YD_HORIZ,
false );
109 connect( _newPartField, &pclass(_newPartField)::valueChanged,
112 connect( _freeSizeSlider, &pclass(_freeSizeSlider)::valueChanged,
128 YWidget::setEnabled( enabled );
134 return _vbox->preferredWidth();
140 return _vbox->preferredHeight();
146 QWidget::resize( newWidth, newHeight );
147 _vbox->setSize ( newWidth, newHeight );
153 YUI_CHECK_PTR( _newPartField );
155 return _newPartField->
value();
161 YUI_CHECK_PTR( _barGraph );
162 YUI_CHECK_PTR( _freeSizeSlider );
163 YUI_CHECK_PTR( _newPartField );
169 _newPartField->setValue( newValue );
171 int freeSize = totalFreeSize() - newValue;
172 _freeSizeSlider->setValue( freeSize );
174 YBarGraphMultiUpdate multiUpdate( _barGraph );
176 _barGraph->setValue( freeSegment, freeSize );
177 _barGraph->setValue( newPartSegment, newValue );
184 int newPartSize = totalFreeSize() - newFreeSize;
210 #include "YQPartitionSplitter.moc"
Helper class to block Qt signals for QWidgets or QObjects as long as this object exists.
void setNewPartSizeSlot(int newNewSize)
Slot for setting the new size.
virtual int value()
Return the value (the size of the new partition).
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.
~YQPartitionSplitter()
Destructor.
virtual int value()
Get the current value (the number entered by the user or set from the outside) of this IntField...
virtual void setValue(int newValue)
Set the value (the size of the new partition).
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
virtual void setEnabled(bool enabled)
Sets the widget's enabled state.
void setFreeSizeSlot(int newFreeSize)
Slot for setting the free size.
virtual int preferredHeight()
Preferred height of the widget.
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 void setEnabled(bool enabled)
Set enabled/disabled state.
virtual int preferredWidth()
Preferred width of the widget.
static YQUI * ui()
Access the global Qt-UI.