本文整理汇总了C++中QVariantMap::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariantMap::empty方法的具体用法?C++ QVariantMap::empty怎么用?C++ QVariantMap::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariantMap
的用法示例。
在下文中一共展示了QVariantMap::empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLocalProperties
void ExternalObjectInterface::updateLocalProperties(const QVariantMap& properties, bool callOnLocalPropertiesChanged)
{
LOG(Trace, "updateLocalProperties");
QVariantMap changedProperties;
QVariantMap::const_iterator it = properties.begin();
QVariantMap::const_iterator itend = properties.end();
for (; it != itend; ++it){
QVariantMap::const_iterator jt = m_localProperties.find(it.key());
if (jt != m_localProperties.end()){
if (jt.value() == it.value()){
// no change
}else{
m_localProperties[it.key()] = it.value();
changedProperties.insert(it.key(), it.value());
}
}else{
// key not found
m_localProperties[it.key()] = it.value();
changedProperties.insert(it.key(), it.value());
}
}
if (callOnLocalPropertiesChanged && !changedProperties.empty()){
onLocalPropertiesChanged(changedProperties);
}
}
示例2: defaultGrid
Grid QDesignerSharedSettings::defaultGrid() const
{
Grid grid;
const QVariantMap defaultGridMap
= m_settings->value(QLatin1String(defaultGridKey), QVariantMap()).toMap();
if (!defaultGridMap.empty())
grid.fromVariantMap(defaultGridMap);
return grid;
}
示例3: firstLessThanSecond
bool AlphabeticalSorterInterface::firstLessThanSecond(const QVariantMap &first,
const QVariantMap &second) const
{
Q_D(const AlphabeticalSorterInterface);
if (d->field.isEmpty()) {
return SorterInterface::firstLessThanSecond(first, second);
}
if (first.empty() && !second.empty())
return true;
if (second.empty())
return false;
return first.value(d->field).toString()
< second.value(d->field).toString();
}
示例4: setOpinions
void Decision::setOpinions(QVariantMap newOpinions)
{
canonicalizeOpinions(newOpinions);
if (newOpinions == opinions())
return;
// Now we actually allocate space for and set the opinions
auto opinionList = m_decision.initOpinions(newOpinions.size());
unsigned currentIndex = 0;
while (!newOpinions.empty()) {
auto builder = opinionList[currentIndex++];
auto key = newOpinions.firstKey();
builder.setContestant(key.toInt());
builder.setOpinion(newOpinions.take(key).toInt());
}
emit opinionsChanged();
}
示例5: preferences
Preferences QDesignerSettings::preferences() const
{
Preferences rc;
#ifdef Q_WS_WIN
const UIMode defaultMode = DockedMode;
#else
const UIMode defaultMode = TopLevelMode;
#endif
rc.m_uiMode = static_cast<UIMode>(value(QLatin1String("UI/currentMode"), defaultMode).toInt());
rc.m_writingSystem = static_cast<QFontDatabase::WritingSystem>(value(QLatin1String("UI/writingSystem"), QFontDatabase::Any).toInt());
rc.m_font = qVariantValue<QFont>(value(QLatin1String("UI/font")));
rc.m_useFont = value(QLatin1String("UI/useFont"), QVariant(false)).toBool();
const QVariantMap defaultGridMap = value(QLatin1String(defaultGridKey), QVariantMap()).toMap();
if (!defaultGridMap.empty())
rc.m_defaultGrid.fromVariantMap(defaultGridMap);
rc.m_additionalTemplatePaths = additionalFormTemplatePaths();
rc.m_previewConfigurationWidgetState = previewConfigurationWidgetState();
rc.m_previewConfiguration = previewConfiguration();
return rc;
}
示例6: getMod
CModEntry CModList::getMod(QString modname) const
{
QVariantMap repo;
QVariantMap local = localModList[modname].toMap();
QVariantMap settings;
QString path = modname;
path = "/" + path.replace(".", "/mods/");
QVariant conf = getValue(modSettings, path);
if(conf.isNull())
{
settings["active"] = true; // default
}
else
{
if(conf.canConvert<QVariantMap>())
settings = conf.toMap();
else
settings.insert("active", conf);
}
for(auto entry : repositories)
{
QVariant repoVal = getValue(entry, path);
if(repoVal.isValid())
{
if(repo.empty())
{
repo = repoVal.toMap();
}
else
{
if(CModEntry::compareVersions(repo["version"].toString(), repoVal.toMap()["version"].toString()))
repo = repoVal.toMap();
}
}
}
return CModEntry(repo, local, settings, modname);
}
示例7: addExtensionDataToDOM
void QSimpleResource::addExtensionDataToDOM(QAbstractFormBuilder *afb,
QDesignerFormEditorInterface *core,
DomWidget *ui_widget, QWidget *widget)
{
QExtensionManager *emgr = core->extensionManager();
if (QDesignerExtraInfoExtension *extra = qt_extension<QDesignerExtraInfoExtension*>(emgr, widget)) {
extra->saveWidgetExtraInfo(ui_widget);
}
if (QDesignerScriptExtension *scriptExt = qt_extension<QDesignerScriptExtension*>(emgr, widget)) {
// Add internal state
const QVariantMap data = scriptExt->data();
if (!data.empty()) {
// Convert the map to a DomState.
// We pass on the widget for property introspection. Thus, non-designable properties
// that have to be converted using QMetaObject (enums and the like) will work.
DomPropertyList properties;
const QVariantMap::const_iterator vcend = data.constEnd();
for (QVariantMap::const_iterator it = data.constBegin(); it != vcend; ++it) {
if (DomProperty *prop = variantToDomProperty(afb, widget, it.key(), it.value()))
properties += prop;
}
if (!properties.empty()) {
DomWidgetData *domData = new DomWidgetData;
domData->setElementProperty(properties);
DomWidgetDataList domDataList;
domDataList += domData;
ui_widget->setElementWidgetData(domDataList);
}
}
// Add script
const QString script = scriptExt->script();
if (!script.isEmpty()) {
DomScripts domScripts = ui_widget->elementScript();
addScript(script, ScriptExtension, domScripts);
ui_widget->setElementScript(domScripts);
}
}
}
示例8: createDialog
/*!
* The construction of the dialog
*
* @param [in] parameters Parameters for the Construction of the dialog.
*/
void EapFastProvWaitNoteDialog::createDialog(const QVariantMap ¶meters )
{
OstTraceFunctionEntry0( EAPFASTPROVWAITNOTEDIALOG_CREATEDIALOG_ENTRY );
qDebug("EapFastProvWaitNoteDialog::createDialog ENTER");
QString mainText;
QString key("notificationtxt");
bool authProvWaitNote = false;
//Get the needed information from parameters that indicates to type of the dialog
//which is either a authenticated or a unauthenticated
if ( parameters.empty() == false ) {
if ( parameters.contains(key) ) {
QVariant variant = parameters.value(key);
authProvWaitNote = variant.toBool();
}
}
if ( authProvWaitNote ) {
mainText = QString(hbTrId("txt_occ_dpopinfo_authenticated_provisioning_in_pro"));
} else {
mainText = QString(hbTrId("txt_occ_dpopinfo_unauthenticated_provisioning_in_p"));
}
// Set the dialog to be on the screen for 4 seconds.
this->setTimeout(4000);
this->setTitle(mainText);
// Connect the about to close and hide signals, so that we are able to inform
// the caller that the dialog was closed
bool connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
Q_ASSERT(connected == true);
connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
Q_ASSERT(connected == true);
OstTraceFunctionExit0( DUP1_EAPFASTPROVWAITNOTEDIALOG_CREATEDIALOG_EXIT );
qDebug("EapFastProvWaitNoteDialog::createDialog EXIT");
}
示例9: getMod
CModEntry CModList::getMod(QString modname) const
{
assert(hasMod(modname));
QVariantMap repo;
QVariantMap local = localModList[modname].toMap();
QVariantMap settings;
QVariant conf = modSettings[modname];
if (conf.isNull())
{
settings["active"] = true; // default
}
else
{
if (conf.canConvert<QVariantMap>())
settings = modSettings[modname].toMap();
else
settings.insert("active", conf);
}
for (auto entry : repositories)
{
if (entry.contains(modname))
{
if (repo.empty())
repo = entry[modname].toMap();
else
{
if (CModEntry::compareVersions(repo["version"].toString(),
entry[modname].toMap()["version"].toString()))
repo = entry[modname].toMap();
}
}
}
return CModEntry(repo, local, settings, modname);
}
示例10: dynamicColor
//.........这里部分代码省略.........
connect(m_removeDynamicAction, SIGNAL(triggered()), this, SLOT(slotRemoveDynamicProperty()));
// Configure
QAction *configureAction = new QAction(tr("Configure Property Editor"), this);
configureAction->setIcon(createIconSet(QLatin1String("configure.png")));
QMenu *configureMenu = new QMenu(this);
configureAction->setMenu(configureMenu);
m_sortingAction->setCheckable(true);
connect(m_sortingAction, SIGNAL(toggled(bool)), this, SLOT(slotSorting(bool)));
m_coloringAction->setCheckable(true);
connect(m_coloringAction, SIGNAL(toggled(bool)), this, SLOT(slotColoring(bool)));
configureMenu->addAction(m_sortingAction);
configureMenu->addAction(m_coloringAction);
#if QT_VERSION >= 0x040600
configureMenu->addSeparator();
configureMenu->addAction(m_treeAction);
configureMenu->addAction(m_buttonAction);
#endif
// Assemble toolbar
QToolBar *toolBar = new QToolBar;
toolBar->addWidget(classWidget);
toolBar->addWidget(m_filterWidget);
toolBar->addWidget(createDropDownButton(m_addDynamicAction));
toolBar->addAction(m_removeDynamicAction);
toolBar->addWidget(createDropDownButton(configureAction));
// Views
QScrollArea *buttonScroll = new QScrollArea(m_stackedWidget);
m_buttonBrowser = new QtButtonPropertyBrowser(buttonScroll);
buttonScroll->setWidgetResizable(true);
buttonScroll->setWidget(m_buttonBrowser);
m_buttonIndex = m_stackedWidget->addWidget(buttonScroll);
connect(m_buttonBrowser, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentItemChanged(QtBrowserItem*)));
m_treeBrowser = new QtTreePropertyBrowser(m_stackedWidget);
m_treeBrowser->setRootIsDecorated(false);
m_treeBrowser->setPropertiesWithoutValueMarked(true);
m_treeBrowser->setResizeMode(QtTreePropertyBrowser::Interactive);
m_treeIndex = m_stackedWidget->addWidget(m_treeBrowser);
connect(m_treeBrowser, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentItemChanged(QtBrowserItem*)));
connect(m_filterWidget, SIGNAL(filterChanged(QString)), this, SLOT(setFilter(QString)));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(toolBar);
layout->addWidget(m_stackedWidget);
layout->setMargin(0);
layout->setSpacing(0);
m_treeFactory = new DesignerEditorFactory(m_core, this);
m_treeFactory->setSpacing(0);
m_groupFactory = new DesignerEditorFactory(m_core, this);
QtVariantPropertyManager *variantManager = m_propertyManager;
m_buttonBrowser->setFactoryForManager(variantManager, m_groupFactory);
m_treeBrowser->setFactoryForManager(variantManager, m_treeFactory);
m_stackedWidget->setCurrentIndex(m_treeIndex);
m_currentBrowser = m_treeBrowser;
m_treeAction->setChecked(true);
connect(m_groupFactory, SIGNAL(resetProperty(QtProperty*)), this, SLOT(slotResetProperty(QtProperty*)));
connect(m_treeFactory, SIGNAL(resetProperty(QtProperty*)), this, SLOT(slotResetProperty(QtProperty*)));
connect(variantManager, SIGNAL(valueChanged(QtProperty*,QVariant,bool)), this, SLOT(slotValueChanged(QtProperty*,QVariant,bool)));
// retrieve initial settings
QDesignerSettingsInterface *settings = m_core->settingsManager();
settings->beginGroup(QLatin1String(SettingsGroupC));
#if QT_VERSION >= 0x040500
const SettingsView view = settings->value(QLatin1String(ViewKeyC), TreeView).toInt() == TreeView ? TreeView : ButtonView;
#endif
// Coloring not available unless treeview and not sorted
m_sorting = settings->value(QLatin1String(SortedKeyC), false).toBool();
m_coloring = settings->value(QLatin1String(ColorKeyC), true).toBool();
const QVariantMap expansionState = settings->value(QLatin1String(ExpansionKeyC), QVariantMap()).toMap();
settings->endGroup();
// Apply settings
m_sortingAction->setChecked(m_sorting);
m_coloringAction->setChecked(m_coloring);
#if QT_VERSION >= 0x040500
switch (view) {
case TreeView:
m_currentBrowser = m_treeBrowser;
m_stackedWidget->setCurrentIndex(m_treeIndex);
m_treeAction->setChecked(true);
break;
case ButtonView:
m_currentBrowser = m_buttonBrowser;
m_stackedWidget->setCurrentIndex(m_buttonIndex);
m_buttonAction->setChecked(true);
break;
}
#endif
// Restore expansionState from QVariant map
if (!expansionState.empty()) {
const QVariantMap::const_iterator cend = expansionState.constEnd();
for (QVariantMap::const_iterator it = expansionState.constBegin(); it != cend; ++it)
m_expansionState.insert(it.key(), it.value().toBool());
}
updateActionsState();
}
示例11: formatPreviewString
QString QgsExpression::formatPreviewString( const QVariant &value, const bool htmlOutput )
{
static const int MAX_PREVIEW = 60;
const QString startToken = htmlOutput ? QStringLiteral( "<i><" ) : QStringLiteral( "<" );
const QString endToken = htmlOutput ? QStringLiteral( "></i>" ) : QStringLiteral( ">" );
if ( value.canConvert<QgsGeometry>() )
{
//result is a geometry
QgsGeometry geom = value.value<QgsGeometry>();
if ( geom.isNull() )
return startToken + tr( "empty geometry" ) + endToken;
else
return startToken + tr( "geometry: %1" ).arg( QgsWkbTypes::displayString( geom.constGet()->wkbType() ) )
+ endToken;
}
else if ( value.value< QgsWeakMapLayerPointer >().data() )
{
return startToken + tr( "map layer" ) + endToken;
}
else if ( !value.isValid() )
{
return htmlOutput ? tr( "<i>NULL</i>" ) : QString();
}
else if ( value.canConvert< QgsFeature >() )
{
//result is a feature
QgsFeature feat = value.value<QgsFeature>();
return startToken + tr( "feature: %1" ).arg( feat.id() ) + endToken;
}
else if ( value.canConvert< QgsInterval >() )
{
//result is a feature
QgsInterval interval = value.value<QgsInterval>();
return startToken + tr( "interval: %1 days" ).arg( interval.days() ) + endToken;
}
else if ( value.canConvert< QgsGradientColorRamp >() )
{
return startToken + tr( "gradient ramp" ) + endToken;
}
else if ( value.type() == QVariant::Date )
{
QDate dt = value.toDate();
return startToken + tr( "date: %1" ).arg( dt.toString( QStringLiteral( "yyyy-MM-dd" ) ) ) + endToken;
}
else if ( value.type() == QVariant::Time )
{
QTime tm = value.toTime();
return startToken + tr( "time: %1" ).arg( tm.toString( QStringLiteral( "hh:mm:ss" ) ) ) + endToken;
}
else if ( value.type() == QVariant::DateTime )
{
QDateTime dt = value.toDateTime();
return startToken + tr( "datetime: %1" ).arg( dt.toString( QStringLiteral( "yyyy-MM-dd hh:mm:ss" ) ) ) + endToken;
}
else if ( value.type() == QVariant::String )
{
const QString previewString = value.toString();
if ( previewString.length() > MAX_PREVIEW + 3 )
{
return tr( "'%1…'" ).arg( previewString.left( MAX_PREVIEW ) );
}
else
{
return '\'' + previewString + '\'';
}
}
else if ( value.type() == QVariant::Map )
{
QString mapStr = QStringLiteral( "{" );
const QVariantMap map = value.toMap();
QString separator;
for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
{
mapStr.append( separator );
if ( separator.isEmpty() )
separator = QStringLiteral( "," );
mapStr.append( QStringLiteral( " '%1': %2" ).arg( it.key(), formatPreviewString( it.value(), htmlOutput ) ) );
if ( mapStr.length() > MAX_PREVIEW - 3 )
{
mapStr = tr( "%1…" ).arg( mapStr.left( MAX_PREVIEW - 2 ) );
break;
}
}
if ( !map.empty() )
mapStr += QStringLiteral( " " );
mapStr += QStringLiteral( "}" );
return mapStr;
}
else if ( value.type() == QVariant::List || value.type() == QVariant::StringList )
{
QString listStr = QStringLiteral( "[" );
const QVariantList list = value.toList();
QString separator;
for ( const QVariant &arrayValue : list )
{
listStr.append( separator );
if ( separator.isEmpty() )
//.........这里部分代码省略.........
示例12: toVariant
//.........这里部分代码省略.........
addProperties(tilesetVariant, tileset.properties());
const QPoint offset = tileset.tileOffset();
if (!offset.isNull()) {
QVariantMap tileOffset;
tileOffset[QLatin1String("x")] = offset.x();
tileOffset[QLatin1String("y")] = offset.y();
tilesetVariant[QLatin1String("tileoffset")] = tileOffset;
}
if (tileset.orientation() != Tileset::Orthogonal || tileset.gridSize() != tileset.tileSize()) {
QVariantMap grid;
grid[QLatin1String("orientation")] = Tileset::orientationToString(tileset.orientation());
grid[QLatin1String("width")] = tileset.gridSize().width();
grid[QLatin1String("height")] = tileset.gridSize().height();
tilesetVariant[QLatin1String("grid")] = grid;
}
// Write the image element
const QUrl &imageSource = tileset.imageSource();
if (!imageSource.isEmpty()) {
const QString rel = toFileReference(imageSource, mMapDir);
tilesetVariant[QLatin1String("image")] = rel;
const QColor transColor = tileset.transparentColor();
if (transColor.isValid())
tilesetVariant[QLatin1String("transparentcolor")] = transColor.name();
tilesetVariant[QLatin1String("imagewidth")] = tileset.imageWidth();
tilesetVariant[QLatin1String("imageheight")] = tileset.imageHeight();
}
// Write the properties, terrain, external image, object group and
// animation for those tiles that have them.
QVariantList tilesVariant;
for (const Tile *tile : tileset.tiles()) {
const Properties properties = tile->properties();
QVariantMap tileVariant;
addProperties(tileVariant, properties);
if (!tile->type().isEmpty())
tileVariant[QLatin1String("type")] = tile->type();
if (tile->terrain() != 0xFFFFFFFF) {
QVariantList terrainIds;
for (int j = 0; j < 4; ++j)
terrainIds << QVariant(tile->cornerTerrainId(j));
tileVariant[QLatin1String("terrain")] = terrainIds;
}
if (tile->probability() != 1.0)
tileVariant[QLatin1String("probability")] = tile->probability();
if (!tile->imageSource().isEmpty()) {
const QString rel = toFileReference(tile->imageSource(), mMapDir);
tileVariant[QLatin1String("image")] = rel;
const QSize tileSize = tile->size();
if (!tileSize.isNull()) {
tileVariant[QLatin1String("imagewidth")] = tileSize.width();
tileVariant[QLatin1String("imageheight")] = tileSize.height();
}
}
if (tile->objectGroup())
tileVariant[QLatin1String("objectgroup")] = toVariant(*tile->objectGroup());
if (tile->isAnimated()) {
QVariantList frameVariants;
for (const Frame &frame : tile->frames()) {
QVariantMap frameVariant;
frameVariant[QLatin1String("tileid")] = frame.tileId;
frameVariant[QLatin1String("duration")] = frame.duration;
frameVariants.append(frameVariant);
}
tileVariant[QLatin1String("animation")] = frameVariants;
}
if (!tileVariant.empty()) {
tileVariant[QLatin1String("id")] = tile->id();
tilesVariant << tileVariant;
}
}
if (!tilesVariant.empty())
tilesetVariant[QLatin1String("tiles")] = tilesVariant;
// Write terrains
if (tileset.terrainCount() > 0) {
QVariantList terrainsVariant;
for (int i = 0; i < tileset.terrainCount(); ++i) {
Terrain *terrain = tileset.terrain(i);
const Properties &properties = terrain->properties();
QVariantMap terrainVariant;
terrainVariant[QLatin1String("name")] = terrain->name();
terrainVariant[QLatin1String("tile")] = terrain->imageTileId();
addProperties(terrainVariant, properties);
terrainsVariant << terrainVariant;
}
tilesetVariant[QLatin1String("terrains")] = terrainsVariant;
}
return tilesetVariant;
}
示例13: AddNode
/* Add a new PBTreeNode based upon the supplied DBus object_path
*/
PBTreeNode* PBTreeNode::AddNode(PBTreeNode* parentNode, \
const QDBusObjectPath &object_path)
{
PBTreeNode* pbtn = NULL;
// special case for the root node
if(parentNode->object_path.path().isNull()) {
// We ARE the parentNode this time
pbtn = parentNode;
}
else {
pbtn = new PBTreeNode();
}
pbtn->object_path = object_path;
pbtn->parent=parentNode;
// The introspected string describing this object
const QString intro_xml = GetIntrospectXml(object_path);
pbtn->introspection=new QDomDocument(intro_xml);
pbtn->xmlstring = intro_xml;
/* We fill in all the children.
*
* We do this by creating a new child node for each node in intro_xml,
* and then introspecting these child nodes until we get nothing more
*/
QDomDocument doc;
doc.setContent(intro_xml);
QDomElement xmlnode=doc.documentElement();
QDomElement child=xmlnode.firstChildElement();
while(!child.isNull()) {
// Is this a node?
if (child.tagName() == "node") {
// Yes, so we should introspect that as well
QString child_path;
if (object_path.path() == "/") {
child_path = object_path.path() + child.attribute("name");
} else {
child_path = object_path.path() + "/" + child.attribute("name");
}
QDBusObjectPath child_object_path(child_path);
PBTreeNode* node = AddNode(pbtn,child_object_path);
if (node) {
pbtn->children.append(node);
}
}
// Is this an interface?
if (child.tagName() == "interface") {
QString iface_name = child.attribute("name");
// we dont need properties from freedesktop interfaces
if (iface_name != ofDIntrospectableName && \
iface_name != ofDPropertiesName) {
QVariantMap properties;
properties = GetObjectProperties(object_path, iface_name);
if (!properties.empty()) {
PBObjectInterface *iface = \
new PBObjectInterface(iface_name,properties);
pbtn->interfaces.append(iface);
}
}
}
child = child.nextSiblingElement();
}
return pbtn;
}
示例14: toVariant
QVariant MapToVariantConverter::toVariant(const Tileset *tileset,
int firstGid) const
{
QVariantMap tilesetVariant;
if (firstGid > 0)
tilesetVariant[QLatin1String("firstgid")] = firstGid;
const QString &fileName = tileset->fileName();
if (!fileName.isEmpty()) {
QString source = mMapDir.relativeFilePath(fileName);
tilesetVariant[QLatin1String("source")] = source;
// Tileset is external, so no need to write any of the stuff below
return tilesetVariant;
}
tilesetVariant[QLatin1String("name")] = tileset->name();
tilesetVariant[QLatin1String("tilewidth")] = tileset->tileWidth();
tilesetVariant[QLatin1String("tileheight")] = tileset->tileHeight();
tilesetVariant[QLatin1String("spacing")] = tileset->tileSpacing();
tilesetVariant[QLatin1String("margin")] = tileset->margin();
tilesetVariant[QLatin1String("tilecount")] = tileset->tileCount();
tilesetVariant[QLatin1String("columns")] = tileset->columnCount();
addProperties(tilesetVariant, tileset->properties());
const QPoint offset = tileset->tileOffset();
if (!offset.isNull()) {
QVariantMap tileOffset;
tileOffset[QLatin1String("x")] = offset.x();
tileOffset[QLatin1String("y")] = offset.y();
tilesetVariant[QLatin1String("tileoffset")] = tileOffset;
}
// Write the image element
const QString &imageSource = tileset->imageSource();
if (!imageSource.isEmpty()) {
const QString rel = mMapDir.relativeFilePath(tileset->imageSource());
tilesetVariant[QLatin1String("image")] = rel;
const QColor transColor = tileset->transparentColor();
if (transColor.isValid())
tilesetVariant[QLatin1String("transparentcolor")] = transColor.name();
tilesetVariant[QLatin1String("imagewidth")] = tileset->imageWidth();
tilesetVariant[QLatin1String("imageheight")] = tileset->imageHeight();
}
// Write the properties, terrain, external image, object group and
// animation for those tiles that have them.
QVariantMap tilePropertiesVariant;
QVariantMap tilePropertyTypesVariant;
QVariantMap tilesVariant;
for (const Tile *tile : tileset->tiles()) {
const Properties properties = tile->properties();
if (!properties.isEmpty()) {
tilePropertiesVariant[QString::number(tile->id())] = toVariant(properties);
tilePropertyTypesVariant[QString::number(tile->id())] = propertyTypesToVariant(properties);
}
QVariantMap tileVariant;
if (tile->terrain() != 0xFFFFFFFF) {
QVariantList terrainIds;
for (int j = 0; j < 4; ++j)
terrainIds << QVariant(tile->cornerTerrainId(j));
tileVariant[QLatin1String("terrain")] = terrainIds;
}
if (tile->probability() != 1.f)
tileVariant[QLatin1String("probability")] = tile->probability();
if (!tile->imageSource().isEmpty()) {
const QString rel = mMapDir.relativeFilePath(tile->imageSource());
tileVariant[QLatin1String("image")] = rel;
}
if (tile->objectGroup())
tileVariant[QLatin1String("objectgroup")] = toVariant(tile->objectGroup());
if (tile->isAnimated()) {
QVariantList frameVariants;
for (const Frame &frame : tile->frames()) {
QVariantMap frameVariant;
frameVariant[QLatin1String("tileid")] = frame.tileId;
frameVariant[QLatin1String("duration")] = frame.duration;
frameVariants.append(frameVariant);
}
tileVariant[QLatin1String("animation")] = frameVariants;
}
if (!tileVariant.empty())
tilesVariant[QString::number(tile->id())] = tileVariant;
}
if (!tilePropertiesVariant.empty()) {
tilesetVariant[QLatin1String("tileproperties")] = tilePropertiesVariant;
tilesetVariant[QLatin1String("tilepropertytypes")] = tilePropertyTypesVariant;
}
if (!tilesVariant.empty())
tilesetVariant[QLatin1String("tiles")] = tilesVariant;
// Write terrains
if (tileset->terrainCount() > 0) {
QVariantList terrainsVariant;
//.........这里部分代码省略.........
示例15: createDialog
/*!
* The construction of the dialog
*
* @param [in] parameters Parameters for the Construction of the dialog.
*/
void EapQueryDialog::createDialog(const QVariantMap ¶meters )
{
OstTraceFunctionEntry0( EAPQUERYDIALOG_CREATEDIALOG_ENTRY );
qDebug("EapQueryDialog::createDialog ENTER");
QString message;
QString authMethodstr;
QString keyauthmethod("authmethod");
QString keymessage("messagetxt");
QVariant tmpVariant;
//Get auth method and message string from parameters
if ( parameters.empty() == false ) {
if ( parameters.contains(keyauthmethod) ) {
tmpVariant = parameters.value(keyauthmethod);
authMethodstr = tmpVariant.toString();
}
if ( parameters.contains(keymessage) ) {
tmpVariant = parameters.value(keymessage);
message = tmpVariant.toString();
}
}
QString labelText1(HbParameterLengthLimiter(
hbTrId("txt_occ_title_1_message").arg(authMethodstr)));
QString labelText2 = message;
//Set the dialog to be on the screen until user reacts
//by pressing the Action button
this->setModal(true);
this->setTimeout(HbPopup::NoTimeout);
this->setDismissPolicy(HbPopup::NoDismiss);
HbLabel* label1 = new HbLabel;
Q_ASSERT(label1 != NULL);
label1->setPlainText(labelText1);
label1->setFontSpec(HbFontSpec(HbFontSpec::Primary));
label1->setTextWrapping(Hb::TextWrapAnywhere);
this->setHeadingWidget(label1);
this->setText(labelText2);
this->setIconVisible(false);
//Remove all default actions from the dialog
QList<QAction*> action_list = this->actions();
for ( int i = 0; i < action_list.count(); i++ ) {
this->removeAction(action_list.at(i));
}
//Add a new Ok button action
HbAction* actionOk = new HbAction(hbTrId("txt_common_button_ok"),this);
this->addAction(actionOk);
//Connect to a SLOT owned by this class
bool connected = connect(actionOk, SIGNAL(triggered()), this, SLOT(okPressed()));
Q_ASSERT(connected == true);
// Connect the about to close and hide signals, so that we are able to inform
// the caller that the dialog was closed
connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog()));
Q_ASSERT(connected == true);
connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog()));
Q_ASSERT(connected == true);
OstTraceFunctionExit0( DUP1_EAPQUERYDIALOG_CREATEDIALOG_EXIT );
qDebug("EapQueryDialog::createDialog EXIT");
}