Unit tests for RemoteList are now ready
[irwi] / src / remotelist.cpp
index 6fc7cd1..5d33a3f 100644 (file)
@@ -1,4 +1,5 @@
 #include "remotelist.h"
+
 #include <QFile> 
 #include <QDomElement> 
 #include <QDomNodeList> 
@@ -21,11 +22,6 @@ RemoteList::RemoteList(QDomDocument &doc)
     parse(doc);
 }
 
-RemoteList::RemoteList(const QString &xmlFile)
-{
-    parse(xmlFile);   
-}
-
 RemoteList::~RemoteList()
 {
 }
@@ -37,24 +33,17 @@ void RemoteList::setContent(QDomDocument &doc)
     parse(doc);
 }
 
-void RemoteList::setContent(const QString &xmlFile)
-{
-    mfgMap.clear();
-    modelMap.clear();
-    parse(xmlFile);
-}
-
 bool RemoteList::isValid()
 {
     return valid;
 }
 
-QList<QChar> RemoteList::letters()
+QStringList RemoteList::letters()
 {
     return mfgMap.keys();
 }
 
-QStringList RemoteList::manufacturers(const QChar &letter)
+QStringList RemoteList::manufacturers(const QString &letter)
 {
     return mfgMap.value(letter);
 }
@@ -64,28 +53,6 @@ QList<Model> RemoteList::models(const QString &manufacturer)
     return modelMap.value(manufacturer);
 }
 
-void RemoteList::parse(const QString &xmlFile)
-{
-    QFile file(xmlFile);
-    QDomDocument doc;
-
-    if (!file.open(QIODevice::ReadOnly))
-    {
-        valid = false;
-        return;
-    }
-
-    if (!doc.setContent(&file))
-    {
-        file.close();
-        valid = false;
-        return;
-    }
-    file.close();   
-
-    parse(doc);
-}
-
 void RemoteList::parse(QDomDocument &doc)
 {
     QDomNodeList chars = doc.elementsByTagName("char");
@@ -100,9 +67,9 @@ void RemoteList::parse(QDomDocument &doc)
         }
     }
 
+    // TODO: more error handling
     valid = (mfgMap.size() > 0 &&
-             modelMap.size() > 0 &&
-             mfgMap.values().size() == modelMap.keys().size());
+             modelMap.size() > 0);
 }
 
 QStringList RemoteList::parseMfgs(QDomElement &charEl)