void QQuickMenuItem::bindToAction(QQuickAction *action) { m_boundAction = action; connect(m_boundAction, SIGNAL(destroyed(QObject*)), this, SLOT(unbindFromAction(QObject*))); connect(m_boundAction, SIGNAL(triggered()), this, SIGNAL(triggered())); connect(m_boundAction, SIGNAL(toggled(bool)), this, SLOT(updateChecked())); connect(m_boundAction, SIGNAL(exclusiveGroupChanged()), this, SIGNAL(exclusiveGroupChanged())); connect(m_boundAction, SIGNAL(enabledChanged()), this, SLOT(updateEnabled())); connect(m_boundAction, SIGNAL(textChanged()), this, SLOT(updateText())); connect(m_boundAction, SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut())); connect(m_boundAction, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged())); connect(m_boundAction, SIGNAL(iconNameChanged()), this, SLOT(updateIcon())); connect(m_boundAction, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged())); connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon())); connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SIGNAL(iconSourceChanged())); if (m_boundAction->parent() != this) { updateText(); updateShortcut(); updateEnabled(); updateIcon(); if (checkable()) updateChecked(); } }
void lmcUserTreeWidget::mouseReleaseEvent(QMouseEvent* event) { QTreeWidget::mouseReleaseEvent(event); QPoint pos = event->pos(); lmcUserTreeWidgetItem* item = (lmcUserTreeWidgetItem*)itemAt(pos); if(item && checkable() && item->checkBoxRect(visualItemRect(item)).contains(pos)) { // toggle checkstate if(item->checkState(0) == Qt::Checked) item->setCheckState(0, Qt::Unchecked); else item->setCheckState(0, Qt::Checked); } }
void lmcUserTreeWidget::keyPressEvent(QKeyEvent* event) { QTreeWidget::keyPressEvent(event); if(event->key() == Qt::Key_Space && selectedItems().count() > 0) { lmcUserTreeWidgetItem* item = (lmcUserTreeWidgetItem*)selectedItems().at(0); if(item && checkable()) { // toggle checkstate if(item->checkState(0) == Qt::Checked) item->setCheckState(0, Qt::Unchecked); else item->setCheckState(0, Qt::Checked); } } }
void CheckBox::toggleChecked() { if (checkable()) { if (_buttonFlag & Tristate) { if (checked()) { setChecked(false); _buttonFlag = (ButtonFlags) (_buttonFlag | Partial); update(); sigCheckStateChanged(Partial); } else if (partial()) { _buttonFlag = (ButtonFlags) (_buttonFlag & ~Partial); update(); sigCheckStateChanged(Unchecked); } else { setChecked(true); update(); sigCheckStateChanged(Checked); } } else { if (checked()) { setChecked(false); update(); sigCheckChanged(false); sigCheckStateChanged(Unchecked); } else { setChecked(true); update(); sigCheckChanged(true); sigCheckStateChanged(Checked); } } } }
vector<LinkStatus*> SearchManager::children(LinkStatus* link) { vector<LinkStatus*> children; if(!link || link->absoluteUrl().hasRef()) return children; vector<Node*> const& nodes = link->childrenNodes(); int count = 0; for(uint i = 0; i != nodes.size(); ++i) { ++count; Node* node = nodes[i]; KURL url; if(node->url().isEmpty()) url = ""; else url = Url::normalizeUrl(node->url(), *link, documentRoot().path()); if( (node->isLink() && checkable(url, *link) && !Url::existUrl(url, children) && !node->url().isEmpty()) || node->malformed() ) { LinkStatus* ls = new LinkStatus(node, link); ls->setAbsoluteUrl(url); if(localDomain(ls->absoluteUrl())) ls->setExternalDomainDepth(-1); else ls->setExternalDomainDepth(link->externalDomainDepth() + 1); //ls->setIsLocalRestrict(localDomain(url)); ls->setIsLocalRestrict(ls->local()); // @todo clean this nonsense if(!validUrl(url)) { ls->setMalformed(true); ls->setErrorOccurred(true); } ls->setOnlyCheckHeader(onlyCheckHeader(ls)); if(link->externalDomainDepth() > external_domain_depth_) { kdDebug(23100) << "link->externalDomainDepth() > external_domain_depth_: " << link->externalDomainDepth() << endl; kdDebug(23100) << "link: " << endl << link->toString() << endl; kdDebug(23100) << "child: " << endl << ls->toString() << endl; } Q_ASSERT(link->externalDomainDepth() <= external_domain_depth_); children.push_back(ls); } if(count == 50) { kapp->processEvents(); count = 0; } } return children; }
void ToolButton::updateTextBaseGeometry() { ILOG_TRACE_W(ILX_TOOLBUTTON); int textHeight = textExtents().height(); int iconW = 0; int iconH = 0; int wUsed = drawFrame() ? stylist()->defaultParameter(StyleHint::ToolButtonLR) : 0; int x = drawFrame() ? stylist()->defaultParameter(StyleHint::ToolButtonLeft) : 0; int yTop = drawFrame() ? stylist()->defaultParameter(StyleHint::ToolButtonTop) : 0; if (checkable()) { if ((_toolButtonStyle == TextOnly) || (_toolButtonStyle == IconOnly) || (_toolButtonStyle == IconBeforeText)) { x += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset); wUsed += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset); } } if (_icon) { if (!_icon->size().isValid()) _icon->setSize(_icon->preferredSize()); iconW = _icon->width(); iconH = _icon->height() + 1; } if (_toolButtonStyle == TextOnly) { int y = (height() - textHeight) / 2; _layout.setBounds(x, y, width() - wUsed, textHeight); } else if (_toolButtonStyle == IconOnly) { _icon->moveTo(x, (height() - iconH) / 2); _layout.setBounds(0, 0, 0, 0); return; } else if (_toolButtonStyle == IconBeforeText) { if (iconW) { _icon->moveTo(x, (height() - iconH) / 2); x += iconW + stylist()->defaultParameter(StyleHint::ButtonOffset); wUsed += iconW + stylist()->defaultParameter(StyleHint::ButtonOffset); } _layout.setBounds(x, (height() - textHeight) / 2, width() - wUsed, textHeight); } else if (_toolButtonStyle == IconBelowText) { _layout.setBounds(x, yTop, width() - wUsed, textHeight); if (iconW) _icon->moveTo((width() - iconW) / 2, yTop + textHeight + 1 + stylist()->defaultParameter(StyleHint::ButtonOffset)); } else // IconAboveText { if (iconW) { _icon->moveTo((width() - iconW) / 2, yTop + 1); yTop += iconH + stylist()->defaultParameter(StyleHint::ButtonOffset) + 1; } _layout.setBounds(x, yTop, width() - wUsed, textHeight); } _layout.doLayout(font()); }
Size ToolButton::preferredSize() const { ILOG_TRACE_W(ILX_TOOLBUTTON); if (text().empty() && !icon()) return stylist()->defaultSize(StyleHint::PushButton); int w = (_tbOptions & DrawFrame) ? stylist()->defaultParameter(StyleHint::ToolButtonLR) : 0; int h = (_tbOptions & DrawFrame) ? stylist()->defaultParameter(StyleHint::ToolButtonTB) : 0; if (checkable()) { if ((_toolButtonStyle == IconBelowText) || (_toolButtonStyle == IconAboveText)) h += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset); else w += stylist()->defaultParameter(StyleHint::ToolButtonIndicator) + stylist()->defaultParameter(StyleHint::ButtonOffset); } if (_toolButtonStyle == TextOnly) { Size s = textExtents(); if (s.isValid()) return Size(w + s.width(), h + s.height()); return stylist()->defaultSize(StyleHint::PushButton); } // calculate image size int imgW = 0; int imgH = 0; if (_icon) { Size s; if (_icon->size().isValid()) s = _icon->size(); else s = _icon->preferredSize(); imgW = s.width(); imgH = s.height() + 2; // 1px for button down movement } if (_toolButtonStyle == IconOnly) { ILOG_DEBUG(ILX_TOOLBUTTON, " -> icon only: %d, %d\n", w + imgW, h + imgH); if (imgW) return Size(w + imgW, h + imgH); return stylist()->defaultSize(StyleHint::PushButton); } else { Size s = textExtents(); if (s.isValid() && imgW) { if (_toolButtonStyle == IconBeforeText) { w += imgW + stylist()->defaultParameter(StyleHint::ButtonOffset) + s.width(); h += std::max(s.height(), imgH); return Size(w, h); } else { // IconBelowText or IconAboveText w += std::max(imgW, s.width()); h += imgH + s.height() + stylist()->defaultParameter(StyleHint::ButtonOffset); return Size(w, h); } } else if (imgW) return Size(w + imgW, h + imgH); else return Size(w + s.width(), h + s.height()); } }