QWidget * KvsObject_wrapper::findTopLevelWidgetToWrap(const QString &szClass,const QString &szName,bool bRecursive) { QWidgetList list = g_pApp->topLevelWidgets(); if(list.isEmpty()) return NULL; Q_FOREACH(QWidget * w,list) { //qDebug("TLW: %s::%s (look for %s::%s)",w->metaObject()->className(),w->objectName().toUtf8().data(),szClass.toUtf8().data(),szName.toUtf8().data()); if( ( szClass.isEmpty() || KviQString::equalCI(w->metaObject()->className(),szClass) ) && ( szName.isEmpty() || KviQString::equalCI(w->objectName(),szName) ) ) return w; } if(bRecursive) { Q_FOREACH(QWidget * w,list) { w = findWidgetToWrap(szClass,szName,w,bRecursive); if(w) return w; } }
/* * Broadcast event to all windows */ bool lamexp_broadcast(int eventType, bool onlyToVisible) { if(QApplication *app = dynamic_cast<QApplication*>(QApplication::instance())) { qDebug("Broadcasting %d", eventType); bool allOk = true; QEvent poEvent(static_cast<QEvent::Type>(eventType)); QWidgetList list = app->topLevelWidgets(); while(!list.isEmpty()) { QWidget *widget = list.takeFirst(); if(!onlyToVisible || widget->isVisible()) { if(!app->sendEvent(widget, &poEvent)) { allOk = false; } } } qDebug("Broadcast %d done (%s)", eventType, (allOk ? "OK" : "Stopped")); return allOk; } else { qWarning("Broadcast failed, could not get QApplication instance!"); return false; } }
static QWidget *focusWidget() { QTT_TRACE_FUNCTION(); QWidget *ret = QApplication::focusWidget(); if (!ret) { QWidgetList topLevel = QApplication::topLevelWidgets(); if (!topLevel.isEmpty()) return topLevel.first(); } return ret; }
QgsLegendModel::QgsLegendModel(): QStandardItemModel(), mAutoUpdate( true ) { setColumnCount( 2 ); if ( QgsMapLayerRegistry::instance() ) { connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( removeLayer( const QString& ) ) ); connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( addLayer( QgsMapLayer* ) ) ); } QWidgetList topLevelWidgets = QApplication::topLevelWidgets(); mHasTopLevelWindow = ( !topLevelWidgets.isEmpty() ); }
void SettingsWidget::listenChildrenStates(const QWidgetList &exceptions) { QWidgetList widgets; if (!exceptions.isEmpty()) { QWidgetList ls1 = findChildren<QWidget *>(); QWidgetList ls2 = exceptions; std::sort(ls1.begin(), ls1.end()); std::sort(ls2.begin(), ls2.end()); std::set_difference(ls1.begin(), ls1.end(), ls2.begin(), ls2.end(), std::insert_iterator<QWidgetList>(widgets, widgets.begin())); } else { widgets = findChildren<QWidget *>(); } foreach (QWidget *widget, widgets) lookForWidgetState(widget); }
bool ResourceExchange::doOpen() { kdDebug() << "ResourceExchange::doOpen()" << endl; mClient = new ExchangeClient(mAccount, mTimeZoneId); connect(mClient, SIGNAL(downloadFinished(int, const QString &)), SLOT(slotDownloadFinished(int, const QString &))); connect(mClient, SIGNAL(event(KCal::Event *, const KURL &)), SLOT(downloadedEvent(KCal::Event *, const KURL &))); #if 0 kdDebug() << "Creating monitor" << endl; QHostAddress ip; ip.setAddress(mAccount->host()); mMonitor = new ExchangeMonitor(mAccount, ExchangeMonitor::CallBack, ip); connect(mMonitor, SIGNAL(notify(const QValueList<long> &, const QValueList<KURL> &)), this, SLOT(slotMonitorNotify(const QValueList<long> &, const QValueList<KURL> &))); connect(mMonitor, SIGNAL(error(int , const QString &)), this, SLOT(slotMonitorError(int , const QString &))); mMonitor->addWatch(mAccount->calendarURL(), ExchangeMonitor::UpdateNewMember, 1); #endif QWidgetList *widgets = QApplication::topLevelWidgets(); if(!widgets->isEmpty()) mClient->setWindow(widgets->first()); delete widgets; mDates = new DateSet(); mEventDates = new QMap<Event, QDateTime>(); mCacheDates = new QMap<QDate, QDateTime>(); mCache = new CalendarLocal(mTimeZoneId); // mOldestDate = 0L; // mNewestDate = 0L; // FIXME: check if server exists, account is OK, etc. return true; }
void menuWindow::sPrepareWindowMenu() { _windowMenu->clear(); if (! _parent->showTopLevel()) { _windowMenu->addAction(_data->_cascade); _windowMenu->addAction(_data->_tile); _windowMenu->addSeparator(); } _windowMenu->addAction(_data->_closeActive); _windowMenu->addAction(_data->_closeAll); QWidgetList windows = _parent->windowList(); bool b; if(_preferences->value("InterfaceWindowOption") != "TopLevel") { b = windows.isEmpty(); } else { b = !windows.isEmpty(); } _data->_cascade->setEnabled(b); _data->_tile->setEnabled(b); _data->_closeActive->setEnabled(b); _data->_closeAll->setEnabled(b); _windowMenu->addSeparator(); if (_parent->showTopLevel()) _data->_lastActive = QApplication::activeWindow(); else if (_parent->workspace() && _parent->workspace()->activeSubWindow()) _data->_lastActive = _parent->workspace()->activeSubWindow()->widget(); else _data->_lastActive = 0; if (_data->_lastActive) { if(!_data->_geometryMenu) _data->_geometryMenu = new QMenu(); _data->_geometryMenu->clear(); _data->_geometryMenu->setTitle(_data->_lastActive->windowTitle()); QString objName = _data->_lastActive->objectName(); _data->_rememberPos->setChecked(xtsettingsValue(objName + "/geometry/rememberPos", true).toBool()); _data->_geometryMenu->addAction(_data->_rememberPos); _data->_rememberSize->setChecked(xtsettingsValue(objName + "/geometry/rememberSize", true).toBool()); _data->_geometryMenu->addAction(_data->_rememberSize); _windowMenu->addMenu(_data->_geometryMenu); _windowMenu->addSeparator(); } QAction *m = 0; foreach (QWidget *wind, windows) { m = _windowMenu->addAction(wind->windowTitle(), this, SLOT(sActivateWindow())); if(m) { m->setData(qVariantFromValue(wind)); m->setCheckable(true); m->setChecked((_data->_lastActive == wind)); } }