From b029b4d576df4e9fa8e138f57d7a97f3aa60dda1 Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 21 Apr 2000 19:31:09 +0000 Subject: [PATCH] Ported from KLibFactory to KParts::Factory. Enables to have a different parent for the widget and for the part, which is the right thing (TM). svn path=/trunk/kdebase/konsole/; revision=47221 --- include/konsole_part.h | 15 ++++++++------- src/konsole_part.C | 17 +++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/konsole_part.h b/include/konsole_part.h index 8208c8c8..579014c6 100644 --- a/include/konsole_part.h +++ b/include/konsole_part.h @@ -24,7 +24,7 @@ #define __KONSOLE_PART_H__ #include -#include +#include #include #include @@ -33,16 +33,17 @@ class konsoleBrowserExtension; class QLabel; class TESession; -class konsoleFactory : public KLibFactory +class konsoleFactory : public KParts::Factory { Q_OBJECT - public: +public: konsoleFactory(); virtual ~konsoleFactory(); - virtual QObject* create(QObject* parent = 0, const char* name = 0, - const char* classname = "QObject", - const QStringList &args = QStringList()); + virtual KParts::Part* createPart(QWidget *parentWidget = 0, const char *widgetName = 0, + QObject* parent = 0, const char* name = 0, + const char* classname = "KParts::Part", + const QStringList &args = QStringList()); static KInstance *instance(); @@ -54,7 +55,7 @@ class konsolePart: public KParts::ReadOnlyPart { Q_OBJECT public: - konsolePart(QWidget *parent, const char *name); + konsolePart(QWidget *parentWidget, const char *widgetName, QObject * parent, const char *name); virtual ~konsolePart(); protected: diff --git a/src/konsole_part.C b/src/konsole_part.C index ff391077..eeae5ac9 100644 --- a/src/konsole_part.C +++ b/src/konsole_part.C @@ -51,8 +51,7 @@ extern "C" }; /** - * We need one static instance of the factory for our C 'main' - * function + * We need one static instance of the factory for our C 'main' function */ KInstance *konsoleFactory::s_instance = 0L; @@ -68,10 +67,12 @@ konsoleFactory::~konsoleFactory() s_instance = 0; } -QObject *konsoleFactory::create(QObject *parent, const char *name, const char*, - const QStringList& ) +KParts::Part *konsoleFactory::createPart(QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, const char*, + const QStringList& ) { - QObject *obj = new konsolePart((QWidget*)parent, name); + kdDebug() << "konsoleFactory::createPart parentWidget=" << parentWidget << " parent=" << parent << endl; + KParts::Part *obj = new konsolePart(parentWidget, widgetName, parent, name); emit objectCreated(obj); return obj; } @@ -86,7 +87,7 @@ KInstance *konsoleFactory::instance() return s_instance; } -konsolePart::konsolePart(QWidget *parent, const char *name) +konsolePart::konsolePart(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name) : KParts::ReadOnlyPart(parent, name) { setInstance(konsoleFactory::instance()); @@ -104,13 +105,13 @@ konsolePart::konsolePart(QWidget *parent, const char *name) const char* shell = getenv("SHELL"); if (shell == NULL || *shell == '\0') shell = "/bin/sh"; eargs.append(shell); - te = new TEWidget(parent); + te = new TEWidget(parentWidget,widgetName); te->setFocusPolicy(QWidget::ClickFocus); te->setMinimumSize(150,70); // allow resizing, cause resize in TEWidget te->setScrollbarLocation(TEWidget::SCRRIGHT); setWidget(te); // faking a KTMainwindow - TESession assumes that (wrong design!) - initial = new TESession((KTMainWindow*)parent, + initial = new TESession((KTMainWindow*)parentWidget, te,shell,eargs,"xterm"); connect( initial,SIGNAL(done(TESession*,int)), this,SLOT(doneSession(TESession*,int)) );