squawk/ui/widgets/settings/settingslist.cpp

39 lines
754 B
C++

#include "settingslist.h"
SettingsList::SettingsList(QWidget* parent):
QListWidget(parent),
lastWidth(0)
{
}
SettingsList::~SettingsList()
{
}
QStyleOptionViewItem SettingsList::viewOptions() const
{
QStyleOptionViewItem option = QListWidget::viewOptions();
if (!iconSize().isValid()) {
option.decorationSize.setWidth(lastWidth);
}
option.rect.setWidth(lastWidth);
return option;
}
void SettingsList::resizeEvent(QResizeEvent* event)
{
lastWidth = event->size().width();
QListWidget::resizeEvent(event);
}
QRect SettingsList::visualRect(const QModelIndex& index) const
{
QRect res = QListWidget::visualRect(index);
if (index.isValid()) {
res.setWidth(lastWidth);
}
return res;
}