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

List:       kde-commits
Subject:    [plasmate/terietor/kconfigxt] /: Populate the ui of kconfigxteditor and make it read "real" data
From:       Giorgos Tsiapaliwkas <terietor () gmail ! com>
Date:       2012-07-11 18:32:43
Message-ID: 20120711183243.E428EA60A6 () git ! kde ! org
[Download RAW message or body]

Git commit f9824efbf8e2ee84c3752c0a14edec7836d0e873 by Giorgos Tsiapaliwkas.
Committed on 30/06/2012 at 15:36.
Pushed by tsiapaliwkas into branch 'terietor/kconfigxt'.

Populate the ui of kconfigxteditor and make it read "real" data
from the xml

M  +114  -6    editors/kconfigxt/kconfigxteditor.cpp
M  +42   -0    editors/kconfigxt/kconfigxteditor.h
M  +41   -32   editors/kconfigxt/kconfigxteditor.ui
M  +194  -56   editors/kconfigxt/kconfigxtparser.cpp
M  +42   -15   editors/kconfigxt/kconfigxtparser.h
M  +10   -12   editors/kconfigxt/standalone/plasmakconfigxteditor.cpp
M  +1    -1    editors/kconfigxt/standalone/plasmakconfigxteditor.h
M  +0    -1    mainwindow.cpp

http://commits.kde.org/plasmate/f9824efbf8e2ee84c3752c0a14edec7836d0e873

diff --git a/editors/kconfigxt/kconfigxteditor.cpp \
b/editors/kconfigxt/kconfigxteditor.cpp index 3ea1ee9..8f48282 100644
--- a/editors/kconfigxt/kconfigxteditor.cpp
+++ b/editors/kconfigxt/kconfigxteditor.cpp
@@ -31,12 +31,15 @@ KConfigXtEditor::KConfigXtEditor(QWidget *parent)
 {
     m_ui.setupUi(this);
 
-    m_ui.twKeyValues->header()->setResizeMode(QHeaderView::ResizeToContents);
+    m_ui.twEntries->header()->setResizeMode(QHeaderView::ResizeToContents);
     m_ui.twGroups->header()->setResizeMode(QHeaderView::ResizeToContents);
 
     m_ui.lblHintIcon->setPixmap(KIcon("dialog-information").pixmap(16, 16));
 
-    connect(m_ui.pbAddGroup, SIGNAL(clicked()), SLOT(createNewGroup()));
+    connect(m_ui.pbAddGroup, SIGNAL(clicked()), this, SLOT(createNewGroup()));
+    connect(m_ui.twGroups, SIGNAL(currentItemChanged(QTreeWidgetItem*, \
QTreeWidgetItem*)), +            this, \
SLOT(setupWidgetsForEntries(QTreeWidgetItem*))); +    connect(m_ui.pbDeleteGroup, \
SIGNAL(clicked()), this, SLOT(removeGroup()));  
     //hide the source related ui stuff
     m_ui.srcLabel1->setVisible(false);
@@ -57,15 +60,17 @@ void KConfigXtEditor::readFile()
         return;
     }
 
+    //check if the xml exists
     if (!QFile::exists(m_filename.pathOrUrl())) {
         setupWidgetsForNewFile();
         return;
     } else {
         m_parser.setConfigXmlFile(m_filename.pathOrUrl());
+        //parse the xml
         m_parser.parse();
+        takeDataFromParser();
+        setupWidgetsForOldFile();
     }
-
-    // TODO: reading goes here
 }
 
 void KConfigXtEditor::writeFile()
@@ -79,8 +84,14 @@ void KConfigXtEditor::setupWidgetsForNewFile()
     createNewGroup();
 }
 
