void Slice::fillTriLayer(QHash<QString, Face*> faces){ QHash<QString, Face*>::iterator i; double zMax=0; for(i = faces.begin(); i != faces.end(); ++i){ if(zMax<i.value()->getMaxZ()->z()) zMax=i.value()->getMaxZ()->z(); } int layersNum=(int)ceil(zMax/layerHeight); qDebug() << "Max z: "<< zMax << "Number of layers: "<<layersNum; //create list for(int j=0; j<layersNum+1; j++){ this->triLayer.append(new QList<Face*>); this->edgeLayer.append(new QList< QList<HalfEdge*> *>); this->pointLayer.append(new QList< QList<QVector3D> *>); } double tempZ; for(i = faces.begin(); i != faces.end(); ++i){ tempZ=(int)((i.value()->getMinZ()->z()/layerHeight)+1)*layerHeight; while(tempZ<=i.value()->getMaxZ()->z()){ this->triLayer.at((int)ceil(tempZ/layerHeight))->append(i.value()); tempZ+=this->layerHeight; } } fillEdgeLayer(); fillPointLayer(); fillPolygonLayer(); }
void commit() { // update all documents // remove previous instances if ( indexPresent() ) { for ( QHash<Node, lucene::document::Document*>::iterator it = documentCache.begin(); it != documentCache.end(); ++it ) { lucene::document::Document* doc = it.value(); if ( const TCHAR* id = doc->get( idFieldName().data() ) ) { // this check is only for testing, it should NEVER fail lucene::index::Term* idTerm = _CLNEW lucene::index::Term( idFieldName().data(), id ); getIndexReader()->deleteDocuments( idTerm ); _CLDECDELETE( idTerm ); } } } // add the updated ones for ( QHash<Node, lucene::document::Document*>::iterator it = documentCache.begin(); it != documentCache.end(); ++it ) { lucene::document::Document* doc = it.value(); // never add empty docs if ( !docEmpty( doc ) ) { getIndexWriter()->addDocument( doc ); } _CLDELETE( doc ); } documentCache.clear(); }
void UltraGridMainWindow::doStart() { if(!started) { pushButton_start->setText("Stop"); started = true; statusBar.showMessage("Running"); QHash<QString, QString> sett = settings.getSettings(); QString command("uv "); if(sett.find("audio_cap") != sett.end()) command += "-s " + sett.find("audio_cap").value(); command += + " "; if(sett.find("audio_play") != sett.end()) command += "-r " + sett.find("audio_play").value(); command += + " "; if(sett.find("display") != sett.end()) { command += "-d " + sett.find("display").value(); if(sett.find("display_details") != sett.end()) command += ":" + sett.find("display_details").value(); } command += + " "; if(sett.find("capture") != sett.end()) { command += "-t " + sett.find("capture").value(); if(sett.find("capture_details") != sett.end()) command += ":" + sett.find("capture_details").value(); } command += + " "; if(sett.find("mtu") != sett.end()) command += "-m " + sett.find("mtu").value(); command += + " "; if(sett.find("compress") != sett.end()) { command += sett.find("compress").value(); if(sett.find("compress").value().compare("JPEG") == 0 && sett.find("compress_jpeg_quality") != sett.end()) { command += ":" + sett.find("compress_jpeg_quality").value(); } } command += + " "; if(sett.find("other") != sett.end()) command += sett.find("other").value(); command += + " "; history.insert(address->text()); updateHistory(); command += address->text(); process.setProcessChannelMode(QProcess::MergedChannels); process.start(command); } else { process.kill(); } }
QString EvaluateSubExpression(const QString& subexpr, const QVariant& v) { if (subexpr.size() == 0) { // limit the displayed decimal places if ((QMetaType::Type)v.type() == QMetaType::Double) { return QString::number(v.toDouble(), 'f', 2); } return v.toString(); } else if (subexpr.at(0) == '[') { int rightbracket = subexpr.indexOf(']'); if (rightbracket > 0) { bool ok = false; int index = subexpr.mid(1, rightbracket-1).toInt(&ok); if (ok && (QMetaType::Type)v.type() == QMetaType::QVariantList) { return EvaluateSubExpression(subexpr.mid(rightbracket + 1), v.toList().at(index)); } } } else { int dot = subexpr.indexOf('.'); QString key = subexpr.mid(0, dot); if ((QMetaType::Type)v.type() == QMetaType::QVariantHash) { QHash<QString, QVariant> h = v.toHash(); QHash<QString, QVariant>::const_iterator it = h.find(key); if (it != h.end()) return EvaluateSubExpression(subexpr.mid(key.length() + 1), *it); } else if ((QMetaType::Type)v.type() == QMetaType::QVariantMap) { QMap<QString, QVariant> h = v.toMap(); QMap<QString, QVariant>::const_iterator it = h.find(key); if (it != h.end()) return EvaluateSubExpression(subexpr.mid(key.length() + 1), *it); } } return ""; }
void AdaptiveLayout::tKey::ArrangeProperties(const QHash<QString, int> &propsOrder, int max) { QVector<int> permutation; permutation.resize(m_Properties.size()); for( QHash<QString, int>::iterator i = m_Properties.begin(); i != m_Properties.end(); ++i ) { int indexFrom = i.value(); int indexTo = indexFrom; QHash<QString, int>::const_iterator p = propsOrder.find(i.key()); if( p != propsOrder.end() ) // If we fail to find, the result may be incorrect { indexTo = p.value(); } i.value() = indexTo; permutation[indexFrom] = indexTo; } QVector<float> newProps; newProps.resize(max + 1); for( int iactor = 0; iactor < m_Actors.size(); iactor++ ) { tActor& actor = m_Actors[iactor]; newProps.fill(0.f); for( int i = 0; i < actor.props.size(); i++ ) { newProps[permutation[i]] = actor.props[i]; } actor.props = newProps; } }
KPrPageLayout * KPrPageLayouts::pageLayout( const QString & name, KoPALoadingContext & loadingContext, const QRectF & pageRect ) { KPrPageLayout * pageLayout = 0; QHash<QString, KoXmlElement*> layouts = loadingContext.odfLoadingContext().stylesReader().presentationPageLayouts(); QHash<QString, KoXmlElement*>::iterator it( layouts.find( name ) ); if ( it != layouts.end() ) { pageLayout = new KPrPageLayout(); if ( pageLayout->loadOdf( *( it.value() ), pageRect ) ) { QMap<KPrPageLayoutWrapper, KPrPageLayout *>::const_iterator it( m_pageLayouts.constFind( KPrPageLayoutWrapper( pageLayout ) ) ); if ( it != m_pageLayouts.constEnd() ) { delete pageLayout; pageLayout = *it; } else { m_pageLayouts.insert( KPrPageLayoutWrapper( pageLayout ), pageLayout ); } } else { delete pageLayout; pageLayout = 0; } } return pageLayout; }
static void fill(Counter &counter, const typename Counter::Container &container, bool fragmented) { qint64 allocated = 0; QHash<void *, int> allocations; for (int i = 0; i < 100; ++i) { for (int j = 0; j < 100; ++j) { int amount = fragmented ? j : i; allocated += amount; counter.request(amount); void *alloc = malloc(amount); allocations.insertMulti(alloc, amount); counter.obtain(reinterpret_cast<quintptr>(alloc)); QCOMPARE(counter.currentTotal(), allocated); } } QCOMPARE(allocated, 99 * 50 * 100); QCOMPARE(counter.currentTotal(), allocated); QCOMPARE(sum(container), allocated); for (auto it = allocations.begin(), end = allocations.end(); it != end; ++it) { free(it.key()); counter.release(reinterpret_cast<quintptr>(it.key())); allocated -= it.value(); QCOMPARE(counter.currentTotal(), allocated); } allocations.clear(); QCOMPARE(allocated, 0); QCOMPARE(counter.currentTotal(), 0); QCOMPARE(sum(container), 0); }
void TwitchApi::putRequest( const QString &urlString, QHash<QString, QString> urlParams) { QUrl url ( urlString ); QUrlQuery query(url); for (QHash<QString, QString>::iterator iter = urlParams.begin(); iter != urlParams.end(); ++iter) { query.addQueryItem(iter.key(),iter.value()); } url.setQuery(query); QNetworkRequest req ( url ); req.setRawHeader("Accept", "application/vnd.twitchtv.v3+json"); req.setRawHeader("Authorization", "OAuth "+this->oAuthAccessToken.toLatin1()); req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); m_nam.put( req, url.toEncoded() ); }
void Locator::buildDocTermMat(const QHash<SymbolPath, SymbolData>& symbolWordList, SparseMatrix& docTermMat, Eigen::VectorXd& radiusVec) { int nSymbols = symbolWordList.size(); int nWords = SymbolWordAttr::totalWords(); QVector<float> wordCountPerDoc(nSymbols,0.f); // total number of words for each doc QVector<float> docCountPerWord(nWords ,0.f); // total number of doc for each word docTermMat = SparseMatrix(nSymbols, nWords); radiusVec.resize(nSymbols); QHash<SymbolPath, SymbolData>::ConstIterator pSymbol; int ithSymbol = 0; for (pSymbol = symbolWordList.begin(); pSymbol != symbolWordList.end(); ++pSymbol, ++ithSymbol) { const SymbolData& item = pSymbol.value(); wordCountPerDoc[ithSymbol] = item.getTotalWordCount(); QMap<int,float>::ConstIterator pWord; for (pWord = item.m_wordWeightMap.begin(); pWord != item.m_wordWeightMap.end(); ++pWord) { int wordId = pWord.key(); float wordCount = pWord.value(); docCountPerWord[wordId] += 1; docTermMat.insert(ithSymbol, wordId) = wordCount; } radiusVec(ithSymbol) = item.getRadius(); } docTermMat.makeCompressed(); }
void VDirectoryTree::updateItemDirectChildren(QTreeWidgetItem *p_item) { QPointer<VDirectory> parentDir; if (p_item) { parentDir = getVDirectory(p_item); } else { parentDir = m_notebook->getRootDir(); } const QVector<VDirectory *> &dirs = parentDir->getSubDirs(); QHash<VDirectory *, QTreeWidgetItem *> itemDirMap; int nrChild = p_item ? p_item->childCount() : topLevelItemCount(); for (int i = 0; i < nrChild; ++i) { QTreeWidgetItem *item = p_item ? p_item->child(i) : topLevelItem(i); itemDirMap.insert(getVDirectory(item), item); } for (int i = 0; i < dirs.size(); ++i) { VDirectory *dir = dirs[i]; QTreeWidgetItem *item = itemDirMap.value(dir, NULL); if (item) { if (p_item) { p_item->removeChild(item); p_item->insertChild(i, item); } else { int topIdx = indexOfTopLevelItem(item); takeTopLevelItem(topIdx); insertTopLevelItem(i, item); } itemDirMap.remove(dir); } else { // Insert a new item if (p_item) { item = new QTreeWidgetItem(p_item); } else { item = new QTreeWidgetItem(this); } fillTreeItem(item, dir); buildSubTree(item, 1); } expandSubTree(item); } // Delete items without corresponding VDirectory for (auto iter = itemDirMap.begin(); iter != itemDirMap.end(); ++iter) { QTreeWidgetItem *item = iter.value(); if (p_item) { p_item->removeChild(item); } else { int topIdx = indexOfTopLevelItem(item); takeTopLevelItem(topIdx); } delete item; } }
/* * Input: A English word * Return: The translation of the word or NULL if the word not found. */ QString QMyHashMap::findWord(QString word) { QHash<QString, QString>::iterator it=dic.find(word); if(it==dic.end()) return ""; return it.value(); }
void VConfigManager::readShortcutsFromSettings() { const QString group("shortcuts"); m_shortcuts.clear(); m_shortcuts = readShortcutsFromSettings(defaultSettings, group); // Update default settings according to user settings. QHash<QString, QString> userShortcuts = readShortcutsFromSettings(userSettings, group); QSet<QString> matched; matched.reserve(m_shortcuts.size()); for (auto it = userShortcuts.begin(); it != userShortcuts.end(); ++it) { auto defaultIt = m_shortcuts.find(it.key()); if (defaultIt != m_shortcuts.end()) { QString sequence = it.value().trimmed(); if (sequence != defaultIt.value()) { if (isValidKeySequence(sequence)) { matched.insert(it.key()); *defaultIt = sequence; } } else { matched.insert(it.key()); } } } if (matched.size() < m_shortcuts.size()) { qDebug() << "override user shortcuts settings using default settings"; writeShortcutsToSettings(userSettings, group, m_shortcuts); } }
void ExtendedDialog::saveConfig() { assert( currentTab() == AUDIO_TAB || currentTab() == VIDEO_TAB ); QHash<QString, QVariant> *hashConfig = &m_hashConfigs[currentTab()]; for( QHash<QString, QVariant>::iterator i = hashConfig->begin(); i != hashConfig->end(); ++i ) { QVariant &value = i.value(); switch( static_cast<QMetaType::Type>(value.type()) ) { case QMetaType::QString: config_PutPsz( p_intf, qtu(i.key()), qtu(value.toString()) ); break; case QMetaType::Int: config_PutInt( p_intf, qtu(i.key()), value.toInt() ) ; break; case QMetaType::Double: case QMetaType::Float: config_PutFloat( p_intf, qtu(i.key()), value.toFloat() ) ; break; default: vlc_assert_unreachable(); } } config_SaveConfigFile( p_intf ); hashConfig->clear(); m_applyButton->setEnabled( false ); }
void QgsHttpRequestHandler::imageColors( QHash<QRgb, int>& colors, const QImage& image ) { colors.clear(); int width = image.width(); int height = image.height(); const QRgb* currentScanLine = nullptr; QHash<QRgb, int>::iterator colorIt; for ( int i = 0; i < height; ++i ) { currentScanLine = ( const QRgb* )( image.scanLine( i ) ); for ( int j = 0; j < width; ++j ) { colorIt = colors.find( currentScanLine[j] ); if ( colorIt == colors.end() ) { colors.insert( currentScanLine[j], 1 ); } else { colorIt.value()++; } } } }
//------------------------------------------------------------------------------ // Name: process_potential_pointer // Desc: //------------------------------------------------------------------------------ void DialogHeap::process_potential_pointer(const QHash<edb::address_t, edb::address_t> &targets, Result &result) { if(IProcess *process = edb::v1::debugger_core->process()) { if(result.data.isEmpty()) { edb::address_t pointer(0); edb::address_t block_ptr = block_start(result); edb::address_t block_end = block_ptr + result.size; while(block_ptr < block_end) { if(process->read_bytes(block_ptr, &pointer, edb::v1::pointer_size())) { auto it = targets.find(pointer); if(it != targets.end()) { #if QT_POINTER_SIZE == 4 result.data += QString("dword ptr [%1] |").arg(edb::v1::format_pointer(it.key())); #elif QT_POINTER_SIZE == 8 result.data += QString("qword ptr [%1] |").arg(edb::v1::format_pointer(it.key())); #endif result.points_to.push_back(it.value()); } } block_ptr += edb::v1::pointer_size(); } result.data.truncate(result.data.size() - 2); } } }
bool BookInfo::locationsHasChanged(const QHash<QString, BookLocation*>& locations) { qDebug() << Q_FUNC_INFO << " " << m_locations.size() << " other: " << locations.size(); if(m_locations.size() != locations.size()) return true; QHash<QString, BookLocation*>::const_iterator it = m_locations.constBegin(); QHash<QString, BookLocation*>::const_iterator itEnd = m_locations.constEnd(); while(it != itEnd) { if(locations.find(it.key()) == locations.end()) return true; else{ if(it.value()->note != locations.find(it.key()).value()->note) return true; if(it.value()->operation != locations.find(it.key()).value()->operation) return true; if(it.value()->pos != locations.find(it.key()).value()->pos) return true; if(it.value()->page!= locations.find(it.key()).value()->page) return true; } ++it; } return false; }
/** * Returns a 255 by 100 QImage containing a Histogram for the given channel. * The background is transparent (Alpha 0, RGB=255) */ QImage Histogram::getImage(Channel channel = LChannel, QBrush pen = Qt::gray) { // Create blank QImage and fill it with transparent background: QImage histImage(255, 100, QImage::Format_ARGB32); histImage.fill(0); QPainter painter(&histImage); painter.setBrush(Qt::transparent); painter.setPen(Qt::transparent); painter.drawRect(0,0,255,100); // Calculate the aspect ratio using the maximal value of the color histograms int maximum = (channel == LChannel ? maximumValue(LChannel) : maximumValue(RGB)); float ratio = 100.0/float(maximum); // Preparing the painter: painter.setBrush(pen); painter.setPen(pen.color()); int h; // Draw histogram QHash<int, int>* hist = get(channel); QHash<int, int>::const_iterator cit = hist->begin(); while (cit != hist->end()) { h = 100 - floor(ratio*cit.value()); painter.drawLine(cit.key(), h, cit.key(), 100); ++cit; } return histImage; }
SmartPointer<IElementReference> CommandService::RegisterElementForCommand( const SmartPointer<ParameterizedCommand>& command, const SmartPointer<UIElement>& element) { if (!command->GetCommand()->IsDefined()) { throw NotDefinedException( "Cannot define a callback for undefined command " + command->GetCommand()->GetId()); } if (element.IsNull()) { throw NotDefinedException("No callback defined for command " + command->GetCommand()->GetId()); } QHash<QString, QString> paramMap = command->GetParameterMap(); QHash<QString, Object::Pointer> parms; for (QHash<QString, QString>::const_iterator i = paramMap.begin(); i != paramMap.end(); ++i) { Object::Pointer value(new ObjectString(i.value())); parms.insert(i.key(), value); } IElementReference::Pointer ref(new ElementReference(command->GetId(), element, parms)); RegisterElement(ref); return ref; }
void BookInfo::setCachesFromInfo(QHash<QString, BookLocation*> locations) { qDebug() << Q_FUNC_INFO; QHash<QString, BookLocation*>::iterator it = m_locations.begin(); QHash<QString, BookLocation*>::iterator itEnd = m_locations.end(); while( it != itEnd ) { if(locationsPosCache.contains(it.value()->bookmark) && it.value()->pos > 0) locationsPosCache.insert(it.value()->bookmark, it.value()->pos); if(locationsPageCache.contains(it.value()->bookmark) && it.value()->pos > 0) locationsPageCache.insert(it.value()->bookmark, it.value()->page); ++it; } QHash<QString, BookLocation*>::iterator itLoc = locations.begin(); QHash<QString, BookLocation*>::iterator itLocEnd = locations.end(); while( itLoc != itLocEnd ) { if(locationsPosCache.contains(itLoc.value()->bookmark) && itLoc.value()->pos > 0) locationsPosCache.insert(itLoc.value()->bookmark, itLoc.value()->pos); if(locationsPageCache.contains(itLoc.value()->bookmark) && itLoc.value()->pos > 0) locationsPageCache.insert(itLoc.value()->bookmark, itLoc.value()->page); ++itLoc; } }
//------------------------------------------------------------------------------ // Name: showEvent // Desc: //------------------------------------------------------------------------------ void DialogPlugins::showEvent(QShowEvent *) { QHash<QString, QObject *> plugins = edb::v1::plugin_list(); plugin_model_->clear(); for(auto it = plugins.begin(); it != plugins.end(); ++it) { const QString filename = it.key(); QString plugin_name; QString author; QString url; // get a QObject from the plugin if(QObject *const p = it.value()) { const QMetaObject *const meta = p->metaObject(); plugin_name = meta->className(); const int author_index = meta->indexOfClassInfo("author"); if(author_index != -1) { author = meta->classInfo(author_index).value(); } const int url_index = meta->indexOfClassInfo("url"); if(url_index != -1) { url = meta->classInfo(url_index).value(); } } plugin_model_->addPlugin(filename, plugin_name, author, url); } ui->plugins_table->resizeColumnsToContents(); }
void TimeZoneWidget::mousePressEvent(QMouseEvent *event) { if (event->button() != Qt::LeftButton) return; // Set nearest location int nX = 999999, mX = event->pos().x(); int nY = 999999, mY = event->pos().y(); QHash<QString, QList<Global::Location> > hash = Global::getLocations(); QHash<QString, QList<Global::Location> >::iterator iter = hash.begin(); while (iter != hash.end()) { QList<Global::Location> locations = iter.value(); for (int i = 0; i < locations.size(); ++i) { Global::Location loc = locations[i]; QPoint locPos = getLocationPosition(loc.longitude, loc.latitude); if ((abs(mX - locPos.x()) + abs(mY - locPos.y()) < abs(mX - nX) + abs(mY - nY))) { currentLocation = loc; nX = locPos.x(); nY = locPos.y(); } } ++iter; } // Set zone image and repaint widget setCurrentLocation(currentLocation); // Emit signal emit locationChanged(currentLocation); }
void Grid::unfixArcConsistency(QHash<Cell*, QSet<char> > diff) { for( auto i=diff.begin(); i!=diff.end(); ++i ){ Cell* cell = i.key(); cell->appendToDomain(i.value()); } }
DENG_ENTRYPOINT void *GetGameAPI(char const *name) { if (auto *ptr = Common_GetGameAPI(name)) { return ptr; } #define HASH_ENTRY(Name, Func) std::make_pair(QByteArray(Name), de::function_cast<void *>(Func)) static QHash<QByteArray, void *> const funcs( { HASH_ENTRY("DrawWindow", D_DrawWindow), HASH_ENTRY("EndFrame", D_EndFrame), HASH_ENTRY("GetInteger", D_GetInteger), HASH_ENTRY("GetPointer", D_GetVariable), HASH_ENTRY("PostInit", D_PostInit), HASH_ENTRY("PreInit", G_PreInit), HASH_ENTRY("Shutdown", D_Shutdown), HASH_ENTRY("TryShutdown", G_TryShutdown), }); #undef HASH_ENTRY auto found = funcs.find(name); if (found != funcs.end()) return found.value(); return nullptr; }
foreach(currentLayer, layers) { QJsonObject layerObject; layerObject["properties"] = ResourcePropertiesToJSON(currentLayer); QHash<TileCoord, Tile> tiles = currentLayer->GetAllTiles(); QHash<TileCoord, Tile>::iterator i = tiles.begin(); QJsonArray tileArray; while(i != tiles.end()) { QJsonObject tileObject; tileObject["oX"] = i.value().origin.first; tileObject["oY"] = i.value().origin.second; tileObject["x"] = i.value().pos.first; tileObject["y"] = i.value().pos.second; tileArray.append(tileObject); ++i; } layerObject["tiles"] = tileArray; layerArray.append(layerObject); }
bool LocalTextRecordingEditor::save(const Media::Recording* recording) { Q_UNUSED(recording) QHash<QByteArray,QByteArray> ret = static_cast<const Media::TextRecording*>(recording)->d_ptr->toJsons(); QDir dir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); //Make sure the directory exist dir.mkdir("text/"); //Save each file for (QHash<QByteArray,QByteArray>::const_iterator i = ret.begin(); i != ret.end(); ++i) { QFile file(QString("%1/text/%2.json").arg(dir.path()).arg(QString(i.key()))); if ( file.open(QIODevice::WriteOnly | QIODevice::Text) ) { QTextStream streamFileOut(&file); streamFileOut.setCodec("UTF-8"); streamFileOut << i.value(); streamFileOut.flush(); file.close(); } } return true; }
bool init() { if( m_script->action()->hadError() ) m_script->action()->clearError(); delete m_engine; m_engine = new QScriptEngine(); // load the Qross QScriptExtensionPlugin plugin that provides // us a bridge between Qross and QtScript. See here plugin.h m_engine->importExtension("qross"); if( m_engine->hasUncaughtException() ) { handleException(); delete m_engine; m_engine = 0; return false; } // the Qross QScriptExtensionPlugin exports the "Qross" property. QScriptValue global = m_engine->globalObject(); m_qross = global.property("Qross"); Q_ASSERT( m_qross.isQObject() ); Q_ASSERT( ! m_engine->hasUncaughtException() ); // Attach our Qross::Action instance to be able to access it in // scripts. Just like at the Kjs-backend we publish our own // action as "self". m_self = m_engine->newQObject( m_script->action() ); global.setProperty("self", m_self, QScriptValue::ReadOnly|QScriptValue::Undeletable); { // publish the global objects. QHash< QString, QObject* > objects = Manager::self().objects(); QHash< QString, QObject* >::Iterator it(objects.begin()), end(objects.end()); for(; it != end; ++it) global.setProperty(it.key(), m_engine->newQObject( it.value() ) ); } { // publish the local objects. QHash< QString, QObject* > objects = m_script->action()->objects(); QHash< QString, QObject* >::Iterator it(objects.begin()), end(objects.end()); for(; it != end; ++it) { copyEnumsToProperties( it.value() ); global.setProperty(it.key(), m_engine->newQObject( it.value() ) ); } } return ! m_engine->hasUncaughtException(); }
Core::Command *NavigationSubWidget::command(const QString &title) const { const QHash<Id, Command *> commandMap = m_parentWidget->commandMap(); QHash<Id, Command *>::const_iterator r = commandMap.find(Id::fromString(title)); if (r != commandMap.end()) return r.value(); return 0; }
bool ODFItem::setFileId(const QHash<QString, quint64> &names, const QString& value, quint64 &fileid) const { if ( value == sUNDEF) { fileid = i64UNDEF; return true; // legal; some properties might not have a value(name) } if ( Ilwis3Connector::ilwisType(value) & itCOORDSYSTEM) { if ( value == "latlonwgs84.csy" ) { Resource resource = mastercatalog()->name2Resource("code=epsg:4326", itCOORDSYSTEM); if ( !resource.isValid()) { return ERROR1(ERR_FIND_SYSTEM_OBJECT_1, "Wgs 84"); } fileid = resource.id(); return true; } if ( value == "unknown.csy" ) { Resource resource = mastercatalog()->name2Resource("code=csy:unknown", itCOORDSYSTEM); if ( !resource.isValid()) { return ERROR1(ERR_FIND_SYSTEM_OBJECT_1, "'Unknown' coordinate system"); } fileid = resource.id(); return true; } } if ( Ilwis3Connector::ilwisType(value) & itGEOREF) { if ( value == "none.grf" ) { Resource resource = mastercatalog()->name2Resource("code=georef:undetermined", itGEOREF); if ( !resource.isValid()) { return ERROR1(ERR_FIND_SYSTEM_OBJECT_1, "'undetermined' georeference"); } fileid = resource.id(); return true; } } QString completeName = (value.contains(QRegExp("\\\\|/"))) ? value : _ini.fileInfo().canonicalPath() + "/" + value; QHash<QString, quint64>::const_iterator iter = names.find(completeName.toLower()); if (iter != names.end()){ fileid = iter.value(); } else { // at this time we can't rely on the working catalog to be set(if we are initializing it), so no normal resolve // the mastercatalog will contain system items at this moment so we can check these first QString baseName = value.left(value.indexOf(".")); IlwisTypes tp = Ilwis3Connector::ilwisType(value); Resource resource = mastercatalog()->name2Resource(baseName, tp); if ( resource.isValid()) { fileid = resource.id(); } else { QUrl url = QUrl::fromLocalFile(completeName); fileid = mastercatalog()->url2id(url, tp); if ( fileid == i64UNDEF) { kernel()->issues()->log(TR(ERR_MISSING_1).arg(completeName)); fileid = i64UNDEF; return false; } } } return true; }
QHash<int, Collection::Album_ptr> LocalCollectionStorage::GetAllAlbums () { QHash<int, Collection::Album_ptr> newAlbums; QSqlQuery getter (DB_); QHash<int, QStringList> trackGenres; if (!getter.exec ("SELECT TrackId, Name FROM genres;")) { Util::DBLock::DumpError (getter); throw std::runtime_error ("cannot fetch genres"); } while (getter.next ()) trackGenres [getter.value (0).toInt ()] << getter.value (1).toString (); if (!getter.exec ("SELECT albums.Id, albums.Name, albums.Year, albums.CoverPath, tracks.Id, tracks.TrackNumber, tracks.Name, tracks.Length, tracks.Path FROM tracks INNER JOIN albums ON tracks.AlbumID = albums.Id;")) { Util::DBLock::DumpError (getter); throw std::runtime_error ("cannot fetch albums"); } while (getter.next ()) { const int albumID = getter.value (0).toInt (); auto albumPos = newAlbums.find (albumID); if (albumPos == newAlbums.end ()) { const Collection::Album a = { albumID, getter.value (1).toString (), getter.value (2).toInt (), getter.value (3).toString (), QList<Collection::Track> () }; albumPos = newAlbums.insert (albumID, Collection::Album_ptr (new Collection::Album (a))); } auto albumPtr = *albumPos; auto& tracks = albumPtr->Tracks_; const int trackId = getter.value (4).toInt (); Collection::Track t = { trackId, getter.value (5).toInt (), getter.value (6).toString (), getter.value (7).toInt (), trackGenres.value (trackId), getter.value (8).toString () }; tracks << t; } getter.finish (); return newAlbums; }
bool ContentDialog::isWidgetActive(int id, const QHash<int, std::tuple<ContentDialog *, GenericChatroomWidget *> > &list) { auto iter = list.find(id); if (iter == list.end()) return false; return std::get<0>(iter.value())->activeChatroomWidget == std::get<1>(iter.value()); }