本文整理汇总了C++中QSourceLocation类的典型用法代码示例。如果您正苦于以下问题:C++ QSourceLocation类的具体用法?C++ QSourceLocation怎么用?C++ QSourceLocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSourceLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleMessage
void MessageValidator::handleMessage(QtMsgType type,
const QString &description,
const QUrl &identifier,
const QSourceLocation &sourceLocation)
{
Q_UNUSED(type);
Q_UNUSED(description);
Q_UNUSED(sourceLocation);
Q_UNUSED(identifier);
QXmlStreamReader reader(description);
m_received = QLatin1String("Type:")
+ QString::number(type)
+ QLatin1String("\nDescription: ")
+ description
+ QLatin1String("\nIdentifier: ")
+ identifier.toString()
+ QLatin1String("\nLocation: ")
+ sourceLocation.uri().toString()
+ QLatin1String("#")
+ QString::number(sourceLocation.line())
+ QLatin1String(",")
+ QString::number(sourceLocation.column());
/* We just walk through it, to check that it's valid. */
while(!reader.atEnd())
reader.readNext();
m_success = !reader.hasError();
}
示例2: handleMessage
void XSLTMessageHandler::handleMessage(QtMsgType type, const QString& description,
const QUrl&, const QSourceLocation& sourceLocation)
{
if (!m_document->frame())
return;
MessageLevel level;
switch (type) {
case QtDebugMsg:
level = TipMessageLevel;
break;
case QtWarningMsg:
level = WarningMessageLevel;
break;
case QtCriticalMsg:
case QtFatalMsg:
level = ErrorMessageLevel;
break;
default:
level = LogMessageLevel;
break;
}
Console* console = m_document->frame()->domWindow()->console();
console->addMessage(XMLMessageSource, LogMessageType, level, description,
sourceLocation.line(), sourceLocation.uri().toString());
}
示例3: handleMessage
void XMessageBoxMessageHandler::handleMessage(QtMsgType type, const QString &description, const QUrl &identifier, const QSourceLocation &sourceLocation)
{
if (description.isEmpty())
{
_message = description;
return;
}
_message = _prefix.arg(sourceLocation.line())
.arg(sourceLocation.column())
.arg(description)
.arg(identifier.toString());
switch (type)
{
case QtDebugMsg:
QMessageBox::information(0, _title, _message);
break;
case QtWarningMsg:
QMessageBox::warning(0, _title, _message);
break;
case QtCriticalMsg:
case QtFatalMsg:
default:
QMessageBox::critical(0, _title, _message);
break;
}
}
示例4: handleMessage
virtual void handleMessage(QtMsgType type,
const QString &description,
const QUrl &identifier,
const QSourceLocation &sourceLocation) {
qDebug() << "Error: " << description << " at line " << sourceLocation.line()
<< " char " << sourceLocation.column() << ".";
}
示例5: QString
void
MyXmlErrorHandler::handleMessage (QtMsgType type, const QString &description,
const QUrl & /*identifier*/,
const QSourceLocation &sourceLocation)
{
QString msg = QString("XML message: %1, at uri= %2 "
"line %3 column %4")
.arg(description)
.arg(sourceLocation.uri ().toString ())
.arg(sourceLocation.line ())
.arg(sourceLocation.column ());
switch (type) {
case QtDebugMsg:
Q_DEBUG(msg);
break;
case QtWarningMsg:
Q_WARN(msg);
break;
case QtCriticalMsg:
case QtFatalMsg:
Q_CRIT(msg);
break;
}
}//MyXmlErrorHandler::handleMessage
示例6: sl
void tst_QSourceLocation::valueConstructor() const
{
const QSourceLocation sl(QUrl(QLatin1String("http://example.com/")), 5, 4);
QCOMPARE(sl.uri(), QUrl(QLatin1String("http://example.com/")));
QCOMPARE(sl.line(), qint64(5));
QCOMPARE(sl.column(), qint64(4));
}
示例7: defaultValues
void tst_QSourceLocation::defaultValues() const
{
QSourceLocation def;
QCOMPARE(def.line(), qint64(-1));
QCOMPARE(def.column(), qint64(-1));
QCOMPARE(def.uri(), QUrl());
}
示例8: QSourceLocation
void tst_QSourceLocation::equalnessOperator_data() const
{
QTest::addColumn<QSourceLocation>("v1");
QTest::addColumn<QSourceLocation>("v2");
QTest::addColumn<bool>("True");
{
QTest::newRow("Default constructed values")
<< QSourceLocation()
<< QSourceLocation()
<< true;
}
{
QSourceLocation modified;
modified.setColumn(4);
QTest::newRow("Default constructed, against column-modified")
<< QSourceLocation()
<< modified
<< false;
}
{
QSourceLocation modified;
modified.setLine(5);
QTest::newRow("Default constructed, against line-modified")
<< QSourceLocation()
<< modified
<< false;
}
{
QSourceLocation modified;
modified.setUri(QUrl(QLatin1String("http://example.com/")));
QTest::newRow("Default constructed, against line-modified")
<< QSourceLocation()
<< modified
<< false;
}
{
QSourceLocation modified;
modified.setUri(QUrl(QLatin1String("http://example.com/")));
modified.setLine(5);
modified.setColumn(4);
QTest::newRow("Default constructed, against all-modified")
<< QSourceLocation()
<< modified
<< false;
}
}
示例9:
QDebug operator<<(QDebug debug, const QSourceLocation &sourceLocation)
{
debug << "QSourceLocation("
<< sourceLocation.uri()
<< ", line:"
<< sourceLocation.line()
<< ", column:"
<< sourceLocation.column()
<< ')';
return debug;
}
示例10: copy
void tst_QSourceLocation::copyConstructor() const
{
{
QSourceLocation def;
QSourceLocation copy(def);
QCOMPARE(def.line(), qint64(-1));
QCOMPARE(def.column(), qint64(-1));
QCOMPARE(def.uri(), QUrl());
}
{
QSourceLocation val;
val.setLine(5);
val.setColumn(600);
val.setUri(QUrl(QLatin1String("http://example.com/")));
QSourceLocation copy(val);
QCOMPARE(copy.line(), qint64(5));
QCOMPARE(copy.column(), qint64(600));
QCOMPARE(copy.uri(), QUrl(QLatin1String("http://example.com/")));
}
{
/* Construct from a const object. */
const QSourceLocation val;
const QSourceLocation val2(val);
QCOMPARE(val, val2);
}
}
示例11: addLocation
void GenericStaticContext::addLocation(const SourceLocationReflection *const reflection,
const QSourceLocation &location)
{
Q_ASSERT(!location.isNull());
Q_ASSERT_X(reflection, Q_FUNC_INFO,
"The reflection cannot be zero.");
m_locations.insert(reflection, location);
}
示例12: constCorrectness
/*!
Call functions that must be const.
*/
void tst_QSourceLocation::constCorrectness() const
{
const QSourceLocation def;
def.line();
def.column();
def.uri();
def.isNull();
const QSourceLocation def2;
/* Equalness operator. */
QVERIFY(def == def2);
QCOMPARE(def, def2);
/* Inverse equalness operator. */
QVERIFY(def != def2);
}
示例13: handleMessage
void ValidatorMessageHandler::handleMessage(QtMsgType type, const QString& description,
const QUrl& /* identifier */, const QSourceLocation& sourceLocation)
{
// convert description from html to text
QDomDocument desc;
QString contentError;
int contentLine;
int contentColumn;
if (!desc.setContent(description, false, &contentError, &contentLine,
&contentColumn)) {
qDebug("ValidatorMessageHandler: could not parse validation error line %d column %d: %s",
contentLine, contentColumn, qPrintable(contentError));
return;
}
QDomElement e = desc.documentElement();
if (e.tagName() != "html") {
qDebug("ValidatorMessageHandler: description is not html");
return;
}
QString descText = e.text();
QString strType;
switch (type) {
case 0: strType = "Debug"; break;
case 1: strType = "Warning"; break;
case 2: strType = "Critical"; break;
case 3: strType = "Fatal"; break;
default: strType = "Unknown"; break;
}
QString errorStr = QString("%1 error: line %2 column %3 %4")
.arg(strType)
.arg(sourceLocation.line())
.arg(sourceLocation.column())
.arg(descText);
// append error, separated by newline if necessary
if (errors != "")
errors += "\n";
errors += errorStr;
}
示例14: QVERIFY
void tst_QSourceLocation::isNull() const
{
{
QSourceLocation def;
QVERIFY(def.isNull());
def.setColumn(4);
QVERIFY(def.isNull());
}
{
QSourceLocation def2;
def2.setLine(4);
QVERIFY(def2.isNull());
}
{
QSourceLocation def3;
def3.setUri(QUrl(QLatin1String("http://example.com/")));
QVERIFY(!def3.isNull());
}
}
示例15: handleMessage
void handleMessage(QtMsgType type, const QString &description,
const QUrl &, const QSourceLocation &sourceLocation)
{
const char* typeName;
switch(type)
{
case QtDebugMsg: typeName = "Debug"; break;
case QtWarningMsg: typeName = "Warning"; break;
case QtCriticalMsg: typeName = "Critical"; break;
case QtFatalMsg:
default: typeName = "Fatal"; break;
}
QXmlStreamReader xml(description);
QString text;
while (!xml.atEnd())
if (xml.readNext() == QXmlStreamReader::Characters)
text += xml.text();
std::cerr << typeName << ": " << qPrintable(text);
if (!sourceLocation.isNull())
std::cerr << " (line " << sourceLocation.line()
<< ", col " << sourceLocation.column() << ")" << std::endl;
}