void ComplexplotWrapper::addToWindowSlot(QString window, int row, int column) { if(destroyed_) return; if(window != "") { QWidgetList widgets = qApp->topLevelWidgets(); for(QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i) { if ((*i)->objectName() == window) { QGridLayout *l = (QGridLayout*)(*i)->layout(); if(row<0) row = l->count()/3; if(column<0) column = l->count()%3; l->addWidget(widget_, row, column); return; } } QWidget *p = new QWidget(); p->setObjectName(window); QGridLayout *layout = new QGridLayout(); p->setLayout(layout); if(row<0) row = 0; if(column<0) column = 0; layout->addWidget(widget_, row, column); p->show(); } }
QString DiffAnalystWindow::getNextDiffSessionName() { QString defaultName = "Untitled-"; int counter = 1; QStringList nameList; QString ret = ""; QWidgetList wl = m_pWs->windowList(QWorkspace::CreationOrder); QWidgetList::iterator it = wl.begin(); QWidgetList::iterator end = wl.end(); for( ; it != end ; it++) { nameList.push_back( (*it)->name() ); } while(1) { QString pattern = QString("^")+ defaultName + QString::number(counter) + "$"; QRegExp regExp(pattern); if(nameList.grep(regExp).size() == 0) { ret = defaultName + QString::number(counter); break; }else{ counter++; } } return ret; }
static QMainWindow* getMainWindow() { QWidgetList widgets = qApp->topLevelWidgets(); for (QWidgetList::iterator i = widgets.begin(); i != widgets.end(); ++i) if ((*i)->objectName() == "MainWindow") return (QMainWindow*) (*i); return NULL; }
// Find the associated menus and toolbars, ignore toolbuttons QWidgetList ActionModel::associatedWidgets(const QAction *action) { QWidgetList rc = action->associatedWidgets(); for (QWidgetList::iterator it = rc.begin(); it != rc.end(); ) if (qobject_cast<const QMenu *>(*it) || qobject_cast<const QToolBar *>(*it)) { ++it; } else { it = rc.erase(it); } return rc; }
QWidget* QgsWFSData::findMainWindow() const { QWidget* mainWindow = 0; QWidgetList topLevelWidgets = qApp->topLevelWidgets(); QWidgetList::iterator it = topLevelWidgets.begin(); for ( ; it != topLevelWidgets.end(); ++it ) { if (( *it )->objectName() == "QgisApp" ) { mainWindow = *it; break; } } return mainWindow; }
bool DiffAnalystWindow::diffSessionNameExists(QString name) { bool ret = false; QStringList nameList; QWidgetList wl = m_pWs->windowList(QWorkspace::CreationOrder); QWidgetList::iterator it = wl.begin(); QWidgetList::iterator end = wl.end(); for( ; it != end ; it++) { nameList.push_back( (*it)->name() ); } QString pattern = QString("^")+ name + "$"; QRegExp regExp(pattern); if(nameList.grep(regExp).size() != 0) ret = true; return ret; }
void BankCardPage::connectDataAwareWidgets(const QWidgetList& widgets) { typedef QWidgetList::const_iterator const_iterator; for (const_iterator i = widgets.begin(), end = widgets.end(); i != end; ++i) { QWidget* widget = *i; if (QLineEdit* edit = qobject_cast<QLineEdit*>(widget)) { QObject::connect(edit, SIGNAL(textEdited(const QString&)), SLOT(on_lineEdit_textEdited(const QString&))); } else if (QTextEdit* edit = qobject_cast<QTextEdit*>(widget)) { QObject::connect(edit, SIGNAL(textChanged()), SLOT(on_textEdit_textChanged())); } } }
/** * @brief 스크린 상의 모든 MainWindow 중에서 마우스가 탭영역(1,2,3)에 올라가있는 메인윈도우를 찾는다. * * @param except 제외할 메인 윈도우. * @return MainWindow * */ MainWindow* CWindowManager::findMainWindowByCursorOnTabWithout(MainWindow* except) { MainWindow* windowToGo = 0; QWidgetList list = qApp->topLevelWidgets(); QWidgetList::iterator it; // 모든 MainWindow를 순회하면서 마우스가 탭 영역에 올라가있는 MainWindow를 찾는다. for(it = list.begin(); it != list.end(); ++it) { MainWindow *item = reinterpret_cast<MainWindow*>(*it); if(except && except == item) { continue; } if(CWindowManager::isCursorOnTabWithEmptyArea(item)) { windowToGo = item; break; } } return windowToGo; }
void Portal::construct_window_menu() { m_window_menu->clear(); m_window_menu->addAction( m_close_action ); m_window_menu->addSeparator(); m_window_menu->addAction( m_tile_action ); m_window_menu->addAction( m_cascade_action ); QWidgetList windows = m_workspace->windowList(); if( windows.size() > 0 ) m_window_menu->addSeparator(); for( QWidgetList::const_iterator witer = windows.begin(); witer != windows.end(); ++witer ) { QWidget *widget = *witer; QAction *action = m_window_menu->addAction( widget->windowTitle(), m_activation_mapper, SLOT(map()) ); m_activation_mapper->setMapping( action, widget ); } }
int QgsGml::getFeatures( const QString& uri, QGis::WkbType* wkbType, QgsRectangle* extent, const QString& userName, const QString& password ) { mUri = uri; mWkbType = wkbType; XML_Parser p = XML_ParserCreateNS( NULL, NS_SEPARATOR ); XML_SetUserData( p, this ); XML_SetElementHandler( p, QgsGml::start, QgsGml::end ); XML_SetCharacterDataHandler( p, QgsGml::chars ); //start with empty extent mExtent.setMinimal(); QNetworkRequest request( mUri ); if ( !userName.isNull() || !password.isNull() ) { request.setRawHeader( "Authorization", "Basic " + QString( "%1:%2" ).arg( userName ).arg( password ).toAscii().toBase64() ); } QNetworkReply* reply = QgsNetworkAccessManager::instance()->get( request ); connect( reply, SIGNAL( finished() ), this, SLOT( setFinished() ) ); connect( reply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( handleProgressEvent( qint64, qint64 ) ) ); //find out if there is a QGIS main window. If yes, display a progress dialog QProgressDialog* progressDialog = 0; QWidget* mainWindow = 0; QWidgetList topLevelWidgets = qApp->topLevelWidgets(); for ( QWidgetList::iterator it = topLevelWidgets.begin(); it != topLevelWidgets.end(); ++it ) { if (( *it )->objectName() == "QgisApp" ) { mainWindow = *it; break; } } if ( mainWindow ) { progressDialog = new QProgressDialog( tr( "Loading GML data\n%1" ).arg( mTypeName ), tr( "Abort" ), 0, 0, mainWindow ); progressDialog->setWindowModality( Qt::ApplicationModal ); connect( this, SIGNAL( dataReadProgress( int ) ), progressDialog, SLOT( setValue( int ) ) ); connect( this, SIGNAL( totalStepsUpdate( int ) ), progressDialog, SLOT( setMaximum( int ) ) ); connect( progressDialog, SIGNAL( canceled() ), this, SLOT( setFinished() ) ); progressDialog->show(); } int atEnd = 0; while ( !atEnd ) { if ( mFinished ) { atEnd = 1; } QByteArray readData = reply->readAll(); if ( readData.size() > 0 ) { if ( XML_Parse( p, readData.constData(), readData.size(), atEnd ) == 0 ) { XML_Error errorCode = XML_GetErrorCode( p ); QString errorString = tr( "Error: %1 on line %2, column %3" ) .arg( XML_ErrorString( errorCode ) ) .arg( XML_GetCurrentLineNumber( p ) ) .arg( XML_GetCurrentColumnNumber( p ) ); QgsMessageLog::logMessage( errorString, tr( "WFS" ) ); } } QCoreApplication::processEvents(); } QNetworkReply::NetworkError replyError = reply->error(); QString replyErrorString = reply->errorString(); delete reply; delete progressDialog; if ( replyError ) { QgsMessageLog::logMessage( tr( "GML Getfeature network request failed with error: %1" ).arg( replyErrorString ), tr( "Network" ), QgsMessageLog::CRITICAL ); return 1; } if ( *mWkbType != QGis::WKBNoGeometry ) { if ( mExtent.isEmpty() ) { //reading of bbox from the server failed, so we calculate it less efficiently by evaluating the features calculateExtentFromFeatures(); } } XML_ParserFree( p ); if ( extent ) *extent = mExtent; return 0; }
/// ///returns a widget ///it supports repeated widget names /// QWidget* getAbsoluteWidget(QStringList path) { _log::misc << "(QWidgetUtils::getAbsoluteWidget)" << std::endl; ///update the view QWidgetUtils::updateAppView(); ///get all the widgets QWidgetList qwl = qApp->allWidgets(); ///get the widget name assert ( path.size() ); QString name = path.back(); if ( name == "" ) { std::cout << "(QWidgetUtils::getAbsoluteWidget) ERROR. The name of the widget is empty." << std::endl; return NULL; } path.pop_back(); //_log::misc << "(QWidgetUtils::getAbsoluteWidget) Name = " << name.toStdString() << std::endl; ///get all widgets with this name QWidgetList qws; foreach ( QWidget *w, qwl ) { if ( getWidgetName ( w ) == name ) { qws.push_back ( w ); } } //_log::misc << "(QWidgetUtils::getAbsoluteWidget) OK" << std::endl; //if there are no selected widgets... if ( qws.size() == 0 ) { _log::misc << "(QWidgetUtils::getAbsoluteWidget) ERROR. There are no selected widgets." << std::endl; return NULL; } //_log::misc << "(QWidgetUtils::getAbsoluteWidget) OK" << std::endl; ///get the concrete widget we are looking for... int level = 1; bool onTopLevel = false; int onTopLevelCount = 0; QWidgetList::iterator qit; /*for (qit = qws.begin(); qit != qws.end(); qit++) { QWidget* w = static_cast<QWidget*> ( *qit ); _log::misc << getWidgetPath(w).toStdString() << std::endl; }*/ // while more than 1 widget remaining // or every widget has been analyzed... while ( qws.size() > 1 && onTopLevelCount < qws.size() ) { //_log::misc << "(QWidgetUtils::getAbsoluteWidget) OK -> " << qws.size() << std::endl; //for the remaining widgets... qit = qws.begin(); while ( qit != qws.end() ) { //get the parent widget QWidget* w = static_cast<QWidget*> ( *qit ); QWidget* wParent = w; assert ( wParent ); onTopLevel = false; for ( int i = 0; i < level; i++ ) { //if we are in a top level widget (with no parent node) //we have to avoid this widget if ( wParent->parent() == NULL ) { onTopLevel = true; onTopLevelCount++; break; } //if not, we go on looking for up else { wParent = static_cast<QWidget*> ( wParent->parent() ); } } //if not at top level... if ( !onTopLevel ) { //we chech the parent name and delete the //widgets whose parent name does not mach if ( getWidgetName ( wParent ) != path.back() ) { qit = qws.erase ( qit ); } else { qit++; } } else { qit++; } } //update the values level++; path.pop_back(); //stop condition (end of the search path) if ( path.size() == 0 ) break; } //_log::misc << "(QWidgetUtils::getAbsoluteWidget) OK" << std::endl; //there has to be only one element at the list if ( qws.size() != 1 ) { std::cout << "(QWidgetUtils::getAbsoluteWidget) ERROR. None or more than one widget selected. Result = " << qws.size() << std::endl; return NULL; } //if not, return the widget return qws.first(); }