| 106 | } |
| 107 | |
| 108 | void ElaFooterDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const |
| 109 | { |
| 110 | ElaFooterModel* model = dynamic_cast<ElaFooterModel*>(const_cast<QAbstractItemModel*>(index.model())); |
| 111 | ElaNavigationNode* node = index.data(Qt::UserRole).value<ElaNavigationNode*>(); |
| 112 | // 背景绘制 |
| 113 | QRect itemRect = option.rect; |
| 114 | painter->save(); |
| 115 | painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); |
| 116 | itemRect.setTop(itemRect.top() + 2); |
| 117 | itemRect.setBottom(itemRect.bottom() - 2); |
| 118 | QPainterPath path; |
| 119 | path.addRoundedRect(itemRect, 8, 8); |
| 120 | if (option.state & QStyle::State_Selected) |
| 121 | { |
| 122 | if (index == _pPressIndex) |
| 123 | { |
| 124 | // 选中时点击 |
| 125 | painter->fillPath(path, ElaThemeColor(_themeMode, BasicHoverAlpha)); |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | if (option.state & QStyle::State_MouseOver) |
| 130 | { |
| 131 | // 选中时覆盖 |
| 132 | painter->fillPath(path, ElaThemeColor(_themeMode, BasicSelectedHoverAlpha)); |
| 133 | } |
| 134 | else |
| 135 | { |
| 136 | // 选中 |
| 137 | painter->fillPath(path, ElaThemeColor(_themeMode, BasicSelectedAlpha)); |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | else |
| 142 | { |
| 143 | if (index == _pPressIndex) |
| 144 | { |
| 145 | // 点击时颜色 |
| 146 | painter->fillPath(path, ElaThemeColor(_themeMode, BasicPressAlpha)); |
| 147 | } |
| 148 | else |
| 149 | { |
| 150 | if (option.state & QStyle::State_MouseOver) |
| 151 | { |
| 152 | // 覆盖时颜色 |
| 153 | painter->fillPath(path, ElaThemeColor(_themeMode, BasicHoverAlpha)); |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | painter->restore(); |
| 158 | |
| 159 | painter->save(); |
| 160 | painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); |
| 161 | itemRect = option.rect; |
| 162 | |
| 163 | //顶边线绘制 |
| 164 | if (index.row() == 0) |
| 165 | { |
no test coverage detected