kate Library API Documentation

kateconfigplugindialogpage.cpp

00001 /* This file is part of the KDE project 00002 Copyright (C) 2001 Christoph Cullmann <cullmann@kde.org> 00003 Copyright (C) 2002 Joseph Wenninger <jowenn@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 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 }
KDE Logo
This file is part of the documentation for kate Library Version 3.2.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Aug 31 00:02:09 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003