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

List:       kde-commits
Subject:    [plasmate/terietor/kconfigxt] /: Initial import for kconfigxt
From:       Giorgos Tsiapaliwkas <terietor () gmail ! com>
Date:       2012-07-11 18:32:43
Message-ID: 20120711183243.D157FA6094 () git ! kde ! org
[Download RAW message or body]

Git commit 9e0e1c43c31b7b8b203cb3a2211afcade6240f59 by Giorgos Tsiapaliwkas.
Committed on 14/06/2012 at 19:20.
Pushed by tsiapaliwkas into branch 'terietor/kconfigxt'.

Initial import for kconfigxt

M  +26   -0    CMakeLists.txt
M  +6    -1    editors/editpage.cpp
M  +1    -0    editors/editpage.h
D  +0    -30   editors/kconfigxt/CMakeLists.txt
M  +25   -31   editors/kconfigxt/kconfigxteditor.cpp
M  +13   -6    editors/kconfigxt/kconfigxteditor.h
M  +37   -3    editors/kconfigxt/kconfigxteditor.ui
M  +79   -21   editors/kconfigxt/kconfigxtparser.cpp
M  +7    -8    editors/kconfigxt/kconfigxtparser.h
A  +60   -0    editors/kconfigxt/standalone/main.cpp     [License: GPL (v2+)]
A  +56   -0    editors/kconfigxt/standalone/plasmakconfigxteditor.cpp     [License: \
GPL (v2+)] A  +29   -0    editors/kconfigxt/standalone/plasmakconfigxteditor.h     \
[License: GPL (v2+)] D  +0    -41   editors/kconfigxt/tests/test_kconfigxteditor.cpp
M  +17   -0    mainwindow.cpp
M  +3    -1    mainwindow.h
M  +5    -1    packagemodel.cpp

