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
|
/***************************************************************************
* Copyright (C) 2004 by Alexander Dymo *
* [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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include "docprojectconfigwidget.h"
#include <tqdir.h>
#include <tqcombobox.h>
#include <kdebug.h>
#include <kurlrequester.h>
#include "domutil.h"
#include "urlutil.h"
#include "tdevproject.h"
#include "tdevdocumentationplugin.h"
#include "documentation_part.h"
#include "documentation_widget.h"
DocProjectConfigWidget::DocProjectConfigWidget(DocumentationPart *part, TQWidget *parent, const char *name)
:DocProjectConfigWidgetBase(parent, name), m_part(part)
{
for (TQValueList<DocumentationPlugin*>::const_iterator it = m_part->m_plugins.constBegin();
it != m_part->m_plugins.constEnd(); ++it)
{
if ((*it)->hasCapability(DocumentationPlugin::ProjectDocumentation))
{
docSystemCombo->insertItem((*it)->pluginName());
m_plugins[(*it)->pluginName()] = *it;
}
}
TQString projectDocSystem = DomUtil::readEntry(*(m_part->projectDom()), "/tdevdocumentation/projectdoc/docsystem");
bool hasProjectDoc = false;
for (int i = 0; i < docSystemCombo->count(); ++i)
{
if (docSystemCombo->text(i) == projectDocSystem)
{
docSystemCombo->setCurrentItem(i);
hasProjectDoc = true;
changeDocSystem(docSystemCombo->currentText());
break;
}
}
if (!hasProjectDoc && docSystemCombo->count() > 0)
{
docSystemCombo->setCurrentItem(0);
changeDocSystem(docSystemCombo->currentText());
}
manualURL->setURL(DomUtil::readEntry(*(m_part->projectDom()), "/tdevdocumentation/projectdoc/usermanualurl"));
}
void DocProjectConfigWidget::changeDocSystem(const TQString &text)
{
if (text.isEmpty())
return;
DocumentationPlugin *plugin = m_plugins[text];
if (!plugin)
return;
catalogURL->setMode(plugin->catalogLocatorProps().first);
catalogURL->setFilter(plugin->catalogLocatorProps().second);
TQString projectDocURL = DomUtil::readEntry(*(m_part->projectDom()), "/tdevdocumentation/projectdoc/docurl");
if (!projectDocURL.isEmpty())
projectDocURL = TQDir::cleanDirPath(m_part->project()->projectDirectory() + "/" + projectDocURL);
catalogURL->setURL(projectDocURL);
catalogURL->setEnabled(true);
}
void DocProjectConfigWidget::accept()
{
if (manualURL->url().isEmpty())
{
if (m_part->m_userManualPlugin)
{
delete m_part->m_userManualPlugin;
m_part->m_userManualPlugin = 0;
}
}
else
{
if (m_part->m_userManualPlugin)
{
delete m_part->m_userManualPlugin;
m_part->m_userManualPlugin = 0;
}
for (TQValueList<DocumentationPlugin*>::const_iterator it = m_part->m_plugins.constBegin();
it != m_part->m_plugins.constEnd(); ++it)
{
if ((*it)->hasCapability(DocumentationPlugin::ProjectUserManual))
m_part->m_userManualPlugin = (*it)->projectDocumentationPlugin(DocumentationPlugin::UserManual);
}
if (m_part->m_userManualPlugin)
m_part->m_userManualPlugin->init(m_part->m_widget->contents(), m_part->m_widget->index(), manualURL->url());
}
m_part->saveProjectDocumentationInfo();
if (docSystemCombo->currentText().isEmpty())
return;
if (catalogURL->url().isEmpty())
{
if (m_part->m_projectDocumentationPlugin)
{
delete m_part->m_projectDocumentationPlugin;
m_part->m_projectDocumentationPlugin = 0;
}
m_part->saveProjectDocumentationInfo();
return;
}
DocumentationPlugin *plugin = m_plugins[docSystemCombo->currentText()];
if (!plugin)
return;
if (m_part->m_projectDocumentationPlugin)
{
delete m_part->m_projectDocumentationPlugin;
m_part->m_projectDocumentationPlugin = 0;
}
m_part->m_projectDocumentationPlugin = plugin->projectDocumentationPlugin(DocumentationPlugin::APIDocs);
m_part->m_projectDocumentationPlugin->init(m_part->m_widget->contents(), m_part->m_widget->index(), catalogURL->url());
m_part->saveProjectDocumentationInfo();
}
#include "docprojectconfigwidget.moc"
|