本文整理汇总了C++中QMap::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ QMap::isEmpty方法的具体用法?C++ QMap::isEmpty怎么用?C++ QMap::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMap
的用法示例。
在下文中一共展示了QMap::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertHtml
void KTextCursor::insertHtml( const QString &text, const QMap<QString, QString>& imgs )
{
if(!imgs.isEmpty())
{
for(QMap<QString,QString>::const_iterator iter = imgs.begin(); iter != imgs.end(); iter++)
{
QString key = iter.key();
QString file = iter.value();
if(moviePool()->insertMovie(file, file))
{
//修改属性为动画。
document()->addResource(QTextDocument::ImageResource, QUrl(file), moviePool()->currentImage(file));
}
else
{
QImage image(file);
if(!image.isNull())
{
document()->addResource(QTextDocument::ImageResource, QUrl(file), image);
}
}
}
}
int istart = position();
insertHtml(text);
int inow = position();
if(!imgs.isEmpty() && inow > istart)
{
setPosition(istart);
movePosition(NextCharacter, KeepAnchor, inow-istart);
QString txt = selectedText();
int index = txt.indexOf(QChar::ObjectReplacementCharacter, 0);
while(index >= 0)
{
/*修改字体类型。*/
setPosition(istart+index);
movePosition(NextCharacter, KeepAnchor, 1);
QTextCharFormat fmt = charFormat();
QTextImageFormat imgFmt = fmt.toImageFormat();
QString key = imgFmt.name();
if(imgs.contains(key))
{
imgFmt.setProperty(KImageKey, key);
imgFmt.setName(imgs.value(key));
imgFmt.setProperty(KAnimationImage, true);
setCharFormat(imgFmt);
}
int idx = index+1;
index = txt.indexOf(QChar::ObjectReplacementCharacter, idx);
}
}
setPosition(inow);
}
示例2: ogcWmsCrsFilterAsSqlExpression
QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression( QSet<QString> * crsFilter )
{
QString sqlExpression = "1"; // it's "SQL" for "true"
QMap<QString, QStringList> authParts;
if ( !crsFilter )
return sqlExpression;
/*
Ref: WMS 1.3.0, section 6.7.3 "Layer CRS":
Every Layer CRS has an identifier that is a character string. Two types of
Layer CRS identifiers are permitted: "label" and "URL" identifiers:
Label: The identifier includes a namespace prefix, a colon, a numeric or
string code, and in some instances a comma followed by additional
parameters. This International Standard defines three namespaces:
CRS, EpsgCrsId and AUTO2 [...]
URL: The identifier is a fully-qualified Uniform Resource Locator that
references a publicly-accessible file containing a definition of the CRS
that is compliant with ISO 19111.
*/
// iterate through all incoming CRSs
Q_FOREACH ( const QString& auth_id, *crsFilter )
{
QStringList parts = auth_id.split( ':' );
if ( parts.size() < 2 )
continue;
authParts[ parts.at( 0 ).toUpper()].append( parts.at( 1 ).toUpper() );
}
if ( authParts.isEmpty() )
return sqlExpression;
if ( !authParts.isEmpty() )
{
QString prefix = " AND (";
Q_FOREACH ( const QString& auth_name, authParts.keys() )
{
sqlExpression += QString( "%1(upper(auth_name)='%2' AND upper(auth_id) IN ('%3'))" )
.arg( prefix,
auth_name,
authParts[auth_name].join( "','" ) );
prefix = " OR ";
}
sqlExpression += ')';
}
示例3: parseParagraphProperty
ParagraphFormatProperty StyleParser::parseParagraphProperty( QDomElement &parent )
{
ParagraphFormatProperty property;
property.setPageNumber( parent.attribute( "page-number" ).toInt() );
static QMap<QString, ParagraphFormatProperty::WritingMode> map;
if ( map.isEmpty() ) {
map.insert( "lr-tb", ParagraphFormatProperty::LRTB );
map.insert( "rl-tb", ParagraphFormatProperty::RLTB );
map.insert( "tb-rl", ParagraphFormatProperty::TBRL );
map.insert( "tb-lr", ParagraphFormatProperty::TBLR );
map.insert( "lr", ParagraphFormatProperty::LR );
map.insert( "rl", ParagraphFormatProperty::RL );
map.insert( "tb", ParagraphFormatProperty::TB );
map.insert( "page", ParagraphFormatProperty::PAGE );
}
property.setWritingMode( map[ parent.attribute( "writing-mode" ) ] );
static QMap<QString, Qt::Alignment> alignMap;
if ( alignMap.isEmpty() ) {
alignMap.insert( "center", Qt::AlignCenter );
alignMap.insert( "left", Qt::AlignLeft );
alignMap.insert( "right", Qt::AlignRight );
alignMap.insert( "justify", Qt::AlignJustify );
if ( property.writingModeIsRightToLeft() ) {
alignMap.insert( "start", Qt::AlignRight );
alignMap.insert( "end", Qt::AlignLeft );
} else {
// not right to left
alignMap.insert( "start", Qt::AlignLeft );
alignMap.insert( "end", Qt::AlignRight );
}
}
if ( parent.hasAttribute( "text-align" ) ) {
property.setTextAlignment( alignMap[ parent.attribute( "text-align", "left" ) ] );
}
const QString marginLeft = parent.attribute( "margin-left" );
if ( !marginLeft.isEmpty() ) {
qreal leftMargin = qRound( convertUnit( marginLeft ) );
property.setLeftMargin( leftMargin );
}
const QString colorText = parent.attribute( "background-color" );
if ( !colorText.isEmpty() && colorText != QLatin1String( "transparent" ) ) {
property.setBackgroundColor( QColor( colorText ) );
}
return property;
}
示例4: parser
void parser(const QByteArray &text) {
QStringList systemWords;
systemWords << "mainpassword" << "login";
QStringList localWords;
localWords << "password" << "login" << "email";
QList<QByteArray> s = text.split('\n');
bool systemFlag = true;
bool systemCounter = false;
bool localFlag = false;
bool localCounter = false;
QMap<QString, QString> localMap;
QMap<QString, QString> systemMap;
QList< QMap<QString, QString> > systemList;
QList< QMap<QString, QString> > sitesList;
int i = 0;
while(i < s.size() - 1) {
QList<QByteArray> l;
l.append(s[i].split(':'));
QString key = QString(l.at(0));
QString value = QString(l.at(1));
if(systemFlag) {
if(!systemCounter) {
QString local = "";
foreach(local, systemWords) {
if(local == key && key != QString("system")) systemMap[key] = value;
}
if(value == QString("end")) systemCounter = true;
}
if( !systemMap.isEmpty() && systemCounter) {
systemList.append(systemMap);
systemMap.clear();
systemCounter = false;
}
}
if (localFlag) {
if(!localCounter) {
QString local = "";
if(value == QString("start")) localMap["site"] = key;
foreach(local, localWords) {
if(local == key && value != QString("end") && value!=QString("start")) {
localMap[key] = value;
}
}
if(value == QString("end")) localCounter = true;
}
if(!localMap.isEmpty() && localCounter) {
sitesList.append(localMap);
localMap.clear();
localCounter = false;
}
}
示例5: populate
/* Mount FAT partition, discover which images we have, and fill in the list */
void MainWindow::populate()
{
if (!QFile::exists("/dev/mmcblk0p1"))
{
// mmcblk0p1 not ready yet, check back in a tenth of a second
QTimer::singleShot(100, this, SLOT(populate()));
return;
}
QProcess::execute("mount /dev/mmcblk0p1 /mnt");
QMap<QString,QString> images = listInstalledImages();
if (images.isEmpty())
{
QMessageBox::critical(this, tr("No OS Images Found on SD Card"), tr("Please add at least one OS image to the /images directory in order to proceed"));
_allowSilent = false;
}
// Fill in list of images
repopulate();
if (!images.isEmpty())
{
QList<QListWidgetItem *> l = ui->list->findItems(RECOMMENDED_IMAGE, Qt::MatchContains);
if (!l.isEmpty())
{
QListWidgetItem *recommendedItem = l.first();
recommendedItem->setText(recommendedItem->text()+" "+tr("[RECOMMENDED]"));
ui->list->setCurrentItem(recommendedItem);
}
else
{
ui->list->setCurrentRow(0);
}
if (_allowSilent && !QFile::exists(FAT_PARTITION_OF_IMAGE) && images.count() == 1)
{
// No OS installed, perform silent installation
qDebug() << "Performing silent installation";
_silent = true;
on_actionWrite_image_to_disk_triggered();
}
}
bool osInstalled = QFile::exists(FAT_PARTITION_OF_IMAGE);
ui->actionEdit_config->setEnabled(osInstalled);
ui->actionCancel->setEnabled(osInstalled);
}
示例6: kspread_convert_speed
//
// convert speeds
//
static bool kspread_convert_speed(const QString& fromUnit,
const QString& toUnit, double value, double& result)
{
static QMap<QString, double> speedMap;
// first-time initialization
if (speedMap.isEmpty()) {
speedMap[ "m/s" ] = 1.0; // meters per second (the reference)
speedMap[ "m/h" ] = 3.6e3; // meters per hour
speedMap[ "mph" ] = 2.2369362920544023; // miles per hour
speedMap[ "kn" ] = 1.9438444924406048; // knot
}
QString fromU = fromUnit;
QString toU = toUnit;
double fromPrefix = kspread_convert_prefix(speedMap, fromU);
double toPrefix = kspread_convert_prefix(speedMap, toU);
if (fromPrefix == 0.0) return false;
if (toPrefix == 0.0) return false;
if (!speedMap.contains(fromU)) return false;
if (!speedMap.contains(toU)) return false;
result = value * fromPrefix * speedMap[toU] / (speedMap[fromU] * toPrefix);
return true;
}
示例7: kspread_convert_time
//
// convert times
//
static bool kspread_convert_time(const QString& fromUnit,
const QString& toUnit, double value, double& result)
{
static QMap<QString, double> timeMap;
// first-time initialization
if (timeMap.isEmpty()) {
timeMap[ "s" ] = 1.0; // second (the reference)
timeMap[ "sec" ] = 1.0; // second (the reference)
timeMap[ "mn" ] = 1.0 / 60; // 24 hour per day
timeMap[ "min" ] = 1.0 / 60; // 24 hour per day
timeMap[ "hr" ] = 1.0 / 3600; // 3600 seconds per hour
timeMap[ "d" ] = 1.0 / (3600 * 24); // 24 hour per day
timeMap[ "day" ] = 1.0 / (3600 * 24); // 24 hour per day
timeMap[ "yr" ] = 1.0 / (3600 * 24 * 365.25); // 24 hour per day
}
QString fromU = fromUnit;
QString toU = toUnit;
double fromPrefix = kspread_convert_prefix(timeMap, fromU);
double toPrefix = kspread_convert_prefix(timeMap, toU);
if (fromPrefix == 0.0) return false;
if (toPrefix == 0.0) return false;
if (!timeMap.contains(fromU)) return false;
if (!timeMap.contains(toU)) return false;
result = value * fromPrefix * timeMap[toU] / (timeMap[fromU] * toPrefix);
return true;
}
示例8: setModelData
void ListInfoWidget::setModelData(QMap<int, QString> &values)
{
if(!datas.isEmpty())
datas.clear();
tableView_listInfo->tableView->clear();
QMap<int, QString>::iterator it = values.begin();
QStringList row;
while(it != values.end()){
row.clear();
row.append(QString::number(it.key()));
row.append(it.value());
datas.append(row);
it++;
}
it--;
row.clear();
if(values.isEmpty()){
row.append(QString::number(1));
}else
row.append(QString::number(it.key() + 1));
row.append("");
datas.append(row);
int rows = datas.size();
edit->setGeometry(258, 155+(rows*38), 100, 30);
tableView_listInfo->setInfoDelegate(datas.size());
if(!datas.isEmpty())
tableView_listInfo->setModelValue(datas);
}
示例9: get
bool Http::get(QUrl url, QByteArray data, QByteArray &result, QMap<QString, QString> cookies, int timeout)
{
QByteArray body;
QByteArray cookiesData = convertData(cookies);
QString urlstr;
if (!data.isEmpty()) {
urlstr.append(url.toEncoded());
urlstr.append('?');
urlstr.append(data);
} else {
urlstr = url.toEncoded();
}
body.append(QString("GET %1 HTTP/1.1\r\n").arg(urlstr));
body.append(QString("Host: %1:%2\r\n").arg(url.host()).arg(url.port()));
body.append("Connection: close\r\n");
if (!cookies.isEmpty()) {
body.append("Cookie: ");
body.append(cookiesData);
body.append("\r\n");
}
body.append("\r\n");
return send(url.host(),url.port(),body,result,timeout);
}
示例10: finish
void QThreadStorageData::finish(void **p)
{
QMap<int, void *> *tls = reinterpret_cast<QMap<int, void *> *>(p);
if (!tls || tls->isEmpty() || !mutex())
return; // nothing to do
DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
QMap<int, void *>::iterator it = tls->begin();
while (it != tls->end()) {
int id = it.key();
void *q = it.value();
it.value() = 0;
++it;
if (!q) {
// data already deleted
continue;
}
mutex()->lock();
void (*destructor)(void *) = destructors()->value(id);
mutex()->unlock();
if (!destructor) {
if (QThread::currentThread())
qWarning("QThreadStorage: Thread %p exited after QThreadStorage %d destroyed",
QThread::currentThread(), id);
continue;
}
destructor(q);
}
tls->clear();
}
示例11: availableMetaData
QStringList CameraBinMetaData::availableMetaData() const
{
static QMap<QByteArray, QString> keysMap;
if (keysMap.isEmpty()) {
Q_FOREACH (const QGStreamerMetaDataKey &metadataKey, *qt_gstreamerMetaDataKeys())
keysMap[QByteArray(metadataKey.gstName)] = metadataKey.qtName;
}
示例12: kspread_convert_force
//
// convert forces
//
static bool kspread_convert_force(const QString& fromUnit,
const QString& toUnit, double value, double& result)
{
static QMap<QString, double> forceMap;
// first-time initialization
if (forceMap.isEmpty()) {
forceMap[ "N" ] = 1.0; // Newton (reference)
forceMap[ "dy" ] = 1.0e5; // dyne
forceMap[ "dyn" ] = 1.0e5; // dyne
forceMap[ "lbf" ] = 1.0 / 4.448222; // Pound force (see "lbm" for pound mass)
forceMap[ "pond" ] = 1.019716e2; // pond
}
QString fromU = fromUnit;
QString toU = toUnit;
double fromPrefix = kspread_convert_prefix(forceMap, fromU);
double toPrefix = kspread_convert_prefix(forceMap, toU);
if (fromPrefix == 0.0) return false;
if (toPrefix == 0.0) return false;
if (!forceMap.contains(fromU)) return false;
if (!forceMap.contains(toU)) return false;
result = value * fromPrefix * forceMap[toU] / (forceMap[fromU] * toPrefix);
return true;
}
示例13: kspread_convert_power
//
// convert powers
//
static bool kspread_convert_power(const QString& fromUnit,
const QString& toUnit, double value, double& result)
{
static QMap<QString, double> powerMap;
// first-time initialization
if (powerMap.isEmpty()) {
powerMap[ "W" ] = 1.0; // Watt (the reference)
// powerMap[ "HP" ] = 1.341022e-3; // Horsepower
powerMap[ "HP" ] = 1.0 / 745.701; // Horsepower (UK)
powerMap[ "PS" ] = 1.359622e-3; // Pferdestaerke (German)
}
QString fromU = fromUnit;
QString toU = toUnit;
double fromPrefix = kspread_convert_prefix(powerMap, fromU);
double toPrefix = kspread_convert_prefix(powerMap, toU);
if (fromPrefix == 0.0) return false;
if (toPrefix == 0.0) return false;
if (!powerMap.contains(fromU)) return false;
if (!powerMap.contains(toU)) return false;
result = value * fromPrefix * powerMap[toU] / (powerMap[fromU] * toPrefix);
return true;
}
示例14: kspread_convert_mass
//
// convert masses
//
static bool kspread_convert_mass(const QString& fromUnit,
const QString& toUnit, double value, double& result)
{
static QMap<QString, double> massMap;
// first-time initialization
if (massMap.isEmpty()) {
massMap[ "g" ] = 1.0; // Gram (the reference )
massMap[ "sg" ] = 6.8522050005347800E-05; // Pieces
massMap[ "lbm" ] = 2.2046229146913400E-03; // Pound
massMap[ "u" ] = 6.0221370000000000E23; // U (atomic mass)
massMap[ "ozm" ] = 3.5273971800362700E-02; // Ounce
massMap[ "stone" ] = 1.574730e-04; // Stone
massMap[ "ton" ] = 1.102311e-06; // Ton
massMap[ "grain" ] = 1.543236E01; // Grain
massMap[ "pweight" ] = 7.054792E-01; // Pennyweight
massMap[ "hweight" ] = 1.968413E-05; // Hundredweight
massMap[ "shweight" ] = 2.204623E-05; // Shorthundredweight
massMap[ "uk_ton" ] = 1.0 / 2240 * 2.2046229146913400E-03; // It's long ton or Imperial ton, 2240 lbm.
}
QString fromU = fromUnit;
QString toU = toUnit;
double fromPrefix = kspread_convert_prefix(massMap, fromU);
double toPrefix = kspread_convert_prefix(massMap, toU);
if (fromPrefix == 0.0) return false;
if (toPrefix == 0.0) return false;
if (!massMap.contains(fromU)) return false;
if (!massMap.contains(toU)) return false;
result = value * fromPrefix * massMap[toU] / (massMap[fromU] * toPrefix);
return true;
}
示例15: setCurveToModify
void FunctionDialog::setCurveToModify(Graph *g, int curve)
{
if (!g)
return;
graph = g;
FunctionCurve *c = (FunctionCurve *)graph->curve(curve);
if (!c)
return;
curveID = curve;
QStringList formulas = c->formulas();
QMap<QString, double> constants = c->constants();
if (!constants.isEmpty()) {
boxConstants->clearContents();
boxConstants->setRowCount(constants.size());
boxConstants->show();
ApplicationWindow *app = (ApplicationWindow *)parent();
QMapIterator<QString, double> i(constants);
int row = 0;
while (i.hasNext()) {
i.next();
boxConstants->setItem(row, 0, new QTableWidgetItem(i.key()));
DoubleSpinBox *sb = new DoubleSpinBox();
sb->setLocale(app->locale());
sb->setDecimals(app->fit_output_precision);
sb->setValue(i.value());
boxConstants->setCellWidget(row, 1, sb);
connect(sb, SIGNAL(valueChanged(double)), this, SLOT(acceptFunction()));
row++;
}
}