File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -715,29 +715,29 @@ VCard VCard::fromFile(const QString &filename)
715
715
if (!file.open (QIODevice::ReadOnly | QIODevice::Text))
716
716
return VCard ();
717
717
718
- return fromFile (file);
718
+ auto vcard = fromDevice (&file);
719
+ file.close ();
720
+ return vcard;
719
721
}
720
722
721
- VCard VCard::fromFile (QFile &file )
723
+ VCard VCard::fromDevice (QIODevice *dev )
722
724
{
723
725
QDomDocument doc;
724
726
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
725
- if (!doc.setContent (&file , true )) {
727
+ if (!doc.setContent (dev , true )) {
726
728
#else
727
- if (!doc.setContent (&file , QDomDocument::ParseOption::UseNamespaceProcessing)) {
729
+ if (!doc.setContent (dev , QDomDocument::ParseOption::UseNamespaceProcessing)) {
728
730
#endif
729
- file.close ();
730
- return VCard ();
731
+ return {};
731
732
}
732
- file.close ();
733
733
734
734
QDomElement root = doc.documentElement ();
735
735
if (root.tagName () != QLatin1String (" vcards" ) || root.namespaceURI () != VCARD_NAMESPACE)
736
- return VCard () ;
736
+ return {} ;
737
737
738
738
QDomElement vCardElement = root.firstChildElement (QLatin1String (" vcard" ));
739
739
if (vCardElement.isNull ())
740
- return VCard () ;
740
+ return {} ;
741
741
742
742
return VCard (vCardElement);
743
743
}
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ class VCard {
252
252
QDomElement toXmlElement (QDomDocument &document) const ;
253
253
254
254
static VCard fromFile (const QString &filename);
255
- static VCard fromFile (QFile &file );
255
+ static VCard fromDevice (QIODevice *dev );
256
256
bool save (const QString &filename) const ;
257
257
258
258
void fromVCardTemp (const XMPP::VCard &tempVCard);
You can’t perform that action at this time.
0 commit comments