Fix deletion of the part (deletes the session and stops bulk_timer)

Some cleanups (openURL/closeURL reimplemented to avoid the framework
to download stuff ;-)

svn path=/trunk/kdebase/konsole/; revision=45428
wilder-portage
David Faure 26 years ago
parent 463aca42fc
commit 33d31c07a4
  1. 15
      include/konsole_part.h
  2. 13
      src/TEmulation.C
  3. 42
      src/konsole_part.C

@ -38,13 +38,13 @@ class konsoleFactory : public KLibFactory
public:
konsoleFactory();
virtual ~konsoleFactory();
virtual QObject* create(QObject* parent = 0, const char* name = 0,
const char* classname = "QObject",
const QStringList &args = QStringList());
static KInstance *instance();
private:
static KInstance *s_instance;
};
@ -55,10 +55,12 @@ class konsolePart: public KParts::ReadOnlyPart
public:
konsolePart(QWidget *parent, const char *name);
virtual ~konsolePart();
protected:
virtual bool openFile();
virtual bool openURL( const KURL & url );
virtual bool openFile() {}
virtual bool closeURL();
protected slots:
void slotNew();
void slotSaveFile();
@ -68,6 +70,7 @@ class konsolePart: public KParts::ReadOnlyPart
QLabel *widget;
// Konsole *kons;
TEWidget *te;
TESession *initial;
konsoleBrowserExtension *m_extension;
/*
KAction *m_NewAction;

@ -106,9 +106,9 @@ TEmulation::TEmulation(TEWidget* gui)
QObject::connect(&bulk_timer, SIGNAL(timeout()), this, SLOT(showBulk()) );
QObject::connect(gui,SIGNAL(changedImageSizeSignal(int,int)),
this,SLOT(onImageSizeChange(int,int)));
QObject::connect(gui,SIGNAL(changedHistoryCursor(int)),
QObject::connect(gui,SIGNAL(changedHistoryCursor(int)),
this,SLOT(onHistoryCursorChange(int)));
QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)),
QObject::connect(gui,SIGNAL(keyPressedSignal(QKeyEvent*)),
this,SLOT(onKeyPress(QKeyEvent*)));
QObject::connect(gui,SIGNAL(beginSelectionSignal(const int,const int)),
this,SLOT(onSelectionBegin(const int,const int)) );
@ -127,6 +127,7 @@ TEmulation::~TEmulation()
{
delete screen[0];
delete screen[1];
bulk_timer.stop();
}
/*! change between primary and alternate screen
@ -178,7 +179,7 @@ void TEmulation::setKeytrans(int no)
void TEmulation::onRcvChar(int c)
// process application unicode input to terminal
// this is a trivial scanner
{
{
c &= 0xff;
switch (c)
{
@ -213,8 +214,8 @@ void TEmulation::onKeyPress( QKeyEvent* ev )
emit sndBlock(ev->text().ascii(),ev->text().length());
}
else if (ev->ascii()>0)
{ unsigned char c[1];
c[0] = ev->ascii();
{ unsigned char c[1];
c[0] = ev->ascii();
emit sndBlock((char*)c,1);
}
}
@ -262,7 +263,7 @@ void TEmulation::setSelection(const BOOL preserve_line_breaks) {
void TEmulation::clearSelection() {
if (!connected) return;
scr->clearSelection();
scr->clearSelection();
showBulk();
}

@ -63,7 +63,7 @@ konsoleFactory::~konsoleFactory()
{
if (s_instance)
delete s_instance;
s_instance = 0;
}
@ -89,11 +89,11 @@ konsolePart::konsolePart(QWidget *parent, const char *name)
: KParts::ReadOnlyPart(parent, name)
{
setInstance(konsoleFactory::instance());
// create a canvas to insert our widget
m_extension = new konsoleBrowserExtension(this);
//bool login_shell = false;
//bool welcome = true;
bool histon = true;
@ -109,7 +109,6 @@ konsolePart::konsolePart(QWidget *parent, const char *name)
const char* shell = getenv("SHELL");
if (shell == NULL || *shell == '\0') shell = "/bin/sh";
//shell = "/usr/bin/mc";
eargs.append(shell);
te = new TEWidget(parent);
te->setFocusPolicy(QWidget::ClickFocus);
@ -117,14 +116,14 @@ konsolePart::konsolePart(QWidget *parent, const char *name)
setWidget(te);
// faking a KTMainwindow - i dont know why it has it this way
kdDebug() << "The shell is:" << shell << "\n";
TESession* initial = new TESession((KTMainWindow*)parent,
te,shell,eargs,"xterm");
initial = new TESession((KTMainWindow*)parent,
te,shell,eargs,"xterm");
// initial->run();
initial->setConnect(TRUE);
QTimer::singleShot(100,initial,SLOT(run()));
QTimer::singleShot(0/*100*/,initial,SLOT(run()));
// setXMLFile("konsole_part.rc");
// kDebugInfo("Loading successful");
// kDebugInfo("XML file set");
@ -149,19 +148,16 @@ void konsolePart::slotLoadFile() {
konsolePart::~konsolePart()
{
closeURL();
delete initial;
//te is deleted by the framework
}
bool konsolePart::openFile()
bool konsolePart::openURL( const KURL & url )
{
// This is a horrible hack
/*
QTimer *delayedLoadTimer = new QTimer(this);
delayedLoadTimer->start(3,true);
connect(delayedLoadTimer, SIGNAL(timeout()),
this, SLOT(slotDelayedLoad()) );
*/
return true;
emit setWindowCaption( url.decodedURL() );
return true;
// TODO: follow directory m_file
// widget->setText(m_file);
/*
@ -173,22 +169,20 @@ bool konsolePart::openFile()
/*
if (!gofw->ds->loadXML(m_file))
return false;
return false;
gofw->dv.center = NULL; // FIXME: this is a hack
gofw->refresh();
gofw->detail->setValues(gofw->dv.center->val);
// return true;
// return true;
kDebugInfo("Loading successful");
*/
return true;
}
/*
bool konsolePart::closeURL()
{
return true;
}
*/
konsoleBrowserExtension::konsoleBrowserExtension(konsolePart *parent)
: KParts::BrowserExtension(parent, "konsoleBrowserExtension")

Loading…
Cancel
Save