+void KConfigXtEditor::setupWidgetsForOldFile()
+{
+    setupWidgetsForGroups();
+}
+
 void KConfigXtEditor::createNewGroup()
 {
+    m_ui.twEntries->clear();
     QString newGroupName;
     if (m_groups.isEmpty()) {
         newGroupName = "General";
@@ -95,12 +106,109 @@ void KConfigXtEditor::createNewGroup()
 
     m_groups.append(newGroupName);
 
-    QTreeWidgetItem* item = new QTreeWidgetItem;
-    item->setText(0, newGroupName);
+    addGroupToUi(newGroupName);
+}
+
+
+void KConfigXtEditor::setupWidgetsForGroups()
+{
+    foreach(const QString& group, m_groups) {
+        addGroupToUi(group);
+    }
+}
+
+void KConfigXtEditor::setupWidgetsForEntries(QTreeWidgetItem *item)
+{
+    //the currectIndex of m_ui.twGroups has changed.
+    //this means that we need to load the data for the new
+    //group so remove the old items
+    m_ui.twEntries->clear();
+
+    if (!item) {
+        return;
+    }
+
+    //take keys,values and types for the specified group
+    takeDataFromParser(item->text(0));
+
+    addEntryToUi(m_keysValuesTypes.entryName(), m_keysValuesTypes.entryType(), \
m_keysValuesTypes.entryValue()); +
+}
+
+void KConfigXtEditor::takeDataFromParser(const QString& group)
+{
+    foreach(const KConfigXtParserItem& item, m_parser.dataList()) {
+
+        //take the name of the groups
+        if (!item.groupName().isEmpty()) {
+            m_groups << item.groupName();
+        }
+
+        if (!group.isEmpty()) {
+            if (item.groupName() == group) {
+                //we have specified a group
+                //so probably we want to populate the
+                //m_ui.twEntries.
+                m_keysValuesTypes = item;
+            } else {
+                //we haven't specified a group.
+                //So we don't want populate the m_ui.twEntries.
+                //clear the item.
+                m_keysValuesTypes = KConfigXtParserItem();
+            }
+        }
+    }
+
+}
+
+void KConfigXtEditor::addGroupToUi(const QString& group)
+{
+    QTreeWidgetItem *item = new QTreeWidgetItem();
+    item->setText(0, group);
     item->setFlags(item->flags() | Qt::ItemIsEditable);
 
     m_ui.twGroups->addTopLevelItem(item);
 
     m_ui.twGroups->setCurrentItem(item);
     m_ui.twGroups->editItem(item);
+    //TODO mem leak?
+}
+
+void KConfigXtEditor::addEntryToUi(const QString& key, const QString& type, const \
QString& value) +{
+    qDebug() << "key:" + key;
+    qDebug() << "type:" + type;
+    qDebug() << "value:" + value;
+    QTreeWidgetItem *item = new QTreeWidgetItem();
+    item->setText(0, key);
+    item->setText(1, type);
+    item->setText(2, value);
+    item->setFlags(item->flags() | Qt::ItemIsEditable);
+
+    m_ui.twEntries->addTopLevelItem(item);
+}
+
+void KConfigXtEditor::removeGroup()
+{
+    QByteArray array;
+    
+    QTreeWidgetItem *item = m_ui.twGroups->currentItem();
+
+    QString group = "<group name=\"" + item->text(0) + "\">";
+
+    QFile xmlFile(m_filename.pathOrUrl());
+    if(!xmlFile.open(QIODevice::ReadWrite)) {
+        return;
+    }
+
+    QTextStream text(&xmlFile);
+
+    while (!text.atEnd()) {
+        QString line = text.readLine();
+        if (line == group) {
+            while (line != "</group>") {
+                array.replace(line,"");
+            }
+        }
+    }
 }
diff --git a/editors/kconfigxt/kconfigxteditor.h \
b/editors/kconfigxt/kconfigxteditor.h index 64ba101..d137e9a 100644
--- a/editors/kconfigxt/kconfigxteditor.h
+++ b/editors/kconfigxt/kconfigxteditor.h
@@ -27,6 +27,8 @@
 #include <QWidget>
 #include <KUrl>
 
+class QTreeWidgetItem;
+
 class KConfigXtEditor : public QWidget
 {
     Q_OBJECT
@@ -58,18 +60,58 @@ private slots:
      */
     void createNewGroup();
 
+    /**
+     * Sets up editor widgets for
+     * the groups. This method should be called every time that the
+     * a group is modified/deleted/etc.
+     **/
+    void setupWidgetsForGroups();
+
+    /**
+     * Sets up editor widgets for
+     * the entries. This method should be called every time that the
+     * an entry is modified/deleted/etc.
+     **/
+    void setupWidgetsForEntries(QTreeWidgetItem *item);
+
+    /**
+     * Removes a group from the xml file
+     **/
+    void removeGroup();
+
 protected:
     Ui::KConfigXtEditor m_ui;
 
 private:
     /**
+     * Sets up editor widgets for an existing file
+     * (e.g. creates a default group etc)
+     */
+    void setupWidgetsForOldFile();
+
+    /**
      * Sets up editor widgets for a new file
      * (e.g. creates a default group etc)
      */
     void setupWidgetsForNewFile();
 
+    /**
+     * This method takes the groups from the parser
+     * If group is specified it will also take the
+     * keys,values and types from the parser for the specified group
+     **/
+    void takeDataFromParser(const QString& group = QString());
+
+    //with this method we avoid duplication
+    void addGroupToUi(const QString& group);
+
+    //with this method we can avoid duplication
+    void addEntryToUi(const QString& entryName,
+                                const QString& entryType, const QString& \
entryValue); +
     KUrl m_filename;
     QStringList m_groups;
+    KConfigXtParserItem m_keysValuesTypes;
 
     KConfigXtParser m_parser;
 };
diff --git a/editors/kconfigxt/kconfigxteditor.ui \
b/editors/kconfigxt/kconfigxteditor.ui index 4d2a9c1..370d4b2 100644
--- a/editors/kconfigxt/kconfigxteditor.ui
+++ b/editors/kconfigxt/kconfigxteditor.ui
@@ -44,11 +44,25 @@
    </item>
    <item>
     <layout class="QGridLayout" name="gridLayout">
-     <item row="0" column="0" colspan="2">
-      <widget class="QTreeWidget" name="twGroups">
+     <item row="1" column="4">
+      <widget class="KPushButton" name="pbAddEntry">
+       <property name="text">
+        <string>Add Entry</string>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="6">
+      <widget class="KPushButton" name="pbDeleteEntry">
+       <property name="text">
+        <string>Delete Entry</string>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="4" colspan="4">
+      <widget class="QTreeWidget" name="twEntries">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
-         <horstretch>1</horstretch>
+         <horstretch>2</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
@@ -57,7 +71,17 @@
        </property>
        <column>
         <property name="text">
-         <string>Group</string>
+         <string notr="true">Key</string>
+        </property>
+       </column>
+       <column>
+        <property name="text">
+         <string>Type</string>
+        </property>
+       </column>
+       <column>
+        <property name="text">
+         <string>Value</string>
         </property>
        </column>
       </widget>
@@ -69,35 +93,33 @@
        </property>
       </widget>
      </item>
-     <item row="0" column="2" colspan="2">
-      <widget class="QTreeWidget" name="twKeyValues">
+     <item row="0" column="0" colspan="4">
+      <widget class="QTreeWidget" name="twGroups">
        <property name="sizePolicy">
         <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
-         <horstretch>2</horstretch>
+         <horstretch>1</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
+       <property name="rootIsDecorated">
+        <bool>false</bool>
+       </property>
        <column>
         <property name="text">
-         <string notr="true">Key</string>
-        </property>
-       </column>
-       <column>
-        <property name="text">
-         <string>Value</string>
+         <string>Group</string>
         </property>
        </column>
       </widget>
      </item>
      <item row="1" column="2">
-      <widget class="KPushButton" name="pbAddKey">
+      <widget class="KPushButton" name="pbDeleteGroup">
        <property name="text">
-        <string>Add Key</string>
+        <string>Delete Grop</string>
        </property>
       </widget>
      </item>
-     <item row="1" column="1">
-      <spacer name="horizontalSpacer">
+     <item row="1" column="5">
+      <spacer name="horizontalSpacer_2">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
@@ -109,8 +131,8 @@
        </property>
       </spacer>
      </item>
-     <item row="1" column="3">
-      <spacer name="horizontalSpacer_2">
+     <item row="1" column="1">
+      <spacer name="horizontalSpacer">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
@@ -173,19 +195,6 @@
      </item>
     </layout>
    </item>
-   <item>
-    <spacer name="verticalSpacer_2">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>40</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
   </layout>
  </widget>
  <customwidgets>
diff --git a/editors/kconfigxt/kconfigxtparser.cpp \
b/editors/kconfigxt/kconfigxtparser.cpp index 82926ab..990eed8 100644
--- a/editors/kconfigxt/kconfigxtparser.cpp
+++ b/editors/kconfigxt/kconfigxtparser.cpp
@@ -25,11 +25,90 @@
 
 #include <QFile>
 #include <QXmlStreamReader>
-/*#include <QDomElement>
-#include <QDomNode>*/
+
+#include <QDebug>
+KConfigXtParserItem::KConfigXtParserItem(QObject* parent)
+{
+}
+
+QString KConfigXtParserItem::groupName() const
+{
+    return m_groupName;
+}
+
+QString KConfigXtParserItem::entryName() const
+{
+    return m_entryName;
+}
+
+QString KConfigXtParserItem::entryType() const
+{
+    return m_entryType;
+}
+
+QString KConfigXtParserItem::entryValue() const
+{
+    return m_entryValue;
+}
+
+void KConfigXtParserItem::setGroupName(const QString& groupName)
+{
+    m_groupName = groupName;
+    qDebug() << "groupName:" + groupName;
+}
+
+void KConfigXtParserItem::setEntryName(const QString& entryName)
+{
+    m_entryName = entryName;
+    qDebug() << "entryName:" + entryName;
+}
+
+void KConfigXtParserItem::setEntryType(const QString& entryType)
+{
+    //those are the possible types
+    QStringList types;
+    types << "string"
+    <<"String"
+    <<"StringList"
+    <<"Font"
+    <<"Rect"
+    <<"Size"
+    <<"Color"
+    <<"Point"
+    <<"Int"
+    <<"UInt"
+    <<"Bool"
+    <<"Double"
+    <<"DateTime"
+    <<"LongLong"
+    <<"ULongLong"
+    <<"IntList"
+    <<"Enum"
+    <<"Path"
+    <<"PathList"
+    <<"Password"
+    <<"Url"
+    <<"UrlList";
+
+    //check if the entryType is valid
+    foreach(const QString& type, types) {
+        if (type == entryType) {
+            //its a type
+            m_entryType = type;
+        }
+    }
+    qDebug() << "entryType:" + entryType;
+}
+
+void KConfigXtParserItem::setEntryValue(const QString& entryValue)
+{
+    m_entryValue = entryValue;
+    qDebug() << "m_entryValue:" + m_entryValue;
+}
 
 KConfigXtParser::KConfigXtParser(QObject *parent)
-        : QObject(parent)
+        : QObject(parent),
+        m_parseResult(false)
 {
 
 }
@@ -38,81 +117,140 @@ void KConfigXtParser::setConfigXmlFile(const QString& filename)
 {
     m_filename = filename;
 }
-#include <QDebug>
-void KConfigXtParser::parse()
+
+bool KConfigXtParser::parse()
 {
     QFile xmlFile(m_filename);
 
     if (!xmlFile.open(QIODevice::ReadWrite)) {
         KMessageBox::error(0, i18n("The xml file isn't writable"));
-        return;
+        return false;
     }
 
-    //we need a temporary hash
-    QHash<QString, QVariant> tmpHash;
-
     QXmlStreamReader reader;
     reader.setDevice(&xmlFile);
-QStringList groups;
-QStringList entries;
-QStringList elses;
-
-    QStringList groupNameList;
-    QStringList entriesList;
-
-    while (!reader.atEnd()) {
-        //for as long as we are still in the same element take the data
-        if (reader.readNextStartElement()) {
-        //ignore all the elements that are
-        //named "kcfg" and "kcgfile" or they are ""
-        //we don't want those to appear in the ui
-            if (reader.name() != "kcfg" && reader.name() != "kcfgfile" && \
                !reader.name().isEmpty()) {
-                //qDebug() << "element text" \
                <<reader.attributes().data()->value().toString();
-              //  qDebug() << "element name" << reader.name().toString()
-                if (reader.name() == "group") {
-                    //we have a new group
-                  //  tmpHash["group"] = \
                reader.attributes().data()->value().toString();
-                    groupNameList << reader.attributes().data()->value().toString();
-                } else if(reader.name() == "entry") {
-                    //we have a new entry
-                    entriesList << reader.attributes().data()->value().toString();
-                } else {
-                  //  reader.readNext();
-                    elses <<  reader.name().toString() + ":" + \
                reader.attributes().data()->value().toString();
-                    //QVector<QXmlStreamAttribute> vector = \
                reader.attributes().data();
-                    qDebug() << "qualifiedName:" + \
                reader.qualifiedName().toString();
-                    qDebug() << "qualifiedValue:" << \
                reader.attributes().value(reader.qualifiedName().toString());
-                }
+
+   //we will parse the file unti its end or until an error occurs
+    while (!reader.atEnd() && !reader.hasError()) {
+        //we need the token in order to check what is the element
+        QXmlStreamReader::TokenType token = reader.readNext();
+
+        //we have an element
+        if(token == QXmlStreamReader::StartElement) {
+            //we have a new group
+            if(reader.name() == "group") {
+                parseGroup(reader);
             }
+
         }
     }
 
+    if(reader.hasError()) {
+        //an error has occured
+        KMessageBox::error(0, i18n("The xml parsing has failed"));
 
-    foreach(const QString& groupName, groupNameList) {
-        foreach(const QString& entry, entriesList) {
-            m_groups[groupName] << entry;
-        }
+        //clear the reader
+        reader.clear();
+        //the parse has failed
+        m_parseResult = false;
     }
-    
-    
-    foreach(QString g, groupNameList) {
-        qDebug() << "groups:" <<g;
+
+    m_dataList.append(m_data);
+    //the parse was successfull
+    m_parseResult = true;
+
+    return m_parseResult;
+}
+
+void KConfigXtParser::parseGroup(QXmlStreamReader& reader)
+{
+    //verify if we really has a group
+    if(reader.tokenType() != QXmlStreamReader::StartElement &&
+        reader.name() == "person") {
+        //fail!
+        return;
     }
-    foreach(QString e, entriesList) {
-        qDebug() << "entries:"<< e;
+
+    //check if <group name="something"> exists
+    if(reader.attributes().hasAttribute("name")) {
+    // We'll add it to the hash
+    m_data.setGroupName(reader.attributes().value("name").toString());
+    qDebug() << "auto einai to name tou group:" + \
reader.attributes().value("name").toString();  }
-    
-    foreach(QString e, elses) {
-        qDebug() << "elses:"<< e;
+
+
+    //we are still in the group element so let's go the next element
+    reader.readNext();
+    //we will loop over the group element until its end
+    while(!(reader.tokenType() == QXmlStreamReader::EndElement &&
+        reader.name() == "group")) {
+        if(reader.tokenType() == QXmlStreamReader::StartElement) {
+            //check if this is an entry element
+            if(reader.name() == "entry") {
+                parseEntry(reader);
+            }
+        }
+        reader.readNext();
     }
 }
 
-QHash<QString, QStringList> KConfigXtParser::groups() const
+void KConfigXtParser::parseEntry(QXmlStreamReader& reader)
 {
-    return m_groups;
+    // Check if we are inside an element like <entry name="interval" type="Int">
+    if(reader.tokenType() != QXmlStreamReader::StartElement) {
+        return;
+    }
+
+    //check if there is a type attribute
+    //if there isn't fail!
+    if (reader.attributes().hasAttribute("type")) {
+        qDebug() << "auto einai to attribute  type tou entry:" + \
reader.attributes().value("type").toString(); +        //now we can take the entry's \
name and type +        \
m_data.setEntryName(reader.attributes().value("name").toString()); +        \
m_data.setEntryType(reader.attributes().value("type").toString()); +
+        m_parseResult = true;
+
+        qDebug() << "entry name:" + reader.name().toString();
+        qDebug() << "entry type:" + reader.attributes().value("type").toString();
+    } else {
+        //there is no type, fail
+        m_parseResult = false;
+        return;
+    }
+
+    //go ahead!
+    reader.readNext();
+
+    //for as long as we are inside the entry element
+    //we need to search for its value
+    int counter = 0;
+    while(!(reader.tokenType() == QXmlStreamReader::EndElement &&
+        reader.name() == "entry")) {
+
+        //we have a default element
+        if (reader.name().toString() == "default") {
+            qDebug() << "mpike!!!";
+
+            //go ahead one more!
+            reader.readNext();
+
+            //we need the text of default
+            QString defaultText = reader.text().toString();
+
+            //check if we have characters
+            if(reader.tokenType() != QXmlStreamReader::Characters) {
+                return;
+            }
+            m_data.setEntryValue(reader.text().toString());
+
+        }
+        reader.readNext();
+    }
 }
 
-QHash<QString, QVariant> KConfigXtParser::keysAndValues() const
+QList<KConfigXtParserItem> KConfigXtParser::dataList() const
 {
-    return m_keysAndValues;
+    return m_dataList;
 }
+
diff --git a/editors/kconfigxt/kconfigxtparser.h \
b/editors/kconfigxt/kconfigxtparser.h index 709c256..73aaedd 100644
--- a/editors/kconfigxt/kconfigxtparser.h
+++ b/editors/kconfigxt/kconfigxtparser.h
@@ -21,12 +21,41 @@
 #ifndef KCONFIGXTPARSER_H
 #define KCONFIGXTPARSER_H
 
-#include <QStringList>
-#include <QHash>
+#include <QMultiHash>
 #include <QVariant>
+#include <QList>
+#include <QXmlStreamReader>
+
+class KConfigXtParserItem
+{
+
+public:
+    KConfigXtParserItem(QObject* parent = 0);
+
+    QString groupName() const;
+    void setGroupName(const QString& groupName);
+
+    QString entryName() const;
+    void setEntryName(const QString& entryName);
+
+    QString entryType() const;
+    void setEntryType(const QString& entryType);
+
+    QString entryValue() const;
+    void setEntryValue(const QString& entryValue);
+
+private:
+    QString m_groupName;
+    QString m_entryName;
+    QString m_entryType;
+    QString m_entryValue;
+};
+
 
 class KConfigXtParser : public QObject
 {
+
+    Q_OBJECT
 public:
     KConfigXtParser(QObject *parent = 0);
 
@@ -36,24 +65,22 @@ public:
      * Parses a kcfg file.
      * Should be called after setConfigXmlFile()
      */
-    void parse();
+    bool parse();
 
-    /*
-     * Returns a list of group names from config file.
-     * Valid only after a successful call to parse()
-     */
-    QHash<QString, QStringList> groups() const;
-
-    /*
-     * Returns a map of keys and values from config file.
+    /**
+     * Returns the data from the xml file.
      * Valid only after a successful call to parse()
-     */
-    QHash<QString, QVariant> keysAndValues() const;
+     **/
+    QList<KConfigXtParserItem> dataList() const;
 
 private:
+    void parseGroup(QXmlStreamReader& reader);
+    void parseEntry(QXmlStreamReader& reader);
+    bool m_parseResult;
+
     QString m_filename;
-    QHash<QString, QStringList> m_groups;
-    QHash<QString, QVariant> m_keysAndValues;
+    QList<KConfigXtParserItem> m_dataList;
+    KConfigXtParserItem m_data;
 };
 
 #endif
diff --git a/editors/kconfigxt/standalone/plasmakconfigxteditor.cpp \
b/editors/kconfigxt/standalone/plasmakconfigxteditor.cpp index cd4d588..ddf7842 \
                100644
--- a/editors/kconfigxt/standalone/plasmakconfigxteditor.cpp
+++ b/editors/kconfigxt/standalone/plasmakconfigxteditor.cpp
@@ -18,7 +18,7 @@ PlasmaKConfigXtEditor::PlasmaKConfigXtEditor(QWidget* parent)
     m_ui.srcRequester->setFilter("*.xml");
 
     //disable the widgets. The user hasn't give a path yet.
-    disableWidgets();
+    enableWidgets(false);
 
     //we want the source relative ui to be visible.
     m_ui.srcLabel1->setVisible(true);
@@ -35,22 +35,20 @@ void PlasmaKConfigXtEditor::checkProjectPath(const QString& path)
 
     //check if the files is an xml
     if(path.endsWith(".xml")) {
-        m_ui.twKeyValues->setEnabled(true);
-        m_ui.twGroups->setEnabled(true);
-        m_ui.pbAddGroup->setEnabled(true);
-        m_ui.pbAddKey->setEnabled(true);
+        enableWidgets(true);
         setFilename(path);
-
     } else {
-        disableWidgets();
+        enableWidgets(false);
     }
 }
 
-void PlasmaKConfigXtEditor::disableWidgets()
+void PlasmaKConfigXtEditor::enableWidgets(bool enable)
 {
-    m_ui.twKeyValues->setEnabled(false);
-    m_ui.twGroups->setEnabled(false);
-    m_ui.pbAddGroup->setEnabled(false);
-    m_ui.pbAddKey->setEnabled(false);
+    m_ui.twEntries->setEnabled(enable);
+    m_ui.twGroups->setEnabled(enable);
+    m_ui.pbAddGroup->setEnabled(enable);
+    m_ui.pbDeleteGroup->setEnabled(enable);
+    m_ui.pbAddEntry->setEnabled(enable);
+    m_ui.pbDeleteEntry->setEnabled(enable);
 }
 
diff --git a/editors/kconfigxt/standalone/plasmakconfigxteditor.h \
b/editors/kconfigxt/standalone/plasmakconfigxteditor.h index 568d6fe..0287e04 100644
--- a/editors/kconfigxt/standalone/plasmakconfigxteditor.h
+++ b/editors/kconfigxt/standalone/plasmakconfigxteditor.h
@@ -22,7 +22,7 @@ public Q_SLOTS:
     void checkProjectPath(const QString& path);
 
 private:
-    void disableWidgets();
+    void enableWidgets(bool enable);
 };
 
 #endif // PUBLISHER_H
diff --git a/mainwindow.cpp b/mainwindow.cpp
index ca8ce39..3b5b180 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -634,7 +634,6 @@ void MainWindow::loadKConfigXtEditor(const KUrl& target)
     }
 
     m_kconfigXtEditor->setFilename(target);
-    qDebug() << "xmllllllllllllllll" << target.pathOrUrl();
     m_kconfigXtEditor->readFile();
     m_central->switchTo(m_kconfigXtEditor);
 


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

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