| 387 | } |
| 388 | |
| 389 | void CWizNoteStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, |
| 390 | const QWidget *w) const |
| 391 | { |
| 392 | switch (pe) |
| 393 | { |
| 394 | case PE_IndicatorBranch: |
| 395 | // 目录树指示箭头绘制 |
| 396 | { |
| 397 | if (const WizCategoryBaseView *view = dynamic_cast<const WizCategoryBaseView *>(w)) |
| 398 | { |
| 399 | if (!view->isCursorEntered()) |
| 400 | return; |
| 401 | |
| 402 | if (opt->state & QStyle::State_Children) { |
| 403 | bool bExpanded = (opt->state & QStyle::State_Open) ? true : false; |
| 404 | // 改变图标尺寸和位置 |
| 405 | QRect rectIcon = opt->rect; |
| 406 | // 调整 brach 图标偏移量 |
| 407 | rectIcon.adjust(0, 0, 0, 0); |
| 408 | // |
| 409 | if ((opt->state & QStyle::State_Selected)) { //(opt->state & State_HasFocus) |
| 410 | //drawcenterImage(p, bExpanded ? m_expandedImageSelected : m_collapsedImageSelected, opt->rect.adjusted(8, 0, 0, 0)); |
| 411 | drawcenterImage(p, bExpanded ? m_expandedImageSelected : m_collapsedImageSelected, rectIcon); |
| 412 | } else { |
| 413 | //drawcenterImage(p, bExpanded ? m_expandedImage : m_collapsedImage, opt->rect.adjusted(8, 0, 0, 0)); |
| 414 | drawcenterImage(p, bExpanded ? m_expandedImage : m_collapsedImage, rectIcon); |
| 415 | } |
| 416 | } |
| 417 | return; |
| 418 | } |
| 419 | } |
| 420 | break; |
| 421 | case PE_IndicatorItemViewItemDrop: |
| 422 | { |
| 423 | if (const WizCategoryBaseView *view = dynamic_cast<const WizCategoryBaseView *>(w)) |
| 424 | { |
| 425 | if (!(view->dragItemFlags() & Qt::ItemIsDropEnabled)) |
| 426 | return; |
| 427 | |
| 428 | p->setRenderHint(QPainter::Antialiasing, true); |
| 429 | |
| 430 | QPen pen; |
| 431 | pen.setStyle(Qt::SolidLine); |
| 432 | // pen.setCapStyle(Qt::RoundCap); |
| 433 | pen.setColor(QColor("#3498DB")); |
| 434 | pen.setWidth(1); |
| 435 | p->setPen(pen); |
| 436 | p->setBrush(Qt::NoBrush); |
| 437 | if(opt->rect.height() == 0) |
| 438 | { |
| 439 | p->drawEllipse(opt->rect.topLeft(), 3, 3); |
| 440 | p->drawLine(QPoint(opt->rect.topLeft().x()+3, opt->rect.topLeft().y()), opt->rect.topRight()); |
| 441 | } else { |
| 442 | p->drawRect(opt->rect); |
| 443 | } |
| 444 | return; |
| 445 | } |
| 446 | } |
no test coverage detected