diff options
Diffstat (limited to 'parts/documentation')
15 files changed, 95 insertions, 49 deletions
diff --git a/parts/documentation/documentation_part.cpp b/parts/documentation/documentation_part.cpp index 75bb7c13..c68add0e 100644 --- a/parts/documentation/documentation_part.cpp +++ b/parts/documentation/documentation_part.cpp @@ -98,7 +98,7 @@ DocumentationPart::DocumentationPart(TQObject *parent, const char *name, const T TQWhatsThis::add(m_widget, i18n("<b>Documentation browser</b><p>" "The documentation browser gives access to various " - "documentation sources (TQt DCF, Doxygen, KDoc, KDevelopTOC and DevHelp " + "documentation sources (TQt DCF, Doxygen, KDoc, TDevelopTOC and DevHelp " "documentation) and the TDevelop manuals. It also provides documentation index " "and full text search capabilities.")); @@ -107,7 +107,7 @@ DocumentationPart::DocumentationPart(TQObject *parent, const char *name, const T setupActions(); - TQTimer::singleShot(0, this, TQT_SLOT(init())); + TQTimer::singleShot(5, this, TQT_SLOT(init())); new KDevDocumentationIface(this); } @@ -135,7 +135,6 @@ void DocumentationPart::loadDocumentationPlugins() docPluginService = *serviceIt; kdDebug() << "DocumentationPart::loadDocumentationPlugins: creating plugin" << docPluginService->name() << endl; - int error; DocumentationPlugin *docPlugin = KParts::ComponentFactory ::createInstanceFromService<DocumentationPlugin>(docPluginService, 0, diff --git a/parts/documentation/interfaces/kdevdocumentationplugin.cpp b/parts/documentation/interfaces/kdevdocumentationplugin.cpp index afc9abad..c79d22d6 100644 --- a/parts/documentation/interfaces/kdevdocumentationplugin.cpp +++ b/parts/documentation/interfaces/kdevdocumentationplugin.cpp @@ -90,8 +90,8 @@ void DocumentationItem::init( ) DocumentationCatalogItem::DocumentationCatalogItem(DocumentationPlugin* plugin, - TDEListView *parent, const TQString &name) - :DocumentationItem(DocumentationItem::Catalog, parent, name), m_plugin(plugin), + TDEListView *parent, TDEListViewItem *after, const TQString &name) + :DocumentationItem(DocumentationItem::Catalog, parent, after, name), m_plugin(plugin), isLoaded(false), isActivated(false), m_isProjectDocumentationItem(false) { setExpandable(true); @@ -440,6 +440,21 @@ void DocumentationPlugin::loadIndex(IndexBox *index, DocumentationCatalogItem *i cacheIndex(item); } +TDEListViewItem* DocumentationPlugin::findCatalogPosition(const TQString &key, const TDEListView *contents) const +{ + TDEListViewItem *curr_item = (TDEListViewItem*)(contents->firstChild()); + if (!curr_item) + return NULL; // Empty listview + + TDEListViewItem *prev_item = NULL; + while (curr_item && curr_item->text(0) <= key) + { + prev_item = curr_item; + curr_item = (TDEListViewItem*)(curr_item->nextSibling()); + } + return prev_item; +} + void DocumentationPlugin::init(TDEListView *contents) { config->setGroup("Locations"); @@ -448,8 +463,15 @@ void DocumentationPlugin::init(TDEListView *contents) for (TQMap<TQString, TQString>::const_iterator it = entryMap.begin(); it != entryMap.end(); ++it) { - if (catalogEnabled(it.key())) - createCatalog(contents, it.key(), config->readPathEntry(it.key())); + TQString cat_key = it.key(); + if (catalogEnabled(cat_key)) + { + // Keep the list in increasing sorted order. Given that the list is + // reasonably short, we can affort to scan through the list each time + // a new item is created + TDEListViewItem *afterItem = findCatalogPosition(cat_key, contents); + createCatalog(contents, afterItem, cat_key, config->readPathEntry(cat_key)); + } } } @@ -472,31 +494,33 @@ void DocumentationPlugin::reinit(TDEListView *contents, IndexBox *index, TQStrin it != entryMap.end(); ++it) { config->setGroup("Locations"); - if (restrictions.contains(it.key()) || (!catalogEnabled(it.key()))) + TQString cat_key = it.key(); + if (restrictions.contains(cat_key) || (!catalogEnabled(cat_key))) { - if (namedCatalogs.contains(it.key())) - delete namedCatalogs[it.key()]; + if (namedCatalogs.contains(cat_key)) + delete namedCatalogs[cat_key]; } else { kdDebug() << "updating 1" << endl; - if (!namedCatalogs.contains(it.key())) //create catalog if it does not exist + if (!namedCatalogs.contains(cat_key)) //create catalog if it does not exist { - DocumentationCatalogItem * item = createCatalog(contents, it.key(), config->readPathEntry(it.key())); + TDEListViewItem *afterItem = findCatalogPosition(cat_key, contents); + DocumentationCatalogItem *item = createCatalog(contents, afterItem, cat_key, config->readPathEntry(cat_key)); loadIndex(index, item); index->setDirty(true); // index->refill(indexes[item]); } - else if (!indexEnabled(namedCatalogs[it.key()])) //clear index if it is disabled in configuration + else if (!indexEnabled(namedCatalogs[cat_key])) //clear index if it is disabled in configuration { kdDebug() << " updating: clearCatalogIndex" << endl; - clearCatalogIndex(namedCatalogs[it.key()]); + clearCatalogIndex(namedCatalogs[cat_key]); } - else if ( (indexEnabled(namedCatalogs[it.key()])) //index is requested in configuration but does not yet exist - && (!indexes.contains(namedCatalogs[it.key()])) ) + else if ( (indexEnabled(namedCatalogs[cat_key])) //index is requested in configuration but does not yet exist + && (!indexes.contains(namedCatalogs[cat_key])) ) { kdDebug() << " index requested " << endl; - loadIndex(index, namedCatalogs[it.key()]); + loadIndex(index, namedCatalogs[cat_key]); index->setDirty(true); } m_indexCreated = true; @@ -676,6 +700,21 @@ ProjectDocumentationPlugin::~ProjectDocumentationPlugin() deinit(); } +TDEListViewItem* ProjectDocumentationPlugin::findCatalogPosition(const TQString &key, const TDEListView *contents) const +{ + TDEListViewItem *curr_item = (TDEListViewItem*)(contents->firstChild()); + if (!curr_item) + return NULL; // Empty listview + + TDEListViewItem *prev_item = NULL; + while (curr_item && curr_item->text(0) <= key) + { + prev_item = curr_item; + curr_item = (TDEListViewItem*)(curr_item->nextSibling()); + } + return prev_item; +} + void ProjectDocumentationPlugin::init(TDEListView *contents, IndexBox *index, const TQString &url) { m_contents = contents; @@ -684,9 +723,10 @@ void ProjectDocumentationPlugin::init(TDEListView *contents, IndexBox *index, co if (m_catalog) deinit(); - m_catalog = m_docPlugin->createCatalog(contents, - m_type == DocumentationPlugin::APIDocs ? i18n("Project API Documentation") - : i18n("Project User Manual"), url); + TQString cat_key = (m_type == DocumentationPlugin::APIDocs ? i18n("Project API Documentation") + : i18n("Project User Manual")); + TDEListViewItem *afterItem = findCatalogPosition(cat_key, contents); + m_catalog = m_docPlugin->createCatalog(contents, afterItem, cat_key, url); if (m_catalog) { m_catalog->setProjectDocumentationItem(true); diff --git a/parts/documentation/interfaces/kdevdocumentationplugin.h b/parts/documentation/interfaces/kdevdocumentationplugin.h index a5dbe458..dcdc3f9a 100644 --- a/parts/documentation/interfaces/kdevdocumentationplugin.h +++ b/parts/documentation/interfaces/kdevdocumentationplugin.h @@ -72,7 +72,7 @@ class DocumentationPlugin; class DocumentationCatalogItem: public DocumentationItem { public: - DocumentationCatalogItem(DocumentationPlugin* plugin, TDEListView *parent, const TQString &name); + DocumentationCatalogItem(DocumentationPlugin* plugin, TDEListView *parent, TDEListViewItem *after, const TQString &name); DocumentationCatalogItem(DocumentationPlugin* plugin, DocumentationItem *parent, const TQString &name); virtual ~DocumentationCatalogItem(); @@ -240,8 +240,9 @@ public: /**Returns the i18n name of the plugin.*/ virtual TQString pluginName() const = 0; - /**Creates documentation catalog with given title and url.*/ - virtual DocumentationCatalogItem *createCatalog(TDEListView *contents, const TQString &title, const TQString &url) = 0; + /**Creates documentation catalog with given title and url. Catalog lists are sorted + alphabetically in increasing order.*/ + virtual DocumentationCatalogItem *createCatalog(TDEListView *contents, TDEListViewItem *after, const TQString &title, const TQString &url) = 0; /**Initialize a list of catalogs. @param contents the listview to fill with catalogs @@ -361,6 +362,9 @@ protected: /**Loads index from cache or creates and caches it if does not exist.*/ void loadIndex(IndexBox *index, DocumentationCatalogItem *item); + /**Find catalog insert position to maintain a sorted order.*/ + TDEListViewItem* findCatalogPosition(const TQString &key, const TDEListView *contents) const; + /**Stores items deleted from configuration. @ref saveCatalogConfiguration uses this to remove entries from configuration file.*/ TQStringList deletedConfigurationItems; @@ -408,6 +412,9 @@ public slots: virtual void reinit(); protected: + /**Find catalog insert position to maintain a sorted order.*/ + TDEListViewItem* findCatalogPosition(const TQString &key, const TDEListView *contents) const; + DocumentationPlugin *m_docPlugin; DocumentationCatalogItem *m_catalog; diff --git a/parts/documentation/plugins/chm/docchmplugin.cpp b/parts/documentation/plugins/chm/docchmplugin.cpp index 5acecce3..753705bd 100644 --- a/parts/documentation/plugins/chm/docchmplugin.cpp +++ b/parts/documentation/plugins/chm/docchmplugin.cpp @@ -51,9 +51,9 @@ DocCHMPlugin::~DocCHMPlugin() } -DocumentationCatalogItem* DocCHMPlugin::createCatalog(TDEListView* contents, const TQString& title, const TQString& url) +DocumentationCatalogItem* DocCHMPlugin::createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url) { - DocumentationCatalogItem *item = new DocumentationCatalogItem(this, contents, title); + DocumentationCatalogItem *item = new DocumentationCatalogItem(this, contents, after, title); item->setURL(KURL(url)); return item; diff --git a/parts/documentation/plugins/chm/docchmplugin.h b/parts/documentation/plugins/chm/docchmplugin.h index 452e1c09..4d053333 100644 --- a/parts/documentation/plugins/chm/docchmplugin.h +++ b/parts/documentation/plugins/chm/docchmplugin.h @@ -35,7 +35,7 @@ public: virtual void setCatalogURL(DocumentationCatalogItem* item); virtual TQString catalogTitle(const TQString& url); virtual TQPair<KFile::Mode, TQString> catalogLocatorProps(); - virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, const TQString& title, const TQString& url); + virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url); virtual void createTOC(DocumentationCatalogItem* item); virtual void createIndex(IndexBox* index, DocumentationCatalogItem* item); diff --git a/parts/documentation/plugins/custom/doccustomplugin.cpp b/parts/documentation/plugins/custom/doccustomplugin.cpp index dd141eba..fa2b14a6 100644 --- a/parts/documentation/plugins/custom/doccustomplugin.cpp +++ b/parts/documentation/plugins/custom/doccustomplugin.cpp @@ -55,9 +55,9 @@ TQString DocCustomPlugin::pluginName() const return i18n("Custom Documentation Collection"); } -DocumentationCatalogItem* DocCustomPlugin::createCatalog(TDEListView* contents, const TQString& title, const TQString& url) +DocumentationCatalogItem* DocCustomPlugin::createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url) { - DocumentationCatalogItem *item = new DocumentationCatalogItem(this, contents, title); + DocumentationCatalogItem *item = new DocumentationCatalogItem(this, contents, after, title); item->setURL(KURL(url)); return item; } diff --git a/parts/documentation/plugins/custom/doccustomplugin.h b/parts/documentation/plugins/custom/doccustomplugin.h index f83daf1a..7370bbc1 100644 --- a/parts/documentation/plugins/custom/doccustomplugin.h +++ b/parts/documentation/plugins/custom/doccustomplugin.h @@ -29,7 +29,7 @@ public: virtual TQString pluginName() const; - virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, const TQString& title, const TQString& url); + virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url); virtual void createTOC(DocumentationCatalogItem* item); virtual void setCatalogURL(DocumentationCatalogItem* item); diff --git a/parts/documentation/plugins/devhelp/docdevhelpplugin.cpp b/parts/documentation/plugins/devhelp/docdevhelpplugin.cpp index 4f2d50d6..5bdfa618 100644 --- a/parts/documentation/plugins/devhelp/docdevhelpplugin.cpp +++ b/parts/documentation/plugins/devhelp/docdevhelpplugin.cpp @@ -41,8 +41,8 @@ class DevHelpDocumentationCatalogItem: public DocumentationCatalogItem { public: DevHelpDocumentationCatalogItem(const TQString &devHelpFile, DocumentationPlugin* plugin, - TDEListView *parent, const TQString &name) - :DocumentationCatalogItem(plugin, parent, name), m_devHelpFile(devHelpFile) + TDEListView *parent, TDEListViewItem *after, const TQString &name) + :DocumentationCatalogItem(plugin, parent, after, name), m_devHelpFile(devHelpFile) { } DevHelpDocumentationCatalogItem(const TQString &devHelpFile, DocumentationPlugin* plugin, @@ -85,9 +85,9 @@ DocDevHelpPlugin::~DocDevHelpPlugin() { } -DocumentationCatalogItem* DocDevHelpPlugin::createCatalog(TDEListView* contents, const TQString& title, const TQString& url) +DocumentationCatalogItem* DocDevHelpPlugin::createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url) { - return new DevHelpDocumentationCatalogItem(url, this, contents, title); + return new DevHelpDocumentationCatalogItem(url, this, contents, after, title); } TQPair<KFile::Mode, TQString> DocDevHelpPlugin::catalogLocatorProps() diff --git a/parts/documentation/plugins/devhelp/docdevhelpplugin.h b/parts/documentation/plugins/devhelp/docdevhelpplugin.h index 6436a1d8..19ff8a75 100644 --- a/parts/documentation/plugins/devhelp/docdevhelpplugin.h +++ b/parts/documentation/plugins/devhelp/docdevhelpplugin.h @@ -40,7 +40,7 @@ public: virtual void createTOC(DocumentationCatalogItem* item); - virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, const TQString& title, const TQString& url); + virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url); virtual bool needRefreshIndex(DocumentationCatalogItem* item); virtual void createIndex(IndexBox* index, DocumentationCatalogItem* item); diff --git a/parts/documentation/plugins/doxygen/docdoxygenplugin.cpp b/parts/documentation/plugins/doxygen/docdoxygenplugin.cpp index 0edcfa33..0359bb22 100644 --- a/parts/documentation/plugins/doxygen/docdoxygenplugin.cpp +++ b/parts/documentation/plugins/doxygen/docdoxygenplugin.cpp @@ -44,8 +44,8 @@ class DoxyDocumentationCatalogItem: public DocumentationCatalogItem { public: DoxyDocumentationCatalogItem(const TQString &origUrl, DocumentationPlugin* plugin, - TDEListView *parent, const TQString &name) - :DocumentationCatalogItem(plugin, parent, name), m_origUrl(origUrl) + TDEListView *parent, TDEListViewItem *after, const TQString &name) + :DocumentationCatalogItem(plugin, parent, after, name), m_origUrl(origUrl) { } DoxyDocumentationCatalogItem(const TQString &origUrl, DocumentationPlugin* plugin, @@ -328,10 +328,10 @@ void DocDoxygenPlugin::createTOC(DocumentationCatalogItem* item) } while (!dirStack.isEmpty()); } -DocumentationCatalogItem *DocDoxygenPlugin::createCatalog(TDEListView *contents, const TQString &title, const TQString &url) +DocumentationCatalogItem *DocDoxygenPlugin::createCatalog(TDEListView *contents, TDEListViewItem *after, const TQString &title, const TQString &url) { kdDebug() << "DocDoxygenPlugin::createCatalog: url=" << url << endl; - DocumentationCatalogItem *item = new DoxyDocumentationCatalogItem(url, this, contents, title); + DocumentationCatalogItem *item = new DoxyDocumentationCatalogItem(url, this, contents, after, title); item->setURL(url); return item; } diff --git a/parts/documentation/plugins/doxygen/docdoxygenplugin.h b/parts/documentation/plugins/doxygen/docdoxygenplugin.h index ebd4a540..afa57cf6 100644 --- a/parts/documentation/plugins/doxygen/docdoxygenplugin.h +++ b/parts/documentation/plugins/doxygen/docdoxygenplugin.h @@ -35,7 +35,7 @@ public: virtual TQString pluginName() const; - virtual DocumentationCatalogItem *createCatalog(TDEListView *contents, const TQString &title, const TQString &url); + virtual DocumentationCatalogItem *createCatalog(TDEListView *contents, TDEListViewItem *after, const TQString &title, const TQString &url); virtual void createTOC(DocumentationCatalogItem* item); virtual void setCatalogURL(DocumentationCatalogItem* item); diff --git a/parts/documentation/plugins/kdevtoc/dockdevtocplugin.cpp b/parts/documentation/plugins/kdevtoc/dockdevtocplugin.cpp index fa17549b..10fe853d 100644 --- a/parts/documentation/plugins/kdevtoc/dockdevtocplugin.cpp +++ b/parts/documentation/plugins/kdevtoc/dockdevtocplugin.cpp @@ -43,8 +43,8 @@ class TOCDocumentationCatalogItem: public DocumentationCatalogItem { public: TOCDocumentationCatalogItem(const TQString &tocFile, DocumentationPlugin* plugin, - TDEListView *parent, const TQString &name) - :DocumentationCatalogItem(plugin, parent, name), m_tocFile(tocFile) + TDEListView *parent, TDEListViewItem *after, const TQString &name) + :DocumentationCatalogItem(plugin, parent, after, name), m_tocFile(tocFile) { } TOCDocumentationCatalogItem(const TQString &tocFile, DocumentationPlugin* plugin, @@ -80,9 +80,9 @@ TQString DocKDevTOCPlugin::pluginName() const return i18n("TDevelopTOC Documentation Collection"); } -DocumentationCatalogItem* DocKDevTOCPlugin::createCatalog(TDEListView* contents, const TQString& title, const TQString& url) +DocumentationCatalogItem* DocKDevTOCPlugin::createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url) { - return new TOCDocumentationCatalogItem(url, this, contents, title); + return new TOCDocumentationCatalogItem(url, this, contents, after, title); } TQPair<KFile::Mode, TQString> DocKDevTOCPlugin::catalogLocatorProps() diff --git a/parts/documentation/plugins/kdevtoc/dockdevtocplugin.h b/parts/documentation/plugins/kdevtoc/dockdevtocplugin.h index 7205cc4c..b6b5c037 100644 --- a/parts/documentation/plugins/kdevtoc/dockdevtocplugin.h +++ b/parts/documentation/plugins/kdevtoc/dockdevtocplugin.h @@ -35,7 +35,7 @@ public: virtual TQString pluginName() const; virtual TQString catalogTitle(const TQString& url); - virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, const TQString& title, const TQString& url); + virtual DocumentationCatalogItem* createCatalog(TDEListView* contents, TDEListViewItem *after, const TQString& title, const TQString& url); virtual void createTOC(DocumentationCatalogItem* item); virtual void setCatalogURL(DocumentationCatalogItem* item); diff --git a/parts/documentation/plugins/qt/docqtplugin.cpp b/parts/documentation/plugins/qt/docqtplugin.cpp index 10271524..8ee2a139 100644 --- a/parts/documentation/plugins/qt/docqtplugin.cpp +++ b/parts/documentation/plugins/qt/docqtplugin.cpp @@ -41,8 +41,8 @@ class TQtDocumentationCatalogItem: public DocumentationCatalogItem { public: TQtDocumentationCatalogItem(const TQString &dcfFile, DocumentationPlugin* plugin, - TDEListView *parent, const TQString &name) - :DocumentationCatalogItem(plugin, parent, name), m_dcfFile(dcfFile) + TDEListView *parent, TDEListViewItem *after, const TQString &name) + :DocumentationCatalogItem(plugin, parent, after, name), m_dcfFile(dcfFile) { } TQtDocumentationCatalogItem(const TQString &dcfFile, DocumentationPlugin* plugin, @@ -331,9 +331,9 @@ TQString DocQtPlugin::catalogTitle(const TQString &url) return docEl.attribute("title", TQString()); } -DocumentationCatalogItem *DocQtPlugin::createCatalog(TDEListView *contents, const TQString &title, const TQString &url) +DocumentationCatalogItem *DocQtPlugin::createCatalog(TDEListView *contents, TDEListViewItem *after, const TQString &title, const TQString &url) { - return new TQtDocumentationCatalogItem(url, this, contents, title); + return new TQtDocumentationCatalogItem(url, this, contents, after, title); } #include "docqtplugin.moc" diff --git a/parts/documentation/plugins/qt/docqtplugin.h b/parts/documentation/plugins/qt/docqtplugin.h index 8eac8456..31b14b9b 100644 --- a/parts/documentation/plugins/qt/docqtplugin.h +++ b/parts/documentation/plugins/qt/docqtplugin.h @@ -35,7 +35,7 @@ public: virtual TQString pluginName() const; - virtual DocumentationCatalogItem *createCatalog(TDEListView *contents, const TQString &title, const TQString &url); + virtual DocumentationCatalogItem *createCatalog(TDEListView *contents, TDEListViewItem *after, const TQString &title, const TQString &url); virtual void createTOC(DocumentationCatalogItem *item); virtual void setCatalogURL(DocumentationCatalogItem *item); |