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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
/***************************************************************************
pluginmanager-configuration.cpp - description
-------------------
begin : Thu Sep 30 2004
copyright : (C) 2004 by Martin Witte
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 "pluginmanager-configuration-ui.h"
#include "include/pluginmanager-configuration.h"
#include "include/kradioapp.h"
#include "include/pluginmanager.h"
#include <klistbox.h>
#include <klistview.h>
#include <kpushbutton.h>
#include <kurlrequester.h>
#include <kinputdialog.h>
#include <tqcheckbox.h>
PluginManagerConfiguration::PluginManagerConfiguration(TQWidget *tqparent, KRadioApp *app, PluginManager *pm)
: PluginManagerConfigurationUI(tqparent),
m_Application(app),
m_PluginManager(pm),
m_dirty(true)
{
noticePluginLibrariesChanged();
noticePluginsChanged();
TQObject::connect(btnAddLibrary, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotAddLibrary()));
TQObject::connect(btnRemoveLibrary, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotRemoveLibrary()));
TQObject::connect(btnNewPluginInstance, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotNewPluginInstance()));
TQObject::connect(btnRemovePluginInstance, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotRemovePluginInstance()));
TQObject::connect(cbShowProgressBar, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetDirty()));
slotCancel();
}
PluginManagerConfiguration::~PluginManagerConfiguration ()
{
}
void PluginManagerConfiguration::noticePluginLibrariesChanged()
{
listPluginLibraries->clear();
const TQMap<TQString, PluginLibraryInfo> &libs = m_Application->getPluginLibraries();
TQMapConstIterator<TQString,PluginLibraryInfo> end = libs.end();
for (TQMapConstIterator<TQString,PluginLibraryInfo> it = libs.begin(); it != end; ++it) {
listPluginLibraries->insertItem(it.key());
}
listPluginClasses->clear();
const TQMap<TQString, PluginClassInfo> &classes = m_Application->getPluginClasses();
TQMapConstIterator<TQString, PluginClassInfo> end_cls = classes.end();
for (TQMapConstIterator<TQString, PluginClassInfo> it = classes.begin(); it != end_cls; ++it) {
listPluginClasses->insertItem(new KListViewItem(listPluginClasses, it.key(), (*it).description));
}
noticePluginsChanged();
}
void PluginManagerConfiguration::noticePluginsChanged()
{
listPluginInstances->clear();
const PluginList &plugins = m_PluginManager->plugins();
const TQMap<TQString, PluginClassInfo> &classes = m_Application->getPluginClasses();
for (PluginIterator it(plugins); it.current(); ++it) {
TQString class_name = it.current()->pluginClassName();
if (classes.tqcontains(class_name)) {
TQString obj_name = it.current()->name();
listPluginInstances->insertItem(new KListViewItem(listPluginInstances, class_name, obj_name, classes[class_name].description));
}
}
}
void PluginManagerConfiguration::slotOK()
{
if (m_dirty) {
m_PluginManager->showProgressBar(cbShowProgressBar->isChecked());
m_dirty = false;
}
}
void PluginManagerConfiguration::slotCancel()
{
if (m_dirty) {
cbShowProgressBar->setChecked(m_PluginManager->showsProgressBar());
noticePluginLibrariesChanged();
noticePluginsChanged();
m_dirty = false;
}
}
void PluginManagerConfiguration::slotAddLibrary()
{
slotSetDirty();
TQString url = editPluginLibrary->url();
if (m_Application && url.length())
m_Application->LoadLibrary(url);
}
void PluginManagerConfiguration::slotRemoveLibrary()
{
slotSetDirty();
if (m_Application) {
TQString lib = listPluginLibraries->currentText();
if (lib.length()) {
m_Application->UnloadLibrary(lib);
}
}
}
void PluginManagerConfiguration::slotNewPluginInstance()
{
slotSetDirty();
if (m_Application && m_PluginManager) {
TQListViewItem *item = listPluginClasses->currentItem();
TQString class_name = item ? item->text(0) : TQString();
bool ok = false;
int default_object_id = 1;
while (m_PluginManager->getPluginByName(class_name + TQString::number(default_object_id)))
++default_object_id;
TQString object_name = KInputDialog::getText(i18n("Enter Plugin Instance Name"),
i18n("Instance Name"),
class_name + TQString::number(default_object_id),
&ok);
if (ok && class_name.length() && object_name.length())
m_Application->CreatePlugin(m_PluginManager, class_name, object_name);
}
}
void PluginManagerConfiguration::slotRemovePluginInstance()
{
slotSetDirty();
if (m_Application && m_PluginManager) {
TQListViewItem *item = listPluginInstances->currentItem();
TQString object_name = item ? item->text(1) : TQString();
if (object_name.length())
m_PluginManager->deletePluginByName(object_name);
}
}
void PluginManagerConfiguration::slotSetDirty()
{
m_dirty = true;
}
#include "pluginmanager-configuration.moc"
|