| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/widgets/qtoolbox.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | class QToolBoxButton : public QAbstractButton | - | ||||||||||||
| 9 | { | - | ||||||||||||
| 10 | public: template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } | - | ||||||||||||
| 11 | #pragma GCC diagnostic push | - | ||||||||||||
| 12 | static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); virtual int qt_metacall(QMetaObject::Call, int, void **); static inline QString tr(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = nullptr, int n = -1) { return staticMetaObject.tr(s, c, n); } private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); | - | ||||||||||||
| 13 | #pragma GCC diagnostic pop | - | ||||||||||||
| 14 | struct QPrivateSignal {}; | - | ||||||||||||
| 15 | public: | - | ||||||||||||
| 16 | QToolBoxButton(QWidget *parent) | - | ||||||||||||
| 17 | : QAbstractButton(parent), selected(false), indexInPage(-1) | - | ||||||||||||
| 18 | { | - | ||||||||||||
| 19 | setBackgroundRole(QPalette::Window); | - | ||||||||||||
| 20 | setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | - | ||||||||||||
| 21 | setFocusPolicy(Qt::NoFocus); | - | ||||||||||||
| 22 |     } never executed:  end of block | 0 | ||||||||||||
| 23 | - | |||||||||||||
| 24 |     inline void setSelected(bool b) { selected = b; update(); } never executed:  end of block | 0 | ||||||||||||
| 25 |     inline void setIndex(int newIndex) { indexInPage = newIndex; } never executed:  end of block | 0 | ||||||||||||
| 26 | - | |||||||||||||
| 27 | QSize sizeHint() const override; | - | ||||||||||||
| 28 | QSize minimumSizeHint() const override; | - | ||||||||||||
| 29 | - | |||||||||||||
| 30 | protected: | - | ||||||||||||
| 31 | void initStyleOption(QStyleOptionToolBox *opt) const; | - | ||||||||||||
| 32 | void paintEvent(QPaintEvent *) override; | - | ||||||||||||
| 33 | - | |||||||||||||
| 34 | private: | - | ||||||||||||
| 35 | bool selected; | - | ||||||||||||
| 36 | int indexInPage; | - | ||||||||||||
| 37 | }; | - | ||||||||||||
| 38 | - | |||||||||||||
| 39 | - | |||||||||||||
| 40 | class QToolBoxPrivate : public QFramePrivate | - | ||||||||||||
| 41 | { | - | ||||||||||||
| 42 | inline QToolBox* q_func() { return static_cast<QToolBox *>(q_ptr); } inline const QToolBox* q_func() const { return static_cast<const QToolBox *>(q_ptr); } friend class QToolBox; | - | ||||||||||||
| 43 | public: | - | ||||||||||||
| 44 | struct Page | - | ||||||||||||
| 45 | { | - | ||||||||||||
| 46 | QToolBoxButton *button; | - | ||||||||||||
| 47 | QScrollArea *sv; | - | ||||||||||||
| 48 | QWidget *widget; | - | ||||||||||||
| 49 | - | |||||||||||||
| 50 |         inline void setText(const QString &text) { button->setText(text); } never executed:  end of block | 0 | ||||||||||||
| 51 |         inline void setIcon(const QIcon &is) { button->setIcon(is); } never executed:  end of block | 0 | ||||||||||||
| 52 | - | |||||||||||||
| 53 |         inline void setToolTip(const QString &tip) { button->setToolTip(tip); } never executed:  end of block | 0 | ||||||||||||
| 54 |         inline QString toolTip() const { return never executed:   button->toolTip();return button->toolTip();never executed:   }return button->toolTip(); | 0 | ||||||||||||
| 55 | - | |||||||||||||
| 56 |         inline QString text() const { return never executed:   button->text();return button->text();never executed:   }return button->text(); | 0 | ||||||||||||
| 57 |         inline QIcon icon() const { return never executed:   button->icon();return button->icon();never executed:   }return button->icon(); | 0 | ||||||||||||
| 58 | - | |||||||||||||
| 59 | inline bool operator==(const Page& other) const | - | ||||||||||||
| 60 | { | - | ||||||||||||
| 61 |             return never executed:   widget == other.widget;return widget == other.widget;never executed:  return widget == other.widget; | 0 | ||||||||||||
| 62 | } | - | ||||||||||||
| 63 | }; | - | ||||||||||||
| 64 | typedef QList<Page> PageList; | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | inline QToolBoxPrivate() | - | ||||||||||||
| 67 | : currentPage(0) | - | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 |     } never executed:  end of block | 0 | ||||||||||||
| 70 | void _q_buttonClicked(); | - | ||||||||||||
| 71 | void _q_widgetDestroyed(QObject*); | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | const Page *page(const QObject *widget) const; | - | ||||||||||||
| 74 | const Page *page(int index) const; | - | ||||||||||||
| 75 | Page *page(int index); | - | ||||||||||||
| 76 | - | |||||||||||||
| 77 | void updateTabs(); | - | ||||||||||||
| 78 | void relayout(); | - | ||||||||||||
| 79 | - | |||||||||||||
| 80 | PageList pageList; | - | ||||||||||||
| 81 | QVBoxLayout *layout; | - | ||||||||||||
| 82 | Page *currentPage; | - | ||||||||||||
| 83 | }; | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | const QToolBoxPrivate::Page *QToolBoxPrivate::page(const QObject *widget) const | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 |     if (!widget
  | 0 | ||||||||||||
| 88 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 89 | - | |||||||||||||
| 90 |     for (PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd()
  | 0 | ||||||||||||
| 91 |         if ((*
 
  | 0 | ||||||||||||
| 92 |             return never executed:   (const Page*) &(*i);return (const Page*) &(*i);never executed:  return (const Page*) &(*i); | 0 | ||||||||||||
| 93 |     return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 94 | } | - | ||||||||||||
| 95 | - | |||||||||||||
| 96 | QToolBoxPrivate::Page *QToolBoxPrivate::page(int index) | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 |     if (index >= 0
 
  | 0 | ||||||||||||
| 99 |         return never executed:   &pageList[index];return &pageList[index];never executed:  return &pageList[index]; | 0 | ||||||||||||
| 100 |     return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | const QToolBoxPrivate::Page *QToolBoxPrivate::page(int index) const | - | ||||||||||||
| 104 | { | - | ||||||||||||
| 105 |     if (index >= 0
 
  | 0 | ||||||||||||
| 106 |         return never executed:   &pageList.at(index);return &pageList.at(index);never executed:  return &pageList.at(index); | 0 | ||||||||||||
| 107 |     return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 108 | } | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | void QToolBoxPrivate::updateTabs() | - | ||||||||||||
| 111 | { | - | ||||||||||||
| 112 |     QToolBoxButton *lastButton = currentPage
  | 0 | ||||||||||||
| 113 | bool after = false; | - | ||||||||||||
| 114 | int index = 0; | - | ||||||||||||
| 115 |     for (index = 0; index < pageList.count()
  | 0 | ||||||||||||
| 116 | const Page &page = pageList.at(index); | - | ||||||||||||
| 117 | QToolBoxButton *tB = page.button; | - | ||||||||||||
| 118 | - | |||||||||||||
| 119 | - | |||||||||||||
| 120 | tB->setIndex(index); | - | ||||||||||||
| 121 | QWidget *tW = page.widget; | - | ||||||||||||
| 122 |         if (after
  | 0 | ||||||||||||
| 123 | QPalette p = tB->palette(); | - | ||||||||||||
| 124 | p.setColor(tB->backgroundRole(), tW->palette().color(tW->backgroundRole())); | - | ||||||||||||
| 125 | tB->setPalette(p); | - | ||||||||||||
| 126 | tB->update(); | - | ||||||||||||
| 127 |         } never executed:   else if (tB->backgroundRole() != QPalette::Windowend of block
  | 0 | ||||||||||||
| 128 | tB->setBackgroundRole(QPalette::Window); | - | ||||||||||||
| 129 | tB->update(); | - | ||||||||||||
| 130 |         } never executed:  end of block | 0 | ||||||||||||
| 131 | after = tB == lastButton; | - | ||||||||||||
| 132 |     } never executed:  end of block | 0 | ||||||||||||
| 133 | } never executed:  end of block | 0 | ||||||||||||
| 134 | - | |||||||||||||
| 135 | QSize QToolBoxButton::sizeHint() const | - | ||||||||||||
| 136 | { | - | ||||||||||||
| 137 | QSize iconSize(8, 8); | - | ||||||||||||
| 138 |     if (!icon().isNull()
  | 0 | ||||||||||||
| 139 | int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() ); | - | ||||||||||||
| 140 | iconSize += QSize(icone + 2, icone); | - | ||||||||||||
| 141 |     } never executed:  end of block | 0 | ||||||||||||
| 142 | QSize textSize = fontMetrics().size(Qt::TextShowMnemonic, text()) + QSize(0, 8); | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | QSize total(iconSize.width() + textSize.width(), qMax(iconSize.height(), textSize.height())); | - | ||||||||||||
| 145 |     return never executed:   total.expandedTo(QApplication::globalStrut());return total.expandedTo(QApplication::globalStrut());never executed:  return total.expandedTo(QApplication::globalStrut()); | 0 | ||||||||||||
| 146 | } | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | QSize QToolBoxButton::minimumSizeHint() const | - | ||||||||||||
| 149 | { | - | ||||||||||||
| 150 |     if (icon().isNull()
  | 0 | ||||||||||||
| 151 |         return never executed:   QSize();return QSize();never executed:  return QSize(); | 0 | ||||||||||||
| 152 | int icone = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, parentWidget() ); | - | ||||||||||||
| 153 |     return never executed:   QSize(icone + 8, icone + 8);return QSize(icone + 8, icone + 8);never executed:  return QSize(icone + 8, icone + 8); | 0 | ||||||||||||
| 154 | } | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | void QToolBoxButton::initStyleOption(QStyleOptionToolBox *option) const | - | ||||||||||||
| 157 | { | - | ||||||||||||
| 158 |     if (!option
  | 0 | ||||||||||||
| 159 |         return; never executed:  return; | 0 | ||||||||||||
| 160 | option->initFrom(this); | - | ||||||||||||
| 161 |     if (selected
  | 0 | ||||||||||||
| 162 |         option->state |= QStyle::State_Selected; never executed:  option->state |= QStyle::State_Selected; | 0 | ||||||||||||
| 163 |     if (isDown()
  | 0 | ||||||||||||
| 164 |         option->state |= QStyle::State_Sunken; never executed:  option->state |= QStyle::State_Sunken; | 0 | ||||||||||||
| 165 | option->text = text(); | - | ||||||||||||
| 166 | option->icon = icon(); | - | ||||||||||||
| 167 | - | |||||||||||||
| 168 | QToolBox *toolBox = static_cast<QToolBox *>(parentWidget()); | - | ||||||||||||
| 169 | const int widgetCount = toolBox->count(); | - | ||||||||||||
| 170 | const int currIndex = toolBox->currentIndex(); | - | ||||||||||||
| 171 |     if (widgetCount == 1
  | 0 | ||||||||||||
| 172 | option->position = QStyleOptionToolBox::OnlyOneTab; | - | ||||||||||||
| 173 |     } never executed:   else if (indexInPage == 0end of block
  | 0 | ||||||||||||
| 174 | option->position = QStyleOptionToolBox::Beginning; | - | ||||||||||||
| 175 |     } never executed:   else if (indexInPage == widgetCount - 1end of block
  | 0 | ||||||||||||
| 176 | option->position = QStyleOptionToolBox::End; | - | ||||||||||||
| 177 |     } never executed:   else {end of block | 0 | ||||||||||||
| 178 | option->position = QStyleOptionToolBox::Middle; | - | ||||||||||||
| 179 |     } never executed:  end of block | 0 | ||||||||||||
| 180 |     if (currIndex == indexInPage - 1
  | 0 | ||||||||||||
| 181 | option->selectedPosition = QStyleOptionToolBox::PreviousIsSelected; | - | ||||||||||||
| 182 |     } never executed:   else if (currIndex == indexInPage + 1end of block
  | 0 | ||||||||||||
| 183 | option->selectedPosition = QStyleOptionToolBox::NextIsSelected; | - | ||||||||||||
| 184 |     } never executed:   else {end of block | 0 | ||||||||||||
| 185 | option->selectedPosition = QStyleOptionToolBox::NotAdjacent; | - | ||||||||||||
| 186 |     } never executed:  end of block | 0 | ||||||||||||
| 187 | } | - | ||||||||||||
| 188 | - | |||||||||||||
| 189 | void QToolBoxButton::paintEvent(QPaintEvent *) | - | ||||||||||||
| 190 | { | - | ||||||||||||
| 191 | QPainter paint(this); | - | ||||||||||||
| 192 | QPainter *p = &paint; | - | ||||||||||||
| 193 | QStyleOptionToolBox opt; | - | ||||||||||||
| 194 | initStyleOption(&opt); | - | ||||||||||||
| 195 | style()->drawControl(QStyle::CE_ToolBoxTab, &opt, p, parentWidget()); | - | ||||||||||||
| 196 | } never executed:  end of block | 0 | ||||||||||||
| 197 | QToolBox::QToolBox(QWidget *parent, Qt::WindowFlags f) | - | ||||||||||||
| 198 | : QFrame(*new QToolBoxPrivate, parent, f) | - | ||||||||||||
| 199 | { | - | ||||||||||||
| 200 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 201 | d->layout = new QVBoxLayout(this); | - | ||||||||||||
| 202 | d->layout->setMargin(0); | - | ||||||||||||
| 203 | setBackgroundRole(QPalette::Button); | - | ||||||||||||
| 204 | } never executed:  end of block | 0 | ||||||||||||
| 205 | - | |||||||||||||
| 206 | - | |||||||||||||
| 207 | - | |||||||||||||
| 208 | - | |||||||||||||
| 209 | - | |||||||||||||
| 210 | QToolBox::~QToolBox() | - | ||||||||||||
| 211 | { | - | ||||||||||||
| 212 | } | - | ||||||||||||
| 213 | int QToolBox::insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text) | - | ||||||||||||
| 214 | { | - | ||||||||||||
| 215 |     if (!widget
  | 0 | ||||||||||||
| 216 |         return never executed:   -1;return -1;never executed:  return -1; | 0 | ||||||||||||
| 217 | - | |||||||||||||
| 218 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 219 | connect(widget, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "342"), this, qFlagLocation("1""_q_widgetDestroyed(QObject*)" "\0" __FILE__ ":" "342")); | - | ||||||||||||
| 220 | - | |||||||||||||
| 221 | QToolBoxPrivate::Page c; | - | ||||||||||||
| 222 | c.widget = widget; | - | ||||||||||||
| 223 | c.button = new QToolBoxButton(this); | - | ||||||||||||
| 224 | c.button->setObjectName(QLatin1String("qt_toolbox_toolboxbutton")); | - | ||||||||||||
| 225 | connect(c.button, qFlagLocation("2""clicked()" "\0" __FILE__ ":" "348"), this, qFlagLocation("1""_q_buttonClicked()" "\0" __FILE__ ":" "348")); | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | c.sv = new QScrollArea(this); | - | ||||||||||||
| 228 | c.sv->setWidget(widget); | - | ||||||||||||
| 229 | c.sv->setWidgetResizable(true); | - | ||||||||||||
| 230 | c.sv->hide(); | - | ||||||||||||
| 231 | c.sv->setFrameStyle(QFrame::NoFrame); | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | c.setText(text); | - | ||||||||||||
| 234 | c.setIcon(icon); | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 |     if (index < 0
 
  | 0 | ||||||||||||
| 237 | index = d->pageList.count(); | - | ||||||||||||
| 238 | d->pageList.append(c); | - | ||||||||||||
| 239 | d->layout->addWidget(c.button); | - | ||||||||||||
| 240 | d->layout->addWidget(c.sv); | - | ||||||||||||
| 241 |         if (index == 0
  | 0 | ||||||||||||
| 242 |             setCurrentIndex(index); never executed:  setCurrentIndex(index); | 0 | ||||||||||||
| 243 |     } never executed:   else {end of block | 0 | ||||||||||||
| 244 | d->pageList.insert(index, c); | - | ||||||||||||
| 245 | d->relayout(); | - | ||||||||||||
| 246 |         if (d->currentPage
  | 0 | ||||||||||||
| 247 | QWidget *current = d->currentPage->widget; | - | ||||||||||||
| 248 | int oldindex = indexOf(current); | - | ||||||||||||
| 249 |             if (index <= oldindex
  | 0 | ||||||||||||
| 250 | d->currentPage = 0; | - | ||||||||||||
| 251 | setCurrentIndex(oldindex); | - | ||||||||||||
| 252 |             } never executed:  end of block | 0 | ||||||||||||
| 253 |         } never executed:  end of block | 0 | ||||||||||||
| 254 |     } never executed:  end of block | 0 | ||||||||||||
| 255 | - | |||||||||||||
| 256 | c.button->show(); | - | ||||||||||||
| 257 | - | |||||||||||||
| 258 | d->updateTabs(); | - | ||||||||||||
| 259 | itemInserted(index); | - | ||||||||||||
| 260 |     return never executed:   index;return index;never executed:  return index; | 0 | ||||||||||||
| 261 | } | - | ||||||||||||
| 262 | - | |||||||||||||
| 263 | void QToolBoxPrivate::_q_buttonClicked() | - | ||||||||||||
| 264 | { | - | ||||||||||||
| 265 | QToolBox * const q = q_func(); | - | ||||||||||||
| 266 | QToolBoxButton *tb = qobject_cast<QToolBoxButton*>(q->sender()); | - | ||||||||||||
| 267 | QWidget* item = 0; | - | ||||||||||||
| 268 |     for (QToolBoxPrivate::PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd()
  | 0 | ||||||||||||
| 269 |         if ((*
 
  | 0 | ||||||||||||
| 270 | item = (*i).widget; | - | ||||||||||||
| 271 |             break; never executed:  break; | 0 | ||||||||||||
| 272 | } | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | q->setCurrentIndex(q->indexOf(item)); | - | ||||||||||||
| 275 | } never executed:  end of block | 0 | ||||||||||||
| 276 | int QToolBox::count() const | - | ||||||||||||
| 277 | { | - | ||||||||||||
| 278 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 279 |     return never executed:   d->pageList.count();return d->pageList.count();never executed:  return d->pageList.count(); | 0 | ||||||||||||
| 280 | } | - | ||||||||||||
| 281 | - | |||||||||||||
| 282 | void QToolBox::setCurrentIndex(int index) | - | ||||||||||||
| 283 | { | - | ||||||||||||
| 284 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 285 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 286 |     if (!c
 
  | 0 | ||||||||||||
| 287 |         return; never executed:  return; | 0 | ||||||||||||
| 288 | - | |||||||||||||
| 289 | c->button->setSelected(true); | - | ||||||||||||
| 290 |     if (d->currentPage
  | 0 | ||||||||||||
| 291 | d->currentPage->sv->hide(); | - | ||||||||||||
| 292 | d->currentPage->button->setSelected(false); | - | ||||||||||||
| 293 |     } never executed:  end of block | 0 | ||||||||||||
| 294 | d->currentPage = c; | - | ||||||||||||
| 295 | d->currentPage->sv->show(); | - | ||||||||||||
| 296 | d->updateTabs(); | - | ||||||||||||
| 297 | currentChanged(index); | - | ||||||||||||
| 298 | } never executed:  end of block | 0 | ||||||||||||
| 299 | - | |||||||||||||
| 300 | void QToolBoxPrivate::relayout() | - | ||||||||||||
| 301 | { | - | ||||||||||||
| 302 | QToolBox * const q = q_func(); | - | ||||||||||||
| 303 | delete layout; | - | ||||||||||||
| 304 | layout = new QVBoxLayout(q); | - | ||||||||||||
| 305 | layout->setMargin(0); | - | ||||||||||||
| 306 |     for (QToolBoxPrivate::PageList::ConstIterator i = pageList.constBegin(); i != pageList.constEnd()
  | 0 | ||||||||||||
| 307 | layout->addWidget((*i).button); | - | ||||||||||||
| 308 | layout->addWidget((*i).sv); | - | ||||||||||||
| 309 |     } never executed:  end of block | 0 | ||||||||||||
| 310 | } never executed:  end of block | 0 | ||||||||||||
| 311 | - | |||||||||||||
| 312 | void QToolBoxPrivate::_q_widgetDestroyed(QObject *object) | - | ||||||||||||
| 313 | { | - | ||||||||||||
| 314 | QToolBox * const q = q_func(); | - | ||||||||||||
| 315 | - | |||||||||||||
| 316 | const QToolBoxPrivate::Page * const c = page(object); | - | ||||||||||||
| 317 |     if (!c
  | 0 | ||||||||||||
| 318 |         return; never executed:  return; | 0 | ||||||||||||
| 319 | - | |||||||||||||
| 320 | layout->removeWidget(c->sv); | - | ||||||||||||
| 321 | layout->removeWidget(c->button); | - | ||||||||||||
| 322 | c->sv->deleteLater(); | - | ||||||||||||
| 323 | delete c->button; | - | ||||||||||||
| 324 | - | |||||||||||||
| 325 | bool removeCurrent = c == currentPage; | - | ||||||||||||
| 326 | pageList.removeAll(*c); | - | ||||||||||||
| 327 | - | |||||||||||||
| 328 |     if (!pageList.count()
  | 0 | ||||||||||||
| 329 | currentPage = 0; | - | ||||||||||||
| 330 | q->currentChanged(-1); | - | ||||||||||||
| 331 |     } never executed:   else if (removeCurrentend of block
  | 0 | ||||||||||||
| 332 | currentPage = 0; | - | ||||||||||||
| 333 | q->setCurrentIndex(0); | - | ||||||||||||
| 334 |     } never executed:  end of block | 0 | ||||||||||||
| 335 | } never executed:  end of block | 0 | ||||||||||||
| 336 | - | |||||||||||||
| 337 | - | |||||||||||||
| 338 | - | |||||||||||||
| 339 | - | |||||||||||||
| 340 | - | |||||||||||||
| 341 | - | |||||||||||||
| 342 | void QToolBox::removeItem(int index) | - | ||||||||||||
| 343 | { | - | ||||||||||||
| 344 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 345 |     if (QWidget *w = widget(index)
  | 0 | ||||||||||||
| 346 | disconnect(w, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "477"), this, qFlagLocation("1""_q_widgetDestroyed(QObject*)" "\0" __FILE__ ":" "477")); | - | ||||||||||||
| 347 | w->setParent(this); | - | ||||||||||||
| 348 | - | |||||||||||||
| 349 | d->_q_widgetDestroyed(w); | - | ||||||||||||
| 350 | itemRemoved(index); | - | ||||||||||||
| 351 |     } never executed:  end of block | 0 | ||||||||||||
| 352 | } never executed:  end of block | 0 | ||||||||||||
| 353 | int QToolBox::currentIndex() const | - | ||||||||||||
| 354 | { | - | ||||||||||||
| 355 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 356 |     return never executed:   d->currentPagereturn d->currentPage ? indexOf(d->currentPage->widget) : -1;
 never executed:  return d->currentPage ? indexOf(d->currentPage->widget) : -1; | 0 | ||||||||||||
| 357 | } | - | ||||||||||||
| 358 | - | |||||||||||||
| 359 | - | |||||||||||||
| 360 | - | |||||||||||||
| 361 | - | |||||||||||||
| 362 | - | |||||||||||||
| 363 | - | |||||||||||||
| 364 | - | |||||||||||||
| 365 | QWidget * QToolBox::currentWidget() const | - | ||||||||||||
| 366 | { | - | ||||||||||||
| 367 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 368 |     return never executed:   d->currentPagereturn d->currentPage ? d->currentPage->widget : 0;
 never executed:  return d->currentPage ? d->currentPage->widget : 0; | 0 | ||||||||||||
| 369 | } | - | ||||||||||||
| 370 | - | |||||||||||||
| 371 | - | |||||||||||||
| 372 | - | |||||||||||||
| 373 | - | |||||||||||||
| 374 | - | |||||||||||||
| 375 | - | |||||||||||||
| 376 | void QToolBox::setCurrentWidget(QWidget *widget) | - | ||||||||||||
| 377 | { | - | ||||||||||||
| 378 | int i = indexOf(widget); | - | ||||||||||||
| 379 |     if (i >= 0
  | 0 | ||||||||||||
| 380 |         setCurrentIndex(i); never executed:  setCurrentIndex(i); | 0 | ||||||||||||
| 381 | else | - | ||||||||||||
| 382 |         QMessageLogger(__FILE__, 525, __PRETTY_FUNCTION__).warning("QToolBox::setCurrentWidget: widget not contained in tool box"); never executed:  QMessageLogger(__FILE__, 525, __PRETTY_FUNCTION__).warning("QToolBox::setCurrentWidget: widget not contained in tool box"); | 0 | ||||||||||||
| 383 | } | - | ||||||||||||
| 384 | - | |||||||||||||
| 385 | - | |||||||||||||
| 386 | - | |||||||||||||
| 387 | - | |||||||||||||
| 388 | - | |||||||||||||
| 389 | - | |||||||||||||
| 390 | QWidget *QToolBox::widget(int index) const | - | ||||||||||||
| 391 | { | - | ||||||||||||
| 392 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 393 |     if (index < 0
 
  | 0 | ||||||||||||
| 394 |         return never executed:   0;return 0;never executed:  return 0; | 0 | ||||||||||||
| 395 |     return never executed:   d->pageList.at(index).widget;return d->pageList.at(index).widget;never executed:  return d->pageList.at(index).widget; | 0 | ||||||||||||
| 396 | } | - | ||||||||||||
| 397 | - | |||||||||||||
| 398 | - | |||||||||||||
| 399 | - | |||||||||||||
| 400 | - | |||||||||||||
| 401 | - | |||||||||||||
| 402 | - | |||||||||||||
| 403 | int QToolBox::indexOf(QWidget *widget) const | - | ||||||||||||
| 404 | { | - | ||||||||||||
| 405 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 406 |     const QToolBoxPrivate::Page *c = (widget
  | 0 | ||||||||||||
| 407 |     return never executed:   creturn c ? d->pageList.indexOf(*c) : -1;
 never executed:  return c ? d->pageList.indexOf(*c) : -1; | 0 | ||||||||||||
| 408 | } | - | ||||||||||||
| 409 | - | |||||||||||||
| 410 | - | |||||||||||||
| 411 | - | |||||||||||||
| 412 | - | |||||||||||||
| 413 | - | |||||||||||||
| 414 | - | |||||||||||||
| 415 | void QToolBox::setItemEnabled(int index, bool enabled) | - | ||||||||||||
| 416 | { | - | ||||||||||||
| 417 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 418 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 419 |     if (!c
  | 0 | ||||||||||||
| 420 |         return; never executed:  return; | 0 | ||||||||||||
| 421 | - | |||||||||||||
| 422 | c->button->setEnabled(enabled); | - | ||||||||||||
| 423 |     if (!enabled
 
  | 0 | ||||||||||||
| 424 | int curIndexUp = index; | - | ||||||||||||
| 425 | int curIndexDown = curIndexUp; | - | ||||||||||||
| 426 | const int count = d->pageList.count(); | - | ||||||||||||
| 427 |         while (curIndexUp > 0
 
  | 0 | ||||||||||||
| 428 |             if (curIndexDown < count-1
  | 0 | ||||||||||||
| 429 |                 if (d->page(++curIndexDown)->button->isEnabled()
  | 0 | ||||||||||||
| 430 | index = curIndexDown; | - | ||||||||||||
| 431 |                     break; never executed:  break; | 0 | ||||||||||||
| 432 | } | - | ||||||||||||
| 433 |             } never executed:  end of block | 0 | ||||||||||||
| 434 |             if (curIndexUp > 0
  | 0 | ||||||||||||
| 435 |                 if (d->page(--curIndexUp)->button->isEnabled()
  | 0 | ||||||||||||
| 436 | index = curIndexUp; | - | ||||||||||||
| 437 |                     break; never executed:  break; | 0 | ||||||||||||
| 438 | } | - | ||||||||||||
| 439 |             } never executed:  end of block | 0 | ||||||||||||
| 440 |         } never executed:  end of block | 0 | ||||||||||||
| 441 | setCurrentIndex(index); | - | ||||||||||||
| 442 |     } never executed:  end of block | 0 | ||||||||||||
| 443 | } never executed:  end of block | 0 | ||||||||||||
| 444 | void QToolBox::setItemText(int index, const QString &text) | - | ||||||||||||
| 445 | { | - | ||||||||||||
| 446 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 447 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 448 |     if (c
  | 0 | ||||||||||||
| 449 |         c->setText(text); never executed:  c->setText(text); | 0 | ||||||||||||
| 450 | } never executed:  end of block | 0 | ||||||||||||
| 451 | - | |||||||||||||
| 452 | - | |||||||||||||
| 453 | - | |||||||||||||
| 454 | - | |||||||||||||
| 455 | - | |||||||||||||
| 456 | void QToolBox::setItemIcon(int index, const QIcon &icon) | - | ||||||||||||
| 457 | { | - | ||||||||||||
| 458 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 459 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 460 |     if (c
  | 0 | ||||||||||||
| 461 |         c->setIcon(icon); never executed:  c->setIcon(icon); | 0 | ||||||||||||
| 462 | } never executed:  end of block | 0 | ||||||||||||
| 463 | - | |||||||||||||
| 464 | - | |||||||||||||
| 465 | - | |||||||||||||
| 466 | - | |||||||||||||
| 467 | - | |||||||||||||
| 468 | - | |||||||||||||
| 469 | void QToolBox::setItemToolTip(int index, const QString &toolTip) | - | ||||||||||||
| 470 | { | - | ||||||||||||
| 471 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 472 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 473 |     if (c
  | 0 | ||||||||||||
| 474 |         c->setToolTip(toolTip); never executed:  c->setToolTip(toolTip); | 0 | ||||||||||||
| 475 | } never executed:  end of block | 0 | ||||||||||||
| 476 | - | |||||||||||||
| 477 | - | |||||||||||||
| 478 | - | |||||||||||||
| 479 | - | |||||||||||||
| 480 | - | |||||||||||||
| 481 | - | |||||||||||||
| 482 | bool QToolBox::isItemEnabled(int index) const | - | ||||||||||||
| 483 | { | - | ||||||||||||
| 484 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 485 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 486 |     return never executed:   creturn c && c->button->isEnabled();
 
 never executed:  return c && c->button->isEnabled(); | 0 | ||||||||||||
| 487 | } | - | ||||||||||||
| 488 | - | |||||||||||||
| 489 | - | |||||||||||||
| 490 | - | |||||||||||||
| 491 | - | |||||||||||||
| 492 | - | |||||||||||||
| 493 | - | |||||||||||||
| 494 | QString QToolBox::itemText(int index) const | - | ||||||||||||
| 495 | { | - | ||||||||||||
| 496 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 497 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 498 |     return never executed:   (creturn (c ? c->text() : QString());
 never executed:  return (c ? c->text() : QString()); | 0 | ||||||||||||
| 499 | } | - | ||||||||||||
| 500 | - | |||||||||||||
| 501 | - | |||||||||||||
| 502 | - | |||||||||||||
| 503 | - | |||||||||||||
| 504 | - | |||||||||||||
| 505 | - | |||||||||||||
| 506 | QIcon QToolBox::itemIcon(int index) const | - | ||||||||||||
| 507 | { | - | ||||||||||||
| 508 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 509 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 510 |     return never executed:   (creturn (c ? c->icon() : QIcon());
 never executed:  return (c ? c->icon() : QIcon()); | 0 | ||||||||||||
| 511 | } | - | ||||||||||||
| 512 | - | |||||||||||||
| 513 | - | |||||||||||||
| 514 | - | |||||||||||||
| 515 | - | |||||||||||||
| 516 | - | |||||||||||||
| 517 | - | |||||||||||||
| 518 | - | |||||||||||||
| 519 | QString QToolBox::itemToolTip(int index) const | - | ||||||||||||
| 520 | { | - | ||||||||||||
| 521 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 522 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 523 |     return never executed:   (creturn (c ? c->toolTip() : QString());
 never executed:  return (c ? c->toolTip() : QString()); | 0 | ||||||||||||
| 524 | } | - | ||||||||||||
| 525 | - | |||||||||||||
| 526 | - | |||||||||||||
| 527 | - | |||||||||||||
| 528 | void QToolBox::showEvent(QShowEvent *e) | - | ||||||||||||
| 529 | { | - | ||||||||||||
| 530 | QWidget::showEvent(e); | - | ||||||||||||
| 531 | } never executed:  end of block | 0 | ||||||||||||
| 532 | - | |||||||||||||
| 533 | - | |||||||||||||
| 534 | void QToolBox::changeEvent(QEvent *ev) | - | ||||||||||||
| 535 | { | - | ||||||||||||
| 536 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 537 |     if(ev->type() == QEvent::StyleChange
  | 0 | ||||||||||||
| 538 |         d->updateTabs(); never executed:  d->updateTabs(); | 0 | ||||||||||||
| 539 | QFrame::changeEvent(ev); | - | ||||||||||||
| 540 | } never executed:  end of block | 0 | ||||||||||||
| 541 | - | |||||||||||||
| 542 | - | |||||||||||||
| 543 | - | |||||||||||||
| 544 | - | |||||||||||||
| 545 | - | |||||||||||||
| 546 | - | |||||||||||||
| 547 | - | |||||||||||||
| 548 | void QToolBox::itemInserted(int index) | - | ||||||||||||
| 549 | { | - | ||||||||||||
| 550 | (void)index; | - | ||||||||||||
| 551 | } never executed:  end of block | 0 | ||||||||||||
| 552 | - | |||||||||||||
| 553 | - | |||||||||||||
| 554 | - | |||||||||||||
| 555 | - | |||||||||||||
| 556 | - | |||||||||||||
| 557 | - | |||||||||||||
| 558 | - | |||||||||||||
| 559 | void QToolBox::itemRemoved(int index) | - | ||||||||||||
| 560 | { | - | ||||||||||||
| 561 | (void)index; | - | ||||||||||||
| 562 | } never executed:  end of block | 0 | ||||||||||||
| 563 | - | |||||||||||||
| 564 | - | |||||||||||||
| 565 | bool QToolBox::event(QEvent *e) | - | ||||||||||||
| 566 | { | - | ||||||||||||
| 567 |     return never executed:   QFrame::event(e);return QFrame::event(e);never executed:  return QFrame::event(e); | 0 | ||||||||||||
| 568 | } | - | ||||||||||||
| 569 | - | |||||||||||||
| 570 | - | |||||||||||||
| 571 | - | |||||||||||||
| Switch to Source code | Preprocessed file |