comparison src/gui/sidebar.cpp @ 15:cde8f67a7c7d

*: update, megacommit :)
author Paper <mrpapersonic@gmail.com>
date Tue, 19 Sep 2023 22:36:08 -0400
parents fc1bf97c528b
children 2743011a6042
comparison
equal deleted inserted replaced
14:a29c9402faf0 15:cde8f67a7c7d
14 setSelectionBehavior(QAbstractItemView::SelectItems); 14 setSelectionBehavior(QAbstractItemView::SelectItems);
15 setMouseTracking(true); 15 setMouseTracking(true);
16 viewport()->setAutoFillBackground(false); 16 viewport()->setAutoFillBackground(false);
17 setStyleSheet("font-size: 12px"); 17 setStyleSheet("font-size: 12px");
18 connect(this, &QListWidget::currentRowChanged, this, 18 connect(this, &QListWidget::currentRowChanged, this,
19 [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); }); 19 [this](int index) { emit CurrentItemChanged(RemoveSeparatorsFromIndex(index)); });
20 } 20 }
21 21
22 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) { 22 QListWidgetItem* SideBar::AddItem(QString name, QIcon icon) {
23 QListWidgetItem* item = new QListWidgetItem(this); 23 QListWidgetItem* item = new QListWidgetItem(this);
24 item->setText(name); 24 item->setText(name);
59 59
60 bool SideBar::IndexIsSeparator(QModelIndex index) const { 60 bool SideBar::IndexIsSeparator(QModelIndex index) const {
61 return !(index.isValid() && index.flags() & Qt::ItemIsEnabled); 61 return !(index.isValid() && index.flags() & Qt::ItemIsEnabled);
62 } 62 }
63 63
64 QItemSelectionModel::SelectionFlags SideBar::selectionCommand(const QModelIndex& index, const QEvent*) const { 64 QItemSelectionModel::SelectionFlags SideBar::selectionCommand(const QModelIndex& index,
65 const QEvent*) const {
65 if (IndexIsSeparator(index)) 66 if (IndexIsSeparator(index))
66 return QItemSelectionModel::NoUpdate; 67 return QItemSelectionModel::NoUpdate;
67 return QItemSelectionModel::ClearAndSelect; 68 return QItemSelectionModel::ClearAndSelect;
68 } 69 }
69 70