本文整理汇总了C++中QVersitDocument::type方法的典型用法代码示例。如果您正苦于以下问题:C++ QVersitDocument::type方法的具体用法?C++ QVersitDocument::type怎么用?C++ QVersitDocument::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVersitDocument
的用法示例。
在下文中一共展示了QVersitDocument::type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: importDocument
/*!
* Converts \a document into a corresponding list of QOrganizerItems. After calling this, the
* converted organizer items can be retrieved by calling items().
*
* Returns true on success. The document should contain at least one subdocument. In the
* importing process, each subdocument roughly corresponds to a QOrganizerItem. If any of the
* subdocuments cannot be imported as organizer items (eg. they don't conform to the iCalendar
* format), false is returned and errorMap() will return a list describing the errors that occurred.
* The successfully imported items will still be available via items().
*
* \sa items(), errorMap()
*/
bool QVersitOrganizerImporter::importDocument(const QVersitDocument& document)
{
d->mItems.clear();
d->mErrors.clear();
bool ok = true;
if (document.type() != QVersitDocument::ICalendar20Type
|| document.componentType() != QLatin1String("VCALENDAR")) {
d->mErrors.insert(-1, QVersitOrganizerImporter::InvalidDocumentError);
return false;
}
const QList<QVersitDocument> subDocuments = document.subDocuments();
if (subDocuments.isEmpty()) {
d->mErrors.insert(-1, QVersitOrganizerImporter::EmptyDocumentError);
return false;
}
int documentIndex = 0;
foreach (const QVersitDocument& subDocument, subDocuments) {
QOrganizerItem item;
QVersitOrganizerImporter::Error error;
if (d->importDocument(document, subDocument, &item, &error)) {
d->mItems.append(item);
} else {
// importDocument can return false with no error if it's a non-document component
if (error != QVersitOrganizerImporter::NoError) {
d->mErrors.insert(documentIndex, error);
ok = false;
}
}
documentIndex++;
}
示例2: foreach
QDebug operator<<(QDebug dbg, const QVersitDocument& document)
{
dbg.nospace() << "QVersitDocument(" << document.type() << ", " << document.componentType() << ')';
foreach (const QVersitProperty& property, document.properties()) {
dbg.space() << '\n' << property;
}
foreach (const QVersitDocument& nested, document.subDocuments()) {
dbg.space() << '\n' << nested;
}
return dbg.maybeSpace();
}
示例3: qHash
/*! Returns the hash value for \a key. */
uint qHash(const QVersitDocument &key)
{
int hash = QT_PREPEND_NAMESPACE(qHash)(key.type());
hash += QT_PREPEND_NAMESPACE(qHash)(key.componentType());
hash += key.properties().length() + key.subDocuments().length();
foreach (const QVersitProperty& property, key.properties()) {
hash += qHash(property);
}
foreach (const QVersitDocument& nested, key.subDocuments()) {
hash += qHash(nested);
}
return hash;
}
示例4: importContact
/*!
* Generates a QContact from \a versitDocument.
*/
bool QVersitContactImporterPrivate::importContact(
const QVersitDocument& document, int contactIndex, QContact* contact,
QVersitContactImporter::Error* error)
{
if (document.componentType() != QStringLiteral("VCARD")
&& document.type() != QVersitDocument::VCard21Type
&& document.type() != QVersitDocument::VCard30Type) {
*error = QVersitContactImporter::InvalidDocumentError;
return false;
}
const QList<QVersitProperty> properties = document.properties();
if (properties.size() == 0) {
*error = QVersitContactImporter::EmptyDocumentError;
return false;
}
// First, do the properties with PREF set so they appear first in the contact details
foreach (const QVersitProperty& property, properties) {
QStringList typeParameters = property.parameters().values(QStringLiteral("TYPE"));
if (typeParameters.contains(QStringLiteral("PREF"), Qt::CaseInsensitive))
importProperty(document, property, contactIndex, contact);
}