kateconfigplugindialogpage.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kateconfigplugindialogpage.h"
00021 #include "kateconfigplugindialogpage.moc"
00022
00023 #include "katepluginmanager.h"
00024 #include "kateconfigdialog.h"
00025 #include <klistbox.h>
00026 #include "kateapp.h"
00027 #include <qstringlist.h>
00028 #include <qhbox.h>
00029 #include <qlabel.h>
00030 #include <klocale.h>
00031 #include <qpushbutton.h>
00032 #include <qtooltip.h>
00033 #include <kiconloader.h>
00034 #include <qwhatsthis.h>
00035
00036 class KatePluginListItem : public QCheckListItem
00037 {
00038 public:
00039 KatePluginListItem(bool checked, KatePluginInfo *info, QListView *parent);
00040 KatePluginInfo *info() const { return mInfo; }
00041
00042 protected:
00043 void stateChange(bool);
00044
00045 private:
00046 KatePluginInfo *mInfo;
00047 bool silentStateChange;
00048 };
00049
00050 KatePluginListItem::KatePluginListItem(bool checked, KatePluginInfo *info, QListView *parent)
00051 : QCheckListItem(parent, info->service->name(), CheckBox)
00052 , mInfo(info)
00053 , silentStateChange(false)
00054 {
00055 silentStateChange = true;
00056 setOn(checked);
00057 silentStateChange = false;
00058 }
00059
00060 void KatePluginListItem::stateChange(bool b)
00061 {
00062 if(!silentStateChange)
00063 static_cast<KatePluginListView *>(listView())->stateChanged(this, b);
00064 }
00065
00066 KatePluginListView::KatePluginListView(QWidget *parent, const char *name)
00067 : KListView(parent, name)
00068 {
00069 }
00070
00071 void KatePluginListView::stateChanged(KatePluginListItem *item, bool b)
00072 {
00073 emit stateChange(item, b);
00074 }
00075
00076 KateConfigPluginPage::KateConfigPluginPage(QWidget *parent, KateConfigDialog *dialog):QVBox(parent)
00077 {
00078 myPluginMan=((KateApp*)kapp)->katePluginManager();
00079 myDialog=dialog;
00080
00081 KatePluginListView* listView = new KatePluginListView(this);
00082 listView->addColumn(i18n("Name"));
00083 listView->addColumn(i18n("Comment"));
00084 QWhatsThis::add(listView,i18n("Here you can see all available Kate plugins. Those with a check mark are loaded, and will be loaded again the next time Kate is started."));
00085
00086 connect(listView, SIGNAL(stateChange(KatePluginListItem *, bool)), this, SLOT(stateChange(KatePluginListItem *, bool)));
00087
00088 for (uint i=0; i<myPluginMan->pluginList().count(); i++)
00089 {
00090 KatePluginListItem *item = new KatePluginListItem(myPluginMan->pluginList().at(i)->load, myPluginMan->pluginList().at(i), listView);
00091 item->setText(0, myPluginMan->pluginList().at(i)->service->name());
00092 item->setText(1, myPluginMan->pluginList().at(i)->service->comment());
00093 }
00094 }
00095
00096 void KateConfigPluginPage::stateChange(KatePluginListItem *item, bool b)
00097 {
00098 if(b)
00099 loadPlugin(item);
00100 else
00101 unloadPlugin(item);
00102
00103 emit changed();
00104 }
00105
00106 void KateConfigPluginPage::loadPlugin (KatePluginListItem *item)
00107 {
00108 myPluginMan->loadPlugin (item->info());
00109 myPluginMan->enablePluginGUI (item->info());
00110 myDialog->addPluginPage (item->info()->plugin);
00111
00112 item->setOn(true);
00113 }
00114
00115 void KateConfigPluginPage::unloadPlugin (KatePluginListItem *item)
00116 {
00117 myDialog->removePluginPage (item->info()->plugin);
00118 myPluginMan->unloadPlugin (item->info());
00119
00120 item->setOn(false);
00121 }
This file is part of the documentation for kate Library Version 3.3.90.