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
wilder-portage
David Faure 26 years ago
parent a9ad7dc519
commit b029b4d576
  1. 15
      include/konsole_part.h
  2. 17
      src/konsole_part.C

@ -24,7 +24,7 @@
#define __KONSOLE_PART_H__
#include <kparts/browserextension.h>
#include <klibloader.h>
#include <kparts/factory.h>
#include <kaction.h>
#include <konsole.h>
@ -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:

@ -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)) );

Loading…
Cancel
Save