Added backend logic for allowing the user to manually update the Documentation Plugin lists. GUI part still to be done.

In the process, fixed some bugs related to deallocation and reinitialization of documentation catalogs and project catalogs.
This relates to bug 1859.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 10 years ago
parent 565f0ae626
commit d676f93b5f

@ -59,9 +59,7 @@ ContentsView::~ContentsView()
m_widget->index()->clear();
}
void ContentsView::itemExecuted(TQListViewItem *item, const TQPoint &// p
, int // col
)
void ContentsView::itemExecuted(TQListViewItem *item, const TQPoint &/*p*/, int /*col*/)
{
DocumentationItem *docItem = dynamic_cast<DocumentationItem*>(item);
if (!docItem)

@ -138,6 +138,8 @@ void DocProjectConfigWidget::accept()
m_part->m_projectDocumentationPlugin = 0;
}
m_part->m_projectDocumentationPlugin = plugin->projectDocumentationPlugin(DocumentationPlugin::APIDocs);
if (!m_part->m_projectDocumentationPlugin) // In case the plugin does not support APIDocs project documentation
return;
m_part->m_projectDocumentationPlugin->init(m_part->m_widget->contents(), m_part->m_widget->index(), catalogURL->url());
m_part->saveProjectDocumentationInfo();

@ -93,7 +93,7 @@ DocumentationPart::DocumentationPart(TQObject *parent, const char *name, const T
connect(core(), TQT_SIGNAL(projectClosed()), this, TQT_SLOT(projectClosed()));
m_widget = new DocumentationWidget(this);
m_widget->setIcon(SmallIcon( info()->icon() ));
m_widget->setIcon(SmallIcon(info()->icon()));
m_widget->setCaption(i18n("Documentation"));
TQWhatsThis::add(m_widget, i18n("<b>Documentation browser</b><p>"
@ -151,6 +151,18 @@ void DocumentationPart::loadDocumentationPlugins()
}
}
void DocumentationPart::reloadDocumentationPlugins()
{
TQValueList<DocumentationPlugin*>::iterator it;
for (it = m_plugins.begin(); it != m_plugins.end(); ++it)
{
DocumentationPlugin *plugin=*it;
plugin->clear();
plugin->autoSetupPlugin();
plugin->reinit(m_widget->contents(), m_widget->index(), TQStringList());
}
}
void DocumentationPart::emitIndexSelected(IndexBox *indexBox)
{
if (!m_hasIndex)
@ -322,7 +334,7 @@ void DocumentationPart::manPage()
void DocumentationPart::infoPage()
{
TQString word = KDevEditorUtil::currentWord( dynamic_cast<KTextEditor::Document*>( partController()->activePart() ) );
TQString word = KDevEditorUtil::currentWord( dynamic_cast<KTextEditor::Document*>( partController()->activePart() ) );
if ( isAssistantUsed() )
{
@ -573,7 +585,7 @@ void DocumentationPart::projectOpened()
it != m_plugins.constEnd(); ++it)
{
if ((*it)->hasCapability(DocumentationPlugin::ProjectDocumentation) &&
((*it)->pluginName() == projectDocSystem))
((*it)->pluginName() == projectDocSystem))
m_projectDocumentationPlugin = (*it)->projectDocumentationPlugin(DocumentationPlugin::APIDocs);
if ((*it)->hasCapability(DocumentationPlugin::ProjectUserManual))
{

@ -84,6 +84,7 @@ signals:
protected:
void loadDocumentationPlugins();
void reloadDocumentationPlugins();
TDEConfig *config();
void setupActions();
void loadSettings();

@ -61,7 +61,6 @@ DocumentationItem::DocumentationItem(DocumentationItem::Type type, TDEListViewIt
init();
}
void DocumentationItem::init( )
{
TQString icon;
@ -83,11 +82,8 @@ void DocumentationItem::init( )
}
//----------------------------------------------------
//class DocumentationCatalogItem
DocumentationCatalogItem::DocumentationCatalogItem(DocumentationPlugin* plugin,
TDEListView *parent, TDEListViewItem *after, const TQString &name)
@ -107,7 +103,7 @@ DocumentationCatalogItem::DocumentationCatalogItem(DocumentationPlugin* plugin,
m_plugin->addCatalog(this);
}
DocumentationCatalogItem::~ DocumentationCatalogItem( )
DocumentationCatalogItem::~DocumentationCatalogItem()
{
m_plugin->clearCatalog(this);
}
@ -141,8 +137,7 @@ void DocumentationCatalogItem::activate()
}
//----------------------------------------------------
//class IndexItemProto
IndexItemProto::IndexItemProto(DocumentationPlugin *plugin, DocumentationCatalogItem *catalog,
@ -159,6 +154,7 @@ IndexItemProto::~IndexItemProto()
}
//----------------------------------------------------
//class IndexItem
IndexItem::IndexItem(IndexBox *listbox, const TQString &text)
@ -177,8 +173,7 @@ IndexItem::List IndexItem::urls() const
}
//----------------------------------------------------
//class ConfigurationItem
ConfigurationItem::ConfigurationItem(TQListView *parent, DocumentationPlugin * plugin, const TQString &title, const TQString &url,
@ -245,12 +240,7 @@ int ConfigurationItem::width(const TQFontMetrics &fm, const TQListView *lv, int
}
//----------------------------------------------------
//class DocumentationPlugin
DocumentationPlugin::DocumentationPlugin(TDEConfig *pluginConfig, TQObject *parent, const char *name)
@ -274,22 +264,22 @@ void DocumentationPlugin::autoSetup()
}
}
void DocumentationPlugin::reload()
{
clear();
for (TQValueList<DocumentationCatalogItem *>::iterator it = catalogs.begin();
it != catalogs.end(); ++it)
{
createTOC(*it);
}
}
void DocumentationPlugin::clear()
{
// Do not clear the project documentation catalogs, since those are handled by
// the ProjectDocumentationPlugin class
for (TQValueList<DocumentationCatalogItem *>::iterator it = catalogs.begin();
it != catalogs.end(); ++it)
it != catalogs.end(); /*none*/)
{
clearCatalog(*it);
if (!(*it)->isProjectDocumentationItem())
{
DocumentationCatalogItem *curr = *it;
++it; // Need to advance before destroying the catalog, otherwise it could crash
//clearCatalog(curr); -- not necessary, already invoked by ~DocumentationCatalogItem()
delete curr; // Destroy and removes the item from the TDEListView
}
else
++it;
}
}
@ -312,9 +302,8 @@ void DocumentationPlugin::clearCatalog(DocumentationCatalogItem *item)
delete *it;
}
indexes.remove(item);
//remove catalog
catalogs.remove(item);
//clear the catalog
catalogs.remove(item); // Removes the item from the catalog list
}
void DocumentationPlugin::createIndex(IndexBox *index)
@ -633,8 +622,7 @@ void DocumentationPlugin::setCatalogEnabled(const TQString &name, bool e)
}
//----------------------------------------------------
//class IndexBox
IndexBox::IndexBox(TQWidget *parent, const char *name)
@ -744,8 +732,11 @@ void ProjectDocumentationPlugin::reinit()
void ProjectDocumentationPlugin::deinit()
{
m_watch->removeFile(m_url);
delete m_catalog;
m_catalog = 0;
if (m_catalog)
{
delete m_catalog;
m_catalog = 0;
}
}
TQString ProjectDocumentationPlugin::pluginName() const

