blob: e7a84d949d2caf71cca4d5d384ca920d800a4b2f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
/***************************************************************************
* Copyright (C) 2003 by KDevelop Authors *
* kdevelop-devel@kde.org *
* *
* 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 <qlayout.h>
#include <qframe.h>
#include <qdir.h>
#include <kparts/part.h>
#include <klibloader.h>
#include <kurl.h>
#include <kdebug.h>
#include <kapplication.h>
#include <kconfig.h>
#include "kdevcore.h"
#include "kdevproject.h"
#include "konsoleviewpart.h"
#include "kdevpartcontroller.h"
#include "konsoleviewwidget.h"
KonsoleViewWidget::KonsoleViewWidget(KonsoleViewPart *part)
: QWidget(0, "konsole widget"), part(0), owner( part )
{
connect(part->partController(), SIGNAL(activePartChanged(KParts::Part*)), this, SLOT(activePartChanged(KParts::Part*)));
vbox = new QVBoxLayout(this);
}
KonsoleViewWidget::~KonsoleViewWidget()
{
}
void KonsoleViewWidget::show()
{
activate();
QWidget::show();
}
void KonsoleViewWidget::activate()
{
kdDebug(9035) << k_funcinfo << endl;
if (part)
return;
KLibFactory *factory = KLibLoader::self()->factory("libkonsolepart");
if (!factory)
return;
part = (KParts::ReadOnlyPart *) factory->create(this);
if (!part)
return;
part->widget()->setFocusPolicy(QWidget::WheelFocus);
setFocusProxy(part->widget());
part->widget()->setFocus();
if (part->widget()->inherits("QFrame"))
((QFrame*)part->widget())->setFrameStyle(QFrame::Panel|QFrame::Sunken);
vbox->addWidget(part->widget());
// this->activePartChanged( owner->partController()->activePart() );
part->widget()->show();
connect(part, SIGNAL(destroyed()), this, SLOT(partDestroyed()));
}
void KonsoleViewWidget::activePartChanged(KParts::Part *activatedPart)
{
kdDebug(9035) << k_funcinfo << endl;
KParts::ReadOnlyPart *ro_part = dynamic_cast<KParts::ReadOnlyPart*>(activatedPart);
if (ro_part && !ro_part->url().isLocalFile())
{
kdDebug(9035) << k_funcinfo << "part is null or not local" << endl;
return;
}
QString dir;
if (ro_part)
dir = ro_part->url().directory();
else if (owner->project())
dir = owner->project()->projectDirectory();
kdDebug(9035) << k_funcinfo "Changing dir to " << dir << endl;
if (dir.isEmpty())
return;
setDirectory( KURL(dir) );
}
void KonsoleViewWidget::setDirectory(const KURL &dirUrl)
{
kdDebug(9035) << k_funcinfo << "part is " << (long)part << endl;
if (part && dirUrl != part->url())
{
kdDebug(9035) << k_funcinfo << "Changing dirUrl.path() == " << dirUrl.path() << endl;
kdDebug(9035) << k_funcinfo << "Changing part->url.path() == " << part->url().path() << endl;
KConfig* config = kapp->config();
kdDebug(9035) << k_funcinfo << "SyncTerminalEmulator: " << config->readBoolEntry("SyncTerminalEmulator") << endl;
if (config->readBoolEntry("SyncTerminalEmulator")) {
part->openURL( dirUrl );
}
}
}
void KonsoleViewWidget::partDestroyed()
{
part = 0;
activate();
}
#include "konsoleviewwidget.moc"
|