[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasmate/terietor/kconfigxt] /: Initial commit for kconfigxtwriter.
From:       Giorgos Tsiapaliwkas <terietor () gmail ! com>
Date:       2012-07-16 15:22:58
Message-ID: 20120716152258.45635A6094 () git ! kde ! org
[Download RAW message or body]

Git commit 00870364fcd560c50d4d47dfab27665063658028 by Giorgos Tsiapaliwkas.
Committed on 16/07/2012 at 17:21.
Pushed by tsiapaliwkas into branch 'terietor/kconfigxt'.

Initial commit for kconfigxtwriter.
Also s/kconfigxtparser/kconfigxtreader

M  +4    -2    CMakeLists.txt
M  +55   -16   editors/kconfigxt/kconfigxteditor.cpp
M  +19   -10   editors/kconfigxt/kconfigxteditor.h
R  +21   -18   editors/kconfigxt/kconfigxtreader.cpp [from: \
editors/kconfigxt/kconfigxtparser.cpp - 083% similarity] R  +11   -10   \
editors/kconfigxt/kconfigxtreader.h [from: editors/kconfigxt/kconfigxtparser.h - 080% \
similarity] A  +171  -0    editors/kconfigxt/kconfigxtwriter.cpp     [License: GPL \
(v2+)] A  +86   -0    editors/kconfigxt/kconfigxtwriter.h     [License: GPL (v2+)]

