diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2014-10-21 19:13:42 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2014-10-21 19:13:42 +0900 |
commit | 8f70b1fe6562378faefb612f4006545cdcf703ab (patch) | |
tree | 19256e4ff96aa6dfb9d73313ba91c87cb332cca1 /parts/documentation/interfaces/kdevdocumentationplugin.cpp | |
parent | 847b6192a9eee538a6d62a0cbbbfffd5270744ac (diff) | |
download | tdevelop-8f70b1fe6562378faefb612f4006545cdcf703ab.tar.gz tdevelop-8f70b1fe6562378faefb612f4006545cdcf703ab.zip |
Sort documentation list in increasing alphabetical order.
Fixed KDE 2 handbook xml tags. This relates to bug 1859.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'parts/documentation/interfaces/kdevdocumentationplugin.cpp')
-rw-r--r-- | parts/documentation/interfaces/kdevdocumentationplugin.cpp | 74 |
1 files changed, 57 insertions, 17 deletions
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); |