Settings saved with ok and cancel added to SettingsView.
[qtmeetings] / src / Domain / Configuration / Configuration.cpp
index 0076e23..9872192 100644 (file)
@@ -155,21 +155,41 @@ void Configuration::saveConnectionSettings( const QDomNode &aXML )
        {
                QDomElement e = node.toElement();
                QString tagName = e.tagName().toLower();
-
                if ( tagName == QString( "serverurl" ) )
                {
                        QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->serverUrl().toString() );
-                       e.replaceChild( t, e.firstChild() );
+                       if ( e.childNodes().length() == 0 )
+                       {
+                               e.appendChild( t );
+                       }
+                       else
+                       {
+                               e.replaceChild( t, e.firstChild() );
+                       }
                }
                else if ( tagName == QString( "username" ) )
                {
                        QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->username() );
-                       e.replaceChild( t, e.firstChild() );
+                       if ( e.childNodes().length() == 0 )
+                       {
+                               e.appendChild( t );
+                       }
+                       else
+                       {
+                               e.replaceChild( t, e.firstChild() );
+                       }
                }
                else if ( tagName == QString( "password" ) )
                {
                        QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->password() );
-                       e.replaceChild( t, e.firstChild() );
+                       if ( e.childNodes().length() == 0 )
+                       {
+                               e.appendChild( t );
+                       }
+                       else
+                       {
+                               e.replaceChild( t, e.firstChild() );
+                       }
                }
                else if ( tagName == QString( "refreshinterval" ) )
                {
@@ -182,6 +202,7 @@ void Configuration::saveConnectionSettings( const QDomNode &aXML )
 
 void Configuration::saveRooms( const QDomNode &aXML )
 {
+       qDebug() << "saveRooms";
        //! List of rooms must be cleared and rewritten again
        QDomDocument doc = aXML.ownerDocument();
        QDomNode root = aXML; 
@@ -190,19 +211,19 @@ void Configuration::saveRooms( const QDomNode &aXML )
        int count = root.childNodes().count();
        QDomNode node = root.firstChild();
        QDomNode next;
-       for (int i=0; i<count; i++)
+       for (int i = 0; i < count; i++)
        {
                qDebug() << "remove " << node.toElement().text();
                next = node.nextSibling();
                node = root.removeChild(node);
                node = next;
        }
-
        QList<Room*>::iterator i;
        for ( i = iRooms.begin(); i != iRooms.end(); ++i )
        {
                QDomElement tag = doc.createElement( "room" );
-               node.appendChild( tag );
+               qDebug() << "write room: " << ( *i )->name() << " to node " << node.toElement().tagName();
+               root.appendChild( tag );
 
                // First room in the list is a dafault room
                if ( i == iRooms.begin() )
@@ -442,6 +463,7 @@ QList<Room*> Configuration::readRooms( const QDomNode &aXML )
                                if ( tagName == QString( "name" ) )
                                {
                                        name = roomElem.text();
+                                       qDebug() << "got room: " << name;
                                }
                                else if ( tagName == QString( "address" ) )
                                {
@@ -619,7 +641,7 @@ DateTimeSettings * Configuration::readDateTimeSettings( const QDomNode &aXML )
                        
                        bool success = false;
                        unsigned int weekDayTmp = e.text().toUInt( &success );
-                       if( success && weekDayTmp >= 0 && weekDayTmp < 7)
+                       if( success && weekDayTmp < 7 )
                        {
                                dayOfWeek = (DateTimeSettings::weekDay)weekDayTmp;
                        }