http://commits.kde.org/plasmate/00870364fcd560c50d4d47dfab27665063658028

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed0b7f7..09696e1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,7 +32,8 @@ set (PlasMate_SRC
     editors/imageviewer/imageviewer.cpp
     editors/text/texteditor.cpp
     editors/kconfigxt/kconfigxteditor.cpp
-    editors/kconfigxt/kconfigxtparser.cpp
+    editors/kconfigxt/kconfigxtreader.cpp
+    editors/kconfigxt/kconfigxtwriter.cpp
     main.cpp
     sidebaritem.cpp
     sidebardelegate.cpp
@@ -145,7 +146,8 @@ install( FILES previewer/windowswitcher/tabboxdelegate.qml \
DESTINATION ${DATA_IN  #plasmakconfigxteditor
 set(plasmakconfigxt_SRCS
      editors/kconfigxt/kconfigxteditor.cpp
-     editors/kconfigxt/kconfigxtparser.cpp
+     editors/kconfigxt/kconfigxtreader.cpp
+     editors/kconfigxt/kconfigxtwriter.cpp
      editors/kconfigxt/standalone/plasmakconfigxteditor.cpp
      editors/kconfigxt/standalone/main.cpp
 )
diff --git a/editors/kconfigxt/kconfigxteditor.cpp \
b/editors/kconfigxt/kconfigxteditor.cpp index 019d7d3..20c6376 100644
--- a/editors/kconfigxt/kconfigxteditor.cpp
+++ b/editors/kconfigxt/kconfigxteditor.cpp
@@ -1,6 +1,7 @@
 /*
    This file is part of the KDE project
    Copyright 2009 by Dmitry Suzdalev <dimsuz@gmail.com>
+   Copyright 2012 by Giorgos Tsiapaliwkas <terietor@gmail.com>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
@@ -19,6 +20,7 @@
 */
 
 #include "kconfigxteditor.h"
+#include "kconfigxtwriter.h"
 
 #include <KDebug>
 #include <KIcon>
@@ -28,6 +30,7 @@
 #include <QFile>
 #include <QHeaderView>
 #include <QTreeWidgetItem>
+#include <QXmlStreamWriter>
 
 KConfigXtEditor::KConfigXtEditor(QWidget *parent)
         : QWidget(parent)
@@ -43,6 +46,7 @@ KConfigXtEditor::KConfigXtEditor(QWidget *parent)
     m_ui.lblHintIcon->setPixmap(KIcon("dialog-information").pixmap(16, 16));
 
     connect(m_ui.pbAddGroup, SIGNAL(clicked()), this, SLOT(createNewGroup()));
+    connect(m_ui.pbAddEntry, SIGNAL(clicked()), this, SLOT(createNewEntry()));
 
     connect(m_ui.twGroups, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
             this, SLOT(setupWidgetsForEntries(QTreeWidgetItem*)));
@@ -68,6 +72,11 @@ void KConfigXtEditor::setFilename(const KUrl& filename)
     m_filename = filename;
 }
 
+KUrl KConfigXtEditor::filename()
+{
+    return m_filename;
+}
+
 void KConfigXtEditor::readFile()
 {
     if (m_filename.isEmpty()) {
@@ -86,11 +95,6 @@ void KConfigXtEditor::readFile()
     }
 }
 
-void KConfigXtEditor::writeFile()
-{
-    // TODO: writing goes here
-}
-
 void KConfigXtEditor::setupWidgetsForNewFile()
 {
     // Add default group
@@ -120,8 +124,48 @@ void KConfigXtEditor::createNewGroup()
     m_groups.append(newGroupName);
 
     addGroupToUi(newGroupName);
+
+    KConfigXtReaderItem newGroupItem;
+    newGroupItem.setGroupName(newGroupName);
+    giveElementsToWriter(newGroupItem);
 }
 
+void KConfigXtEditor::createNewEntry()
+{
+    QTreeWidgetItem *currentGroupItem = m_ui.twGroups->currentItem();
+
+    //check if the ptr is evil!!
+    if (!currentGroupItem) {
+        return;
+    }
+
+    KConfigXtReaderItem newEntryItem;
+    newEntryItem.setGroupName(currentGroupItem->text(0));
+    newEntryItem.setEntryName("TODO");
+    //remember we need a valid type due to the
+    //internal check
+    newEntryItem.setEntryType("String");
+    newEntryItem.setEntryValue("TODO");
+
+    //create the entries for the existing data
+    setupWidgetsForEntries(currentGroupItem);
+
+    //add our new entry into the tree
+    addEntryToUi(newEntryItem.entryName(),
+                 newEntryItem.entryType(), newEntryItem.entryValue());
+
+    giveElementsToWriter(newEntryItem);
+}
+
+void KConfigXtEditor::giveElementsToWriter(KConfigXtReaderItem& newElement)
+{
+    takeDataFromParser();
+    m_keysValuesTypes.append(newElement);
+    KConfigXtWriter writer(filename().pathOrUrl());
+    QList<KConfigXtWriterItem> list = writer.readerItemsToWriterIems(m_groups, \
m_keysValuesTypes); +    writer.setData(list);
+    writer.writeXML();
+}
 
 void KConfigXtEditor::setupWidgetsForGroups()
 {
@@ -155,10 +199,9 @@ void KConfigXtEditor::setupWidgetsForEntries(QTreeWidgetItem \
*item)  //take keys,values and types for the specified group
     takeDataFromParser(item->text(0));
 
-   foreach(const KConfigXtParserItem& item, m_keysValuesTypes) {
+   foreach(const KConfigXtReaderItem& item, m_keysValuesTypes) {
        addEntryToUi(item.entryName(), item.entryType(), item.entryValue());
     }
-
 }
 
 void KConfigXtEditor::addEntryToUi(const QString& key, const QString& type, const \
QString& value) @@ -170,26 +213,22 @@ void KConfigXtEditor::addEntryToUi(const \
QString& key, const QString& type, cons  item->setFlags(item->flags() | \
Qt::ItemIsEditable);  }
 
-void KConfigXtEditor::takeDataFromParser(const QString& group)
+void KConfigXtEditor::takeDataFromParser()
 {
-
     //we need to update the data of our parser first
     m_parser.parse();
 
-    foreach(const KConfigXtParserItem& item, m_parser.dataList()) {
+    foreach(const KConfigXtReaderItem& item, m_parser.dataList()) {
 
-        //take the name of the groups also due to the fact
+        //take the name of the groups, also due to the fact
         //that we take data from a parser we have to be careful so
         //check if the group exists in the list
         if (!item.groupName().isEmpty() && !m_groups.contains(item.groupName())) {
             m_groups << item.groupName();
         }
 
-        if (!group.isEmpty() && item.groupName() == group
-            && !m_keysValuesTypes.contains(item)) {
-            //we have specified a group
-            //so probably we want to populate the
-            //m_ui.twEntries.
+        if (!m_keysValuesTypes.contains(item)) {
+            //take the entrie
             m_keysValuesTypes.append(item);
         }
     }
diff --git a/editors/kconfigxt/kconfigxteditor.h \
b/editors/kconfigxt/kconfigxteditor.h index 046bd92..a7d3225 100644
--- a/editors/kconfigxt/kconfigxteditor.h
+++ b/editors/kconfigxt/kconfigxteditor.h
@@ -1,6 +1,7 @@
 /*
    This file is part of the KDE project
    Copyright 2009 by Dmitry Suzdalev <dimsuz@gmail.com>
+   Copyright 2012 by Giorgos Tsiapaliwkas <terietor@gmail.com>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
@@ -22,7 +23,7 @@
 
 #include "ui_kconfigxteditor.h"
 
-#include "kconfigxtparser.h"
+#include "kconfigxtreader.h"
 
 #include <QWidget>
 #include <KUrl>
@@ -45,6 +46,7 @@ public:
      * Sets filename to edit
      */
     void setFilename(const KUrl& filename);
+    KUrl filename();
 
 public slots:
     /**
@@ -53,12 +55,6 @@ public slots:
      */
     void readFile();
 
-    /**
-     * Writes config values to config file specified with setFilename according
-     * to current editor widgets state
-     */
-    void writeFile();
-
 private slots:
     /**
      * Creates new kconfig group
@@ -66,6 +62,19 @@ private slots:
     void createNewGroup();
 
     /**
+     * Creates new entry
+     */
+    void createNewEntry();
+
+    /**
+     * Write elements in the xml
+     * When a new group or new entry will be
+     * created, this method will write them
+     * into the xml
+     **/
+    void giveElementsToWriter(KConfigXtReaderItem& newElement);
+
+    /**
      * Sets up editor widgets for
      * the groups. This method should be called every time that the
      * a group is modified/deleted/etc.
@@ -134,7 +143,7 @@ private:
      * and m_keysValuesTypes
      */
 
-    void takeDataFromParser(const QString& group = QString());
+    void takeDataFromParser();
 
     //with this method we avoid duplication
     void addGroupToUi(const QString& group);
@@ -153,9 +162,9 @@ private:
 
     KUrl m_filename;
     QStringList m_groups;
-    QList<KConfigXtParserItem> m_keysValuesTypes;
+    QList<KConfigXtReaderItem> m_keysValuesTypes;
 
-    KConfigXtParser m_parser;
+    KConfigXtReader m_parser;
 
     QString m_lastGroupItem;
     //avoid duplication
diff --git a/editors/kconfigxt/kconfigxtparser.cpp \
b/editors/kconfigxt/kconfigxtreader.cpp similarity index 83%
rename from editors/kconfigxt/kconfigxtparser.cpp
rename to editors/kconfigxt/kconfigxtreader.cpp
index 994596c..bde4e4e 100644
--- a/editors/kconfigxt/kconfigxtparser.cpp
+++ b/editors/kconfigxt/kconfigxtreader.cpp
@@ -1,6 +1,7 @@
 /*
    This file is part of the KDE project
    Copyright 2009 by Dmitry Suzdalev <dimsuz@gmail.com>
+   Copyright 2012 by Giorgos Tsiapaliwkas <terietor@gmail.com>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
@@ -18,7 +19,7 @@
    Boston, MA 02110-1301, USA.
 */
 
-#include "kconfigxtparser.h"
+#include "kconfigxtreader.h"
 
 #include <KMessageBox>
 #include <KLocalizedString>
@@ -26,42 +27,44 @@
 #include <QFile>
 #include <QXmlStreamReader>
 
-KConfigXtParserItem::KConfigXtParserItem(QObject* parent)
+#include <KDebug>
+
+KConfigXtReaderItem::KConfigXtReaderItem(QObject* parent)
 {
     Q_UNUSED(parent)
 }
 
-QString KConfigXtParserItem::groupName() const
+QString KConfigXtReaderItem::groupName() const
 {
     return m_groupName;
 }
 
-QString KConfigXtParserItem::entryName() const
+QString KConfigXtReaderItem::entryName() const
 {
     return m_entryName;
 }
 
-QString KConfigXtParserItem::entryType() const
+QString KConfigXtReaderItem::entryType() const
 {
     return m_entryType;
 }
 
-QString KConfigXtParserItem::entryValue() const
+QString KConfigXtReaderItem::entryValue() const
 {
     return m_entryValue;
 }
 
-void KConfigXtParserItem::setGroupName(const QString& groupName)
+void KConfigXtReaderItem::setGroupName(const QString& groupName)
 {
     m_groupName = groupName;
 }
 
-void KConfigXtParserItem::setEntryName(const QString& entryName)
+void KConfigXtReaderItem::setEntryName(const QString& entryName)
 {
     m_entryName = entryName;
 }
 
-bool KConfigXtParserItem::operator==(const KConfigXtParserItem& item)
+bool KConfigXtReaderItem::operator==(const KConfigXtReaderItem& item)
 {
     if (this->entryName() == item.entryName()) {
         return true;
@@ -70,7 +73,7 @@ bool KConfigXtParserItem::operator==(const KConfigXtParserItem& \
item)  }
 }
 
-void KConfigXtParserItem::setEntryType(const QString& entryType)
+void KConfigXtReaderItem::setEntryType(const QString& entryType)
 {
     //those are the possible types
     QStringList types;
@@ -106,24 +109,24 @@ void KConfigXtParserItem::setEntryType(const QString& \
entryType)  }
 }
 
-void KConfigXtParserItem::setEntryValue(const QString& entryValue)
+void KConfigXtReaderItem::setEntryValue(const QString& entryValue)
 {
     m_entryValue = entryValue;
 }
 
-KConfigXtParser::KConfigXtParser(QObject *parent)
+KConfigXtReader::KConfigXtReader(QObject *parent)
         : QObject(parent),
         m_parseResult(false)
 {
 
 }
 
-void KConfigXtParser::setConfigXmlFile(const QString& filename)
+void KConfigXtReader::setConfigXmlFile(const QString& filename)
 {
     m_filename = filename;
 }
 
-bool KConfigXtParser::parse()
+bool KConfigXtReader::parse()
 {
     //we will parse the xml again so clear the list
     if (!m_dataList.isEmpty()) {
@@ -158,7 +161,7 @@ bool KConfigXtParser::parse()
     if(reader.hasError()) {
         //an error has occured
         KMessageBox::error(0, i18n("The xml parsing has failed"));
-
+        kDebug() << "parsing error!!!!" << reader.errorString();
         //clear the reader
         reader.clear();
         //the parse has failed
@@ -171,7 +174,7 @@ bool KConfigXtParser::parse()
     return m_parseResult;
 }
 
-void KConfigXtParser::parseGroup(QXmlStreamReader& reader)
+void KConfigXtReader::parseGroup(QXmlStreamReader& reader)
 {
     //verify if we really has a group
     if(reader.tokenType() != QXmlStreamReader::StartElement &&
@@ -202,7 +205,7 @@ void KConfigXtParser::parseGroup(QXmlStreamReader& reader)
     }
 }
 
-void KConfigXtParser::parseEntry(QXmlStreamReader& reader)
+void KConfigXtReader::parseEntry(QXmlStreamReader& reader)
 {
     // Check if we are inside an element like <entry name="interval" type="Int">
     if(reader.tokenType() != QXmlStreamReader::StartElement) {
@@ -254,7 +257,7 @@ void KConfigXtParser::parseEntry(QXmlStreamReader& reader)
     m_dataList.append(m_data);
 }
 
-QList<KConfigXtParserItem> KConfigXtParser::dataList() const
+QList<KConfigXtReaderItem> KConfigXtReader::dataList() const
 {
     return m_dataList;
 }
diff --git a/editors/kconfigxt/kconfigxtparser.h \
b/editors/kconfigxt/kconfigxtreader.h similarity index 80%
rename from editors/kconfigxt/kconfigxtparser.h
rename to editors/kconfigxt/kconfigxtreader.h
index cb964bd..ff49ccc 100644
--- a/editors/kconfigxt/kconfigxtparser.h
+++ b/editors/kconfigxt/kconfigxtreader.h
@@ -1,6 +1,7 @@
 /*
    This file is part of the KDE project
    Copyright 2009 by Dmitry Suzdalev <dimsuz@gmail.com>
+   Copyright 2012 by Giorgos Tsiapaliwkas <terietor@gmail.com>
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
@@ -18,19 +19,19 @@
    Boston, MA 02110-1301, USA.
 */
 
-#ifndef KCONFIGXTPARSER_H
-#define KCONFIGXTPARSER_H
+#ifndef KCONFIGXTREADER_H
+#define KCONFIGXTREADER_H
 
 #include <QMultiHash>
 #include <QVariant>
 #include <QList>
 #include <QXmlStreamReader>
 
-class KConfigXtParserItem
+class KConfigXtReaderItem
 {
 
 public:
-    KConfigXtParserItem(QObject* parent = 0);
+    KConfigXtReaderItem(QObject* parent = 0);
 
     QString groupName() const;
     void setGroupName(const QString& groupName);
@@ -44,7 +45,7 @@ public:
     QString entryValue() const;
     void setEntryValue(const QString& entryValue);
 
-    bool operator==(const KConfigXtParserItem& item);
+    bool operator==(const KConfigXtReaderItem& item);
 
 private:
     QString m_groupName;
@@ -54,12 +55,12 @@ private:
 };
 
 
-class KConfigXtParser : public QObject
+class KConfigXtReader : public QObject
 {
 
     Q_OBJECT
 public:
-    KConfigXtParser(QObject *parent = 0);
+    KConfigXtReader(QObject *parent = 0);
 
     void setConfigXmlFile(const QString& filename);
 
@@ -73,7 +74,7 @@ public:
      * Returns the data from the xml file.
      * Valid only after a successful call to parse()
      **/
-    QList<KConfigXtParserItem> dataList() const;
+    QList<KConfigXtReaderItem> dataList() const;
 
 private:
     void parseGroup(QXmlStreamReader& reader);
@@ -81,8 +82,8 @@ private:
     bool m_parseResult;
 
     QString m_filename;
-    QList<KConfigXtParserItem> m_dataList;
-    KConfigXtParserItem m_data;
+    QList<KConfigXtReaderItem> m_dataList;
+    KConfigXtReaderItem m_data;
 };
 
 #endif
diff --git a/editors/kconfigxt/kconfigxtwriter.cpp \
b/editors/kconfigxt/kconfigxtwriter.cpp new file mode 100644
index 0000000..eca35dd
--- /dev/null
+++ b/editors/kconfigxt/kconfigxtwriter.cpp
@@ -0,0 +1,171 @@
+/*
+   This file is part of the KDE project
+   Copyright 2012 by Giorgos Tsiapaliwkas <terietor@gmail.com>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#include "kconfigxtwriter.h"
+
+#include <KMessageBox>
+#include <KLocalizedString>
+
+#include <QFile>
+#include <QXmlStreamWriter>
+
+#include <KDebug>
+
+KConfigXtWriterItem::KConfigXtWriterItem(QObject* parent)
+{
+    Q_UNUSED(parent)
+}
+
+QString KConfigXtWriterItem::group() const
+{
+    return m_group;
+}
+
+
+void KConfigXtWriterItem::setGroup(const QString& group)
+{
+    m_group = group;
+}
+
+QList< KConfigXtReaderItem > KConfigXtWriterItem::entries() const
+{
+    return m_entries;
+}
+
+void KConfigXtWriterItem::setEntries(QList<KConfigXtReaderItem> entries)
+{
+    m_entries = entries;
+}
+
+KConfigXtWriter::KConfigXtWriter(QObject *parent)
+        : QObject(parent)
+{
+}
+
+KConfigXtWriter::KConfigXtWriter(const QString& xmlFilePath, QObject *parent)
+        : QObject(parent)
+{
+    setConfigXmlFile(xmlFilePath);
+}
+
+void KConfigXtWriter::setConfigXmlFile(const QString& filename)
+{
+    QFile xmlFile(filename);
+
+    //clear the file
+    xmlFile.resize(0);
+
+    if (!xmlFile.open(QIODevice::ReadWrite)) {
+        return;
+    }
+
+    m_writer.setDevice(&xmlFile);
+
+}
+
+QList< KConfigXtWriterItem > KConfigXtWriter::data()
+{
+    return m_dataList;
+}
+
+void KConfigXtWriter::setData(QList< KConfigXtWriterItem > dataList)
+{
+    m_dataList = dataList;
+}
+
+void KConfigXtWriter::writeXML()
+{
+    if (m_dataList.isEmpty()) {
+        return;
+    }
+
+    m_writer.setAutoFormatting(true);
+    m_writer.writeStartDocument();
+
+    foreach(const KConfigXtWriterItem& writerItem, m_dataList) {
+        //start group
+        m_writer.writeStartElement("group");
+        //start kcfg element
+        m_writer.writeStartElement("kcfg");
+
+        //TODO add the above into the xml
+        /*every kconfigxt xml file contains the below data
+         * 
+         *   <?xml version="1.0" encoding="UTF-8"?>
+         *   <kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
+         *   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         *   xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
+         *   http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
+         *   <kcfgfile name=""/>
+         *   </kcfg>
+         *
+         */
+
+        m_writer.writeAttribute("name", writerItem.group());
+
+        foreach(const KConfigXtReaderItem& readerItem, writerItem.entries()) {
+            //start entry
+            m_writer.writeStartElement("entry");
+            m_writer.writeAttribute("name", readerItem.entryName());
+            m_writer.writeAttribute("type", readerItem.entryType());
+            //start default
+            m_writer.writeStartElement("default");
+            m_writer.writeCharacters(readerItem.entryValue());
+            //end default
+            m_writer.writeEndElement();
+            //end entry
+            m_writer.writeEndElement();
+        }
+        //end group
+        m_writer.writeEndElement();
+    }
+    //end kcfg
+    m_writer.writeEndElement();
+    //end the document
+    m_writer.writeEndDocument();
+}
+
+QList<KConfigXtWriterItem> KConfigXtWriter::readerItemsToWriterIems(QStringList& \
groupList, +                                            QList<KConfigXtReaderItem> \
entriesList) const +{
+
+    QList<KConfigXtWriterItem> list;
+
+    foreach(const QString& group, groupList) {
+        KConfigXtWriterItem tmpItem;
+        tmpItem.setGroup(group);
+        QList<KConfigXtReaderItem> tmpEntryList;
+        foreach (const KConfigXtReaderItem& entry, entriesList) {
+            if (group == entry.groupName()) {
+                KConfigXtReaderItem tmpEntry;
+                tmpEntry.setEntryName(entry.entryName());
+                tmpEntry.setEntryType(entry.entryType());
+                tmpEntry.setEntryValue(entry.entryValue());
+
+                tmpEntryList.append(tmpEntry);
+            }
+        }
+        tmpItem.setEntries(tmpEntryList);
+        list.append(tmpItem);
+    }
+
+    return list;
+}
+
diff --git a/editors/kconfigxt/kconfigxtwriter.h \
b/editors/kconfigxt/kconfigxtwriter.h new file mode 100644
index 0000000..ea3607d
--- /dev/null
+++ b/editors/kconfigxt/kconfigxtwriter.h
@@ -0,0 +1,86 @@
+/*
+   This file is part of the KDE project
+   Copyright 2012 by Giorgos Tsiapaliwkas <terietor@gmail.com>
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public
+   License as published by the Free Software Foundation; either
+   version 2 of the License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.  If not, write to
+   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KCONFIGXTWRITER_H
+#define KCONFIGXTWRITER_H
+
+#include <QMultiHash>
+#include <QVariant>
+#include <QList>
+#include <QXmlStreamReader>
+
+#include "kconfigxtreader.h"
+
+class KConfigXtWriterItem
+{
+
+public:
+    KConfigXtWriterItem(QObject* parent = 0);
+
+    QString group() const;
+    void setGroup(const QString& groupName);
+
+    QList<KConfigXtReaderItem> entries() const;
+    void setEntries(QList<KConfigXtReaderItem> entries);
+
+private:
+    QString m_group;
+    QList<KConfigXtReaderItem> m_entries;
+};
+
+
+class KConfigXtWriter : public QObject
+{
+
+    Q_OBJECT
+public:
+    KConfigXtWriter(QObject *parent = 0);
+    KConfigXtWriter( const QString& xmlFilePath, QObject *parent = 0);
+
+    /**
+     * This is the xml in which the data will be
+     * writen
+     **/
+    void setConfigXmlFile(const QString& filename);
+
+    /**
+     * Returns the data that will be writen in the xml
+     **/
+    QList<KConfigXtWriterItem> data();
+
+    /**
+     * Sets the data that will be writen in the xml
+     **/
+    void setData(QList<KConfigXtWriterItem> dataList);
+
+    /**
+     * writes the data in the xml
+     **/
+    void writeXML();
+
+    QList<KConfigXtWriterItem> readerItemsToWriterIems(QStringList& groupList,
+                                                       QList<KConfigXtReaderItem> \
entriesList) const; +
+private:
+    QList<KConfigXtWriterItem> m_dataList;
+    QXmlStreamWriter m_writer;
+};
+
+#endif


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic