KDevelop API Documentation

parts/doctreeview/doctreeprojectconfigwidget.cpp

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2002 by Bernd Gehrmann * 00003 * bernd@kdevelop.org * 00004 * Copyright (C) 2002 by Sebastian Kratzert * 00005 * skratzert@gmx.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 ***************************************************************************/ 00013 00014 // KDE 00015 #include <kurlrequester.h> 00016 #include <kfiledialog.h> 00017 #include <klocale.h> 00018 #include <kstandarddirs.h> 00019 #include <kconfig.h> 00020 #include <kdebug.h> 00021 00022 // Local directory 00023 #include "doctreeprojectconfigwidget.h" 00024 #include "doctreeviewpart.h" 00025 #include "doctreeviewwidget.h" 00026 #include "doctreeviewfactory.h" 00027 #include "misc.h" 00028 00029 // KDevelop 00030 #include "kdevproject.h" 00031 #include "domutil.h" 00032 00033 00034 class DocCheckItem: public QCheckListItem 00035 { 00036 public: 00037 enum DocType 00038 { 00039 QT_XML, 00040 DOXYGEN, 00041 KDOC, 00042 TOC, 00043 DEVHELP 00044 }; 00045 00046 DocCheckItem ( DocTreeProjectConfigWidget *widget, DocType type, QCheckListItem * parent, const QString & text, Type tt = Controller ) 00047 :QCheckListItem(parent, text, tt), m_widget(widget), m_type(type) 00048 { 00049 } 00050 00051 DocCheckItem ( DocTreeProjectConfigWidget *widget, DocType type, QListViewItem * parent, const QString & text, Type tt = Controller ) 00052 :QCheckListItem(parent, text, tt), m_widget(widget), m_type(type) 00053 { 00054 } 00055 00056 DocCheckItem ( DocTreeProjectConfigWidget *widget, DocType type, QListView * parent, const QString & text, Type tt = Controller ) 00057 :QCheckListItem(parent, text, tt), m_widget(widget), m_type(type) 00058 { 00059 } 00060 00061 virtual DocType type() 00062 { 00063 return m_type; 00064 } 00065 00066 virtual QString name() const 00067 { 00068 return m_name; 00069 } 00070 void setName(const QString &name) 00071 { 00072 m_name = name; 00073 } 00074 00075 protected: 00076 virtual void stateChange ( bool state ) 00077 { 00078 if (state == true) 00079 { 00080 switch (type()) 00081 { 00082 case QT_XML: 00083 m_widget->m_ignoreQT_XML.remove( name() ); 00084 break; 00085 00086 case DOXYGEN: 00087 m_widget->m_ignoreDoxygen.remove( name() ); 00088 break; 00089 00090 case KDOC: 00091 m_widget->m_ignoreKDoc.remove( name() ); 00092 break; 00093 00094 case TOC: 00095 m_widget->m_ignoreToc.remove( name() ); 00096 break; 00097 00098 case DEVHELP: 00099 m_widget->m_ignoreDevHelp.remove( name() ); 00100 break; 00101 00102 default: 00103 kdDebug(9002) << "item unchecked with unknown DocType: " << name() << endl; 00104 } 00105 } 00106 else 00107 { 00108 switch (type()) 00109 { 00110 case QT_XML: 00111 m_widget->m_ignoreQT_XML << name(); 00112 break; 00113 00114 case DOXYGEN: 00115 m_widget->m_ignoreDoxygen << name(); 00116 break; 00117 00118 case KDOC: 00119 m_widget->m_ignoreKDoc << name(); 00120 break; 00121 00122 case TOC: 00123 m_widget->m_ignoreToc << name(); 00124 break; 00125 00126 case DEVHELP: 00127 m_widget->m_ignoreDevHelp << name(); 00128 break; 00129 00130 default: 00131 kdDebug(9002) << "item unchecked with unknown DocType: " << name() << endl; 00132 } 00133 } 00134 } 00135 00136 private: 00137 DocTreeProjectConfigWidget *m_widget; 00138 DocType m_type; 00139 QString m_name; 00140 }; 00141 00142 00143 DocTreeProjectConfigWidget::DocTreeProjectConfigWidget(DocTreeViewWidget *widget, 00144 QWidget *parent, KDevProject *project, const char *name): DocTreeProjectConfigWidgetBase(parent, name) 00145 00146 { 00147 m_widget = widget; 00148 m_project = project; 00149 00150 readConfig(); 00151 00152 docListView->addColumn(i18n("Title")); 00153 docListView->addColumn(i18n("URL")); 00154 docListView->setAllColumnsShowFocus(true); 00155 } 00156 00157 /* 00158 DocTreeProjectConfigWidget::~DocTreeProjectConfigWidget() 00159 {} 00160 */ 00161 00162 void DocTreeProjectConfigWidget::readConfig() 00163 { 00164 QMap<QString, QString> xmap; 00165 QDomDocument d; 00166 KConfig* config = DocTreeViewFactory::instance()->config(); 00167 KStandardDirs* dirs = DocTreeViewFactory::instance()->dirs(); 00168 QStringList tocs; 00169 00170 if (m_project->projectDom()) 00171 d = *m_project->projectDom(); 00172 00173 QString userdocDir = DomUtil::readEntry(d , 00174 "/kdevdoctreeview/projectdoc/userdocDir", m_project->projectDirectory() + "/html/" ); 00175 userdocdirEdit->setURL( userdocDir[0] != QChar('/') ? m_project->projectDirectory() + QString("/") + userdocDir : userdocDir ); 00176 userdocdirEdit->fileDialog()->setMode( KFile::Directory ); 00177 00178 QString apidocDir = DomUtil::readEntry(d, 00179 "/kdevdoctreeview/projectdoc/apidocDir", m_project->projectDirectory() + "/html/" ); 00180 apidocdirEdit->setURL( apidocDir[0] != QChar('/') ? m_project->projectDirectory() + QString("/") + apidocDir : apidocDir ); 00181 apidocdirEdit->fileDialog()->setMode( KFile::Directory ); 00182 00183 m_ignoreQT_XML = DomUtil::readListEntry(d, "/kdevdoctreeview/ignoreqt_xml", "toc"); 00184 m_ignoreDoxygen = DomUtil::readListEntry(d, "/kdevdoctreeview/ignoredoxygen", "toc"); 00185 m_ignoreKDoc = DomUtil::readListEntry(d, "/kdevdoctreeview/ignorekdocs", "toc"); 00186 m_ignoreToc = DomUtil::readListEntry(d, "/kdevdoctreeview/ignoretocs", "toc"); 00187 m_ignoreDevHelp = DomUtil::readListEntry(d, "/kdevdoctreeview/ignoredevhelp", "toc"); 00188 00189 m_qtDocs = new QListViewItem(docListView, i18n("Qt Documentation Collection")); 00190 m_qtDocs->setOpen(true); 00191 m_doxygenDocs = new QListViewItem(docListView, i18n("Doxygen Documentation Collection")); 00192 m_doxygenDocs->setOpen(true); 00193 m_kdocDocs = new QListViewItem(docListView, i18n("KDoc Documentation Collection")); 00194 m_kdocDocs->setOpen(true); 00195 m_tocDocs = new QListViewItem(docListView, i18n("KDevelopTOC Documentation Collection")); 00196 m_tocDocs->setOpen(true); 00197 m_devHelpDocs = new QListViewItem(docListView, i18n("DevHelp Documentation Collection")); 00198 m_devHelpDocs->setOpen(true); 00199 00200 // Read qt *.xml Config ( DocType = QT_XML ) 00201 xmap = config->entryMap("General Qt"); 00202 for (QMap<QString, QString>::Iterator itx = xmap.begin(); itx != xmap.end(); ++itx) 00203 { 00205 const QString name(itx.key()); 00206 DocCheckItem *item = new DocCheckItem(this, DocCheckItem::QT_XML, m_qtDocs, itx.key(), QCheckListItem::CheckBox); 00207 item->setText(1, config->readPathEntry(itx.key())); 00208 item->setName(name); 00209 item->setOn(!m_ignoreQT_XML.contains( name )); 00210 } 00211 00212 // Read Doxygen Config ( DocType = DOXYGEN ) 00213 xmap = config->entryMap("General Doxygen"); 00214 for (QMap<QString, QString>::Iterator itx = xmap.begin(); itx != xmap.end(); ++itx) 00215 { 00217 const QString name(itx.key()); 00218 DocCheckItem *item = new DocCheckItem(this, DocCheckItem::DOXYGEN, m_doxygenDocs, itx.key(), QCheckListItem::CheckBox); 00219 item->setText(1, config->readPathEntry(itx.key())); 00220 item->setName(name); 00221 item->setOn(!m_ignoreDoxygen.contains( name )); 00222 } 00223 00224 00225 // Read KDoc Config ( DocType = KDOC ) 00226 xmap = config->entryMap("General KDoc"); 00227 for (QMap<QString, QString>::Iterator itx = xmap.begin(); itx != xmap.end(); ++itx) 00228 { 00230 const QString name(itx.key()); 00231 DocCheckItem *item = new DocCheckItem(this, DocCheckItem::KDOC, m_kdocDocs, itx.key(), QCheckListItem::CheckBox); 00232 item->setText(1, config->readPathEntry(itx.key())); 00233 item->setName(name); 00234 item->setOn(!m_ignoreKDoc.contains( name )); 00235 } 00236 00237 // Read Toc Config ( DocType = TOC ) 00238 tocs = dirs->findAllResources("doctocs", QString::null, false, true); 00239 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit) 00240 { 00241 const QString name( QFileInfo(*tit).baseName() ); 00242 const QString location( DocTreeViewTool::tocLocation( *tit ) ); 00243 const QString title (DocTreeViewTool::tocTitle( *tit )); 00244 DocCheckItem *item = new DocCheckItem(this, DocCheckItem::TOC, m_tocDocs, title, QCheckListItem::CheckBox); 00245 item->setText(1, location); 00246 item->setName(name); 00247 item->setOn(!m_ignoreToc.contains( name )); 00248 } 00249 00250 // Read DevHelp Config ( DocType = DEVHELP ) 00251 tocs = dirs->findAllResources("docdevhelp", QString::null, false, true); 00252 for (QStringList::Iterator tit = tocs.begin(); tit != tocs.end(); ++tit) 00253 { 00254 const QString name( QFileInfo(*tit).baseName() ); 00255 BookInfo inf = DocTreeViewTool::devhelpInfo(*tit); 00256 DocCheckItem *item = new DocCheckItem(this, DocCheckItem::DEVHELP, m_devHelpDocs, inf.title, QCheckListItem::CheckBox); 00257 item->setText(1, DocTreeViewTool::devhelpLocation(name, inf.defaultLocation)); 00258 item->setName(name); 00259 item->setOn(!m_ignoreDevHelp.contains( name )); 00260 } 00261 } 00262 00263 void DocTreeProjectConfigWidget::storeConfig() 00264 { 00265 QDomDocument d; 00266 00267 if (m_project->projectDom()) 00268 d = *m_project->projectDom(); 00269 00270 QString userdocUrl = userdocdirEdit->url(); 00271 QString apidocUrl = apidocdirEdit->url(); 00272 00273 if( userdocUrl.startsWith(m_project->projectDirectory()) ) 00274 userdocUrl = userdocUrl.mid( m_project->projectDirectory().length() + 1 ); 00275 00276 if( apidocUrl.startsWith(m_project->projectDirectory()) ) 00277 apidocUrl = apidocUrl.mid( m_project->projectDirectory().length() + 1 ); 00278 00279 DomUtil::writeEntry(d, 00280 "/kdevdoctreeview/projectdoc/userdocDir", userdocUrl ); 00281 DomUtil::writeEntry(d, 00282 "/kdevdoctreeview/projectdoc/apidocDir", apidocUrl ); 00283 00284 DomUtil::writeListEntry(d, 00285 "/kdevdoctreeview/ignoreqt_xml", "toc", m_ignoreQT_XML ); 00286 DomUtil::writeListEntry(d, 00287 "/kdevdoctreeview/ignoredoxygen", "toc", m_ignoreDoxygen ); 00288 DomUtil::writeListEntry(d, 00289 "/kdevdoctreeview/ignorekdocs", "toc", m_ignoreKDoc ); 00290 DomUtil::writeListEntry(d, 00291 "/kdevdoctreeview/ignoretocs", "toc", m_ignoreToc ); 00292 DomUtil::writeListEntry(d, 00293 "/kdevdoctreeview/ignoredevhelp", "toc", m_ignoreDevHelp ); 00294 } 00295 00296 void DocTreeProjectConfigWidget::accept() 00297 { 00298 storeConfig(); 00299 m_widget->configurationChanged(); 00300 } 00301 00302 /* 00303 void DocTreeProjectConfigWidget::setProject(KDevProject* project) 00304 { 00305 readConfig(); 00306 m_project = project; 00307 } 00308 00309 */ 00310 00311 #include "doctreeprojectconfigwidget.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.0.4.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Oct 19 08:01:50 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003