@ -315,8 +315,6 @@ public:
/**Returns a title of catalog defined by an url parameter.*/
virtual TQString catalogTitle(const TQString &url) = 0;
/**Reloads documentation catalogs and indices.*/
virtual void reload();
/**Clears documentation catalogs and indices.*/
virtual void clear();

@ -115,6 +115,13 @@ bool DocCHMPlugin::needRefreshIndex(DocumentationCatalogItem* // item
void DocCHMPlugin::autoSetupPlugin()
{
// Clear groups, to allow for re-autosetup calls
config->deleteGroup("Index");
config->deleteGroup("Index Settings");
config->deleteGroup("Locations");
config->deleteGroup("Search Settings");
config->deleteGroup("TOC Settings");
config->sync();
return;
}
@ -194,4 +201,12 @@ void DocCHMPlugin::setCatalogURL(DocumentationCatalogItem* item)
item->setURL(chmURL);
}
ProjectDocumentationPlugin *DocCHMPlugin::projectDocumentationPlugin(ProjectDocType type)
{
if (type == APIDocs)
return new ProjectDocumentationPlugin(this, type);
return DocumentationPlugin::projectDocumentationPlugin(type);
}
#include "docchmplugin.moc"

@ -44,6 +44,9 @@ public:
virtual TQStringList fullTextSearchLocations();
virtual void autoSetupPlugin();
virtual ProjectDocumentationPlugin* projectDocumentationPlugin(ProjectDocType type);
protected:
TQString getSpecialData(const TQString& name, KURL url);
};

