/
waterstone
/
TaskList_Demo
Обзор
Документация
Войти
/
waterstone
/
TaskList_Demo
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
QPixmapCache
src/tasklist_action_cell_delegate.cpp
54 строки
2 KB
Peter Sakhno
Initial commit
15 янв 2026, 14:24
15 янв 2026, 14:24
ac4daae
Код
Авторство
О чём код?
#include "tasklist_action_cell_delegate.h" #include <QStyle> #include <QApplication> #include "tasklist_main_view.h" #include "tasklist_table_model.h" void TaskListActionCellDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { if (!m_template_button) { TaskListMainViewQP mainview; for (auto w : qApp->topLevelWidgets()) { mainview = qobject_cast<TaskListMainView*>(w); if (mainview) break; } if (mainview) { m_template_button = new QPushButton(mainview); m_template_button->hide(); m_template_button->lower(); } } QStyleOptionButton button; if (m_template_button) button.initFrom(m_template_button); button.rect = option.rect.adjusted(2, 2, -2, -2); button.text = index.data().toString(); button.state = option.state; if (m_mouse_pressed_index.isValid() && index == m_mouse_pressed_index) button.state |= QStyle::State_Sunken; QApplication::style()->drawControl(QStyle::CE_PushButton, &button, painter, m_template_button); } bool TaskListActionCellDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index) { if (event != nullptr) { if (QEvent::MouseButtonPress == event->type()) m_mouse_pressed_index = index; else if (QEvent::MouseButtonRelease == event->type()) { if (m_mouse_pressed_index.isValid()) m_mouse_pressed_index = {}; } } return QStyledItemDelegate::editorEvent(event, model, option, index); }