本文整理汇总了C++中QMap::firstKey方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::firstKey方法的具体用法?C++ QMap::firstKey怎么用?C++ QMap::firstKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::firstKey方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: postSave
void Image::postSave(QMap<QString, Image::SaveResult> result, bool addMd5, bool startCommands, int count)
{
const QString &path = result.firstKey();
Image::SaveResult res = result[path];
postSaving(path, addMd5 && res == SaveResult::Saved, startCommands, count);
}
示例2: SetVector
bool BloombergVector::SetVector(const QList<QDate>& Dates, const QList<double>& Values) {
Q_D(BloombergVector);
if (
Dates.size() != Values.size() //Each date has a value and vice versa
|| Values.isEmpty() //The vectors are not empty
|| Dates.toSet().size()!=Dates.size() //There are no duplicates in the dates
) return false;
QMap<QDate, double> SortedValues;
for (int i = 0; i <Dates.size(); i++) {
if (Dates.at(i).isNull())
return false;
if (Values.at(i)<0.0)
return false;
SortedValues.insert(Dates.at(i), Values.at(i));
}
d->m_AnchorDate = SortedValues.firstKey();
d->m_VectVal.clear();
int NumMonths;
for (auto i = SortedValues.constBegin()+1; i != SortedValues.constEnd(); i++) {
NumMonths = MonthDiff(i.key(), (i - 1).key());
for (int j = 0; j < NumMonths; j++)
d->m_VectVal.append((i - 1).value());
}
d->m_VectVal.append(SortedValues.last());
RepackVector();
return true;
}
示例3: showSearchResult
// 显示在线音乐搜索结果
void NetWorkWidget::showSearchResult(QMap<QString, QStringList> musicList)
{
musicUrls = musicList.first();
QString musicName = musicList.firstKey();
while(tableWidget->rowCount())
{
tableWidget->removeRow(tableWidget->rowCount()-1);
}
for (int i=0; i<musicUrls.count(); ++i)
{
tableWidget->insertRow(tableWidget->rowCount());
tableWidget->setItem(tableWidget->rowCount()-1, 0, new QTableWidgetItem(musicName));
tableWidget->setItem(tableWidget->rowCount()-1, 1, new QTableWidgetItem("试听"));
tableWidget->setItem(tableWidget->rowCount()-1, 2, new QTableWidgetItem("下载"));
}
}
示例4: expireCacheLocked
void TileCache::expireCacheLocked() {
if (m_cache.size() > CACHE_ITEMS) {
// qDebug() << "Cache size" << m_cache.size() << "and maximum is" << CACHE_ITEMS;
QMap<qint64, int> map;
for (QSet<CacheItem>::const_iterator iter = m_cache.constBegin();
iter != m_cache.constEnd(); iter++) {
map.insert(iter->ts, 0);
}
while (m_cache.size() >= CACHE_ITEMS) {
if (!map.isEmpty()) {
qint64 ts = map.firstKey();
map.remove(ts);
expireCacheTsLocked(ts);
} else {
break;
}
}
// qDebug() << "Cache size" << m_cache.size();
}
}
示例5: loadRefDatas
void PluginGauss::loadRefDatas()//const ProjectSettings& settings)
{
mRefDatas.clear();
QString calibPath = getRefsPath();
QDir calibDir(calibPath);
QFileInfoList files = calibDir.entryInfoList(QStringList(), QDir::Files);
for(int i=0; i<files.size(); ++i)
{
if(files[i].suffix().toLower() == "csv")
{
QFile file(files[i].absoluteFilePath());
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
QMap<QString, QMap<double, double> > curves;
QMap<double, double> curveG;
QMap<double, double> curveG95Sup;
QMap<double, double> curveG95Inf;
QTextStream stream(&file);
while(!stream.atEnd())
{
QString line = stream.readLine();
if(!isComment(line))
{
QStringList values = line.split(",");
if(values.size() >= 3)
{
double t = values[0].toDouble();
double g = values[1].toDouble();
double gSup = g + 1.96 * values[2].toDouble();
double gInf = g - 1.96 * values[2].toDouble();
curveG[t] = g;
curveG95Sup[t] = gSup;
curveG95Inf[t] = gInf;
}
}
}
file.close();
// The curves do not have 1-year precision!
// We have to interpolate in the blanks
double tmin = curveG.firstKey();
double tmax = curveG.lastKey();
for(double t=tmin; t<tmax; ++t)//t+=settings.mStep)//++t)
{
if(curveG.find(t) == curveG.end())
{
// This actually return the iterator with the nearest greater key !!!
QMap<double, double>::const_iterator iter = curveG.lowerBound(t);
if(iter != curveG.end())
{
double t_upper = iter.key();
--iter;
if(iter != curveG.begin())
{
double t_under = iter.key();
//qDebug() << t_under << " < " << t << " < " << t_upper;
double g_under = curveG[t_under];
double g_upper = curveG[t_upper];
double gsup_under = curveG95Sup[t_under];
double gsup_upper = curveG95Sup[t_upper];
double ginf_under = curveG95Inf[t_under];
double ginf_upper = curveG95Inf[t_upper];
curveG[t] = interpolate(t, t_under, t_upper, g_under, g_upper);
curveG95Sup[t] = interpolate(t, t_under, t_upper, gsup_under, gsup_upper);
curveG95Inf[t] = interpolate(t, t_under, t_upper, ginf_under, ginf_upper);
}
else
{
curveG[t] = 0;
curveG95Sup[t] = 0;
curveG95Inf[t] = 0;
}
}
else
{
curveG[t] = 0;
curveG95Sup[t] = 0;
curveG95Inf[t] = 0;
}
}
}
// Store the resulting curves :
curves["G"] = curveG;
curves["G95Sup"] = curveG95Sup;
curves["G95Inf"] = curveG95Inf;
//.........这里部分代码省略.........
示例6: qDebug
void Level::rubeB2DLevel(b2dJson& mBox2dJson)
{
if(mJsonFilePath.isEmpty()){
qDebug() << " mJsonFilePath is empty ";
}
if(!Util::fileExists(mJsonFilePath)){
qDebug() << " Level: " << mJsonFilePath << " does not exists. ";
return;
}
std::string worldJson = Util::readFileAsStdString(mJsonFilePath);
std::string errorstring;
b2World* w = mBox2dJson.readFromString(worldJson,errorstring,mWorld.get());
if(w){
//custom properties to be read
int useWorldGravity = mBox2dJson.getCustomInt(w,"use_world_gravity",0);
float grav_x ;
float grav_y ;
if(useWorldGravity){
grav_x = mBox2dJson.getCustomFloat(w,"world_gravity_x",0);
grav_y = mBox2dJson.getCustomFloat(w,"world_gravity_y",0);
w->SetGravity(b2Vec2(grav_x,grav_y));
}
qDebug() << " Reading jsonfile Complete! \n\t ";
//check if there is a camera body
//used for camera bounds. (Square body)
b2Body* cam_body = mBox2dJson.getBodyByName("camera");
if(cam_body){
b2Fixture* cam_fixture = cam_body->GetFixtureList();
if(cam_fixture){
QRectF bbox = Box2dUtil::toQRectF(cam_fixture->GetAABB(0));
this->setCameraBoundary(bbox);
cam_body->SetActive(false);
#ifdef D_PARSE
qDebug() << "Bounding box "<< bbox;
#endif
}
#ifdef D_PARSE
qDebug() << "camera found!";
#endif
}
//TODO: this is sooooo lazy,
for(QVariant v:mLevelActorMapping){
QMap<QString,QVariant> tmp = v.toMap();
qDebug() << " Mapped LevelActorrr " << tmp;
mLevelActorMap.insert(tmp.firstKey(),tmp.first().toString());
}
Engine* engine = Engine::getInstance();
QQmlEngine* qmlEngine = engine->getQmlEngine();
// Check if bodies are referenced in the Actor Mapping Category
Body* b = nullptr;
std::string actorTypeString;
b2Body* body = mWorld->GetBodyList();
while(body){
actorTypeString = mBox2dJson.getCustomString(body,"actorType");
if(actorTypeString.empty() || actorTypeString == "none"){
b = Body::BodyFromb2Body(body);
if(b) b->setParent(this);
}else{
actorFromMapping(body,actorTypeString,qmlEngine);
}
body = body->GetNext();
}
// Use Nodes for parsing the specific type of node
//QList<LevelNode*> nodes = findChildren<LevelNode*>();
for(LevelNode* node: findChildren<LevelNode*>()) {
switch(node->type()) {
case LevelNode::BODY_REFERENCE:{
actorReferenceBody(node);
}break;
case LevelNode::ACTOR_COMPONENT_W_BODY:{
actorComponentWithBody(node,qmlEngine);
}break;
default:{
qDebug() << " unknown LevelNode type = " << node->type();
}
}
}
//check for images associated with the body.
int imageCount = 0;
body = nullptr;
b = nullptr;
QString image_path;
Actor* actor = nullptr;
ImageRenderer* img_renderer = nullptr;
std::vector<b2dJsonImage*> world_images;
imageCount = mBox2dJson.getAllImages(world_images);
//.........这里部分代码省略.........