本文整理汇总了C++中QMap::key方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::key方法的具体用法?C++ QMap::key怎么用?C++ QMap::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getIdByElement
uint getIdByElement(Element * element) const
{
if ( element->isNode() )
{
Node * node;
node = static_cast<Node *>(element);
return nodes.key(node);
}
else if ( element->isStore() )
{
Store * store;
store = static_cast<Store *>(element);
return stores.key(store);
}
else if ( element->isSwitch() )
{
Switch * aswitch;
aswitch = static_cast<Switch *>(element);
return switches.key(aswitch);
}
else
{
return (uint)-1;
}
}
示例2: adjustFanSpeed
void radeon_profile::adjustFanSpeed() {
if (device.gpuTemeperatureData.current != device.gpuTemeperatureData.currentBefore) {
if (currentFanProfile.contains(device.gpuTemeperatureData.current)) { // Exact match
device.setPwmValue(device.features.pwmMaxSpeed * currentFanProfile.value(device.gpuTemeperatureData.current) / 100);
return;
}
// find bounds of current temperature
const QMap<int,unsigned int>::const_iterator high = currentFanProfile.upperBound(device.gpuTemeperatureData.current),
low = high - 1;
int hSpeed = high.value(),
lSpeed = low.value();
if (high == currentFanProfile.constBegin()) {
device.setPwmValue(device.features.pwmMaxSpeed * hSpeed / 100);
return;
}
if (low == currentFanProfile.constEnd()) {
device.setPwmValue(device.features.pwmMaxSpeed * lSpeed / 100);
return;
}
// calculate two point stright line equation based on boundaries of current temperature
// y = mx + b = (y2-y1)/(x2-x1)*(x-x1)+y1
int hTemperature = high.key(),
lTemperature = low.key();
float speed = (float)((hSpeed - lSpeed) / (hTemperature - lTemperature) * (device.gpuTemeperatureData.current - lTemperature)) + lSpeed;
device.setPwmValue(device.features.pwmMaxSpeed * speed / 100);
}
}
示例3: fromEscapedString
static QString fromEscapedString(const QString & val) {
QString ret(val);
foreach(const QString & val, escapeCharacters.values()) {
ret.replace(val, escapeCharacters.key(val));
}
return ret;
}
示例4:
Solid::OpticalDisc::DiscType OpticalDisc::discType() const
{
const QString discType = m_device->prop("DriveMedia").toString();
QMap<Solid::OpticalDisc::DiscType, QString> map;
map[Solid::OpticalDisc::CdRom] = "optical_cd";
map[Solid::OpticalDisc::CdRecordable] = "optical_cd_r";
map[Solid::OpticalDisc::CdRewritable] = "optical_cd_rw";
map[Solid::OpticalDisc::DvdRom] = "optical_dvd";
map[Solid::OpticalDisc::DvdRecordable] = "optical_dvd_r";
map[Solid::OpticalDisc::DvdRewritable] ="optical_dvd_rw";
map[Solid::OpticalDisc::DvdRam] ="optical_dvd_ram";
map[Solid::OpticalDisc::DvdPlusRecordable] ="optical_dvd_plus_r";
map[Solid::OpticalDisc::DvdPlusRewritable] ="optical_dvd_plus_rw";
map[Solid::OpticalDisc::DvdPlusRecordableDuallayer] ="optical_dvd_plus_r_dl";
map[Solid::OpticalDisc::DvdPlusRewritableDuallayer] ="optical_dvd_plus_rw_dl";
map[Solid::OpticalDisc::BluRayRom] ="optical_bd";
map[Solid::OpticalDisc::BluRayRecordable] ="optical_bd_r";
map[Solid::OpticalDisc::BluRayRewritable] ="optical_bd_re";
map[Solid::OpticalDisc::HdDvdRom] ="optical_hddvd";
map[Solid::OpticalDisc::HdDvdRecordable] ="optical_hddvd_r";
map[Solid::OpticalDisc::HdDvdRewritable] ="optical_hddvd_rw";
// TODO add these to Solid
//map[Solid::OpticalDisc::MagnetoOptical] ="optical_mo";
//map[Solid::OpticalDisc::MountRainer] ="optical_mrw";
//map[Solid::OpticalDisc::MountRainerWritable] ="optical_mrw_w";
return map.key( discType, Solid::OpticalDisc::UnknownDiscType );
}
示例5: HandleQueryCompletedL
void MsgAudioSelectionEngine::HandleQueryCompletedL(CMdEQuery& aQuery,
TInt aError)
{
iNameList.clear();
iUriList.clear();
if (aError == KErrCancel)
{
emit queryError(aError);
return;
}
else
{
QMap<QString,QString> nameUriList;
CMdEObjectQuery* query = static_cast<CMdEObjectQuery*> (&aQuery);
TInt count = query->Count();
for (TInt i = 0; i < count; ++i)
{
CMdEObject* object =
(CMdEObject*) query->TakeOwnershipOfResult(i);
CleanupStack::PushL(object);
CMdEPropertyDef& propDef = MsgAudioSelectionEngine::PropertyDefL(
iSession, MsgAudioSelectionEngine::EAttrFileName);
CMdEProperty* property = 0;
TInt err = object->Property(propDef, property, 0);
if (err != KErrNotFound && property)
{
QString songName(XQConversions::s60DescToQString(
property->TextValueL()));
QString uriValue(XQConversions::s60DescToQString(
object->Uri()));
//insert into the map
nameUriList.insertMulti(uriValue, songName);
}
CleanupStack::PopAndDestroy(object);
}
//now get all the song names and sort them
iNameList = nameUriList.values();
iNameList.sort();
// go through the song list and get the associated uri
// insert into the uri list
int nameListTotal = iNameList.count();
for(int nameListCount = 0;
nameListCount<nameListTotal;
nameListCount++)
{
QString key = nameUriList.key(iNameList.at(nameListCount));
iUriList.append(key);
nameUriList.remove(key);
}
// emit the list to the model
emit queryComplete(iNameList, iUriList);
}
}
示例6: data
QVariant NumberCompletionModel::data(const QModelIndex& index, int role ) const
{
if (!index.isValid()) return QVariant();
const QMap<int,PhoneNumber*>::iterator i = const_cast<NumberCompletionModel*>(this)->m_hNumbers.end()-1-index.row();
const PhoneNumber* n = i.value();
const int weight = i.key ();
bool needAcc = (role>=100 || role == Qt::UserRole) && n->account() && n->account() != AccountListModel::instance()->currentAccount()
&& n->account()->alias() != Account::ProtocolName::IP2IP;
switch (static_cast<NumberCompletionModel::Columns>(index.column())) {
case NumberCompletionModel::Columns::CONTENT:
switch (role) {
case Qt::DisplayRole:
return n->uri();
break;
case Qt::ToolTipRole:
return QString("<table><tr><td>%1</td></tr><tr><td>%2</td></tr></table>").arg(n->primaryName()).arg(n->category()->name());
break;
case Qt::DecorationRole:
return n->icon();
break;
case NumberCompletionModel::Role::ALTERNATE_ACCOUNT:
case Qt::UserRole:
if (needAcc)
return n->account()->alias();
else
return QString();
case NumberCompletionModel::Role::FORCE_ACCOUNT:
return needAcc;
case NumberCompletionModel::Role::ACCOUNT:
if (needAcc)
return QVariant::fromValue(const_cast<Account*>(n->account()));
break;
};
break;
case NumberCompletionModel::Columns::NAME:
switch (role) {
case Qt::DisplayRole:
return n->primaryName();
};
break;
case NumberCompletionModel::Columns::ACCOUNT:
switch (role) {
case Qt::DisplayRole:
return n->account()?n->account()->id():AccountListModel::instance()->currentAccount()->id();
};
break;
case NumberCompletionModel::Columns::WEIGHT:
switch (role) {
case Qt::DisplayRole:
return weight;
};
break;
};
return QVariant();
}
示例7: createViewerForType
void JoCASSViewer::createViewerForType(QMap<QString,DataViewer*>::iterator view,
Result<float>::shared_pointer result)
{
//qDebug()<<"create viewer"<<view.key()<<result->dim();
switch (result->dim())
{
case 0:
view.value() = new ZeroDViewer(view.key(),this);
break;
case 1:
view.value() = new OneDViewer(view.key(),this);
break;
case 2:
view.value() = new TwoDViewer(view.key(),this);
break;
}
view.value()->show();
connect(view.value(),SIGNAL(viewerClosed(DataViewer*)),
this,SLOT(removeViewer(DataViewer*)));
//qDebug()<<"created viewer"<<view.key()<<result->dim();
}
示例8: GetSelectionOffset
int BookViewPreview::GetSelectionOffset(const QMap<int, QString> &node_offsets,
Searchable::Direction search_direction)
{
QList<ViewEditor::ElementIndex> cl = GetCaretLocation();
// remove final #text node if it exists
if (cl.at(cl.count()-1).name == "#text") {
cl.removeLast();
}
QString caret_node = ConvertHierarchyToQWebPath(cl);
bool searching_down = search_direction == Searchable::Direction_Down ? true : false;
int local_offset = GetLocalSelectionOffset(!searching_down);
int search_start = node_offsets.key(caret_node) + local_offset;
return search_start;
}
示例9:
void Plugin::_loadConfiguration()
{
QMap<QString, gnutls_sec_param_t> secParams;
int expiration;
int i;
secParams.insert("LOW", GNUTLS_SEC_PARAM_LOW);
secParams.insert("LEGACY", GNUTLS_SEC_PARAM_LEGACY);
secParams.insert("NORMAL", GNUTLS_SEC_PARAM_NORMAL);
secParams.insert("HIGH", GNUTLS_SEC_PARAM_HIGH);
secParams.insert("ULTRA", GNUTLS_SEC_PARAM_ULTRA);
if ((this->priorityStrings = this->api->configuration(true).get("priority_strings").toLatin1()).isEmpty())
this->priorityStrings = "SECURE128:-VERS-SSL3.0";
if ((this->crtFile = this->api->configuration(true).get("crt")).isEmpty())
this->crtFile = "crt.pem";
if ((this->keyFile = this->api->configuration(true).get("key")).isEmpty())
this->keyFile = "key.pem";
if ((this->dhParamsFile = this->api->configuration(true).get("dh_params")).isEmpty())
this->dhParamsFile = "dh_params.pem";
if (!(this->secParam = secParams.value(this->api->configuration(true).get("sec_param").toUpper())))
this->secParam = GNUTLS_SEC_PARAM_HIGH;
if (!(expiration = this->api->configuration(true).get("dh_params_expiration").toUInt()))
expiration = 90;
if (!(this->handshakeTimeout = this->api->configuration(true).get("handshake_timeout").toInt()))
this->handshakeTimeout = 5000;
if ((this->keyPassword = this->api->configuration(true).get("private_key_password").toLatin1()).isEmpty())
this->api->configuration(true).set("private_key_password", (this->keyPassword = this->_generatePassword())).save();
this->dhParamsExpiration = QDateTime::currentDateTime().addDays(-expiration);
this->crtFile.prepend(this->api->getPluginPath());
this->keyFile.prepend(this->api->getPluginPath());
this->dhParamsFile.prepend(this->api->getPluginPath());
// Appends the sec param to the file name
if ((i = this->dhParamsFile.lastIndexOf('.')) >= 0)
this->dhParamsFile.insert(i, "." + secParams.key(this->secParam).toLower());
else
this->dhParamsFile.append("." + secParams.key(this->secParam).toLower());
}
示例10: GetSelectionOffset
int BookViewPreview::GetSelectionOffset(const QMap<int, QString> &node_offsets,
Searchable::Direction search_direction)
{
QList<ViewEditor::ElementIndex> cl = GetCaretLocation();
// remove final #text node if it exists
// Some BookView tabs with only SVG images report a cl.count of 0
// meaning there is no cursor, so test for that case
if ((cl.count() > 0) && (cl.at(cl.count()-1).name == "#text")) {
cl.removeLast();
}
QString caret_node = ConvertHierarchyToQWebPath(cl);
bool searching_down = search_direction == Searchable::Direction_Down ? true : false;
int local_offset = GetLocalSelectionOffset(!searching_down);
int search_start = node_offsets.key(caret_node) + local_offset;
return search_start;
}
示例11: SServer
void CP2PServers::SyncServers(const QVariantMap& Response)
{
QMap<QString, SServer*> OldServers = m_Servers;
foreach (const QVariant& vServer,Response["Servers"].toList())
{
QVariantMap Server = vServer.toMap();
QString Url = Server["Url"].toString();
SServer* pServer = OldServers.take(Url);
if(!pServer)
{
pServer = new SServer();
pServer->pItem = new QTreeWidgetItem();
m_pServerTree->addTopLevelItem(pServer->pItem);
pServer->pItem->setText(eUrl, Url);
m_Servers.insert(Url, pServer);
}
QFont Font = pServer->pItem->font(eUrl);
if(Font.bold() != Server["IsStatic"].toBool())
{
Font.setBold(Server["IsStatic"].toBool());
pServer->pItem->setFont(eUrl, Font);
}
pServer->pItem->setText(eName, Server["Name"].toString());
pServer->pItem->setData(eName, Qt::UserRole, Server["IsStatic"]);
pServer->pItem->setText(eVersion, Server["Version"].toString());
pServer->pItem->setText(eStatus, Server["Status"].toString());
pServer->pItem->setData(eStatus, Qt::UserRole, Server["Status"]);
pServer->pItem->setText(eUsers, Server["UserCount"].toString() + "(" + Server["LowIDCount"].toString() + ")/" + Server["UserLimit"].toString());
pServer->pItem->setText(eFiles, Server["FileCount"].toString() + "|" + Server["HardLimit"].toString() + "(" + Server["SoftLimit"].toString() + ")");
pServer->pItem->setText(eDescription, Server["Description"].toString());
}
foreach(SServer* pServer, OldServers)
{
m_Servers.remove(OldServers.key(pServer));
delete pServer->pItem;
delete pServer;
}
示例12: generateSumCnfFlie
//read sum rule file to generate CNF file
void generateSumCnfFlie()
{
QFile file(ruleFileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "cannot open file";
return;
}
QTextStream stream(&file);
QFile clauseFile(cnfFileName);
if (!clauseFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug() << "cannot open file";
return;
}
QTextStream cnfStream(&clauseFile);
QString resultCnfClause = "";
int numberOfClause = 0;
while (!stream.atEnd()) {
QString line = stream.readLine();
QStringList elements = line.split(" || ");
// qDebug() << "elements:" << elements;
QString cnfLine = "";
foreach (QString ele, elements)
{
bool isNOT = false;
QString varLogical = ele.trimmed();
if (ele.contains("!"))
{
varLogical = varLogical.split("!").at(1);
isNOT = true;
}
if (!mapVariables.values().contains(varLogical))
{
mapVariables.insert(globalIndex++,varLogical);
}
cnfLine.append(QString("%1 ").arg(isNOT ? - mapVariables.key(varLogical) : mapVariables.key(varLogical)));
}
cnfLine.append("0");
numberOfClause++;
resultCnfClause.append(cnfLine).append("\n");
}
示例13: handleGpuChange
void MainForm::handleGpuChange(const QString& type)
{
QString prev = comboFSAA->currentText();
QList<int> caps = g_mapGPUCaps[type];
int gindex = comboGpuType->currentIndex();
int newindex = 0;
comboFSAA->clear();
for(int i=0;i<caps.size();i++)
{
QString name = g_mapAATypes.key(caps[i]);
comboFSAA->addItem(name);
if(name == prev)
newindex = i;
}
comboFSAA->setCurrentIndex(newindex);
newindex = comboAniso->currentIndex();
comboAniso->clear();
QStringList list;
list << "<default>" << "Disabled" << "2x anisotropic filtering";
if(gindex >= 2)
{
list << "4x anisotropic filtering" << "8x anisotropic filtering";
if(gindex >= 3)
list << "16x anisotropic filtering";
}
if(newindex > list.size()-1)
newindex = list.size()-1;
else if(newindex < 0)
newindex = 0;
comboAniso->addItems(list);
comboAniso->setCurrentIndex(newindex);
}
示例14: populateRadioButtons
void PopupEnumeratedValue::populateRadioButtons(QMap<QString, int> enumeratedValue, bool init)
{
group = new QButtonGroup();
foreach (int val, enumeratedValue.values())
{
QRadioButton *radio = new QRadioButton(enumeratedValue.key(val));
group->addButton(radio);
group->setId(radio, val);
if(init)
{
if(m_attribute->defaultValue() == val)
radio->setChecked(true);
}
else
{
if(m_attribute->currentValue() == val)
radio->setChecked(true);
}
ui->verticalGroupBox->layout()->addWidget(radio);
}
}
示例15: scalePixmap
void GraphicsView::scalePixmap()
{
this->scene()->clear();
int h = pixmap.height() * freqZoomFactor;
int w = pixmap.width() * timeZoomFactor;
graphicsPixmapItem = this->scene()->addPixmap(
pixmap.scaled(w,h,Qt::IgnoreAspectRatio,Qt::SmoothTransformation) );
this->scene()->setSceneRect(0,0,w,h);
QMap<QGraphicsItem*,MarkerPoint> tempMap (markerPointMap);
markerPointMap.clear();
MarkerPoint::setMaxX( sceneRect().width() );
MarkerPoint::setMaxY( sceneRect().height() );
MarkerPoint marker;
foreach (marker,tempMap)
{
bool selected = ( tempMap.key(marker) == selectedMarker );
marker.refresh();
if (selected)
selectedMarker = addItem(marker, markerPointSelectedRadius);
else
addItem(marker, markerPointRadius);
}