From d676f93b5f3a7481fc0588f087bef418879e6f78 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 30 Oct 2014 14:50:07 +0900 Subject: 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 --- .../interfaces/kdevdocumentationplugin.cpp | 61 +++++++++------------- 1 file changed, 26 insertions(+), 35 deletions(-) (limited to 'parts/documentation/interfaces/kdevdocumentationplugin.cpp') diff --git a/parts/documentation/interfaces/kdevdocumentationplugin.cpp b/parts/documentation/interfaces/kdevdocumentationplugin.cpp index 74122b1f..636731f9 100644 --- a/parts/documentation/interfaces/kdevdocumentationplugin.cpp +++ b/parts/documentation/interfaces/kdevdocumentationplugin.cpp @@ -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::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::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 -- cgit v1.2.3