| 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(QWidget *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(QWidget *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::Window end 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 == 0 end of block
 | 0 | ||||||||||||
| 174 | option->position = QStyleOptionToolBox::Beginning; | - | ||||||||||||
| 175 | } never executed: else if (indexInPage == widgetCount - 1 end 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 + 1 end 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__ ":" "348"), this, qFlagLocation("1""_q_widgetDestroyed(QObject*)" "\0" __FILE__ ":" "348")); | - | ||||||||||||
| 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__ ":" "354"), this, qFlagLocation("1""_q_buttonClicked()" "\0" __FILE__ ":" "354")); | - | ||||||||||||
| 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 | QWidget *p = (QWidget*)object; | - | ||||||||||||
| 317 | - | |||||||||||||
| 318 | const QToolBoxPrivate::Page *c = page(p); | - | ||||||||||||
| 319 | if (!p 
 
 | 0 | ||||||||||||
| 320 | return; never executed:  return; | 0 | ||||||||||||
| 321 | - | |||||||||||||
| 322 | layout->removeWidget(c->sv); | - | ||||||||||||
| 323 | layout->removeWidget(c->button); | - | ||||||||||||
| 324 | c->sv->deleteLater(); | - | ||||||||||||
| 325 | delete c->button; | - | ||||||||||||
| 326 | - | |||||||||||||
| 327 | bool removeCurrent = c == currentPage; | - | ||||||||||||
| 328 | pageList.removeAll(*c); | - | ||||||||||||
| 329 | - | |||||||||||||
| 330 | if (!pageList.count() 
 | 0 | ||||||||||||
| 331 | currentPage = 0; | - | ||||||||||||
| 332 | q->currentChanged(-1); | - | ||||||||||||
| 333 | } never executed: else if (removeCurrent end of block
 | 0 | ||||||||||||
| 334 | currentPage = 0; | - | ||||||||||||
| 335 | q->setCurrentIndex(0); | - | ||||||||||||
| 336 | } never executed:  end of block | 0 | ||||||||||||
| 337 | } never executed:  end of block | 0 | ||||||||||||
| 338 | - | |||||||||||||
| 339 | - | |||||||||||||
| 340 | - | |||||||||||||
| 341 | - | |||||||||||||
| 342 | - | |||||||||||||
| 343 | - | |||||||||||||
| 344 | void QToolBox::removeItem(int index) | - | ||||||||||||
| 345 | { | - | ||||||||||||
| 346 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 347 | if (QWidget *w = widget(index) 
 | 0 | ||||||||||||
| 348 | disconnect(w, qFlagLocation("2""destroyed(QObject*)" "\0" __FILE__ ":" "485"), this, qFlagLocation("1""_q_widgetDestroyed(QObject*)" "\0" __FILE__ ":" "485")); | - | ||||||||||||
| 349 | w->setParent(this); | - | ||||||||||||
| 350 | - | |||||||||||||
| 351 | d->_q_widgetDestroyed(w); | - | ||||||||||||
| 352 | itemRemoved(index); | - | ||||||||||||
| 353 | } never executed:  end of block | 0 | ||||||||||||
| 354 | } never executed:  end of block | 0 | ||||||||||||
| 355 | int QToolBox::currentIndex() const | - | ||||||||||||
| 356 | { | - | ||||||||||||
| 357 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 358 | return never executed: d->currentPage ? indexOf(d->currentPage->widget) : -1; return d->currentPage ? indexOf(d->currentPage->widget) : -1;never executed:  return d->currentPage ? indexOf(d->currentPage->widget) : -1; | 0 | ||||||||||||
| 359 | } | - | ||||||||||||
| 360 | - | |||||||||||||
| 361 | - | |||||||||||||
| 362 | - | |||||||||||||
| 363 | - | |||||||||||||
| 364 | - | |||||||||||||
| 365 | - | |||||||||||||
| 366 | - | |||||||||||||
| 367 | QWidget * QToolBox::currentWidget() const | - | ||||||||||||
| 368 | { | - | ||||||||||||
| 369 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 370 | return never executed: d->currentPage ? d->currentPage->widget : 0; return d->currentPage ? d->currentPage->widget : 0;never executed:  return d->currentPage ? d->currentPage->widget : 0; | 0 | ||||||||||||
| 371 | } | - | ||||||||||||
| 372 | - | |||||||||||||
| 373 | - | |||||||||||||
| 374 | - | |||||||||||||
| 375 | - | |||||||||||||
| 376 | - | |||||||||||||
| 377 | - | |||||||||||||
| 378 | void QToolBox::setCurrentWidget(QWidget *widget) | - | ||||||||||||
| 379 | { | - | ||||||||||||
| 380 | int i = indexOf(widget); | - | ||||||||||||
| 381 | if (__builtin_expect(!!(i < 0), false) 
 | 0 | ||||||||||||
| 382 | QMessageLogger(__FILE__, 531, __PRETTY_FUNCTION__).warning("QToolBox::setCurrentWidget: widget not contained in tool box"); never executed:  QMessageLogger(__FILE__, 531, __PRETTY_FUNCTION__).warning("QToolBox::setCurrentWidget: widget not contained in tool box"); | 0 | ||||||||||||
| 383 | else | - | ||||||||||||
| 384 | setCurrentIndex(i); never executed:  setCurrentIndex(i); | 0 | ||||||||||||
| 385 | } | - | ||||||||||||
| 386 | - | |||||||||||||
| 387 | - | |||||||||||||
| 388 | - | |||||||||||||
| 389 | - | |||||||||||||
| 390 | - | |||||||||||||
| 391 | - | |||||||||||||
| 392 | QWidget *QToolBox::widget(int index) const | - | ||||||||||||
| 393 | { | - | ||||||||||||
| 394 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 395 | if (index < 0 
 
 | 0 | ||||||||||||
| 396 | return never executed: 0; return 0;never executed:  return 0; | 0 | ||||||||||||
| 397 | return never executed: d->pageList.at(index).widget; return d->pageList.at(index).widget;never executed:  return d->pageList.at(index).widget; | 0 | ||||||||||||
| 398 | } | - | ||||||||||||
| 399 | - | |||||||||||||
| 400 | - | |||||||||||||
| 401 | - | |||||||||||||
| 402 | - | |||||||||||||
| 403 | - | |||||||||||||
| 404 | - | |||||||||||||
| 405 | int QToolBox::indexOf(QWidget *widget) const | - | ||||||||||||
| 406 | { | - | ||||||||||||
| 407 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 408 | const QToolBoxPrivate::Page *c = (widget 
 | 0 | ||||||||||||
| 409 | return never executed: c ? d->pageList.indexOf(*c) : -1; return c ? d->pageList.indexOf(*c) : -1;never executed:  return c ? d->pageList.indexOf(*c) : -1; | 0 | ||||||||||||
| 410 | } | - | ||||||||||||
| 411 | - | |||||||||||||
| 412 | - | |||||||||||||
| 413 | - | |||||||||||||
| 414 | - | |||||||||||||
| 415 | - | |||||||||||||
| 416 | - | |||||||||||||
| 417 | void QToolBox::setItemEnabled(int index, bool enabled) | - | ||||||||||||
| 418 | { | - | ||||||||||||
| 419 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 420 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 421 | if (!c 
 | 0 | ||||||||||||
| 422 | return; never executed:  return; | 0 | ||||||||||||
| 423 | - | |||||||||||||
| 424 | c->button->setEnabled(enabled); | - | ||||||||||||
| 425 | if (!enabled 
 
 | 0 | ||||||||||||
| 426 | int curIndexUp = index; | - | ||||||||||||
| 427 | int curIndexDown = curIndexUp; | - | ||||||||||||
| 428 | const int count = d->pageList.count(); | - | ||||||||||||
| 429 | while (curIndexUp > 0 
 
 | 0 | ||||||||||||
| 430 | if (curIndexDown < count-1 
 | 0 | ||||||||||||
| 431 | if (d->page(++curIndexDown)->button->isEnabled() 
 | 0 | ||||||||||||
| 432 | index = curIndexDown; | - | ||||||||||||
| 433 | break; never executed:  break; | 0 | ||||||||||||
| 434 | } | - | ||||||||||||
| 435 | } never executed:  end of block | 0 | ||||||||||||
| 436 | if (curIndexUp > 0 
 | 0 | ||||||||||||
| 437 | if (d->page(--curIndexUp)->button->isEnabled() 
 | 0 | ||||||||||||
| 438 | index = curIndexUp; | - | ||||||||||||
| 439 | break; never executed:  break; | 0 | ||||||||||||
| 440 | } | - | ||||||||||||
| 441 | } never executed:  end of block | 0 | ||||||||||||
| 442 | } never executed:  end of block | 0 | ||||||||||||
| 443 | setCurrentIndex(index); | - | ||||||||||||
| 444 | } never executed:  end of block | 0 | ||||||||||||
| 445 | } never executed:  end of block | 0 | ||||||||||||
| 446 | void QToolBox::setItemText(int index, const QString &text) | - | ||||||||||||
| 447 | { | - | ||||||||||||
| 448 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 449 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 450 | if (c 
 | 0 | ||||||||||||
| 451 | c->setText(text); never executed:  c->setText(text); | 0 | ||||||||||||
| 452 | } never executed:  end of block | 0 | ||||||||||||
| 453 | - | |||||||||||||
| 454 | - | |||||||||||||
| 455 | - | |||||||||||||
| 456 | - | |||||||||||||
| 457 | - | |||||||||||||
| 458 | void QToolBox::setItemIcon(int index, const QIcon &icon) | - | ||||||||||||
| 459 | { | - | ||||||||||||
| 460 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 461 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 462 | if (c 
 | 0 | ||||||||||||
| 463 | c->setIcon(icon); never executed:  c->setIcon(icon); | 0 | ||||||||||||
| 464 | } never executed:  end of block | 0 | ||||||||||||
| 465 | - | |||||||||||||
| 466 | - | |||||||||||||
| 467 | - | |||||||||||||
| 468 | - | |||||||||||||
| 469 | - | |||||||||||||
| 470 | - | |||||||||||||
| 471 | void QToolBox::setItemToolTip(int index, const QString &toolTip) | - | ||||||||||||
| 472 | { | - | ||||||||||||
| 473 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 474 | QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 475 | if (c 
 | 0 | ||||||||||||
| 476 | c->setToolTip(toolTip); never executed:  c->setToolTip(toolTip); | 0 | ||||||||||||
| 477 | } never executed:  end of block | 0 | ||||||||||||
| 478 | - | |||||||||||||
| 479 | - | |||||||||||||
| 480 | - | |||||||||||||
| 481 | - | |||||||||||||
| 482 | - | |||||||||||||
| 483 | - | |||||||||||||
| 484 | bool QToolBox::isItemEnabled(int index) const | - | ||||||||||||
| 485 | { | - | ||||||||||||
| 486 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 487 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 488 | return never executed: c && c->button->isEnabled(); return c && c->button->isEnabled();never executed:  return c && c->button->isEnabled(); | 0 | ||||||||||||
| 489 | } | - | ||||||||||||
| 490 | - | |||||||||||||
| 491 | - | |||||||||||||
| 492 | - | |||||||||||||
| 493 | - | |||||||||||||
| 494 | - | |||||||||||||
| 495 | - | |||||||||||||
| 496 | QString QToolBox::itemText(int index) const | - | ||||||||||||
| 497 | { | - | ||||||||||||
| 498 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 499 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 500 | return never executed: (c ? c->text() : QString()); return (c ? c->text() : QString());never executed:  return (c ? c->text() : QString()); | 0 | ||||||||||||
| 501 | } | - | ||||||||||||
| 502 | - | |||||||||||||
| 503 | - | |||||||||||||
| 504 | - | |||||||||||||
| 505 | - | |||||||||||||
| 506 | - | |||||||||||||
| 507 | - | |||||||||||||
| 508 | QIcon QToolBox::itemIcon(int index) const | - | ||||||||||||
| 509 | { | - | ||||||||||||
| 510 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 511 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 512 | return never executed: (c ? c->icon() : QIcon()); return (c ? c->icon() : QIcon());never executed:  return (c ? c->icon() : QIcon()); | 0 | ||||||||||||
| 513 | } | - | ||||||||||||
| 514 | - | |||||||||||||
| 515 | - | |||||||||||||
| 516 | - | |||||||||||||
| 517 | - | |||||||||||||
| 518 | - | |||||||||||||
| 519 | - | |||||||||||||
| 520 | - | |||||||||||||
| 521 | QString QToolBox::itemToolTip(int index) const | - | ||||||||||||
| 522 | { | - | ||||||||||||
| 523 | const QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 524 | const QToolBoxPrivate::Page *c = d->page(index); | - | ||||||||||||
| 525 | return never executed: (c ? c->toolTip() : QString()); return (c ? c->toolTip() : QString());never executed:  return (c ? c->toolTip() : QString()); | 0 | ||||||||||||
| 526 | } | - | ||||||||||||
| 527 | - | |||||||||||||
| 528 | - | |||||||||||||
| 529 | - | |||||||||||||
| 530 | void QToolBox::showEvent(QShowEvent *e) | - | ||||||||||||
| 531 | { | - | ||||||||||||
| 532 | QWidget::showEvent(e); | - | ||||||||||||
| 533 | } never executed:  end of block | 0 | ||||||||||||
| 534 | - | |||||||||||||
| 535 | - | |||||||||||||
| 536 | void QToolBox::changeEvent(QEvent *ev) | - | ||||||||||||
| 537 | { | - | ||||||||||||
| 538 | QToolBoxPrivate * const d = d_func(); | - | ||||||||||||
| 539 | if(ev->type() == QEvent::StyleChange 
 | 0 | ||||||||||||
| 540 | d->updateTabs(); never executed:  d->updateTabs(); | 0 | ||||||||||||
| 541 | QFrame::changeEvent(ev); | - | ||||||||||||
| 542 | } never executed:  end of block | 0 | ||||||||||||
| 543 | - | |||||||||||||
| 544 | - | |||||||||||||
| 545 | - | |||||||||||||
| 546 | - | |||||||||||||
| 547 | - | |||||||||||||
| 548 | - | |||||||||||||
| 549 | - | |||||||||||||
| 550 | void QToolBox::itemInserted(int index) | - | ||||||||||||
| 551 | { | - | ||||||||||||
| 552 | (void)index; | - | ||||||||||||
| 553 | } never executed:  end of block | 0 | ||||||||||||
| 554 | - | |||||||||||||
| 555 | - | |||||||||||||
| 556 | - | |||||||||||||
| 557 | - | |||||||||||||
| 558 | - | |||||||||||||
| 559 | - | |||||||||||||
| 560 | - | |||||||||||||
| 561 | void QToolBox::itemRemoved(int index) | - | ||||||||||||
| 562 | { | - | ||||||||||||
| 563 | (void)index; | - | ||||||||||||
| 564 | } never executed:  end of block | 0 | ||||||||||||
| 565 | - | |||||||||||||
| 566 | - | |||||||||||||
| 567 | bool QToolBox::event(QEvent *e) | - | ||||||||||||
| 568 | { | - | ||||||||||||
| 569 | return never executed: QFrame::event(e); return QFrame::event(e);never executed:  return QFrame::event(e); | 0 | ||||||||||||
| 570 | } | - | ||||||||||||
| 571 | - | |||||||||||||
| 572 | - | |||||||||||||
| 573 | - | |||||||||||||
| Switch to Source code | Preprocessed file |