本文整理汇总了C++中QStringRef::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringRef::contains方法的具体用法?C++ QStringRef::contains怎么用?C++ QStringRef::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringRef
的用法示例。
在下文中一共展示了QStringRef::contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rangeAt
// ### the name and behavior of this function is dubious
QmlJS::AST::Node *SemanticInfo::declaringMemberNoProperties(int cursorPosition) const
{
AST::Node *node = rangeAt(cursorPosition);
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition*>(node)) {
const QStringRef name = objectDefinition->qualifiedTypeNameId->name;
if (!name.isEmpty() && name.at(0).isLower()) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 1)
return path.at(path.size() - 2);
} else if (name.contains(QLatin1String("GradientStop"))) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 2)
return path.at(path.size() - 3);
}
} else if (UiObjectBinding *objectBinding = cast<UiObjectBinding*>(node)) {
const QStringRef name = objectBinding->qualifiedTypeNameId->name;
if (name.contains(QLatin1String("Gradient"))) {
QList<AST::Node *> path = rangePath(cursorPosition);
if (path.size() > 1)
return path.at(path.size() - 2);
}
}
return node;
}
示例2: parse
/*!
\internal
Parses \a pattern.
Allowed is f.ex.:
qt.core.io.debug FullText, QtDebugMsg
qt.core.* LeftFilter, all types
*.io.warning RightFilter, QtWarningMsg
*.core.* MidFilter
*/
void QLoggingRule::parse(const QStringRef &pattern)
{
QStringRef p;
// strip trailing ".messagetype"
if (pattern.endsWith(QLatin1String(".debug"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 6); // strlen(".debug")
messageType = QtDebugMsg;
} else if (pattern.endsWith(QLatin1String(".info"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 5); // strlen(".info")
messageType = QtInfoMsg;
} else if (pattern.endsWith(QLatin1String(".warning"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 8); // strlen(".warning")
messageType = QtWarningMsg;
} else if (pattern.endsWith(QLatin1String(".critical"))) {
p = QStringRef(pattern.string(), pattern.position(),
pattern.length() - 9); // strlen(".critical")
messageType = QtCriticalMsg;
} else {
p = pattern;
}
if (!p.contains(QLatin1Char('*'))) {
flags = FullText;
} else {
if (p.endsWith(QLatin1Char('*'))) {
flags |= LeftFilter;
p = QStringRef(p.string(), p.position(), p.length() - 1);
}
if (p.startsWith(QLatin1Char('*'))) {
flags |= RightFilter;
p = QStringRef(p.string(), p.position() + 1, p.length() - 1);
}
if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end
flags = 0;
}
category = p.toString();
}
示例3: parseGradient
QLinearGradient PropertyReader::parseGradient(const QString &propertyName, bool *isBound) const
{
if (!m_doc)
return QLinearGradient();
*isBound = false;
for (UiObjectMemberList *members = m_ast->members; members; members = members->next) {
UiObjectMember *member = members->member;
if (UiObjectBinding* objectBinding = cast<UiObjectBinding *>(member)) {
UiObjectInitializer *initializer = objectBinding->initializer;
const QString astValue = cleanupSemicolon(textAt(m_doc,
initializer->lbraceToken,
initializer->rbraceToken));
const QString objectPropertyName = objectBinding->qualifiedId->name.toString();
const QStringRef typeName = objectBinding->qualifiedTypeNameId->name;
if (objectPropertyName == propertyName && typeName.contains(QLatin1String("Gradient"))) {
QLinearGradient gradient;
QVector<QGradientStop> stops;
for (UiObjectMemberList *members = initializer->members; members; members = members->next) {
UiObjectMember *member = members->member;
if (UiObjectDefinition *objectDefinition = cast<UiObjectDefinition *>(member)) {
PropertyReader localParser(m_doc, objectDefinition->initializer);
if (localParser.hasProperty(QLatin1String("color")) && localParser.hasProperty(QLatin1String("position"))) {
QColor color = QmlJS::toQColor(localParser.readProperty(QLatin1String("color")).toString());
qreal position = localParser.readProperty(QLatin1String("position")).toReal();
if (localParser.isBindingOrEnum(QLatin1String("color")) || localParser.isBindingOrEnum(QLatin1String("position")))
*isBound = true;
stops.append( QPair<qreal, QColor>(position, color));
}
}
}
gradient.setStops(stops);
return gradient;
}
}
}
return QLinearGradient();
}
示例4: metaContent
QString HtmlNoteReader::metaContent(const QString &html, const QString &name)
{
if(html.isEmpty())
return QString();
QString content = html;
QTime time; // avoid forever loop
time.start();
int metaIdx = 0;
int endIdx = 0;
// find the meta elements in the html files and read the uuid
while(metaIdx != -1 && time.elapsed() < 1500)
{
metaIdx = content.indexOf("<meta",endIdx+1);
if(metaIdx==-1)
break;
endIdx = content.indexOf(">",metaIdx+1);
#if QT_VERSION >= 0x040800 // Qt Version > 4.8
QStringRef metaLine = content.midRef(metaIdx,endIdx-metaIdx+1); // e.g. <meta name="qrichtext" content="1" />
#else
QString metaLine = content.mid(metaIdx,endIdx-metaIdx+1); // e.g. <meta name="qrichtext" content="1" />
#endif
if(metaLine.contains(name))
{
int idx = metaLine.lastIndexOf('\"');
int beforeIdx = metaLine.lastIndexOf('\"',idx-1);
if(idx != -1 || beforeIdx != -1)
{
#if QT_VERSION >= 0x040800 // Qt Version > 4.8
return metaLine.toString().mid(beforeIdx +1,(idx-beforeIdx+1) -2); // +1 and -1 to take the content between the " "
#else
return metaLine.mid(beforeIdx +1,(idx-beforeIdx+1) -2); // +1 and -1 to take the content between the " "
#endif
}
}
}
return QString();
}
示例5: start
XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection) :
QObject(),
_address(QString::fromStdString(address)),
_port(port),
_activePlayerRequest(R"({"id":666,"jsonrpc":"2.0","method":"Player.GetActivePlayers"})"),
_currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})"),
_checkScreensaverRequest(R"({"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}})"),
_getStereoscopicMode(R"({"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":669})"),
_getXbmcVersion(R"({"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["version"]},"id":670})"),
_socket(),
_grabVideo(grabVideo),
_grabPhoto(grabPhoto),
_grabAudio(grabAudio),
_grabMenu(grabMenu),
_grabScreensaver(grabScreensaver),
_enable3DDetection(enable3DDetection),
_previousScreensaverMode(false),
_previousGrabbingMode(GRABBINGMODE_INVALID),
_previousVideoMode(VIDEO_2D),
_xbmcVersion(0)
{
// setup socket
connect(&_socket, SIGNAL(readyRead()), this, SLOT(receiveReply()));
connect(&_socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
connect(&_socket, SIGNAL(connected()), this, SLOT(connected()));
connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
}
void XBMCVideoChecker::start()
{
reconnect();
}
void XBMCVideoChecker::receiveReply()
{
// expect that the reply is received as a single message. Probably oke considering the size of the expected reply
QString reply(_socket.readAll());
std::cout << "Message from XBMC: " << reply.toStdString() << std::endl;
if (reply.contains("\"method\":\"Player.OnPlay\""))
{
// send a request for the current player state
_socket.write(_activePlayerRequest.toUtf8());
return;
}
else if (reply.contains("\"method\":\"Player.OnStop\""))
{
// the player has stopped
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
setVideoMode(VIDEO_2D);
}
else if (reply.contains("\"method\":\"GUI.OnScreensaverActivated\""))
{
setScreensaverMode(!_grabScreensaver);
}
else if (reply.contains("\"method\":\"GUI.OnScreensaverDeactivated\""))
{
setScreensaverMode(false);
}
else if (reply.contains("\"id\":666"))
{
// Result of Player.GetActivePlayers
// always start a new video in 2D mode
emit videoMode(VIDEO_2D);
if (reply.contains("video"))
{
// video is playing
setGrabbingMode(_grabVideo ? GRABBINGMODE_VIDEO : GRABBINGMODE_OFF);
// we need to get the filename
// first retrieve the playerid
QString key = "\"playerid\":";
QRegExp regex(key + "(\\d+)");
int pos = regex.indexIn(reply);
if (pos > 0)
{
// now request info of the playing item
QStringRef idText(&reply, pos + key.length(), regex.matchedLength() - key.length());
_socket.write(_currentPlayingItemRequest.arg(idText.toString()).toUtf8());
}
}
else if (reply.contains("picture"))
{
// picture viewer is playing
setGrabbingMode(_grabPhoto ? GRABBINGMODE_PHOTO : GRABBINGMODE_OFF);
}
else if (reply.contains("audio"))
{
// audio is playing
setGrabbingMode(_grabAudio ? GRABBINGMODE_AUDIO : GRABBINGMODE_OFF);
}
else
{
// Nothing is playing.
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
}
}
//.........这里部分代码省略.........