29 #include <QListWidgetItem>
30 #include <QPushButton>
31 #include <QToolButton>
34 #include "core/common/WLogger.h"
35 #include "core/common/WPropertyVariable.h"
36 #include "core/common/WItemSelector.h"
37 #include "core/common/WItemSelection.h"
39 #include "../WGuiConsts.h"
40 #include "../WQtGui.h"
41 #include "../WMainWindow.h"
43 #include "WPropertySelectionWidget.h"
52 QPixmap ensureSize( QPixmap pix )
55 int maxW = WMIN_WIDGET_HEIGHT;
56 int maxH = WMIN_WIDGET_HEIGHT;
58 if( ( pix.width() > maxW ) || ( pix.height() > maxH ) )
60 return pix.scaled( maxW, maxH, Qt::KeepAspectRatio );
69 m_selectionProperty( property ),
70 m_layout( &m_parameterWidgets ),
76 m_layout.setMargin( WGLOBAL_MARGIN );
77 m_layout.setSpacing( WGLOBAL_SPACING );
84 m_combo->setMinimumHeight( WMIN_WIDGET_HEIGHT );
95 m_list->setSelectionMode( QAbstractItemView::ExtendedSelection );
101 QToolButton* selAllButton =
new QToolButton(
this );
103 connect( act, SIGNAL( triggered(
bool ) ),
m_list, SLOT( selectAll() ) );
104 selAllButton->setDefaultAction( act );
105 selAllButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
106 selAllButton->setMinimumHeight( WMIN_WIDGET_HEIGHT );
107 selAllButton->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) );
109 m_layout.addWidget( selAllButton, 1, 0 );
117 if(
m_property->getPurpose() == PV_PURPOSE_INFORMATION )
123 m_list->setEnabled(
false );
166 for(
size_t i = 0; i < sValid.
sizeAll(); ++i )
168 m_combo->addItem( QString::fromStdString( sValid.
atAll( i )->getName() ) );
170 if( sValid.
atAll( i )->getIcon() )
173 QPixmap pix = ensureSize( QPixmap( sValid.
atAll( i )->getIcon() ) );
176 m_combo->setItemIcon( i, QIcon( pix ) );
177 m_combo->setIconSize( QSize( pix.width(), pix.height() ) );
182 if( sValid.
size() == 0 )
184 m_combo->setCurrentIndex( -1 );
198 int scrollPosition =
m_list->verticalScrollBar()->sliderPosition();
204 for(
size_t i = 0; i < sValid.
sizeAll(); ++i )
207 QWidget* widget =
new QWidget(
m_list );
208 QHBoxLayout* layoutWidget =
new QHBoxLayout();
209 layoutWidget->setContentsMargins( 5, 0, 0, 0 );
210 layoutWidget->setSpacing( 0 );
211 layoutWidget->setSizeConstraint( QLayout::SetMaximumSize );
212 widget->setLayout( layoutWidget );
214 QWidget* innerWidget =
new QWidget( widget );
215 QVBoxLayout* layoutInnerWidget =
new QVBoxLayout();
216 layoutInnerWidget->setContentsMargins( 5, 0, 0, 0 );
217 layoutInnerWidget->setSpacing( 0 );
218 layoutInnerWidget->setSizeConstraint( QLayout::SetMaximumSize );
219 innerWidget->setLayout( layoutInnerWidget );
222 if( sValid.
atAll( i )->getIcon() )
224 QLabel* icon =
new QLabel();
225 QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
226 icon->setSizePolicy( sizePolicy );
227 icon->setPixmap( ensureSize( QPixmap( sValid.
atAll( i )->getIcon() ) ) );
228 layoutWidget->addWidget( icon );
232 layoutInnerWidget->addWidget(
new QLabel(
"<b>" + QString::fromStdString( sValid.
atAll( i )->getName() )+
"</b>" ) );
234 if( !sValid.
atAll( i )->getDescription().empty() )
236 layoutInnerWidget->addWidget(
new QLabel( QString::fromStdString( sValid.
atAll( i )->getDescription() ) ) );
239 layoutWidget->addWidget( innerWidget );
243 item->setSizeHint( widget->sizeHint() );
245 m_list->setItemWidget( item, widget );
246 m_list->setMinimumHeight( widget->height() * 3.5 );
250 for(
size_t i = 0; i < sValid.
size(); ++i )
255 m_list->verticalScrollBar()->setSliderPosition( scrollPosition );
267 l.push_back( index );
289 for(
int i = 0; i <
m_list->count(); ++i )
291 if(
m_list->item( i )->isSelected() )
This class represents a subset of a WItemSelection.
std::vector< size_t > IndexList
The type used for storing index lists.
virtual size_t size() const
The number of selected items.
virtual size_t sizeAll() const
Gives the count of elements in the set of selectable items.
virtual const std::shared_ptr< WItemSelectionItem > atAll(size_t index) const
Gets the item with the given index from the WItemSelection.
void lock()
Read locks the underlying selection.
virtual size_t getItemIndexOfSelected(size_t index) const
Helps to get the index of an selected item in the WItemSelection.
static WMainWindow * getMainWindow()
Returns the current main window instance or NULL if not existent.