KDevelop API Documentation

docprojectconfigwidget.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Alexander Dymo                                  *
00003  *   adymo@mksat.net                                                       *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #include "docprojectconfigwidget.h"
00021 
00022 #include <qdir.h>
00023 #include <qcombobox.h>
00024 
00025 #include <kdebug.h>
00026 #include <kurlrequester.h>
00027 
00028 #include "domutil.h"
00029 #include "urlutil.h"
00030 #include "kdevproject.h"
00031 #include "kdevdocumentationplugin.h"
00032 
00033 #include "documentation_part.h"
00034 #include "documentation_widget.h"
00035 
00036 DocProjectConfigWidget::DocProjectConfigWidget(DocumentationPart *part, QWidget *parent, const char *name)
00037     :DocProjectConfigWidgetBase(parent, name), m_part(part)
00038 {
00039     for (QValueList<DocumentationPlugin*>::const_iterator it = m_part->m_plugins.constBegin();
00040         it != m_part->m_plugins.constEnd(); ++it)
00041     {
00042         if ((*it)->hasCapability(DocumentationPlugin::ProjectDocumentation))
00043         {
00044             docSystemCombo->insertItem((*it)->pluginName());
00045             m_plugins[(*it)->pluginName()] = *it;
00046         }
00047     }
00048     QString projectDocSystem = DomUtil::readEntry(*(m_part->projectDom()), "/kdevdocumentation/projectdoc/docsystem");
00049     
00050     bool hasProjectDoc = false;
00051     for (int i = 0; i < docSystemCombo->count(); ++i)
00052     {
00053         if (docSystemCombo->text(i) == projectDocSystem)
00054         {
00055             docSystemCombo->setCurrentItem(i);
00056             hasProjectDoc = true;
00057             changeDocSystem(docSystemCombo->currentText());
00058             break;
00059         }
00060     }
00061     if (!hasProjectDoc && docSystemCombo->count() > 0)
00062     {
00063         docSystemCombo->setCurrentItem(0);
00064         changeDocSystem(docSystemCombo->currentText());
00065     }
00066 
00067     manualURL->setURL(DomUtil::readEntry(*(m_part->projectDom()), "/kdevdocumentation/projectdoc/usermanualurl"));
00068 }
00069 
00070 void DocProjectConfigWidget::changeDocSystem(const QString &text)
00071 {
00072     if (text.isEmpty())
00073         return;
00074     
00075     DocumentationPlugin *plugin = m_plugins[text];
00076     if (!plugin)
00077         return;
00078     
00079     catalogURL->setMode(plugin->catalogLocatorProps().first);
00080     catalogURL->setFilter(plugin->catalogLocatorProps().second);
00081     
00082     QString projectDocURL = DomUtil::readEntry(*(m_part->projectDom()), "/kdevdocumentation/projectdoc/docurl");
00083     if (!projectDocURL.isEmpty())
00084         projectDocURL = QDir::cleanDirPath(m_part->project()->projectDirectory() + "/" + projectDocURL);
00085 
00086     catalogURL->setURL(projectDocURL);
00087     catalogURL->setEnabled(true);
00088 }
00089 
00090 void DocProjectConfigWidget::accept()
00091 {
00092     if (manualURL->url().isEmpty())
00093     {
00094         if (m_part->m_userManualPlugin)
00095         {
00096             delete m_part->m_userManualPlugin;
00097             m_part->m_userManualPlugin = 0;
00098         }
00099     }
00100     else
00101     {
00102         if (m_part->m_userManualPlugin)
00103         {
00104             delete m_part->m_userManualPlugin;
00105             m_part->m_userManualPlugin = 0;
00106         }
00107         for (QValueList<DocumentationPlugin*>::const_iterator it = m_part->m_plugins.constBegin();
00108             it != m_part->m_plugins.constEnd(); ++it)
00109         {
00110             if ((*it)->hasCapability(DocumentationPlugin::ProjectUserManual))
00111                 m_part->m_userManualPlugin = (*it)->projectDocumentationPlugin(DocumentationPlugin::UserManual);
00112         }
00113         if (m_part->m_userManualPlugin)
00114             m_part->m_userManualPlugin->init(m_part->m_widget->contents(), m_part->m_widget->index(), manualURL->url());
00115     }
00116     m_part->saveProjectDocumentationInfo();
00117     
00118     if (docSystemCombo->currentText().isEmpty())
00119         return;
00120     if (catalogURL->url().isEmpty())
00121     {
00122         if (m_part->m_projectDocumentationPlugin)
00123         {
00124             delete m_part->m_projectDocumentationPlugin;
00125             m_part->m_projectDocumentationPlugin = 0;
00126         }
00127         m_part->saveProjectDocumentationInfo();
00128         return;
00129     }
00130         
00131     DocumentationPlugin *plugin = m_plugins[docSystemCombo->currentText()];
00132     if (!plugin)
00133         return;
00134     
00135     if (m_part->m_projectDocumentationPlugin)
00136     {
00137         delete m_part->m_projectDocumentationPlugin;
00138         m_part->m_projectDocumentationPlugin = 0;
00139     }
00140     m_part->m_projectDocumentationPlugin = plugin->projectDocumentationPlugin(DocumentationPlugin::APIDocs);
00141     m_part->m_projectDocumentationPlugin->init(m_part->m_widget->contents(), m_part->m_widget->index(), catalogURL->url());
00142     
00143     m_part->saveProjectDocumentationInfo();
00144 }
00145 
00146 #include "docprojectconfigwidget.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:39 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003