本文整理汇总了C++中QStringRef::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::toString方法的具体用法?C++ QStringRef::toString怎么用?C++ QStringRef::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleNetworkData
//! [9]
void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply)
{
QUrl url = networkReply->url();
if (!networkReply->error()) {
QStringList choices;
QStringList hits;
QByteArray response(networkReply->readAll());
QXmlStreamReader xml(response);
while (!xml.atEnd()) {
xml.readNext();
if (xml.tokenType() == QXmlStreamReader::StartElement)
if (xml.name() == "suggestion") {
QStringRef str = xml.attributes().value("data");
choices << str.toString();
}
if (xml.tokenType() == QXmlStreamReader::StartElement)
if (xml.name() == "num_queries") {
QStringRef str = xml.attributes().value("int");
hits << str.toString();
}
}
showCompletion(choices, hits);
}
networkReply->deleteLater();
}
示例2: parseReflink
QString ZefaniaLex::parseReflink()
{
const QStringRef fscope = m_xml->attributes().value("fscope");
const QStringRef mscope = m_xml->attributes().value("mscope");
const QStringRef target = m_xml->attributes().value("target");
QString ret;
if(!mscope.isEmpty()) {
VerseUrl burl;
burl.fromMscope(mscope.toString());
QString text;
if(!fscope.isEmpty()) {
text = fscope.toString();
} else {
text = m_refText.toString(burl);
}
m_xml->skipCurrentElement();
ret = "<span class=\"crossreference\"><a class=\"reflink\" href=\"" + burl.toString() + "\">" + text + "</a></span>";
} else if(!target.isEmpty()) {
/* if(target == "XXX") {
}*/
ret = m_xml->readElementText(QXmlStreamReader::IncludeChildElements);
}
return ret;
}
示例3:
void AccelTreeBuilder<FromDocument>::whitespaceOnly(const QStringRef &ch)
{
Q_ASSERT(!ch.isEmpty());
Q_ASSERT(ch.toString().trimmed().isEmpty());
/* This gets problematic due to how QXmlStreamReader works(which
* is the only one we get whitespaceOnly() events from). Namely, text intermingled
* with CDATA gets reported as individual Characters events, and
* QXmlStreamReader::isWhitespace() can return differently for each of those. However,
* it will occur very rarely, so this workaround of 1) mistakenly compressing 2) decompressing 3)
* appending, will happen infrequently.
*/
if(m_hasCharacters)
{
if(m_isCharactersCompressed)
{
m_characters = CompressedWhitespace::decompress(m_characters);
m_isCharactersCompressed = false;
}
m_characters.append(ch.toString());
}
else
{
/* We haven't received a text node previously. */
m_characters = CompressedWhitespace::compress(ch);
m_isCharactersCompressed = true;
m_isPreviousAtomic = false;
m_hasCharacters = true;
}
}
示例4: whitespaceOnly
/*!
\internal
This function may be called instead of characters() if, and only if,
\a value consists only of whitespace.
The caller gurantees that \a value is not empty.
\e Whitespace refers to a sequence of characters that are either
spaces, tabs, or newlines, in any order. In other words, not all
the Unicode whitespace category is considered whitespace here.
However, there is no guarantee or requirement that whitespaceOnly()
is called for text nodes containing whitespace only. characters()
may be called just as well. This is why the default implementation
for whitespaceOnly() calls characters().
\sa characters()
*/
void QAbstractXmlReceiver::whitespaceOnly(const QStringRef &value)
{
Q_ASSERT_X(value.toString().trimmed().isEmpty(), Q_FUNC_INFO,
"The caller must guarantee only whitespace is passed. Use characters() in other cases.");
const QString &v = value.toString();
characters(QStringRef(&v));
}
示例5: parseSubtask
void parseSubtask(QXmlStreamReader & in, Task & task)
{
QXmlStreamAttributes attrs = in.attributes();
QString title = attrs.value("title").toString();
Task::SubTask& st(task.subTasks[title]);
QStringRef bgColor = attrs.value("bgcolor");
QStringRef fgColor = attrs.value("fgcolor");
QStringRef active = attrs.value("active");
st.title = title;
if (!bgColor.isEmpty())
st.bgColor = QColor(bgColor.toString());
if (!fgColor.isEmpty())
st.fgColor = QColor(fgColor.toString());
if (!active.isEmpty())
st.active = active.toString().toUInt();
// read subtask
while(!in.atEnd()) {
QXmlStreamReader::TokenType token = in.readNext();
if (token == QXmlStreamReader::StartElement) {
QString elementName = in.name().toString();
if (0) {
} else if (elementName.compare("description", Qt::CaseInsensitive) == 0){
st.description = in.readElementText();
} else if (elementName.compare("hits", Qt::CaseInsensitive) == 0) {
parseHits(in, task, st.title);
}
} else if (token == QXmlStreamReader::EndElement && in.name().toString().compare("subtask", Qt::CaseInsensitive) == 0) {
return;
}
}
}
示例6: attribute
void DirectoryScanner::attribute(const QXmlName &name, const QStringRef &value)
{
QString localName(name.localName(namePool));
if(localName == "name") {
this->name = value.toString();
} else if(localName == "title") {
title = value.toString();
} else if(localName == "type") {
type = value.toString();
fsBaseFinder.setShortcutMode(type == "shortcut");
} else if(localName == "ev") {
fsBaseFinder.setEV(value.toString());
} else if(localName == "path") {
fsBaseFinder.setPath(value.toString());
regBaseFinder.setPath(value.toString());
} else if(localName == "key") {
regBaseFinder.setKey(value.toString());
} else if(localName == "root") {
regBaseFinder.setRoot(value.toString());
} else if(localName == "includepath") {
include << value.toString();
} else if(localName == "excludepath") {
exclude << value.toString();
}
}
示例7: generateGraphics
ViewItem* LabelItemFactory::generateGraphics(QXmlStreamReader& xml, ObjectStore *store, View *view, ViewItem *parent) {
LabelItem *rc = 0;
while (!xml.atEnd()) {
bool validTag = true;
if (xml.isStartElement()) {
if (!rc && xml.name().toString() == "label") {
QXmlStreamAttributes attrs = xml.attributes();
QStringRef av;
av = attrs.value("text");
if (!av.isNull()) {
Q_ASSERT(!rc);
rc = new LabelItem(view, av.toString());
if (parent) {
rc->setParentViewItem(parent);
// Add any new specialized LabelItem Properties here.
}
}
av = attrs.value("scale");
if (!av.isNull()) {
rc->setLabelScale(QVariant(av.toString()).toInt());
}
av = attrs.value("color");
if (!av.isNull()) {
rc->setLabelColor(QColor(av.toString()));
}
av = attrs.value("font");
if (!av.isNull()) {
QFont font;
font.fromString(av.toString());
rc->setLabelFont(font);
}
av = attrs.value("fixleft");
if (!av.isNull()) {
rc->setFixLeft(QVariant(av.toString()).toBool());
}
} else {
Q_ASSERT(rc);
if (!rc->parse(xml, validTag) && validTag) {
ViewItem *i = GraphicsFactory::parse(xml, store, view, rc);
if (!i) {
}
}
}
} else if (xml.isEndElement()) {
if (xml.name().toString() == "label") {
break;
} else {
validTag = false;
}
}
if (!validTag) {
qDebug("invalid Tag\n");
Debug::self()->log(QObject::tr("Error creating box object from Kst file."), Debug::Warning);
delete rc;
return 0;
}
xml.readNext();
}
return rc;
}
示例8: reader
// Convenience to create a Dom Widget from widget box xml code.
DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool insertFakeTopLevel,
QString *errorMessage)
{
QXmlStreamReader reader(xml);
DomUI *ui = 0;
// The xml description must either contain a root element "ui" with a child element "widget"
// or "widget" as the root element (4.3 legacy)
const QString widgetTag = QLatin1String("widget");
while (!reader.atEnd()) {
if (reader.readNext() == QXmlStreamReader::StartElement) {
const QStringRef name = reader.name();
if (ui) {
reader.raiseError(tr("Unexpected element <%1>").arg(name.toString()));
continue;
}
if (name.compare(QLatin1String("widget"), Qt::CaseInsensitive) == 0) { // 4.3 legacy, wrap into DomUI
ui = new DomUI;
DomWidget *widget = new DomWidget;
widget->read(reader);
ui->setElementWidget(widget);
} else if (name.compare(QLatin1String("ui"), Qt::CaseInsensitive) == 0) { // 4.4
ui = new DomUI;
ui->read(reader);
} else {
reader.raiseError(tr("Unexpected element <%1>").arg(name.toString()));
}
}
}
if (reader.hasError()) {
delete ui;
*errorMessage = tr("A parse error occurred at line %1, column %2 of the XML code "
"specified for the widget %3: %4\n%5")
.arg(reader.lineNumber()).arg(reader.columnNumber()).arg(name)
.arg(reader.errorString()).arg(xml);
return 0;
}
if (!ui || !ui->elementWidget()) {
delete ui;
*errorMessage = tr("The XML code specified for the widget %1 does not contain "
"any widget elements.\n%2").arg(name).arg(xml);
return 0;
}
if (insertFakeTopLevel) {
DomWidget *fakeTopLevel = new DomWidget;
fakeTopLevel->setAttributeClass(QLatin1String("QWidget"));
QList<DomWidget *> children;
children.push_back(ui->takeElementWidget());
fakeTopLevel->setElementWidget(children);
ui->setElementWidget(fakeTopLevel);
}
return ui;
}
示例9: resolveSymbol
String resolveSymbol(QStringRef const &symbol) const
{
if(!resolverFunc)
{
return symbol.toString();
}
return resolverFunc(symbol.toString());
}
示例10: if
void
XmlQueryReader::readQuery()
{
while( !atEnd() )
{
readNext();
if( isStartElement() )
{
if( name() == "filters" )
readFilters();
else if( name() == "order" )
{
QXmlStreamAttributes attr = attributes();
QStringRef fieldStr = attr.value( "field" );
QStringRef valueStr = attr.value( "value" );
qint64 field = Meta::fieldForName( fieldStr.toString() );
bool descending = valueStr == "descending";
if( field != 0 )
d->qm->orderBy( field, descending );
}
else if( name() == "limit" )
{
QStringRef value = attributes().value( "value" );
if( !value.isEmpty() )
d->qm->limitMaxResultSize( value.toString().toInt() );
}
else if( name() == "onlyCompilations" )
{
d->qm->setAlbumQueryMode( Collections::QueryMaker::OnlyCompilations );
}
else if( name() == "onlyNormalAlbums" )
{
d->qm->setAlbumQueryMode( Collections::QueryMaker::OnlyNormalAlbums );
}
else if( name() == "onlyTrackArtists" )
{
d->qm->setArtistQueryMode( Collections::QueryMaker::TrackArtists );
}
else if( name() == "onlyAlbumArtists" )
{
d->qm->setArtistQueryMode( Collections::QueryMaker::AlbumArtists );
}
else if( name() == "AlbumOrTrackArtists" )
{
d->qm->setArtistQueryMode( Collections::QueryMaker::AlbumOrTrackArtists );
}
else if( name() == "returnValues" )
readReturnValues();
//add more container elements here
else
ignoreElements();
}
}
}
示例11: sendLocationMessage
void Server::sendLocationMessage(QStringRef values){
QStringList valueArray = values.toString().split("|");
QString name = valueArray[0];
for (int i = 0; i < nickContainer->size(); ++i){
if (nickContainer->at(i) == name){
clientContainer->at(i)->write("/Location::" + values.toString().toLatin1());
}
}
}
示例12: handleStartElement
void PrivacyQueryFactory::handleStartElement(const QStringRef &name, const QStringRef &uri,
const QXmlStreamAttributes &attributes)
{
Q_UNUSED(uri);
m_depth++;
if (m_depth == 1) {
m_query.reset(new PrivacyQuery);
} if (m_depth == 2) {
QStringRef listName = attributes.value(QLatin1String("name"));
if (name == QLatin1String("list")) {
m_state = AtList;
m_name = listName.toString();
} else if (name == QLatin1String("active")) {
m_query->activeList = listName.toString();
} else if (name == QLatin1String("default")) {
m_query->defaultList = listName.toString();
}
} else if (m_depth == 3 && m_state == AtList && name == QLatin1String("item")) {
// We should provide fallback as said in rfc-3920
m_items.append(m_items.isEmpty() ? PrivacyItem() : m_items.last());
PrivacyItem &item = m_items.last();
m_state = AtItem;
QStringRef data = attributes.value(QLatin1String("value"));
int type = strToEnum(attributes.value(QLatin1String("type")), privacy_types);
if (type == -1 && !data.isEmpty())
type = item.type();
switch (type) {
case PrivacyItem::ByJID:
item.setJID(data.toString());
break;
case PrivacyItem::ByGroup:
item.setGroup(data.toString());
break;
case PrivacyItem::BySubscription:
item.setSubscription(strToEnum<PrivacyItem::SubscriptionType>(data, subscription_types));
break;
default:
item = PrivacyItem();
break;
}
data = attributes.value(QLatin1String("action"));
item.setAction(strToEnum<PrivacyItem::Action>(data, privacy_actions));
item.setOrder(attributes.value(QLatin1String("order")).toString().toInt());
item.setStanzaTypes(0);
} else if (m_depth == 4 && m_state == AtItem) {
int data = strToEnum(name, privacy_stanzas);
if (data == -1)
return;
PrivacyItem &item = m_items.last();
item.setStanzaTypes(item.stanzaTypes() | static_cast<PrivacyItem::StanzaType>(1 << data));
}
}
示例13: handleCharacterData
void EntityTimeFactory::handleCharacterData(const QStringRef &text)
{
if (m_state == AtUtc) {
m_utc = Util::fromStamp(text.toString());
} else if (m_state == AtTzo) {
QString str = text.toString();
int multiple = str.startsWith('-') ? -1 : 1;
QTime delta = QTime::fromString(str.mid(1), QLatin1String("hh:mm"));
m_tzo = multiple * (delta.hour() * 60 + delta.minute());
}
Q_UNUSED(text);
}
示例14: handleCharacterData
void BookmarkFactory::handleCharacterData(const QStringRef &text)
{
switch(m_state) {
case AtNick:
m_conference.setNick(text.toString());
break;
case AtPassword:
m_conference.setPassword(text.toString());
break;
default:
break;
}
}
示例15: handleCharacterData
void MessageFactory::handleCharacterData(const QStringRef &name)
{
StanzaFactory::handleCharacterData(name);
if(m_depth == 2) {
MessagePrivate *p = static_cast<MessagePrivate*>(m_stanza.data());
if(m_state == AtBody)
p->body = name.toString();
else if(m_state == AtSubject)
p->subject = name.toString();
else if(m_state == AtThread)
p->thread = name.toString();
}
}