http://commits.kde.org/plasmate/9e0e1c43c31b7b8b203cb3a2211afcade6240f59

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd9fb1c..ed0b7f7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,6 +31,8 @@ set (PlasMate_SRC
     editors/imageviewer/imageloader.cpp
     editors/imageviewer/imageviewer.cpp
     editors/text/texteditor.cpp
+    editors/kconfigxt/kconfigxteditor.cpp
+    editors/kconfigxt/kconfigxtparser.cpp
     main.cpp
     sidebaritem.cpp
     sidebardelegate.cpp
@@ -69,6 +71,7 @@ set (WindowSwitcherPreviewer_SRC
     previewer/windowswitcher/standalone/main.cpp
     previewer/windowswitcher/standalone/windowswitcherpreviewer.cpp
 )
+
 if (DEBUG_MODEL)
       set (PlasMate_SRC
          ${PlasMate_SRC}
@@ -81,6 +84,7 @@ kde4_add_ui_files (PlasMate_SRC
    startpage.ui
    editors/metadata/metadata.ui
    publisher/publisher.ui
+   editors/kconfigxt/kconfigxteditor.ui
 )
 
 include_directories(${KDE4_INCLUDES}
@@ -103,6 +107,7 @@ target_link_libraries(plasmate
                       ${KDE4_PLASMA_LIBS}
                       ${KDE4_KNEWSTUFF3_LIBRARY}
                       ${QT_QTWEBKIT_LIBRARY}
+                      ${QT_QTXML_LIBRARY}
                       ${LIBATTICA_LIBRARY_DIRS}
                       ${QGPGME_LIBRARIES}
                       ${QT_QTDECLARATIVE_LIBRARIES}
@@ -136,4 +141,25 @@ previewer/windowswitcher/thumbnails/systemsettings.png
 previewer/windowswitcher/thumbnails/dolphin.png
 DESTINATION ${DATA_INSTALL_DIR}/plasmate)
 install( FILES previewer/windowswitcher/tabboxdelegate.qml DESTINATION \
${DATA_INSTALL_DIR}/plasmate) +
+#plasmakconfigxteditor
+set(plasmakconfigxt_SRCS
+     editors/kconfigxt/kconfigxteditor.cpp
+     editors/kconfigxt/kconfigxtparser.cpp
+     editors/kconfigxt/standalone/plasmakconfigxteditor.cpp
+     editors/kconfigxt/standalone/main.cpp
+)
+
+kde4_add_ui_files (plasmakconfigxt_SRCS
+    editors/kconfigxt/kconfigxteditor.ui
+)
+
+kde4_add_executable(plasmakconfigxteditor ${plasmakconfigxt_SRCS})
+target_link_libraries(plasmakconfigxteditor
+                        ${KDE4_KDEUI_LIBS}
+                        ${KDE4_KIO_LIBRARY}
+                        ${QT_QTXML_LIBRARY}
+)
+
+install(TARGETS plasmakconfigxteditor ${INSTALL_TARGETS_DEFAULT_ARGS})
 macro_display_feature_log()
diff --git a/editors/editpage.cpp b/editors/editpage.cpp
index d366e14..91f6bce 100644
--- a/editors/editpage.cpp
+++ b/editors/editpage.cpp
@@ -122,6 +122,11 @@ void EditPage::findEditor(const QModelIndex &index)
             return;
         }
 
+        if (mimetype == "[plasmate]/kconfigxteditor") {
+            emit loadKConfigXtEditor(target);
+            return;
+        }
+
         if (mimetype == "[plasmate]/new") {
             const QString packagePath = \
                index.data(PackageModel::packagePathRole).toString();
             const QString dialogText = i18n("Enter a name for the new file:");
@@ -184,7 +189,7 @@ void EditPage::findEditor(const QModelIndex &index)
 bool EditPage::hasExtension(const QString& filename)
 {
     QStringList list;
-    list << ".rb" << ".js" << ".qml" << ".py";
+    list << ".rb" << ".js" << ".qml" << ".py" << ".xml";
     foreach (const QString &str, list) {
         if (filename.endsWith(str)) {
             return true;
diff --git a/editors/editpage.h b/editors/editpage.h
index 4219028..8cc5fab 100644
--- a/editors/editpage.h
+++ b/editors/editpage.h
@@ -57,6 +57,7 @@ signals:
     void loadEditor(const KService::List offers, KUrl target);
     void loadMetaDataEditor(KUrl target);
     void loadImageViewer(const KUrl &target);
+    void loadKConfigXtEditor(const KUrl &target);
 };
 
 #endif
diff --git a/editors/kconfigxt/CMakeLists.txt b/editors/kconfigxt/CMakeLists.txt
deleted file mode 100644
index e919eb2..0000000
--- a/editors/kconfigxt/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-project( plasmate-kconfigxt-editor )
-
-find_package(KDE4 REQUIRED)
-include(KDE4Defaults)
-
-set(kconfigxt_editor_SRCS
-    kconfigxteditor.cpp
-    kconfigxtparser.cpp)
-
-kde4_add_ui_files (kconfigxt_editor_SRCS
-   kconfigxteditor.ui
-)
-
-add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
-include_directories(${KDE4_INCLUDES} ../..)
-
-kde4_add_plugin(plasmate_kconfigxt_editor ${kconfigxt_editor_SRCS})
-target_link_libraries(plasmate_kconfigxt_editor ${KDE4_PLASMA_LIBS} \
                ${KDE4_KIO_LIBS})
-
-set( testkconfigxt_SRCS tests/test_kconfigxteditor.cpp
-     kconfigxteditor.cpp
-     kconfigxtparser.cpp
-      )
-
-kde4_add_ui_files (testkconfigxt_SRCS
-   kconfigxteditor.ui
-)
-
-kde4_add_executable( testkconfigxt TEST ${testkconfigxt_SRCS})
-target_link_libraries( testkconfigxt ${KDE4_KDEUI_LIBS} ${KDE4_PLASMA_LIBS} )
diff --git a/editors/kconfigxt/kconfigxteditor.cpp \
b/editors/kconfigxt/kconfigxteditor.cpp index 91d78ac..3ea1ee9 100644
--- a/editors/kconfigxt/kconfigxteditor.cpp
+++ b/editors/kconfigxt/kconfigxteditor.cpp
@@ -19,56 +19,50 @@
 */
 
 #include "kconfigxteditor.h"
-#include "ui_kconfigxteditor.h"
 
 #include <KDebug>
 #include <KIcon>
 #include <QFile>
 #include <QHeaderView>
-
-class KConfigXtEditorPrivate
-{
-public:
-    Ui::KConfigXtEditor *ui;
-    QString filename;
-    QStringList groups;
-};
+#include <QTreeWidgetItem>
 
 KConfigXtEditor::KConfigXtEditor(QWidget *parent)
-        : QWidget(parent), d(new KConfigXtEditorPrivate)
+        : QWidget(parent)
 {
-    d->ui = new Ui::KConfigXtEditor;
-    d->ui->setupUi(this);
+    m_ui.setupUi(this);
 
-    d->ui->twKeyValues->header()->setResizeMode(QHeaderView::ResizeToContents);
-    d->ui->twGroups->header()->setResizeMode(QHeaderView::ResizeToContents);
+    m_ui.twKeyValues->header()->setResizeMode(QHeaderView::ResizeToContents);
+    m_ui.twGroups->header()->setResizeMode(QHeaderView::ResizeToContents);
 
-    d->ui->lblHintIcon->setPixmap(KIcon("dialog-information").pixmap(16, 16));
+    m_ui.lblHintIcon->setPixmap(KIcon("dialog-information").pixmap(16, 16));
 
-    connect(d->ui->pbAddGroup, SIGNAL(clicked()), SLOT(createNewGroup()));
-}
+    connect(m_ui.pbAddGroup, SIGNAL(clicked()), SLOT(createNewGroup()));
 
-KConfigXtEditor::~KConfigXtEditor()
-{
-    delete d->ui;
-    delete d;
+    //hide the source related ui stuff
+    m_ui.srcLabel1->setVisible(false);
+    m_ui.srcLabel2->setVisible(false);
+    m_ui.srcRequester->setVisible(false);
+    m_ui.srcSeparator->setVisible(false);
 }
 
-void KConfigXtEditor::setFilename(const QString& filename)
+void KConfigXtEditor::setFilename(const KUrl& filename)
 {
-    d->filename = filename;
+    m_filename = filename;
 }
 
 void KConfigXtEditor::readFile()
 {
-    if (d->filename.isEmpty()) {
+    if (m_filename.isEmpty()) {
         kDebug() << "Empty filename given!";
         return;
     }
 
-    if (!QFile::exists(d->filename)) {
+    if (!QFile::exists(m_filename.pathOrUrl())) {
         setupWidgetsForNewFile();
         return;
+    } else {
+        m_parser.setConfigXmlFile(m_filename.pathOrUrl());
+        m_parser.parse();
     }
 
     // TODO: reading goes here
@@ -88,25 +82,25 @@ void KConfigXtEditor::setupWidgetsForNewFile()
 void KConfigXtEditor::createNewGroup()
 {
     QString newGroupName;
-    if (d->groups.isEmpty()) {
+    if (m_groups.isEmpty()) {
         newGroupName = "General";
     } else {
         int counter = 1;
         newGroupName = QString("Group %1").arg(counter);
-        while (d->groups.contains(newGroupName)) {
+        while (m_groups.contains(newGroupName)) {
             counter++;
             newGroupName = QString("Group %1").arg(counter);
         }
     }
 
-    d->groups.append(newGroupName);
+    m_groups.append(newGroupName);
 
     QTreeWidgetItem* item = new QTreeWidgetItem;
     item->setText(0, newGroupName);
     item->setFlags(item->flags() | Qt::ItemIsEditable);
 
-    d->ui->twGroups->addTopLevelItem(item);
+    m_ui.twGroups->addTopLevelItem(item);
 
-    d->ui->twGroups->setCurrentItem(item);
-    d->ui->twGroups->editItem(item);
+    m_ui.twGroups->setCurrentItem(item);
+    m_ui.twGroups->editItem(item);
 }
diff --git a/editors/kconfigxt/kconfigxteditor.h \
b/editors/kconfigxt/kconfigxteditor.h index e00ab84..64ba101 100644
--- a/editors/kconfigxt/kconfigxteditor.h
+++ b/editors/kconfigxt/kconfigxteditor.h
@@ -20,9 +20,12 @@
 #ifndef KCONFIGXT_EDITOR_H
 #define KCONFIGXT_EDITOR_H
 
-#include <QWidget>
+#include "ui_kconfigxteditor.h"
+
+#include "kconfigxtparser.h"
 
-class KConfigXtEditorPrivate;
+#include <QWidget>
+#include <KUrl>
 
 class KConfigXtEditor : public QWidget
 {
@@ -30,12 +33,11 @@ class KConfigXtEditor : public QWidget
 
 public:
     KConfigXtEditor(QWidget *parent = 0);
-    ~KConfigXtEditor();
 
     /**
      * Sets filename to edit
      */
-    void setFilename(const QString& filename);
+    void setFilename(const KUrl& filename);
 
 public slots:
     /**
@@ -56,6 +58,9 @@ private slots:
      */
     void createNewGroup();
 
+protected:
+    Ui::KConfigXtEditor m_ui;
+
 private:
     /**
      * Sets up editor widgets for a new file
@@ -63,8 +68,10 @@ private:
      */
     void setupWidgetsForNewFile();
 
-private:
-    KConfigXtEditorPrivate *const d;
+    KUrl m_filename;
+    QStringList m_groups;
+
+    KConfigXtParser m_parser;
 };
 
 #endif
diff --git a/editors/kconfigxt/kconfigxteditor.ui \
b/editors/kconfigxt/kconfigxteditor.ui index 8375b93..4d2a9c1 100644
--- a/editors/kconfigxt/kconfigxteditor.ui
+++ b/editors/kconfigxt/kconfigxteditor.ui
@@ -6,12 +6,36 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>300</height>
+    <width>648</width>
+    <height>574</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
+    <layout class="QVBoxLayout" name="verticalLayout_3">
+     <item>
+      <widget class="QLabel" name="srcLabel1">
+       <property name="text">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; \
font-size:12pt; font-weight:600;&quot;&gt;Source&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
 +       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="KSeparator" name="srcSeparator"/>
+     </item>
+     <item>
+      <widget class="QLabel" name="srcLabel2">
+       <property name="text">
+        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Choose your file, your \
file should be an xml file&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> +       \
</property> +      </widget>
+     </item>
+     <item>
+      <widget class="KUrlRequester" name="srcRequester"/>
+     </item>
+    </layout>
+   </item>
+   <item>
     <widget class="QLabel" name="label">
      <property name="text">
       <string>Configuration file layout:</string>
@@ -66,7 +90,7 @@
       </widget>
      </item>
      <item row="1" column="2">
-      <widget class="KPushButton" name="kpushbutton_2">
+      <widget class="KPushButton" name="pbAddKey">
        <property name="text">
         <string>Add Key</string>
        </property>
@@ -166,10 +190,20 @@
  </widget>
  <customwidgets>
   <customwidget>
+   <class>KSeparator</class>
+   <extends>QFrame</extends>
+   <header>kseparator.h</header>
+  </customwidget>
+  <customwidget>
    <class>KPushButton</class>
    <extends>QPushButton</extends>
    <header>kpushbutton.h</header>
   </customwidget>
+  <customwidget>
+   <class>KUrlRequester</class>
+   <extends>QFrame</extends>
+   <header>kurlrequester.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
diff --git a/editors/kconfigxt/kconfigxtparser.cpp \
b/editors/kconfigxt/kconfigxtparser.cpp index 50da89f..82926ab 100644
--- a/editors/kconfigxt/kconfigxtparser.cpp
+++ b/editors/kconfigxt/kconfigxtparser.cpp
@@ -20,41 +20,99 @@
 
 #include "kconfigxtparser.h"
 
-class KConfigXtParserPrivate
-{
-public:
-    QString filename;
-    QStringList groups;
-    QHash<QString, QVariant> keysAndValues;
-};
-
-KConfigXtParser::KConfigXtParser()
-        : d(new KConfigXtParserPrivate())
-{
+#include <KMessageBox>
+#include <KLocalizedString>
 
-}
+#include <QFile>
+#include <QXmlStreamReader>
+/*#include <QDomElement>
+#include <QDomNode>*/
 
-KConfigXtParser::~KConfigXtParser()
+KConfigXtParser::KConfigXtParser(QObject *parent)
+        : QObject(parent)
 {
-    delete d;
+
 }
 
 void KConfigXtParser::setConfigXmlFile(const QString& filename)
 {
-    d->filename = filename;
+    m_filename = filename;
 }
-
-bool KConfigXtParser::parse()
+#include <QDebug>
+void KConfigXtParser::parse()
 {
-    return true;
+    QFile xmlFile(m_filename);
+
+    if (!xmlFile.open(QIODevice::ReadWrite)) {
+        KMessageBox::error(0, i18n("The xml file isn't writable"));
+        return;
+    }
+
+    //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()); +                }
+            }
+        }
+    }
+
+
+    foreach(const QString& groupName, groupNameList) {
+        foreach(const QString& entry, entriesList) {
+            m_groups[groupName] << entry;
+        }
+    }
+    
+    
+    foreach(QString g, groupNameList) {
+        qDebug() << "groups:" <<g;
+    }
+    foreach(QString e, entriesList) {
+        qDebug() << "entries:"<< e;
+    }
+    
+    foreach(QString e, elses) {
+        qDebug() << "elses:"<< e;
+    }
 }
 
-QStringList KConfigXtParser::groups() const
+QHash<QString, QStringList> KConfigXtParser::groups() const
 {
-    return d->groups;
+    return m_groups;
 }
 
 QHash<QString, QVariant> KConfigXtParser::keysAndValues() const
 {
-    return d->keysAndValues;
+    return m_keysAndValues;
 }
diff --git a/editors/kconfigxt/kconfigxtparser.h \
b/editors/kconfigxt/kconfigxtparser.h index de9746f..709c256 100644
--- a/editors/kconfigxt/kconfigxtparser.h
+++ b/editors/kconfigxt/kconfigxtparser.h
@@ -25,13 +25,10 @@
 #include <QHash>
 #include <QVariant>
 
-class KConfigXtParserPrivate;
-
-class KConfigXtParser
+class KConfigXtParser : public QObject
 {
 public:
-    KConfigXtParser();
-    ~KConfigXtParser();
+    KConfigXtParser(QObject *parent = 0);
 
     void setConfigXmlFile(const QString& filename);
 
@@ -39,13 +36,13 @@ public:
      * Parses a kcfg file.
      * Should be called after setConfigXmlFile()
      */
-    bool parse();
+    void parse();
 
     /*
      * Returns a list of group names from config file.
      * Valid only after a successful call to parse()
      */
-    QStringList groups() const;
+    QHash<QString, QStringList> groups() const;
 
     /*
      * Returns a map of keys and values from config file.
@@ -54,7 +51,9 @@ public:
     QHash<QString, QVariant> keysAndValues() const;
 
 private:
-    KConfigXtParserPrivate *const d;
+    QString m_filename;
+    QHash<QString, QStringList> m_groups;
+    QHash<QString, QVariant> m_keysAndValues;
 };
 
 #endif
diff --git a/editors/kconfigxt/standalone/main.cpp \
b/editors/kconfigxt/standalone/main.cpp new file mode 100644
index 0000000..a6dfe5d
--- /dev/null
+++ b/editors/kconfigxt/standalone/main.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012 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.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <KApplication>
+#include <KAboutData>
+#include <KLocale>
+#include <KCmdLineArgs>
+
+#include <QDialog>
+#include <QVBoxLayout>
+#include <QScopedPointer>
+
+#include "plasmakconfigxteditor.h"
+
+int main(int argc, char *argv[])
+{
+    KAboutData aboutData("plasmakconfigxteditor", 0, ki18n("Plasma KConfigXt \
Editor"), +                         "0.1alpha3", ki18n("Plasma KConfigXt Editor"),
+                         KAboutData::License_GPL,
+                         ki18n("Copyright 2012 Plasma Development Team"),
+                         KLocalizedString(), "", "plasma-devel@kde.org");
+
+    aboutData.addAuthor(ki18n("Giorgos Tsiapaliwkas"), ki18n("Author"), \
"terietor@gmail.com"); +    aboutData.setProgramIconName("plasmagik");
+
+    KCmdLineArgs::init(argc, argv, &aboutData);
+
+    KCmdLineOptions options;
+    KCmdLineArgs::addCmdLineOptions(options);
+    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+    KApplication app;
+
+    PlasmaKConfigXtEditor *editor = new PlasmaKConfigXtEditor();
+    QVBoxLayout *l = new QVBoxLayout();
+
+    QScopedPointer<QDialog> dialog(new QDialog());
+
+    l->addWidget(editor);
+    dialog->setLayout(l);
+
+    dialog->exec();
+
+    return app.exec();
+}
+
+
diff --git a/editors/kconfigxt/standalone/plasmakconfigxteditor.cpp \
b/editors/kconfigxt/standalone/plasmakconfigxteditor.cpp new file mode 100644
index 0000000..cd4d588
--- /dev/null
+++ b/editors/kconfigxt/standalone/plasmakconfigxteditor.cpp
@@ -0,0 +1,56 @@
+/*
+ *  Copyright 2012 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.
+ */
+
+#include "plasmakconfigxteditor.h"
+
+PlasmaKConfigXtEditor::PlasmaKConfigXtEditor(QWidget* parent)
+        : KConfigXtEditor(parent)
+{
+    connect(m_ui.srcRequester, SIGNAL(textChanged(const QString&)), this, \
SLOT(checkProjectPath(const QString&))); +
+    //we want only the xml files
+    m_ui.srcRequester->setFilter("*.xml");
+
+    //disable the widgets. The user hasn't give a path yet.
+    disableWidgets();
+
+    //we want the source relative ui to be visible.
+    m_ui.srcLabel1->setVisible(true);
+    m_ui.srcLabel2->setVisible(true);
+    m_ui.srcRequester->setVisible(true);
+    m_ui.srcSeparator->setVisible(true);
+}
+
+void PlasmaKConfigXtEditor::checkProjectPath(const QString& path)
+{
+    if (path.isEmpty()) {
+        return;
+    }
+
+    //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);
+        setFilename(path);
+
+    } else {
+        disableWidgets();
+    }
+}
+
+void PlasmaKConfigXtEditor::disableWidgets()
+{
+    m_ui.twKeyValues->setEnabled(false);
+    m_ui.twGroups->setEnabled(false);
+    m_ui.pbAddGroup->setEnabled(false);
+    m_ui.pbAddKey->setEnabled(false);
+}
+
diff --git a/editors/kconfigxt/standalone/plasmakconfigxteditor.h \
b/editors/kconfigxt/standalone/plasmakconfigxteditor.h new file mode 100644
index 0000000..568d6fe
--- /dev/null
+++ b/editors/kconfigxt/standalone/plasmakconfigxteditor.h
@@ -0,0 +1,29 @@
+/*
+ *  Copyright 2012 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.
+ */
+
+#ifndef PLASMAREMOTEINSTALLER_H
+#define PLASMAREMOTEINSTALLER_H
+
+#include "../kconfigxteditor.h"
+
+class PlasmaKConfigXtEditor : public KConfigXtEditor
+{
+    Q_OBJECT;
+public:
+    PlasmaKConfigXtEditor(QWidget* parent = 0);
+
+public Q_SLOTS:
+    void checkProjectPath(const QString& path);
+
+private:
+    void disableWidgets();
+};
+
+#endif // PUBLISHER_H
+
diff --git a/editors/kconfigxt/tests/test_kconfigxteditor.cpp \
b/editors/kconfigxt/tests/test_kconfigxteditor.cpp deleted file mode 100644
index f7ece0e..0000000
--- a/editors/kconfigxt/tests/test_kconfigxteditor.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <KApplication>
-#include <KAboutData>
-#include <KCmdLineArgs>
-#include <KLocale>
-#include <QDir>
-#include <QVBoxLayout>
-#include <KPushButton>
-
-#include "../kconfigxteditor.h"
-
-int main(int argc, char **argv)
-{
-//    KCmdLineArgs::init(argc, argv);
-//    KApplication app;
-
-    QApplication app(argc, argv);
-
-    QWidget *top = new QWidget();
-    QVBoxLayout *vbox = new QVBoxLayout(top);
-
-    KConfigXtEditor *ed = new KConfigXtEditor(top);
-    vbox->addWidget(ed);
-
-    KPushButton *save = new KPushButton(top);
-    save->setText("&Save");
-    vbox->addWidget(save);
-
-    QString filename;
-    if (argc == 2) {
-        filename = QDir::currentPath() + '/' + argv[1];
-    }
-
-    ed->setFilename(filename);
-    ed->readFile();
-
-    QObject::connect(save, SIGNAL(clicked()), ed, SLOT(writeFile()));
-
-    top->show();
-
-    return app.exec();
-}
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 6e48940..ca8ce39 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -50,6 +50,7 @@ along with this program.  If not, see \
<http://www.gnu.org/licenses/>.  #include "editors/metadata/metadataeditor.h"
 #include "editors/imageviewer/imageviewer.h"
 #include "editors/text/texteditor.h"
+#include "editors/kconfigxt/kconfigxteditor.h"
 #include "savesystem/timeline.h"
 #include "mainwindow.h"
 #include "packagemodel.h"
@@ -111,6 +112,7 @@ MainWindow::MainWindow(QWidget *parent)
         m_isPlasmateCreatedPackage(true),
         m_part(0),
         m_notesPart(0),
+        m_kconfigXtEditor(0),
         m_notesWidget(0)
 {
     setXMLFile("plasmateui.rc");
@@ -624,6 +626,20 @@ void MainWindow::loadImageViewer(const KUrl& target)
     updateSideBar();
 }
 
+void MainWindow::loadKConfigXtEditor(const KUrl& target)
+{
+    saveEditorData();
+    if (!m_kconfigXtEditor) {
+        m_kconfigXtEditor = new KConfigXtEditor(this);
+    }
+
+    m_kconfigXtEditor->setFilename(target);
+    qDebug() << "xmllllllllllllllll" << target.pathOrUrl();
+    m_kconfigXtEditor->readFile();
+    m_central->switchTo(m_kconfigXtEditor);
+
+    updateSideBar();
+}
 
 void MainWindow::loadMetaDataEditor(KUrl target)
 {
@@ -700,6 +716,7 @@ void MainWindow::loadProject(const QString &path)
         connect(m_editPage, SIGNAL(loadEditor(KService::List, KUrl)), this, \
                SLOT(loadRequiredEditor(const KService::List, KUrl)));
         connect(m_editPage, SIGNAL(loadMetaDataEditor(KUrl)), this, \
                SLOT(loadMetaDataEditor(KUrl)));
         connect(m_editPage, SIGNAL(loadImageViewer(KUrl)), this, \
SLOT(loadImageViewer(KUrl))); +        connect(m_editPage, \
                SIGNAL(loadKConfigXtEditor(KUrl)), this, \
                SLOT(loadKConfigXtEditor(KUrl)));
         m_editPage->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
     }
 
diff --git a/mainwindow.h b/mainwindow.h
index 520c26c..874683e 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -41,6 +41,7 @@ class PackageModel;
 class StartPage;
 class Sidebar;
 class TimeLine;
+class KConfigXtEditor;
 class MetaDataEditor;
 class ImageViewer;
 class TextEditor;
@@ -100,6 +101,7 @@ private Q_SLOTS:
     void loadRequiredEditor(const KService::List offers, KUrl target);
     void loadMetaDataEditor(KUrl target);
     void loadImageViewer(const KUrl& target);
+    void loadKConfigXtEditor(const KUrl& target);
     void updateActions();
     void toggleDocumentation();
     void toggleTimeLine();
@@ -156,7 +158,7 @@ private:
     Publisher *m_publisher;
     DocBrowser *m_browser;
     TextEditor *m_textEditor;
-
+    KConfigXtEditor *m_kconfigXtEditor;
 
     QDockWidget *m_filelist;
     EditPage *m_editPage;
diff --git a/packagemodel.cpp b/packagemodel.cpp
index b9040bc..c598b60 100644
--- a/packagemodel.cpp
+++ b/packagemodel.cpp
@@ -171,13 +171,17 @@ QVariant PackageModel::data(const QModelIndex &index, int role) \
const  if (index.row() == 0) {
                 if (!qstrcmp(key, "images")) {
                     return QStringList("[plasmate]/imageDialog");
-                } else {
+                }else {
                     return QStringList("[plasmate]/new");
                 }
             }
             if (!qstrcmp(key, "images")) {
                 return QStringList("[plasmate]/imageViewer");
             }
+
+            if (!qstrcmp(key, "config")) {
+                return QStringList("[plasmate]/kconfigxteditor");
+            }
             return m_package->structure()->mimetypes(key);
         }
         break;


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

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