@ -161,6 +161,14 @@ bool DocDevHelpPlugin::needRefreshIndex(DocumentationCatalogItem* item)
void DocDevHelpPlugin::autoSetupPlugin()
{
// Clear groups, to allow for re-autosetup calls
config->deleteGroup("Index");
config->deleteGroup("Index Settings");
config->deleteGroup("Locations");
config->deleteGroup("Search Settings");
config->deleteGroup("TOC Settings");
config->sync();
TQValueStack<TQString> scanStack;
pushToScanStack(scanStack, getenv("DEVHELP_SEARCH_PATH"));
@ -214,6 +222,8 @@ void DocDevHelpPlugin::autoSetupPlugin()
{
scanDevHelpDir(*it);
}
config->sync();
}
void DocDevHelpPlugin::scanDevHelpDir(const TQString &path)

@ -187,9 +187,17 @@ bool DocDoxygenPlugin::needRefreshIndex(DocumentationCatalogItem* item)
void DocDoxygenPlugin::autoSetupPlugin()
{
// Clear groups, to allow for re-autosetup calls
config->deleteGroup("Index");
config->deleteGroup("Index Settings");
config->deleteGroup("Locations");
config->deleteGroup("Search Settings");
config->deleteGroup("TOC Settings");
config->sync();
autoSetupDocs(TDELIBS_DOXYDIR, "en/tdelibs-apidocs", "The TDE API Reference");
autoSetupDocs("", "en/tdevelop-apidocs", "The TDevelop Platform API Documentation");
config->sync();
}
void DocDoxygenPlugin::autoSetupDocs(const TQString &defaultDir, const TQString &searchDir,

@ -123,6 +123,14 @@ bool DocKDevTOCPlugin::needRefreshIndex(DocumentationCatalogItem* /*item*/)
void DocKDevTOCPlugin::autoSetupPlugin()
{
// Clear groups, to allow for re-autosetup calls
config->deleteGroup("Index");
config->deleteGroup("Index Settings");
config->deleteGroup("Locations");
config->deleteGroup("Search Settings");
config->deleteGroup("TOC Settings");
config->sync();
TQStringList tocsDir = DocKDevTOCPluginFactory::instance()->dirs()->findAllResources("data", "kdevdocumentation/tocs/*.toc");
for (TQStringList::const_iterator it = tocsDir.begin(); it != tocsDir.end(); ++it)
@ -130,6 +138,7 @@ void DocKDevTOCPlugin::autoSetupPlugin()
config->setGroup("Locations");
config->writePathEntry(catalogTitle(*it), *it);
}
config->sync();
}
void DocKDevTOCPlugin::createIndex(IndexBox* index, DocumentationCatalogItem* item)

@ -137,6 +137,14 @@ void DocQtPlugin::createTOC(DocumentationCatalogItem *item)
void DocQtPlugin::autoSetupPlugin()
{
// Clear groups, to allow for re-autosetup calls
config->deleteGroup("Index");
config->deleteGroup("Index Settings");
config->deleteGroup("Locations");
config->deleteGroup("Search Settings");
config->deleteGroup("TOC Settings");
config->sync();
TQString qtDocDir(QT_DOCDIR);
qtDocDir = URLUtil::envExpand(qtDocDir);
if (qtDocDir.isEmpty())
@ -144,7 +152,7 @@ void DocQtPlugin::autoSetupPlugin()
qtDocDir = getenv("QTDIR");
}
if (!qtDocDir.isEmpty())
{
{
config->setGroup("Search Settings");
config->writeEntry("TQt Reference Documentation", true);
config->setGroup("Index Settings");
@ -156,6 +164,8 @@ void DocQtPlugin::autoSetupPlugin()
config->writePathEntry("Guide to the TQt Translation Tools", qtDocDir + TQString("/linguist.dcf"));
config->writePathEntry("qmake User Guide", qtDocDir + TQString("/qmake.dcf"));
}
config->sync();
}
void DocQtPlugin::setCatalogURL(DocumentationCatalogItem *item)

Loading…
Cancel
Save