/*! \internal */ void QDeclarativeGeoMap::populateMap() { QObjectList kids = children(); for (int i = 0; i < kids.size(); ++i) { // dispatch items appropriately QDeclarativeGeoMapItemView *mapView = qobject_cast<QDeclarativeGeoMapItemView *>(kids.at(i)); if (mapView) { m_mapViews.append(mapView); setupMapView(mapView); continue; } QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(kids.at(i)); if (mapItem) { addMapItem(mapItem); } } }
void FontHelper::SetFont(QWidget * w) { #ifndef Q_OS_MAC QObjectList widgetList = w->children(); for (int k = 0, sz = widgetList.size(); k < sz; ++k) { QWidget * tw = dynamic_cast<QWidget*>(widgetList[k]); if (tw) { int pt = tw->fontInfo().pointSize(); bool bold = tw->fontInfo().bold(); tw->setFont(FontHelper::pt(pt, bold)); SetFont(tw); } } #endif // Q_OS_MAC }
/*! \internal */ void QDeclarativeGeoMap::onMapChildrenChanged() { if (!m_componentCompleted || !m_mappingManagerInitialized) return; int maxChildZ = 0; QObjectList kids = children(); bool foundCopyrights = false; for (int i = 0; i < kids.size(); ++i) { QDeclarativeGeoMapCopyrightNotice *copyrights = qobject_cast<QDeclarativeGeoMapCopyrightNotice *>(kids.at(i)); if (copyrights) { foundCopyrights = true; } else { QDeclarativeGeoMapItemBase *mapItem = qobject_cast<QDeclarativeGeoMapItemBase *>(kids.at(i)); if (mapItem) { if (mapItem->z() > maxChildZ) maxChildZ = mapItem->z(); } } } QDeclarativeGeoMapCopyrightNotice *copyrights = m_copyrights.data(); // if copyrights object not found within the map's children if (!foundCopyrights) { // if copyrights object was deleted! if (!copyrights) { // create a new one and set its parent, re-assign it to the weak pointer, then connect the copyrights-change signal m_copyrights = new QDeclarativeGeoMapCopyrightNotice(this); copyrights = m_copyrights.data(); connect(m_map, SIGNAL(copyrightsChanged(QImage)), copyrights, SLOT(copyrightsChanged(QImage))); connect(m_map, SIGNAL(copyrightsChanged(QString)), copyrights, SLOT(copyrightsChanged(QString))); connect(copyrights, SIGNAL(linkActivated(QString)), this, SIGNAL(copyrightLinkActivated(QString))); } else { // just re-set its parent. copyrights->setParent(this); } } // put the copyrights notice object at the highest z order copyrights->setCopyrightsZ(maxChildZ + 1); }
static QVector<QwtPicker *> activePickers( QWidget *w ) { QVector<QwtPicker *> pickers; QObjectList children = w->children(); for ( int i = 0; i < children.size(); i++ ) { QObject *obj = children[i]; if ( obj->inherits( "QwtPicker" ) ) { QwtPicker *picker = ( QwtPicker * )obj; if ( picker->isEnabled() ) pickers += picker; } } return pickers; }
void MvcpThread::do_cls(mvcp a_mvcp, QObject* parent) { QObjectList* result = new QObjectList; mvcp_dir dir = mvcp_dir_init(a_mvcp, parent->property("path").toString().toUtf8().constData()); int n = mvcp_dir_count(dir); for (int i = 0; i < n; i++) { mvcp_dir_entry_t entry; mvcp_dir_get(dir, i, &entry); QObject* o = new QObject; o->setObjectName(QString::fromUtf8(entry.full)); o->setProperty("name", QString::fromUtf8(entry.name)); o->setProperty("dir", entry.dir); o->setProperty("size", entry.size); result->append(o); } mvcp_dir_close(dir); emit clsResult(parent, result); }
QString Folder::sizeToString() { int size = 0; QObjectList* folderLst = (QObjectList*)children(); if (folderLst) { Folder *f; for (f = (Folder*)folderLst->first(); f; f = (Folder*)folderLst->next()) size += sizeof(f); } myWidget *w; for (w = lstWindows.first(); w ; w = lstWindows.next()) size += sizeof(w); return QString::number(8*size/1024.0,'f',1)+" "+tr("kB")+" ("+QString::number(8*size)+" "+tr("bytes")+")"; }
QMenuBar * QMainWindow::menuBar() const { if ( d->mb ) return d->mb; QObjectList * l = ((QObject*)this)->queryList( "QMenuBar", 0, FALSE, FALSE ); QMenuBar * b; if ( l && l->count() ) b = (QMenuBar *)l->first(); else b = new QMenuBar( (QMainWindow *)this, "automatic menu bar" ); delete l; ((QMainWindowPrivate*)d)->mb = b; d->mb->installEventFilter( this ); ((QMainWindow *)this)->triggerLayout(); return b; }
bool Task::take(const QDomElement &x) { const QObjectList p = children(); // pass along the xml Task *t; for(QObjectList::ConstIterator it = p.begin(); it != p.end(); ++it) { QObject *obj = *it; if(!obj->inherits("XMPP::Task")) continue; t = static_cast<Task*>(obj); if(t->take(x)) return true; } return false; }
void MainWindow::timerHit() { QObjectList objList = this->children(); for(int i = 0; i < objList.size(); i++) { if (dynamic_cast<View*>(objList.at(i)) != 0 ) { dynamic_cast<View*>(objList.at(i))->Update(game->getScreen(), game->getBBS(), game->getSS()); } } if (game->Collision(j,s, game->getObjects().back()->get_y()) && !c) { timer->stop(); nameline = new QLineEdit(this); nameline->move(this->width()/2 - 50, this->height()/2 - 50); nameline->setPlaceholderText("Enter your name here."); nameline->show(); scorebutton = new QPushButton("Save Scores", this); scorebutton->move(this->width()/2 - 50, this->height()/2 + 50); connect(scorebutton, SIGNAL(clicked()), this, SLOT(savescorebutton_clicked())); scorebutton->show(); newgame = new QPushButton("Restart?", this); newgame->move(this->width()/2 - 150, this->height()/2); connect(newgame, SIGNAL(clicked()), this, SLOT(restart_clicked())); newgame->show(); endgame = new QPushButton("End Game?", this); endgame->move(this->width()/2 + 50, this->height()/2); connect(endgame, SIGNAL(clicked()), this, SLOT(endgame_clicked())); endgame->show(); //QMessageBox::critical(this, "Game Over...", "You have died!"); } scoresheet.incScore(); int score = scoresheet.getScore(); QString scorey = QString::number(score); scorelabel->setText(scorey); scorelabel->show(); }
void QSAEditor::completeQObject(const QVector<QObject *> &objects, const QString &object, QVector<CompletionEntry> &res) { for ( int i = 0; i < objects.count(); i++ ) { QObject *qobj = objects[ i ]; if ( !qobj ) continue; // children QObjectList clist; if ( qobj == qApp ) clist = interpreter()->topLevelObjects() != 0 ? *((QObjectList*)interpreter()->topLevelObjects()) : QObjectList(); else clist = qobj->children(); if ( !clist.isEmpty() ) { for (int ci = 0; ci<clist.size(); ++ci) { const QObject *o = clist.at(ci); CompletionEntry c; c.type = o->isWidgetType() ? "widget" : "object"; c.text = o->objectName(); c.postfix2 = o->metaObject()->className(); if ( !c.postfix2.isEmpty() ) c.postfix2.prepend( QString::fromLatin1(" : ") ); res << c; } } QSObject qsobj = interpreter()->wrap( qobj ); int flags = 0; if ( i == 0 ) flags |= IncludeSuperClass; completeQMetaObject( qobj->metaObject(), object, res, flags, qsobj ); } }
Item::~Item() { // cout << name() << " deleting children" << endl; if (!children().isEmpty()) { QObjectList childList = children(); while(!childList.isEmpty() ) { delete childList.takeFirst(); } } // cout << name() << " deleting listviewitem" << endl; delete treeWidgetItem_; // Remove the QTreeWidgetItem from the map to Item itemMap_.erase(treeWidgetItem_); // cout << name() << " deleting" << endl; }
IPCamSetting::IPCamSetting(QWidget *parent) : QGroupBox(parent), ui(new Ui::IPCamSetting) { ui->setupUi(this); QObjectList objList = this->children(); QObjectList::iterator objIter = objList.begin(), objEnd = objList.end(); QObjectList::iterator lineEditIter = objList.begin(); IsInherit predLabel("QLabel"), predLineEdit("QLineEdit"); while ((objIter = std::find_if(objIter, objEnd, predLabel)) != objEnd) { lineEditIter = std::find_if(lineEditIter, objEnd, predLineEdit); if (lineEditIter != objEnd) { m_mapLabelToLineEdit.insert(dynamic_cast<QLabel*>(*objIter)->text(), dynamic_cast<QLineEdit*>(*lineEditIter)); ++lineEditIter; } ++objIter; } }
/*! Returns true if any of the child QWidgets has different minimum and maximum sizes, as set by qt_ui_element_rep::as_qwidget() for resize_widgets. */ bool qt_window_widget_rep::has_resizable_children (QWidget* w, bool ret) { // Ignore any non QWidgets if (!w) return false; // Hack: these must always be resizable if (qobject_cast<QMainWindow*> (w) || qobject_cast<QDockWidget*> (w)) return true; ret = (w->minimumSize() != QSize (0,0) && w->maximumSize() != QSize (QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) && w->minimumSize() != w->maximumSize()); QObjectList ch = w->children(); for (int i=0; i<ch.size(); ++i) ret = ret || has_resizable_children (qobject_cast<QWidget*> (ch[i]), ret); return ret; }
bool SGMainWindowEvent::eventFilter(QObject* object, QEvent* evt) { QWidget* focusWidget = QApplication::focusWidget(); if (focusWidget == NULL) return true; if (m_focusWidgetName == focusWidget->objectName().toStdString().c_str()) return QObject::eventFilter(object, evt); QObjectList objList = focusWidget->children(); bool glWidgetExists = false; for (int i = 0; i < objList.length(); i++) { QWidget* widget = (QWidget*)objList[i]; QObjectList objList2 = widget->children(); for (int j = 0; j < objList2.length(); j++) { QWidget* widget2 = (QWidget*)objList2[j]; if (strcmp(widget2->metaObject()->className(), "QmayaGLWidget") == 0) { if (m_beforeWidget != NULL) { m_beforeWidget->releaseKeyboard(); m_beforeWidget->removeEventFilter(toolEvent); } widget2->installEventFilter(toolEvent); widget2->grabKeyboard(); m_beforeWidget = widget2; m_focusWidgetName = focusWidget->objectName().toStdString().c_str(); glWidgetExists = true; SGKey::initializeKeys(); SGMouse::initializeButtons(); break; } } if (glWidgetExists)break; } if (!glWidgetExists) { if (m_beforeWidget != NULL) { m_beforeWidget->releaseKeyboard(); m_beforeWidget->removeEventFilter(toolEvent); } m_focusWidgetName = focusWidget->objectName().toStdString().c_str(); } return QObject::eventFilter(object, evt); }
/* sets all children of the group box except the qt_groupbox_checkbox to either disabled/enabled */ void QGroupBoxPrivate::_q_setChildrenEnabled(bool b) { Q_Q(QGroupBox); QObjectList childList = q->children(); for (int i = 0; i < childList.size(); ++i) { QObject *o = childList.at(i); if (o->isWidgetType()) { QWidget *w = static_cast<QWidget *>(o); if (b) { if (!w->testAttribute(Qt::WA_ForceDisabled)) w->setEnabled(true); } else { if (w->isEnabled()) { w->setEnabled(false); w->setAttribute(Qt::WA_ForceDisabled, false); } } } } }
/*! \reimp */ QSize QSplitter::sizeHint() const { Q_D(const QSplitter); ensurePolished(); int l = 0; int t = 0; QObjectList childList = children(); for (int i = 0; i < childList.size(); ++i) { if (QWidget *w = qobject_cast<QWidget *>(childList.at(i))) { if (w->isHidden()) continue; QSize s = w->sizeHint(); if (s.isValid()) { l += d->pick(s); t = qMax(t, d->trans(s)); } } } return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l); }
/*! Loads widgets and objects from the docml file. */ void WlanLoginView::loadDocml() { OstTraceFunctionEntry0( WLANLOGINVIEW_LOADDOCML_ENTRY ); setObjectName(QString("wlanLoginView")); QObjectList objectList; objectList.append(this); mDocLoader->setObjectTree(objectList); bool ok = false; mDocLoader->load(wlanLoginViewDocml, &ok); Q_ASSERT(ok); //Fetch pointer for progress bar mProgressBar = reinterpret_cast<HbProgressBar *>( mDocLoader->findObject("progressBar")); Q_ASSERT(mProgressBar); //Fetch pointer for scroll area content mScrollAreaContent = reinterpret_cast<HbWidget *>( mDocLoader->findObject("scrollAreaContent")); Q_ASSERT(mScrollAreaContent); //Fetch pointer for Web View mWebView = reinterpret_cast<WlanLoginWebView *>( mDocLoader->findObject("webView")); Q_ASSERT(mWebView); //Fetch pointer for cancel action mCancelAction = qobject_cast<HbAction*> ( mDocLoader->findObject("cancelAction")); Q_ASSERT(mCancelAction != NULL); //Fetch pointer for next action mNextAction = qobject_cast<HbAction*> ( mDocLoader->findObject("nextAction")); Q_ASSERT(mNextAction != NULL); OstTraceFunctionExit0( WLANLOGINVIEW_LOADDOCML_EXIT ); }
void PTEDialog::connectChilds_(QObject* o) { QPushButton* w = dynamic_cast<QPushButton*>(o); if (w != 0) { String s = ascii(w->text()); if (s.size() > 2) return; Position an = PTE[s].getAtomicNumber(); w->setToolTip(atomProperties_(an)); connect(w, SIGNAL(released()), this, SLOT(elementClicked_())); return; } // iterate over all buttons in the button group QObjectList ol = o->children(); QObjectList::iterator it = ol.begin(); for (; it != ol.end(); it++) { connectChilds_(*it); } }
/// ///Return a QStringList with the Widget's brothers names /// QStringList * getWidgetBrothers(const QWidget * w) { //FIXME check if this method returns empty-name children QStringList * brothers = new QStringList(); assert(w->parent()); QObjectList oblist = w->parent()->children(); QString objectName = getWidgetPath((QObject *)w); QObjectList::iterator it; for(it = oblist.begin(); it != oblist.end(); it++) { assert((QObject *)*it); QString childName = getWidgetPath((QObject *)*it); if ((childName!="") && (objectName != childName)) brothers->push_back(childName); } return brothers; }
/* * Description: initializing. */ void IRNowPlayingView::initialize() { LOG_METHOD; setObjectName(NOW_PLAYING_VIEW_OBJECT_NAME); QObjectList roots; roots.append(this); iLoader.setObjectTree(roots); // Load XML file iLoader.load(NOW_PLAYING_VIEW_LAYOUT_FILENAME); initMenu(); initToolBar(); initWidget(); #ifdef SUBTITLE_STR_BY_LOCID setTitle(hbTrId("txt_irad_title_internet_radio")); #else setTitle("Internet radio"); #endif handleOrientationChanged(getViewManager()->orientation()); }
void IRTermsConsView::initViewContents() { setObjectName(TERMS_CONS_VIEW_BASE_OBJECT_VIEW); QObjectList roots; roots.append(this); iLoader.setObjectTree(roots); iLoader.load(TERMS_CONS_VIEW_LAYOUT_FILENAME); // load correct orientation connect( getViewManager(), SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( handleOrientationChanged(Qt::Orientation) ) ); handleOrientationChanged(getViewManager()->orientation()); HbPushButton *acceptButton = qobject_cast<HbPushButton *>(iLoader.findObject(TERMS_CONS_VIEW_ACCEPT_BTN)); HbPushButton *declineButton = qobject_cast<HbPushButton *>(iLoader.findObject(TERMS_CONS_VIEW_DECLINE_BTN)); connect( acceptButton, SIGNAL(released()), iApplication, SLOT(handleTermsConsAccepted()) ); connect( declineButton, SIGNAL(released()), iApplication, SIGNAL(quit()) ); }
void tst_QColumnView::grips() { QColumnView view; QDirModel model; view.setModel(&model); QCOMPARE(view.resizeGripsVisible(), true); view.setResizeGripsVisible(true); QCOMPARE(view.resizeGripsVisible(), true); { const QObjectList list = view.viewport()->children(); for (int i = 0 ; i < list.count(); ++i) { if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i))) QVERIFY(view->cornerWidget() != 0); } } view.setResizeGripsVisible(false); QCOMPARE(view.resizeGripsVisible(), false); { const QObjectList list = view.viewport()->children(); for (int i = 0 ; i < list.count(); ++i) { if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i))) { if (view->isVisible()) QVERIFY(view->cornerWidget() == 0); } } } view.setResizeGripsVisible(true); QCOMPARE(view.resizeGripsVisible(), true); }
void BaseMainPage::focusNextRightChild() { if(!m_pCtrlPage) return; if(isNavigatorMode()) { if(m_nNavigatorCnt <= 0) return; int tindex = (m_nCurrentNavigator+1)%m_nNavigatorCnt; navigatorPageAt(tindex); return; } QObjectList list = m_pCtrlPage->xList; if(list.length() == 0) return; QObject *obj = m_pCtrlPage->focusWidget(); int index = list.indexOf(obj); if(index == -1) index = list.length()-1; if(index == list.length()-1) { index = -1; } index++; QWidget *tab =static_cast<QWidget *>(list.at(index)); tab->setFocus(); }
Folder* Folder::findSubfolder(const QString& s, bool caseSensitive, bool partialMatch) { QObjectList folderList = children(); if (!folderList.isEmpty()){ QObject * f; foreach(f,folderList){ QString name = static_cast<Folder *>(f)->name(); if (partialMatch){ if (caseSensitive && name.startsWith(s,Qt::CaseSensitive)) return static_cast<Folder *>(f); else if (!caseSensitive && name.startsWith(s,Qt::CaseInsensitive)) return static_cast<Folder *>(f); } else // partialMatch == false { if (caseSensitive && name == s) return static_cast<Folder *>(f); else if ( !caseSensitive && (name.toLower() == s.toLower()) ) return static_cast<Folder *>(f); } }
void PolicyView::init(PolicyXML * _policy) { if (policy_ == _policy) return; // delete all childs QObjectList * childs; while((childs = const_cast<QObjectList *>(viewport()->children())) != NULL && !childs->isEmpty()) { delete childs->first(); } policy_ = _policy; if (policy_ == NULL) return; policy_->setWidget(this); //------------------------- // rebuild the widget list QListViewItem * i = policy_->listViewItem()->firstChild(); while (i != NULL) { Item * item = policy_->itemFromListViewItem(i); PatternXML * pattern = dynamic_cast<PatternXML *>(item); if (pattern != NULL) addPatternWidget(pattern); i = i->nextSibling(); } QRect r = viewport()->childrenRect(); QPoint s = viewportToContents(r.bottomRight()); resizeContents(s.x(), s.y()); setContentsPos(0, 0); }
QObjectList findObjectRecursively(QObject* parent, bool returnFirst, QObjectList& targetList) { const QObjectList& children = parent->children(); Q_FOREACH(QObject* child, children) { // if(satisfies(child)) { // targetList.push_back(child); // if(returnFirst) // return targetList; // } findObjectRecursively(child, returnFirst, targetList); if(returnFirst && targetList.size()>0) { return targetList; } }
void BasketStatusBar::setupStatusBar() { QWidget* parent = statusBar(); QObjectList lst = parent->findChildren<QObject*>("KRSqueezedTextLabel"); //Tools::printChildren(parent); if (lst.count() == 0) { m_basketStatus = new QLabel(parent); QSizePolicy policy(QSizePolicy::Ignored, QSizePolicy::Ignored); policy.setHorizontalStretch(0); policy.setVerticalStretch(0); policy.setHeightForWidth(false); m_basketStatus->setSizePolicy(policy); addWidget(m_basketStatus, 1, false); // Fit all extra space and is hiddable } else m_basketStatus = static_cast<QLabel*>(lst.at(0)); lst.clear(); m_selectionStatus = new QLabel(i18n("Loading..."), parent); addWidget(m_selectionStatus, 0, true); m_lockStatus = new QLabel(0/*this*/); m_lockStatus->setMinimumSize(18, 18); m_lockStatus->setAlignment(Qt::AlignCenter); // addWidget( m_lockStatus, 0, true ); m_lockStatus->installEventFilter(this); m_savedStatusPixmap = SmallIcon("document-save"); m_savedStatus = new QLabel(parent); m_savedStatus->setPixmap(m_savedStatusPixmap); m_savedStatus->setFixedSize(m_savedStatus->sizeHint()); m_savedStatus->clear(); //m_savedStatus->setPixmap(m_savedStatusIconSet.pixmap(QIconSet::Small, QIconSet::Disabled)); //m_savedStatus->setEnabled(false); addWidget(m_savedStatus, 0, true); m_savedStatus->setToolTip("<p>" + i18n("Shows if there are changes that have not yet been saved.")); }
void WidgetSizeHelper::setDefaultFontSize(QWidget* pWidget) { // we get all of pWidget's children QObjectList children = pWidget->children(); // for each child for ( int i = 0; i < children.length(); i++ ) { /* * we change its font size if it is of one of those types * * - QLabel * - QLineEdit * - QRadioButton * - QGroupBox * - QCheckBox * - QStatusBar */ QWidget* pChild = static_cast<QWidget*> ( children.at(i) ); if ( qobject_cast<QLabel*>(pChild) != NULL || qobject_cast<QLineEdit*>(pChild) != NULL || qobject_cast<QRadioButton*>(pChild) != NULL || qobject_cast<QGroupBox*>(pChild) != NULL || qobject_cast<QCheckBox*>(pChild) != NULL || qobject_cast<QStatusBar*>(pChild) != NULL ) { QFont lFont = pChild->font(); lFont.setPointSize(Constants::MAC_FONT_SIZE); pChild->setFont(lFont); } // and scan it, if it has children if ( ! pChild->children().isEmpty() ) { setDefaultFontSize( pChild ); } } }
void EmoticonSelector::prepareList(void) { // kdDebug(14000) << k_funcinfo << "called." << endl; int row = 0; int col = 0; QMap<QString, QStringList> list = Kopete::Emoticons::self()->emoticonAndPicList(); int emoticonsPerRow = static_cast<int>(sqrt(list.count())); //kdDebug(14000) << "emoticonsPerRow=" << emoticonsPerRow << endl; if ( lay ) { QObjectList *objList = queryList( "EmoticonLabel" ); //kdDebug(14000) << k_funcinfo << "There are " << objList->count() << " EmoticonLabels to delete." << endl; objList->setAutoDelete(true); objList->clear(); delete objList; delete lay; } lay = new QGridLayout(this, 0, 0, 4, 4, "emoticonLayout"); movieList.clear(); for (QMap<QString, QStringList>::const_iterator it = list.constBegin(); it != list.constEnd(); ++it ) { QWidget *w = new EmoticonLabel(it.data().first(), it.key(), this); movieList.push_back( ((QLabel*)w)->movie() ); connect(w, SIGNAL(clicked(const QString&)), this, SLOT(emoticonClicked(const QString&))); // kdDebug(14000) << "adding Emoticon to row=" << row << ", col=" << col << "." << endl; lay->addWidget(w, row, col); if ( col == emoticonsPerRow ) { col = 0; row++; } else col++; } resize(minimumSizeHint()); }
static QwtArray<QwtPicker *> activePickers(QWidget *w) { QwtArray<QwtPicker *> pickers; #if QT_VERSION >= 0x040000 QObjectList children = w->children(); for ( int i = 0; i < children.size(); i++ ) { QObject *obj = children[i]; if ( obj->inherits("QwtPicker") ) { QwtPicker *picker = (QwtPicker *)obj; if ( picker->isEnabled() ) pickers += picker; } } #else QObjectList *children = (QObjectList *)w->children(); if ( children ) { for ( QObjectListIterator it(*children); it.current(); ++it ) { QObject *obj = (QObject *)it.current(); if ( obj->inherits("QwtPicker") ) { QwtPicker *picker = (QwtPicker *)obj; if ( picker->isEnabled() ) { pickers.resize(pickers.size() + 1); pickers[int(pickers.size()) - 1] = picker; } } } } #endif return pickers; }