I looked at the techbase about kparts and studied kwrite code a bit, and
finally started to try with embedding a text editing kpart in Plasmate.
I know there's a lot to be done. Just to make sure if I'm going in the right
direction and to find possible problems, I've attached a patch that displays
a katepart as the central widget in plasmate when user selects
Edit>-Executable Scripts>New...
Please correct me wherever I'm wrong. Especially in the 'if' part of
'MainWindow::loadRequiredEditor' function.
Thanks :)
--
Shantanu Tushar (GMT +0530)
http://www.shantanutushar.com
Index: mainwindow.cpp
===================================================================
--- mainwindow.cpp (revision 965779)
+++ mainwindow.cpp (working copy)
@@ -159,6 +159,7 @@ void MainWindow::changeTab(int tab)
m_editPage = new EditPage(this);
m_editPage->setModel(m_model);
setCentralWidget(m_editPage);
+ connect(m_editPage, SIGNAL(treeActivated(const QModelIndex &)), this, SLOT(loadRequiredEditor(const QModelIndex &)));
}
break;
case PublishTab: {
@@ -177,6 +178,14 @@ void MainWindow::changeTab(int tab)
m_oldTab = tab;
}
+void MainWindow::loadRequiredEditor(const QModelIndex &index)
+{
+ if ((index.data(Qt::DisplayRole).toString() == "New...") &&
+ (index.parent().data(Qt::DisplayRole)).toString() == "Executable Scripts") {
+ showEditor();
+ }
+}
+
void MainWindow::loadProject(const QString &name, const QString &type)
{
kDebug() << "Loading project named" << name << "...";
Index: mainwindow.h
===================================================================
--- mainwindow.h (revision 965779)
+++ mainwindow.h (working copy)
@@ -54,6 +54,8 @@ class MainWindow : public KParts::MainWi
void changeTab(int tab);
void loadProject(const QString &name, const QString &type);
+ void loadRequiredEditor(const QModelIndex &index);
+
private:
enum WorkflowTabs { StartPageTab = 0,
EditTab,
Index: editors/editpage.cpp
===================================================================
--- editors/editpage.cpp (revision 965779)
+++ editors/editpage.cpp (working copy)
@@ -15,6 +15,14 @@ EditPage::EditPage(QWidget *parent)
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addWidget(m_tree);
layout->addWidget(m_editor);
+
+ connect(m_tree, SIGNAL(activated(const QModelIndex &)), this, SLOT(slotTreeActivated(const QModelIndex &)));
+}
+
+void EditPage::slotTreeActivated(const QModelIndex &index)
+{
+ kDebug() << "EDITOR LOAD";
+ emit treeActivated(index);
}
void EditPage::setModel(PackageModel *model)
Index: editors/editpage.h
===================================================================
--- editors/editpage.h (revision 965779)
+++ editors/editpage.h (working copy)
@@ -3,6 +3,7 @@
#define EDITPAGE_H
#include <QWidget>
+#include <QModelIndex>
class QTreeView;
class QWidget;
@@ -21,6 +22,12 @@ public:
private:
QTreeView *m_tree;
QWidget *m_editor;
+
+private Q_SLOTS:
+ void slotTreeActivated(const QModelIndex &index);
+
+signals:
+ void treeActivated(const QModelIndex &index);
};
#endif
_______________________________________________
Plasma-devel mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/plasma-devel