QTreeWidgetItem * QgsCustomizationDialog::createTreeItemWidgets() { QgsDebugMsg( "Entered" ); QDomDocument myDoc( "QgsWidgets" ); QFile myFile( QgsApplication::pkgDataPath() + "/resources/customization.xml" ); if ( !myFile.open( QIODevice::ReadOnly ) ) { return NULL; } if ( !myDoc.setContent( &myFile ) ) { myFile.close(); return NULL; } myFile.close(); QDomElement myRoot = myDoc.documentElement(); if ( myRoot.tagName() != "qgiswidgets" ) { return NULL; } QTreeWidgetItem *myItem = readWidgetsXmlNode( myRoot ); // Do not translate "Widgets", currently it is also used as path myItem->setData( 0, Qt::DisplayRole, "Widgets" ); return myItem; }
void Server::processTextMessage(QString message) { QWebSocket *pClient = qobject_cast<QWebSocket *>(sender()); QSqlQuery query("SELECT players.first_name, players.last_name, players.date_of_birth FROM players LIMIT 0,10" , db.myDatabase); /* * Pseudo code (frontend): * recieve JSon object * present JSon object to the user * * TODO: * * Frontend: * Get a input more usable than a string, * maybe through a table (generated by a hardcoded query) made clickable through JQuery * * Backend: * If the Pseudo code above is complete it should be pretty much done. * Pretty up the code, fix the Databasemanager class, it is pretty useless atm. */ QJsonObject myJsonObject; QString tArray[3] = {"players.first_name", "players.last_name", "players.date_of_birth "}; QJsonArray myArray[3]; while(query.next()) for(int i=0 ; i<3 ; i++) { myArray[i].push_back(query.value(i).toString()); } for(int i = 0 ; i<3 ; i++) myJsonObject.insert(tArray[i], myArray[i]); QJsonDocument myDoc(myJsonObject); if (pClient) { qDebug() << myDoc.toJson(); pClient->sendTextMessage(myDoc.toJson()); } }
bool LeafMatchExpression::_matches( const FieldRef& fieldRef, const MatchableDocument* doc, MatchDetails* details ) const { bool traversedArray = false; size_t idxPath = 0; BSONElement e = doc->getFieldDottedOrArray( fieldRef, &idxPath, &traversedArray ); if ( e.type() != Array || traversedArray ) { return matchesSingleElement( e ); } string rest = fieldRef.dottedField( idxPath + 1 ); StringData next; bool nextIsNumber = false; if ( rest.size() > 0 ) { next = fieldRef.getPart( idxPath + 1 ); nextIsNumber = isAllDigits( next ); } BSONObjIterator i( e.Obj() ); while ( i.more() ) { BSONElement x = i.next(); bool found = false; if ( rest.size() == 0 ) { found = matchesSingleElement( x ); } else if ( x.type() == Object ) { FieldRef myFieldRef; myFieldRef.parse( rest ); BSONMatchableDocument myDoc( x.Obj() ); found = _matches( myFieldRef, &myDoc, NULL ); } if ( !found && nextIsNumber && next == x.fieldName() ) { string reallyNext = fieldRef.dottedField( idxPath + 2 ); if ( reallyNext.size() == 0 ) { found = matchesSingleElement( x ); } else if ( x.isABSONObj() ) { // TODO: this is slow FieldRef myFieldRef; myFieldRef.parse( "x." + reallyNext ); BSONObjBuilder b; b.appendAs( x, "x" ); BSONObj temp = b.obj(); BSONMatchableDocument myDoc( temp ); found = _matches( myFieldRef, &myDoc, NULL ); } } if ( found ) { if ( !_allHaveToMatch ) { if ( details && details->needRecord() ) { // this block doesn't have to be inside the _allHaveToMatch handler // but this matches the old semantics details->setElemMatchKey( x.fieldName() ); } return true; } } else if ( _allHaveToMatch ) { return false; } } if ( rest.size() > 0 ) { // we're supposed to have gone further down return false; } return matchesSingleElement( e ); }