本文整理汇总了C++中QMap::find方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::find方法的具体用法?C++ QMap::find怎么用?C++ QMap::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: remove
/*!
Removes the mapping from application \a app to its process id.
\internal
*/
void OomPrivate::remove(const QString& app)
{
if (app.isEmpty())
return;
int pid = 0;
QMap<QString,int>::iterator i;
i = important_procs_.find(app);
if (i != important_procs_.end()) {
pid = i.value();
important_procs_.erase(i);
qLog(OOM) << "Removed important proc:" << app << pid;
return;
}
i = critical_procs_.find(app);
if (i != critical_procs_.end()) {
pid = i.value();
critical_procs_.erase(i);
qLog(OOM) << "Removed critical proc:" << app << pid;
return;
}
i = expendable_procs_.find(app);
if (i != expendable_procs_.end()) {
pid = i.value();
expendable_procs_.erase(i);
qLog(OOM) << "Removed expendable proc:" << app << pid;
return;
}
}
示例2: execute_server
void SetFixNodeStateExecutor::execute_server() {
int id;
bool state;
*stream >> id >> state;
Data::Graph * currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();
if (nodes->contains(id)) {
this->SetFixNodeState(*nodes->find(id), state);
} else {
QMap<qlonglong, osg::ref_ptr<Data::Node> >* mergeNodes = currentGraph->getMetaNodes();
if (mergeNodes->contains(id)) {
this->SetFixNodeState(*mergeNodes->find(id),state);
}
}
Server * server = Server::getInstance();
server->sendFixNodeState(id, state);
if (((QOSG::CoreWindow *)server->getCoreWindowReference())->playing()) {
server->getLayoutThread()->play();
}
}
示例3: addPresetNPCDialogData
void MagicTowerLoader::addPresetNPCDialogData(const QMap<QString, QString>& parameters)
{
NPCDialogData* object = new NPCDialogData();
QString presetName = parameters["name"];
for(int i=1;;i++)
{
QString pattern = QString("page%1_").arg(i);
if(parameters.find(pattern+"title")==parameters.end()) break;
QString title = parameters[pattern+"title"];
QString titlePixmap = parameters[pattern+"titlePixmap"];
QString content = parameters[pattern+"content"];
if(parameters.find(pattern+"options")==parameters.end())
{
object->addPage(titlePixmap,title,content);
continue;
}
QStringList listOption = parameters[pattern+"options"].trimmed().split("|");
QStringList listProp = parameters[pattern+"purchasedProperties"].trimmed().split("|");
QString costProperty = parameters[pattern+"costProperty"];
int costValues = parameters[pattern+"costValues"].toInt();
int costIncreaseMode = parameters[pattern+"costIncreaseMode"].toInt();
int costIncreaseRate = parameters[pattern+"costIncreaseRate"].toInt();
QStringList listValueString = parameters[pattern+"purchasedValues"].trimmed().split("|");
QList<int> listValue;
for(int i=0;i<listValueString.size();i++)
{
listValue << listValueString[i].toInt();
}
object->addPage(titlePixmap,title,content,costProperty,costValues,costIncreaseMode,costIncreaseRate,listOption,listProp,listValue);
}
objectPreset[presetName] = object;
}
示例4: execute_client
void MoveNodeExecutor::execute_client() {
int id;
float x,y,z;
*stream >> id >> x >> y >> z;
Data::Graph * currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();
//qDebug() << "Moving" << id << "to" << x << y << z;
if (nodes->contains(id)) {
this->moveNode(*nodes->find(id), osg::Vec3(x,y,z));
} else {
QMap<qlonglong, osg::ref_ptr<Data::Node> >* mergeNodes = currentGraph->getMetaNodes();
if (mergeNodes->contains(id)) {
this->moveNode(*mergeNodes->find(id), osg::Vec3(x,y,z));
} else {
qDebug() << "Nepoznam uzol" << id;
}
}
//TODO: refactor
// Stupid way to fix restriction shape refreshing
((QOSG::CoreWindow *)Client::getInstance()->getCoreWindowReference())->getLayoutThread()->pause();
((QOSG::CoreWindow *)Client::getInstance()->getCoreWindowReference())->getLayoutThread()->play();
}
示例5: execute_server
void NewEdgeExecutor::execute_server()
{
Server* server = Server::getInstance();
QString name;
int from, to;
bool oriented;
*stream >> name >> from >> to >> oriented;
//qDebug()<< "[NEW NODE]" << "[" << x << "," << y << "," << z << "]";
Data::Graph* currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();
osg::ref_ptr<Data::Node> node_from = *nodes->find( from );
osg::ref_ptr<Data::Node> node_to = *nodes->find( to );
Data::Type* type = currentGraph->addType( Data::GraphLayout::META_EDGE_TYPE );
osg::ref_ptr<Data::Edge> newEdge = currentGraph->addEdge( "NewEdge",node_from,node_to,type,oriented );
if ( ( ( QOSG::CoreWindow* )server->getCoreWindowReference() )->playing() ) {
server->getLayoutThread()->play();
}
server->sendNewEdge( newEdge );
}
示例6: setCheckingMail
void NetworkAccount::setCheckingMail(bool checking)
{
mCheckingMail = checking;
if(host().isEmpty())
return;
if(checking)
{
if(s_serverConnections.find(host()) != s_serverConnections.end())
s_serverConnections[host()] += 1;
else
s_serverConnections[host()] = 1;
kdDebug(5006) << "check mail started - connections for host "
<< host() << " now is "
<< s_serverConnections[host()] << endl;
}
else
{
if(s_serverConnections.find(host()) != s_serverConnections.end() &&
s_serverConnections[host()] > 0)
{
s_serverConnections[host()] -= 1;
kdDebug(5006) << "connections to server " << host()
<< " now " << s_serverConnections[host()] << endl;
}
}
}
示例7: generete_doc
void StringClient::generete_doc(QMap<QString, QString> message)
{
rapidjson::Document d;
d.SetObject();
rapidjson::Document::AllocatorType& allocator = d.GetAllocator();
auto name = message.find("name");
rapidjson::Value name_value;
name_value.SetString(name.value().toUtf8().constData(), name.value().toUtf8().size(), allocator);
d.AddMember("name", name_value, allocator);
auto type = message.find("type");
rapidjson::Value type_value;
type_value.SetString(type.value().toUtf8().constData(), type.value().toUtf8().size(), allocator);
d.AddMember("type", type_value, allocator);
auto msg = message.find("msg");
rapidjson::Value msg_value;
msg_value.SetString(msg.value().toUtf8().constData(), msg.value().toUtf8().size(), allocator);
d.AddMember("msg", msg_value, allocator);
auto addressee = message.find("addressee");
rapidjson::Value addressee_value;
addressee_value.SetString(addressee.value().toUtf8().constData(), addressee.value().toUtf8().size(), allocator);
d.AddMember("addressee", addressee_value, allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer, rapidjson::Document::EncodingType, rapidjson::ASCII<> > writer(buffer);
d.Accept(writer);
tcp_socket_->write(buffer.GetString());
tcp_socket_->write("\n");
}
示例8: fromText
void ITranslatable::fromText(QStringList &text)
{
//Get Translation map
QMap <QString,QWidget*> paramMap = getParameterMap();
for (int i=0; i<text.count(); ++i) {
QString t = text.at(i);
//Get param key
QString key = t.section("=",0,0).trimmed();
if (paramMap.find(key) != paramMap.end()) {
QWidget* p = paramMap.find(key).value();
//Is text type.
QLineEdit* l = dynamic_cast<QLineEdit*>(p);
if (l) {
l->setText(t.section("=",1,1).trimmed());
continue;
}
//Is checkbox type.
QCheckBox* b = dynamic_cast<QCheckBox*>(p);
if (b) {
if (t.section("=",1,1).trimmed() == "yes")
b->setChecked(true);
else
b->setChecked(false);
continue;
}
}
}
}
示例9: execute_client
void SetFixNodeStateExecutor::execute_client() {
int id;
bool state;
*stream >> id >> state;
Data::Graph * currentGraph = Manager::GraphManager::getInstance()->getActiveGraph();
QMap<qlonglong, osg::ref_ptr<Data::Node> >* nodes = currentGraph -> getNodes();
Client * client = Client::getInstance();
if (nodes->contains(id)) {
Data::Node * node = *nodes->find(id);
this->SetFixNodeState(node, state);
if (client->selected_nodes.contains(node)) {
client->selected_nodes.removeOne(node);
}
} else {
QMap<qlonglong, osg::ref_ptr<Data::Node> >* mergeNodes = currentGraph->getMetaNodes();
if (mergeNodes->contains(id)) {
Data::Node * node = *mergeNodes->find(id);
this->SetFixNodeState(node,state);
if (client->selected_nodes.contains(node)) {
client->selected_nodes.removeOne(node);
}
}
}
}
示例10:
ConfCertDialog::~ConfCertDialog()
{
QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.find(peerId);
if (it != instances_ssl.end())
instances_ssl.erase(it);
QMap<RsPgpId, ConfCertDialog*>::iterator it2 = instances_pgp.find(pgpId);
if (it2 != instances_pgp.end())
instances_pgp.erase(it2);
}
示例11: getSettings
QMap<qlonglong, osg::Vec4f> Model::EdgeDAO::getColors( QSqlDatabase* conn, bool* error, qlonglong graphID, qlonglong layoutID )
{
*error = FALSE;
bool error2 = false;
osg::Vec4f color;
qlonglong id;
QMap<qlonglong, osg::Vec4f> colors;
QMap<qlonglong, QString> edgeColorR;
QMap<qlonglong, QString> edgeColorG;
QMap<qlonglong, QString> edgeColorB;
QMap<qlonglong, QString> edgeColorA;
QMap<qlonglong, QString>::iterator iter_r;
QMap<qlonglong, QString>::iterator iter_g;
QMap<qlonglong, QString>::iterator iter_b;
QMap<qlonglong, QString>::iterator iter_a;
edgeColorR = getSettings( conn, &error2, graphID, layoutID, "color_r" );
if ( error2 ) {
qDebug() << "[Model::EdgeDAO::getColors] Could not get color_r setting";
*error = error2;
return colors;
}
edgeColorG = getSettings( conn, &error2, graphID, layoutID, "color_g" );
if ( error2 ) {
qDebug() << "[Model::EdgeDAO::getColors] Could not get color_g setting";
*error = error2;
return colors;
}
edgeColorB = getSettings( conn, &error2, graphID, layoutID, "color_b" );
if ( error2 ) {
qDebug() << "[Model::EdgeDAO::getColors] Could not get color_b setting";
*error = error2;
return colors;
}
edgeColorA = getSettings( conn, &error2, graphID, layoutID, "color_a" );
if ( error2 ) {
qDebug() << "[Model::NodeDAO::getColors] Could not get color_a setting";
*error = error2;
return colors;
}
//nacitavame ulozene farby v databaze
for ( iter_r = edgeColorR.begin(); iter_r != edgeColorR.end(); ++iter_r ) {
id = iter_r.key();
iter_g = edgeColorG.find( id );
iter_b = edgeColorB.find( id );
iter_a = edgeColorA.find( id );
color = osg::Vec4f( iter_r.value().toFloat(), iter_g.value().toFloat(), iter_b.value().toFloat(), iter_a.value().toFloat() );
colors.insert( id, color );
}
return colors;
}
示例12: calcExpansion
/*!
* \brief calcExpansion estimates the thermal expansion value for corrections.
* \param tp
* \param SET
*/
void SimpleTemperatureCompensation::calcExpansion(TrafoParam &tp)
{
FunctionConfiguration myConfig = this->getFunctionConfiguration();
QMap<QString,QString> stringParameter = myConfig.stringParameter;
QMap<QString,double> doubleParameter = myConfig.doubleParameter;
QString material = "";
double actTemp = 20.0;
double refTemp = 20.0;
double tempAccuracy = 0.0;
double expansionCoefficient = 0.0;
if(stringParameter.contains("material")){
material = static_cast<QString>(stringParameter.find("material").value());
protMaterial = material;
expansionCoefficient = Materials::getExpansionCoefficient(material);
protExpansionCoeff = QString::number(expansionCoefficient,'f',6);
}
if(doubleParameter.contains("actualTemperature")){
actTemp = static_cast<double>(doubleParameter.find("actualTemperature").value());
protActTemp = QString::number(actTemp,'f',2);
}
if(doubleParameter.contains("referenceTemperature")){
refTemp = static_cast<double>(doubleParameter.find("referenceTemperature").value());
protRefTemp = QString::number(refTemp,'f',2);
}
if(doubleParameter.contains("temperatureAccuracy")){
tempAccuracy = static_cast<double>(doubleParameter.find("temperatureAccuracy").value());
protTempAccuracy = QString::number(tempAccuracy,'f',2);
}
double expansion = (actTemp-refTemp)*expansionCoefficient;
protExpansion = QString::number(expansion,'f',6);
double m = 1.0/(1+ (expansion));
OiMat eMat(4,4);
for(int i = 0; i < 4; i++){
eMat.setAt(i,i, 1.0);
}
OiMat scale(4,4);
scale.setAt(0,0,m);
scale.setAt(1,1,m);
scale.setAt(2,2,m);
scale.setAt(3,3,1.0);
tp.setHomogenMatrix(eMat, eMat, scale);
this->calcAccuracy(tp,tempAccuracy,expansion);
this->calcAccuracy(tp,tempAccuracy,expansion);
}
示例13:
ConfCertDialog::~ConfCertDialog()
{
// if(peerId.isNull())
{
QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.find(peerId);
if (it != instances_ssl.end())
instances_ssl.erase(it);
}
// else
{
QMap<RsPgpId, ConfCertDialog*>::iterator it = instances_pgp.find(pgpId);
if (it != instances_pgp.end())
instances_pgp.erase(it);
}
}
示例14: main
int main(int argc,char *argv[])
{
QCoreApplication a(argc,argv);
QMap<QString,QString> map;
map.insert("beijing","111");
map.insert("shanghai","021");
map.insert("tianjing","022");
map.insert("chongqing","0222");
map.insert("changchun","0431");
QMap<QString,QString>::const_iterator i;
for(i = map.constBegin();i!=map.constEnd();++i)
{
qDebug()<<i.key()<<" "<<i.value();
}
QMap<QString,QString>::iterator mi;
mi = map.find("chongqing");
if(mi!=map.end())
{
mi.value()="043200";
}
QMap<QString,QString>::const_iterator modi;
qDebug()<<"";
for(modi = map.constBegin();modi!=map.constEnd();++modi)
{
qDebug()<<modi.key()<<" "<<modi.value();
}
return a.exec();
}
示例15: checkMinDistance
bool QgsPointSample::checkMinDistance( QgsPoint& pt, QgsSpatialIndex& index, double minDistance, QMap< QgsFeatureId, QgsPoint >& pointMap )
{
if ( minDistance <= 0 )
{
return true;
}
QList<QgsFeatureId> neighborList = index.nearestNeighbor( pt, 1 );
if ( neighborList.isEmpty() )
{
return true;
}
QMap< QgsFeatureId, QgsPoint >::const_iterator it = pointMap.find( neighborList[0] );
if ( it == pointMap.constEnd() ) //should not happen
{
return true;
}
QgsPoint neighborPt = it.value();
if ( neighborPt.sqrDist( pt ) < ( minDistance * minDistance ) )
{
return false;
}
return true;
}