File indexing completed on 2024-12-15 04:03:31
0001 0002 /* 0003 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org> 0004 All rights reserved. 0005 0006 Redistribution and use in source and binary forms, with or without 0007 modification, are permitted provided that the following conditions 0008 are met: 0009 0010 1. Redistributions of source code must retain the above copyright 0011 notice, this list of conditions and the following disclaimer. 0012 2. Redistributions in binary form must reproduce the above copyright 0013 notice, this list of conditions and the following disclaimer in the 0014 documentation and/or other materials provided with the distribution. 0015 0016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 0028 0029 #define DEBUG_KP_TOOL_WIDGET_BASE 0 0030 0031 0032 #include "kpToolWidgetBase.h" 0033 0034 #include "kpDefs.h" 0035 0036 #include <KConfig> 0037 #include <KConfigGroup> 0038 #include <KSharedConfig> 0039 #include "kpLogCategories.h" 0040 0041 #include <QEvent> 0042 #include <QHelpEvent> 0043 #include <QPainter> 0044 #include <QPixmap> 0045 #include <QToolTip> 0046 0047 0048 //--------------------------------------------------------------------- 0049 0050 kpToolWidgetBase::kpToolWidgetBase (QWidget *parent, const QString &name) 0051 : QFrame(parent), m_baseWidget(nullptr), 0052 m_selectedRow(-1), m_selectedCol(-1) 0053 { 0054 setObjectName (name); 0055 0056 setFrameStyle (QFrame::Panel | QFrame::Sunken); 0057 0058 setFixedSize (44, 66); 0059 setSizePolicy (QSizePolicy::Minimum, QSizePolicy::Minimum); 0060 } 0061 0062 //--------------------------------------------------------------------- 0063 0064 kpToolWidgetBase::~kpToolWidgetBase () = default; 0065 0066 //--------------------------------------------------------------------- 0067 0068 // public 0069 void kpToolWidgetBase::addOption (const QPixmap &pixmap, const QString &toolTip) 0070 { 0071 if (m_pixmaps.isEmpty ()) { 0072 startNewOptionRow (); 0073 } 0074 0075 m_pixmaps.last ().append (pixmap); 0076 m_pixmapRects.last ().append (QRect ()); 0077 m_toolTips.last ().append (toolTip); 0078 } 0079 0080 //--------------------------------------------------------------------- 0081 0082 // public 0083 void kpToolWidgetBase::startNewOptionRow () 0084 { 0085 m_pixmaps.append (QList <QPixmap> ()); 0086 m_pixmapRects.append (QList <QRect> ()); 0087 m_toolTips.append (QList <QString> ()); 0088 } 0089 0090 //--------------------------------------------------------------------- 0091 0092 // public 0093 void kpToolWidgetBase::finishConstruction (int fallBackRow, int fallBackCol) 0094 { 0095 #if DEBUG_KP_TOOL_WIDGET_BASE 0096 qCDebug(kpLogWidgets) << "kpToolWidgetBase(" << objectName () 0097 << ")::kpToolWidgetBase(fallBack:row=" << fallBackRow 0098 << ",col=" << fallBackCol 0099 << ")"; 0100 #endif 0101 0102 relayoutOptions (); 0103 0104 // HACK: Undo the maximum half of setFixedSize() in the ctor to avoid 0105 // bizarre redraw errors when tool widgets are hidden and others 0106 // are shown. 0107 // 0108 // The reason why we didn't just use setMinimumSize() in the ctor is 0109 // because all tool widgets construct pixmaps whose sizes are dependent 0110 // on the size() in the ctor, so we needed to get the correct size 0111 // in there. This is bad design because it means that tool widgets 0112 // can't really be resized. 0113 setMaximumSize (QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); 0114 0115 const QPair <int, int> rowColPair = defaultSelectedRowAndCol (); 0116 if (!setSelected (rowColPair.first, rowColPair.second, false/*don't save*/)) 0117 { 0118 if (!setSelected (fallBackRow, fallBackCol)) 0119 { 0120 if (!setSelected (0, 0)) 0121 { 0122 qCCritical(kpLogWidgets) << "kpToolWidgetBase::finishConstruction() " 0123 "can't even fall back to setSelected(row=0,col=0)"; 0124 } 0125 } 0126 } 0127 } 0128 0129 //--------------------------------------------------------------------- 0130 0131 // private 0132 QList <int> kpToolWidgetBase::spreadOutElements (const QList <int> &sizes, int max) 0133 { 0134 if (sizes.count () == 0) { 0135 return {}; 0136 } 0137 0138 if (sizes.count () == 1) 0139 { 0140 QList <int> ret; 0141 ret.append (sizes.first () > max ? 0 : 1/*margin*/); 0142 return ret; 0143 } 0144 0145 QList <int> retOffsets; 0146 for (int i = 0; i < sizes.count (); i++) { 0147 retOffsets.append (0); 0148 } 0149 0150 int totalSize = 0; 0151 for (int i = 0; i < sizes.count (); i++) { 0152 totalSize += sizes [i]; 0153 } 0154 0155 int margin = 1; 0156 0157 // if don't fit with margin, then just return elements 0158 // packed right next to each other 0159 if (totalSize + margin * 2 > max) 0160 { 0161 retOffsets [0] = 0; 0162 for (int i = 1; i < sizes.count (); i++) { 0163 retOffsets [i] = retOffsets [i - 1] + sizes [i - 1]; 0164 } 0165 0166 return retOffsets; 0167 } 0168 0169 int maxLeftOver = max - (totalSize + margin * 2 * sizes.count()); 0170 0171 int startCompensating = -1; 0172 int numCompensate = 0; 0173 0174 int spacing = 0; 0175 0176 spacing = maxLeftOver / (sizes.count () - 1); 0177 if (spacing * int (sizes.count () - 1) < maxLeftOver) 0178 { 0179 numCompensate = maxLeftOver - spacing * (sizes.count () - 1); 0180 startCompensating = ((sizes.count () - 1) - numCompensate) / 2; 0181 } 0182 0183 retOffsets [0] = margin; 0184 for (int i = 1; i < sizes.count (); i++) 0185 { 0186 retOffsets [i] += retOffsets [i - 1] + 0187 sizes [i - 1] + 0188 spacing + 0189 ((numCompensate && 0190 i >= startCompensating && 0191 i < startCompensating + numCompensate) ? 1 : 0); 0192 } 0193 0194 return retOffsets; 0195 } 0196 0197 //--------------------------------------------------------------------- 0198 0199 // public 0200 QPair <int, int> kpToolWidgetBase::defaultSelectedRowAndCol () const 0201 { 0202 int row = -1, col = -1; 0203 0204 if (!objectName ().isEmpty ()) 0205 { 0206 KConfigGroup cfg (KSharedConfig::openConfig (), QStringLiteral(kpSettingsGroupTools)); 0207 0208 row = cfg.readEntry (objectName () + QLatin1String (" Row"), -1); 0209 col = cfg.readEntry (objectName () + QLatin1String (" Col"), -1); 0210 } 0211 0212 #if DEBUG_KP_TOOL_WIDGET_BASE 0213 qCDebug(kpLogWidgets) << "kpToolWidgetBase(" << objectName () 0214 << ")::defaultSelectedRowAndCol() returning row=" << row 0215 << " col=" << col; 0216 #endif 0217 0218 return qMakePair (row, col); 0219 } 0220 0221 //--------------------------------------------------------------------- 0222 0223 // public 0224 int kpToolWidgetBase::defaultSelectedRow () const 0225 { 0226 return defaultSelectedRowAndCol ().first; 0227 } 0228 0229 //--------------------------------------------------------------------- 0230 0231 // public 0232 int kpToolWidgetBase::defaultSelectedCol () const 0233 { 0234 return defaultSelectedRowAndCol ().second; 0235 } 0236 0237 //--------------------------------------------------------------------- 0238 0239 // public 0240 void kpToolWidgetBase::saveSelectedAsDefault () const 0241 { 0242 #if DEBUG_KP_TOOL_WIDGET_BASE 0243 qCDebug(kpLogWidgets) << "kpToolWidgetBase(" << objectName () 0244 << ")::saveSelectedAsDefault() row=" << m_selectedRow 0245 << " col=" << m_selectedCol; 0246 #endif 0247 0248 if (objectName ().isEmpty ()) { 0249 return; 0250 } 0251 0252 KConfigGroup cfg (KSharedConfig::openConfig (), QStringLiteral(kpSettingsGroupTools)); 0253 0254 cfg.writeEntry (objectName () + QLatin1String (" Row"), m_selectedRow); 0255 cfg.writeEntry (objectName () + QLatin1String (" Col"), m_selectedCol); 0256 cfg.sync (); 0257 } 0258 0259 //--------------------------------------------------------------------- 0260 0261 // public 0262 void kpToolWidgetBase::relayoutOptions () 0263 { 0264 #if DEBUG_KP_TOOL_WIDGET_BASE 0265 qCDebug(kpLogWidgets) << "kpToolWidgetBase::relayoutOptions() size=" << size (); 0266 #endif 0267 0268 while (!m_pixmaps.isEmpty () && m_pixmaps.last ().count () == 0) 0269 { 0270 #if DEBUG_KP_TOOL_WIDGET_BASE 0271 qCDebug(kpLogWidgets) << "\tkilling #" << m_pixmaps.count () - 1; 0272 #endif 0273 m_pixmaps.removeLast (); 0274 m_pixmapRects.removeLast (); 0275 m_toolTips.removeLast (); 0276 } 0277 0278 if (m_pixmaps.isEmpty ()) { 0279 return; 0280 } 0281 0282 #if DEBUG_KP_TOOL_WIDGET_BASE 0283 qCDebug(kpLogWidgets) << "\tsurvived killing of empty rows"; 0284 qCDebug(kpLogWidgets) << "\tfinding heights of rows:"; 0285 #endif 0286 0287 QList <int> maxHeightOfRow; 0288 for (int r = 0; r < m_pixmaps.count (); r++) { 0289 maxHeightOfRow.append (0); 0290 } 0291 0292 for (int r = 0; r < m_pixmaps.count (); r++) 0293 { 0294 for (int c = 0; c < m_pixmaps [r].count (); c++) 0295 { 0296 if (c == 0 || m_pixmaps [r][c].height () > maxHeightOfRow [r]) { 0297 maxHeightOfRow [r] = m_pixmaps [r][c].height (); 0298 } 0299 } 0300 #if DEBUG_KP_TOOL_WIDGET_BASE 0301 qCDebug(kpLogWidgets) << "\t\t" << r << ": " << maxHeightOfRow [r]; 0302 #endif 0303 } 0304 0305 QList <int> rowYOffset = spreadOutElements (maxHeightOfRow, height ()); 0306 #if DEBUG_KP_TOOL_WIDGET_BASE 0307 qCDebug(kpLogWidgets) << "\tspread out offsets of rows:"; 0308 for (int r = 0; r < (int) rowYOffset.count (); r++) { 0309 qCDebug(kpLogWidgets) << "\t\t" << r << ": " << rowYOffset [r]; 0310 } 0311 #endif 0312 0313 for (int r = 0; r < m_pixmaps.count (); r++) 0314 { 0315 #if DEBUG_KP_TOOL_WIDGET_BASE 0316 qCDebug(kpLogWidgets) << "\tlaying out row " << r << ":"; 0317 #endif 0318 0319 QList <int> widths; 0320 for (int c = 0; c < m_pixmaps [r].count (); c++) 0321 widths.append (m_pixmaps [r][c].width ()); 0322 #if DEBUG_KP_TOOL_WIDGET_BASE 0323 qCDebug(kpLogWidgets) << "\t\twidths of cols:"; 0324 for (int c = 0; c < m_pixmaps [r].count (); c++) { 0325 qCDebug(kpLogWidgets) << "\t\t\t" << c << ": " << widths [c]; 0326 } 0327 #endif 0328 0329 QList <int> colXOffset = spreadOutElements (widths, width ()); 0330 #if DEBUG_KP_TOOL_WIDGET_BASE 0331 qCDebug(kpLogWidgets) << "\t\tspread out offsets of cols:"; 0332 for (int c = 0; c < colXOffset.count (); c++) { 0333 qCDebug(kpLogWidgets) << "\t\t\t" << c << ": " << colXOffset [c]; 0334 } 0335 #endif 0336 0337 for (int c = 0; c < colXOffset.count (); c++) 0338 { 0339 int x = colXOffset [c]; 0340 int y = rowYOffset [r]; 0341 int w, h; 0342 0343 if (c == colXOffset.count () - 1) 0344 { 0345 if (x + m_pixmaps [r][c].width () >= width ()) { 0346 w = m_pixmaps [r][c].width (); 0347 } 0348 else { 0349 w = width () - 1 - x; 0350 } 0351 } 0352 else { 0353 w = colXOffset [c + 1] - x; 0354 } 0355 0356 if (r == m_pixmaps.count () - 1) 0357 { 0358 if (y + m_pixmaps [r][c].height () >= height ()) { 0359 h = m_pixmaps [r][c].height (); 0360 } 0361 else { 0362 h = height () - 1 - y; 0363 } 0364 } 0365 else { 0366 h = rowYOffset [r + 1] - y; 0367 } 0368 0369 m_pixmapRects [r][c] = QRect (x, y, w, h); 0370 } 0371 } 0372 0373 update (); 0374 } 0375 0376 //--------------------------------------------------------------------- 0377 0378 0379 // public 0380 int kpToolWidgetBase::selectedRow () const 0381 { 0382 return m_selectedRow; 0383 } 0384 0385 //--------------------------------------------------------------------- 0386 0387 // public 0388 int kpToolWidgetBase::selectedCol () const 0389 { 0390 return m_selectedCol; 0391 } 0392 0393 //--------------------------------------------------------------------- 0394 0395 // public 0396 int kpToolWidgetBase::selected () const 0397 { 0398 if (m_selectedRow < 0 || 0399 m_selectedRow >= m_pixmaps.count () || 0400 m_selectedCol < 0) 0401 { 0402 return -1; 0403 } 0404 0405 int upto = 0; 0406 for (int y = 0; y < m_selectedRow; y++) { 0407 upto += m_pixmaps [y].count (); 0408 } 0409 0410 if (m_selectedCol >= m_pixmaps [m_selectedRow].count ()) { 0411 return -1; 0412 } 0413 0414 upto += m_selectedCol; 0415 0416 return upto; 0417 } 0418 0419 //--------------------------------------------------------------------- 0420 0421 0422 // public 0423 bool kpToolWidgetBase::hasPreviousOption (int *row, int *col) const 0424 { 0425 #if DEBUG_KP_TOOL_WIDGET_BASE 0426 qCDebug(kpLogWidgets) << "kpToolWidgetBase(" << objectName () 0427 << ")::hasPreviousOption() current row=" << m_selectedRow 0428 << " col=" << m_selectedCol; 0429 #endif 0430 if (row) { 0431 *row = -1; 0432 } 0433 if (col) { 0434 *col = -1; 0435 } 0436 0437 0438 if (m_selectedRow < 0 || m_selectedCol < 0) { 0439 return false; 0440 } 0441 0442 int newRow = m_selectedRow, 0443 newCol = m_selectedCol; 0444 0445 newCol--; 0446 if (newCol < 0) 0447 { 0448 newRow--; 0449 if (newRow < 0) { 0450 return false; 0451 } 0452 0453 newCol = m_pixmaps [newRow].count () - 1; 0454 if (newCol < 0) { 0455 return false; 0456 } 0457 } 0458 0459 0460 if (row) { 0461 *row = newRow; 0462 } 0463 if (col) { 0464 *col = newCol; 0465 } 0466 0467 return true; 0468 } 0469 0470 //--------------------------------------------------------------------- 0471 0472 // public 0473 bool kpToolWidgetBase::hasNextOption (int *row, int *col) const 0474 { 0475 #if DEBUG_KP_TOOL_WIDGET_BASE 0476 qCDebug(kpLogWidgets) << "kpToolWidgetBase(" << objectName () 0477 << ")::hasNextOption() current row=" << m_selectedRow 0478 << " col=" << m_selectedCol; 0479 #endif 0480 0481 if (row) { 0482 *row = -1; 0483 } 0484 if (col) { 0485 *col = -1; 0486 } 0487 0488 0489 if (m_selectedRow < 0 || m_selectedCol < 0) { 0490 return false; 0491 } 0492 0493 int newRow = m_selectedRow, 0494 newCol = m_selectedCol; 0495 0496 newCol++; 0497 if (newCol >= m_pixmaps [newRow].count ()) 0498 { 0499 newRow++; 0500 if (newRow >= m_pixmaps.count ()) { 0501 return false; 0502 } 0503 0504 newCol = 0; 0505 if (newCol >= m_pixmaps [newRow].count ()) { 0506 return false; 0507 } 0508 } 0509 0510 0511 if (row) { 0512 *row = newRow; 0513 } 0514 if (col) { 0515 *col = newCol; 0516 } 0517 0518 return true; 0519 } 0520 0521 //--------------------------------------------------------------------- 0522 0523 0524 // public slot virtual 0525 bool kpToolWidgetBase::setSelected (int row, int col, bool saveAsDefault) 0526 { 0527 #if DEBUG_KP_TOOL_WIDGET_BASE 0528 qCDebug(kpLogWidgets) << "kpToolWidgetBase::setSelected(row=" << row 0529 << ",col=" << col 0530 << ",saveAsDefault=" << saveAsDefault 0531 << ")"; 0532 #endif 0533 0534 if (row < 0 || col < 0 || 0535 row >= m_pixmapRects.count () || col >= m_pixmapRects [row].count ()) 0536 { 0537 #if DEBUG_KP_TOOL_WIDGET_BASE 0538 qCDebug(kpLogWidgets) << "\tout of range"; 0539 #endif 0540 return false; 0541 } 0542 0543 if (row == m_selectedRow && col == m_selectedCol) 0544 { 0545 #if DEBUG_KP_TOOL_WIDGET_BASE 0546 qCDebug(kpLogWidgets) << "\tNOP"; 0547 #endif 0548 0549 if (saveAsDefault) { 0550 saveSelectedAsDefault (); 0551 } 0552 0553 return true; 0554 } 0555 0556 const int wasSelectedRow = m_selectedRow; 0557 const int wasSelectedCol = m_selectedCol; 0558 0559 m_selectedRow = row; 0560 m_selectedCol = col; 0561 0562 if (wasSelectedRow >= 0 && wasSelectedCol >= 0) 0563 { 0564 // unhighlight old option 0565 update (m_pixmapRects [wasSelectedRow][wasSelectedCol]); 0566 } 0567 0568 // highlight new option 0569 update (m_pixmapRects [row][col]); 0570 0571 #if DEBUG_KP_TOOL_WIDGET_BASE 0572 qCDebug(kpLogWidgets) << "\tOK"; 0573 #endif 0574 0575 if (saveAsDefault) { 0576 saveSelectedAsDefault (); 0577 } 0578 0579 Q_EMIT optionSelected (row, col); 0580 return true; 0581 } 0582 0583 //--------------------------------------------------------------------- 0584 0585 // public slot 0586 bool kpToolWidgetBase::setSelected (int row, int col) 0587 { 0588 return setSelected (row, col, true/*set as default*/); 0589 } 0590 0591 //--------------------------------------------------------------------- 0592 0593 0594 // public slot 0595 bool kpToolWidgetBase::selectPreviousOption () 0596 { 0597 int newRow, newCol; 0598 if (!hasPreviousOption (&newRow, &newCol)) { 0599 return false; 0600 } 0601 0602 return setSelected (newRow, newCol); 0603 } 0604 0605 //--------------------------------------------------------------------- 0606 0607 // public slot 0608 bool kpToolWidgetBase::selectNextOption () 0609 { 0610 int newRow, newCol; 0611 if (!hasNextOption (&newRow, &newCol)) { 0612 return false; 0613 } 0614 0615 return setSelected (newRow, newCol); 0616 } 0617 0618 //--------------------------------------------------------------------- 0619 0620 0621 // protected virtual [base QWidget] 0622 bool kpToolWidgetBase::event (QEvent *e) 0623 { 0624 // TODO: It's unclear when we should call the base, call accept() and 0625 // return true or false. Look at other event() handlers. The 0626 // kpToolText one is wrong since after calling accept(), it calls 0627 // its base which calls ignore() :) 0628 if (e->type () == QEvent::ToolTip) 0629 { 0630 auto *he = dynamic_cast<QHelpEvent *> (e); 0631 #if DEBUG_KP_TOOL_WIDGET_BASE 0632 qCDebug(kpLogWidgets) << "kpToolWidgetBase::event() QHelpEvent pos=" << he->pos (); 0633 #endif 0634 0635 bool showedText = false; 0636 for (int r = 0; r < m_pixmapRects.count (); r++) 0637 { 0638 for (int c = 0; c < m_pixmapRects [r].count (); c++) 0639 { 0640 if (m_pixmapRects [r][c].contains (he->pos ())) 0641 { 0642 const QString tip = m_toolTips [r][c]; 0643 #if DEBUG_KP_TOOL_WIDGET_BASE 0644 qCDebug(kpLogWidgets) << "\tin option: r=" << r << "c=" << c 0645 << "tip='" << tip << "'"; 0646 #endif 0647 if (!tip.isEmpty ()) 0648 { 0649 QToolTip::showText (he->globalPos (), tip, this); 0650 showedText = true; 0651 } 0652 0653 e->accept (); 0654 goto exit_loops; 0655 } 0656 } 0657 } 0658 0659 exit_loops: 0660 if (!showedText) 0661 { 0662 #if DEBUG_KP_TOOL_WIDGET_BASE 0663 qCDebug(kpLogWidgets) << "\thiding text"; 0664 #endif 0665 QToolTip::hideText (); 0666 } 0667 0668 return true; 0669 } 0670 0671 return QWidget::event (e); 0672 } 0673 0674 //--------------------------------------------------------------------- 0675 0676 0677 // protected virtual [base QWidget] 0678 void kpToolWidgetBase::mousePressEvent (QMouseEvent *e) 0679 { 0680 e->ignore (); 0681 0682 if (e->button () != Qt::LeftButton) { 0683 return; 0684 } 0685 0686 0687 for (int i = 0; i < m_pixmapRects.count (); i++) 0688 { 0689 for (int j = 0; j < m_pixmapRects [i].count (); j++) 0690 { 0691 if (m_pixmapRects [i][j].contains (e->pos ())) 0692 { 0693 setSelected (i, j); 0694 e->accept (); 0695 return; 0696 } 0697 } 0698 } 0699 } 0700 0701 //--------------------------------------------------------------------- 0702 0703 // protected virtual [base QWidget] 0704 void kpToolWidgetBase::paintEvent (QPaintEvent *e) 0705 { 0706 #if DEBUG_KP_TOOL_WIDGET_BASE && 1 0707 qCDebug(kpLogWidgets) << "kpToolWidgetBase::paintEvent(): rect=" << contentsRect (); 0708 #endif 0709 0710 // Draw frame first. 0711 QFrame::paintEvent (e); 0712 0713 QPainter painter (this); 0714 0715 for (int i = 0; i < m_pixmaps.count (); i++) 0716 { 0717 #if DEBUG_KP_TOOL_WIDGET_BASE && 1 0718 qCDebug(kpLogWidgets) << "\tRow: " << i; 0719 #endif 0720 0721 for (int j = 0; j < m_pixmaps [i].count (); j++) 0722 { 0723 QRect rect = m_pixmapRects [i][j]; 0724 QPixmap pixmap = m_pixmaps [i][j]; 0725 0726 #if DEBUG_KP_TOOL_WIDGET_BASE && 1 0727 qCDebug(kpLogWidgets) << "\t\tCol: " << j << " rect=" << rect; 0728 #endif 0729 0730 if (i == m_selectedRow && j == m_selectedCol) 0731 { 0732 painter.fillRect(rect, palette().color(QPalette::Highlight).rgb()); 0733 } 0734 0735 #if DEBUG_KP_TOOL_WIDGET_BASE && 1 0736 qCDebug(kpLogWidgets) << "\t\t\tdraw pixmap @ x=" 0737 << rect.x () + (rect.width () - pixmap.width ()) / 2 0738 << " y=" 0739 << rect.y () + (rect.height () - pixmap.height ()) / 2; 0740 0741 #endif 0742 0743 painter.drawPixmap(QPoint(rect.x () + (rect.width () - pixmap.width ()) / 2, 0744 rect.y () + (rect.height () - pixmap.height ()) / 2), 0745 pixmap); 0746 } 0747 } 0748 } 0749 0750 //--------------------------------------------------------------------- 0751 0752 #include "moc_kpToolWidgetBase.cpp"