diff options
Diffstat (limited to 'sigmodr/models/WeatherGroupModel.cpp')
-rw-r--r-- | sigmodr/models/WeatherGroupModel.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/sigmodr/models/WeatherGroupModel.cpp b/sigmodr/models/WeatherGroupModel.cpp index 7d36cb21..6d51fd2a 100644 --- a/sigmodr/models/WeatherGroupModel.cpp +++ b/sigmodr/models/WeatherGroupModel.cpp @@ -28,9 +28,6 @@ // KDE includes #include <KMenu> -// Qt includes -#include <QtCore/QFile> - Sigmodr::WeatherGroupModel::WeatherGroupModel(BaseModel* parent, Sigmod::Sigmod* sigmod) : GroupModel(parent, sigmod, "Weathers") { @@ -57,18 +54,14 @@ bool Sigmodr::WeatherGroupModel::setData(const QVariant& value, int role) { if (role == Sigmodr::BaseModel::XmlRole) { - if (value.canConvert<QString>()) + QString data = value.toString(); + if (!data.isEmpty()) { - QFile file(value.toString()); QDomDocument xml; - if ((file.open(QIODevice::ReadOnly) && xml.setContent(&file)) || xml.setContent(value.toString())) + if (loadFromData(data, &xml) && (xml.doctype().name() == "Weather")) { - if (xml.doctype().name() == "Weather") - { - addObject(qobject_cast<Sigmod::Sigmod*>(m_object)->newWeather(xml.documentElement())); - return true; - } - file.close(); + addObject(qobject_cast<Sigmod::Sigmod*>(m_object)->newWeather(xml.documentElement())); + return true; } } } |