55 setEditTriggers(QAbstractItemView::NoEditTriggers);
60 setFrameShape(QFrame::StyledPanel);
61 setFrameShadow(QFrame::Raised);
68 setMinimumHeight(300);
70 verticalScrollBar()->setPageStep(3);
71 verticalScrollBar()->setSingleStep(1);
73 model_ =
new QStandardItemModel(
this);
112 QModelIndex top = model_->index(index, 0, QModelIndex());
113 QModelIndex bottom = model_->index(index, 0, QModelIndex());
115 QItemSelection selection(top, bottom);
116 selectionModel()->reset();
117 selectionModel()->select(selection, QItemSelectionModel::Select);
138void NavDelegate::paint(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index)
const
140 const bool is_selected = option.state & QStyle::State_Selected;
141 const QPalette& palette = QApplication::palette();
143 QString nav_name = displayText(index.data(), option.locale);
148 QLinearGradient background_gradient(option.rect.topLeft(), option.rect.bottomLeft());
151 background_gradient.setColorAt(0, palette.color(QPalette::Highlight).lighter(125));
152 background_gradient.setColorAt(1, palette.color(QPalette::Highlight));
153 painter->fillRect(option.rect, QBrush(background_gradient));
157 background_gradient.setColorAt(0, palette.color(QPalette::Light));
158 background_gradient.setColorAt(1, palette.color(QPalette::Light).darker(105));
159 painter->fillRect(option.rect, QBrush(background_gradient));
164 painter->setPen(palette.color(QPalette::Button));
165 painter->drawLine(option.rect.topLeft(), option.rect.topRight());
166 painter->setPen(palette.color(QPalette::Light));
167 const QPoint offset(0, 1);
168 painter->drawLine(option.rect.topLeft() + offset, option.rect.topRight() + offset);
171 QRect text_rect(option.rect.x() + 10, option.rect.y(), option.rect.width() - 10, option.rect.height());
172 QFont text_font(painter->font());
173 text_font.setPixelSize(14);
174 painter->setFont(text_font);
179 painter->setPen(palette.color(QPalette::HighlightedText));
181 else if (!option.state.testFlag(QStyle::State_Enabled))
183 painter->setPen(palette.color(QPalette::Dark));
187 painter->setPen(palette.color(QPalette::ButtonText));
190 painter->drawText(text_rect, Qt::AlignLeft | Qt::AlignVCenter, nav_name);