• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Documentation Part Interfaces Library
 

KDevelop Documentation Part Interfaces Library

  • parts
  • documentation
  • interfaces
kdevdocumentationplugin.cpp
1 /* This file is part of the KDE project
2  Copyright (C) 2004 by Alexander Dymo <cloudtemple@mksat.net>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 #include "kdevdocumentationplugin.h"
20 
21 #include <tqfile.h>
22 #include <tqpainter.h>
23 #include <tqstyle.h>
24 #include <tqheader.h>
25 #include <tqtextstream.h>
26 
27 #include <kstandarddirs.h>
28 #include <kiconloader.h>
29 #include <tdeconfig.h>
30 #include <kdebug.h>
31 #include <kdirwatch.h>
32 #include <tdelocale.h>
33 
34 //class DocumentationItem
35 
36 DocumentationItem::DocumentationItem(DocumentationItem::Type type, TDEListView *parent,
37  const TQString &name)
38  :TDEListViewItem(parent, name), m_type(type)
39 {
40  init();
41 }
42 
43 DocumentationItem::DocumentationItem(DocumentationItem::Type type, TDEListViewItem *parent,
44  const TQString &name)
45  :TDEListViewItem(parent, name), m_type(type)
46 {
47  init();
48 }
49 
50 DocumentationItem::DocumentationItem(DocumentationItem::Type type, TDEListView *parent,
51  TDEListViewItem *after, const TQString &name)
52  :TDEListViewItem(parent, after, name), m_type(type)
53 {
54  init();
55 }
56 
57 DocumentationItem::DocumentationItem(DocumentationItem::Type type, TDEListViewItem * parent,
58  TDEListViewItem * after, const TQString & name )
59  :TDEListViewItem(parent, after, name), m_type(type)
60 {
61  init();
62 }
63 
64 void DocumentationItem::init( )
65 {
66  TQString icon;
67 
68  switch (m_type)
69  {
70  case Collection:
71  case Catalog:
72  icon = "folder";
73  break;
74  case Book:
75  icon = "contents";
76  break;
77  default:
78  icon = "text-x-generic";
79  }
80 
81  setPixmap(0, SmallIcon(icon));
82 }
83 
84 
85 //----------------------------------------------------
86 //class DocumentationCatalogItem
87 
88 DocumentationCatalogItem::DocumentationCatalogItem(DocumentationPlugin* plugin,
89  TDEListView *parent, TDEListViewItem *after, const TQString &name)
90  :DocumentationItem(DocumentationItem::Catalog, parent, after, name), m_plugin(plugin),
91  isLoaded(false), isActivated(false), m_isProjectDocumentationItem(false)
92 {
93  setExpandable(true);
94  m_plugin->addCatalog(this);
95 }
96 
97 DocumentationCatalogItem::DocumentationCatalogItem(DocumentationPlugin* plugin,
98  DocumentationItem *parent, const TQString &name)
99  :DocumentationItem(DocumentationItem::Catalog, parent, name), m_plugin(plugin),
100  isLoaded(false), isActivated(false), m_isProjectDocumentationItem(false)
101 {
102  setExpandable(true);
103  m_plugin->addCatalog(this);
104 }
105 
106 DocumentationCatalogItem::~DocumentationCatalogItem()
107 {
108  m_plugin->clearCatalog(this);
109 }
110 
111 void DocumentationCatalogItem::setOpen(bool o)
112 {
113  if (o)
114  {
115  load();
116  }
117  DocumentationItem::setOpen(o);
118 }
119 
120 void DocumentationCatalogItem::load()
121 {
122 if(isLoaded)
123 return;
124 
125  plugin()->createTOC(this);
126  isLoaded = true;
127 }
128 
129 void DocumentationCatalogItem::activate()
130 {
131  if (!isActivated)
132  {
133  plugin()->setCatalogURL(this);
134  isActivated = true;
135  }
136  DocumentationItem::activate();
137 }
138 
139 
140 //----------------------------------------------------
141 //class IndexItemProto
142 
143 IndexItemProto::IndexItemProto(DocumentationPlugin *plugin, DocumentationCatalogItem *catalog,
144  IndexBox *listbox, const TQString &text, const TQString &description)
145  : m_listbox(listbox), m_text(text), m_description(description)
146 {
147  plugin->indexes[catalog].append(this);
148  m_listbox->addIndexItem(this);
149 }
150 
151 IndexItemProto::~IndexItemProto()
152 {
153  m_listbox->removeIndexItem(this);
154 }
155 
156 
157 //----------------------------------------------------
158 //class IndexItem
159 
160 IndexItem::IndexItem(IndexBox *listbox, const TQString &text)
161  :TQListBoxText(listbox, text), m_listbox(listbox)
162 {
163 }
164 
165 IndexItem::List IndexItem::urls() const
166 {
167  List urlList;
168  TQValueList<IndexItemProto*> itemProtos = m_listbox->items[text()];
169  for (TQValueList<IndexItemProto*>::const_iterator it = itemProtos.begin();
170  it != itemProtos.end(); ++it)
171  urlList.append(tqMakePair((*it)->description(), (*it)->url()));
172  return urlList;
173 }
174 
175 
176 //----------------------------------------------------
177 //class ConfigurationItem
178 
179 ConfigurationItem::ConfigurationItem(TQListView *parent, DocumentationPlugin * plugin, const TQString &title, const TQString &url,
180  bool indexPossible, bool fullTextSearchPossible)
181  :TQCheckListItem(parent, "", TQCheckListItem::CheckBox), m_title(title), m_url(url),
182  m_origTitle(title), m_contents(true), m_index(false), m_fullTextSearch(false),
183  m_indexPossible(indexPossible), m_fullTextSearchPossible(fullTextSearchPossible),
184  m_docPlugin( plugin )
185 {
186  setText(3, m_title);
187  setText(4, m_url);
188 }
189 
190 void ConfigurationItem::paintCell(TQPainter *p, const TQColorGroup &cg, int column,
191  int width, int align)
192 {
193  if ( (column == 0) || (column == 1) || (column == 2) )
194  {
195  if ( !p )
196  return;
197 
198  TQListView *lv = listView();
199  if ( !lv )
200  return;
201 
202  const BackgroundMode bgmode = lv->viewport()->backgroundMode();
203  const TQColorGroup::ColorRole crole = TQPalette::backgroundRoleFromMode( bgmode );
204  p->fillRect(0, 0, width, height(), cg.brush(crole));
205 
206  TQFontMetrics fm(lv->fontMetrics());
207  int boxsize = lv->style().pixelMetric(TQStyle::PM_CheckListButtonSize, lv);
208  int marg = lv->itemMargin();
209  int styleflags = TQStyle::Style_Default;
210 
211  if (((column == 0) && m_contents) || ((column == 1) && m_index) || ((column == 2) && m_fullTextSearch))
212  styleflags |= TQStyle::Style_On;
213  else
214  styleflags |= TQStyle::Style_Off;
215  if ((column == 0) || ((column == 1) && m_indexPossible) || ((column == 2) && m_fullTextSearchPossible))
216  styleflags |= TQStyle::Style_Enabled;
217 
218  int x = 0;
219  int y = 0;
220  x += 3;
221  if (align & AlignVCenter)
222  y = ((height() - boxsize) / 2) + marg;
223  else
224  y = (fm.height() + 2 + marg - boxsize) / 2;
225 
226  TQStyleOption opt(this);
227  lv->style().tqdrawPrimitive(TQStyle::PE_CheckListIndicator, p,
228  TQRect(x, y, boxsize, fm.height() + 2 + marg), cg, styleflags, opt);
229 
230  return;
231  }
232  TQListViewItem::paintCell(p, cg, column, width, align);
233 }
234 
235 int ConfigurationItem::width(const TQFontMetrics &fm, const TQListView *lv, int c) const
236 {
237  if ((c == 0) || (c == 1) || (c == 2))
238  return lv->style().pixelMetric(TQStyle::PM_CheckListButtonSize, lv) + 4;
239  return TQListViewItem::width(fm, lv, c);
240 }
241 
242 
243 //----------------------------------------------------
244 //class DocumentationPlugin
245 
246 DocumentationPlugin::DocumentationPlugin(TDEConfig *pluginConfig, TQObject *parent, const char *name)
247  :TQObject(parent, name), config(pluginConfig), m_indexCreated(false)
248 {
249 }
250 
251 DocumentationPlugin::~DocumentationPlugin()
252 {
253 }
254 
255 void DocumentationPlugin::autoSetup()
256 {
257  config->setGroup("General");
258  if ( ! config->readBoolEntry("Autosetup", false) )
259  {
260  autoSetupPlugin();
261  config->setGroup("General");
262  config->writeEntry("Autosetup", true);
263  config->sync();
264  }
265 }
266 
267 void DocumentationPlugin::clear()
268 {
269  // Do not clear the project documentation catalogs, since those are handled by
270  // the ProjectDocumentationPlugin class
271  for (TQValueList<DocumentationCatalogItem *>::iterator it = catalogs.begin();
272  it != catalogs.end(); /*none*/)
273  {
274  if (!(*it)->isProjectDocumentationItem())
275  {
276  DocumentationCatalogItem *curr = *it;
277  ++it; // Need to advance before destroying the catalog, otherwise it could crash
278  //clearCatalog(curr); -- not necessary, already invoked by ~DocumentationCatalogItem()
279  delete curr; // Destroy and removes the item from the TDEListView
280  }
281  else
282  ++it;
283  }
284 }
285 
286 void DocumentationPlugin::clearCatalog(DocumentationCatalogItem *item)
287 {
288  //clear named catalog map
289  for (TQMap<TQString, DocumentationCatalogItem*>::iterator it = namedCatalogs.begin();
290  it != namedCatalogs.end(); ++it)
291  {
292  if (it.data() == item)
293  {
294  namedCatalogs.remove(it);
295  break;
296  }
297  }
298  //clear indexes for catalog
299  TQValueList<IndexItemProto *> idx = indexes[item];
300  for (TQValueList<IndexItemProto *>::iterator it = idx.begin(); it != idx.end(); ++it)
301  {
302  delete *it;
303  }
304  indexes.remove(item);
305  //clear the catalog
306  catalogs.remove(item); // Removes the item from the catalog list
307 }
308 
309 void DocumentationPlugin::createIndex(IndexBox *index)
310 {
311  if (m_indexCreated)
312  return;
313 
314  for (TQValueList<DocumentationCatalogItem *>::iterator it = catalogs.begin();
315  it != catalogs.end(); ++it)
316  {
317  loadIndex(index, *it);
318  }
319  m_indexCreated = true;
320 }
321 
322 void DocumentationPlugin::cacheIndex(DocumentationCatalogItem *item)
323 {
324  kdDebug() << "Creating index cache for " << item->text(0) << endl;
325 
326  TQString cacheName = locateLocal("data", TQString("kdevdocumentation/index/cache_") + item->text(0));
327  TQFile cacheFile(cacheName);
328  if (!cacheFile.open(IO_WriteOnly))
329  return;
330 
331  TQTextStream str(&cacheFile);
332  str.setEncoding(TQTextStream::Unicode);
333  str << CACHE_VERSION << endl;
334 
335  TQValueList<IndexItemProto*> catalogIndexes = indexes[item];
336  for (TQValueList<IndexItemProto*>::const_iterator it = catalogIndexes.constBegin();
337  it != catalogIndexes.constEnd(); ++it)
338  {
339  str << (*it)->text() << endl;
340  str << (*it)->description() << endl;
341  str << (*it)->url().url() << endl;
342  }
343 
344  cacheFile.close();
345 }
346 
347 bool DocumentationPlugin::loadCachedIndex(IndexBox *index, DocumentationCatalogItem *item)
348 {
349  TQString cacheName = locateLocal("data", TQString("kdevdocumentation/index/cache_") + item->cacheVersion() + item->text(0));
350  TQFile cacheFile(cacheName);
351  if (!cacheFile.open(IO_ReadOnly))
352  return false;
353 
354  kdDebug() << "Using cached index for item: " << item->text(0) << endl;
355 
356  TQTextStream str(&cacheFile);
357  str.setEncoding(TQTextStream::Unicode);
358  TQString cache = str.read();
359  TQStringList cacheList = TQStringList::split("\n", cache, true);
360  TQString ver = cacheList.first();
361  if (ver != CACHE_VERSION)
362  {
363  kdDebug() << "Wrong cache version: " << ver << endl;
364  return false;
365  }
366  TQStringList::const_iterator it = cacheList.begin();
367  it++;
368  TQString s[3]; int c = 0;
369  for (; it != cacheList.end(); ++it)
370  {
371  s[c] = *it;
372  if (c == 2)
373  {
374  IndexItemProto *ii = new IndexItemProto(this, item, index, s[0], s[1]);
375  ii->addURL(KURL(s[2]));
376  c = 0;
377  }
378  else c++;
379  }
380  cacheFile.close();
381 
382  return true;
383 }
384 
385 void DocumentationPlugin::addCatalog(DocumentationCatalogItem *item)
386 {
387  catalogs.append(item);
388  namedCatalogs[item->text(0)] = item;
389 // indexes[item] = TQValueList<IndexItem*>();
390 }
391 
392 void DocumentationPlugin::addCatalogConfiguration(TDEListView *configurationView,
393  const TQString &title, const TQString &url)
394 {
395  new ConfigurationItem(configurationView, this, title, url,
396  hasCapability(Index), hasCapability(FullTextSearch));
397 }
398 
399 void DocumentationPlugin::editCatalogConfiguration(ConfigurationItem *configurationItem,
400  const TQString &title, const TQString &url)
401 {
402  configurationItem->setTitle(title);
403  configurationItem->setURL(url);
404 }
405 
406 void DocumentationPlugin::deleteCatalogConfiguration(const ConfigurationItem *const configurationItem)
407 {
408  deletedConfigurationItems << configurationItem->title();
409 }
410 
411 void DocumentationPlugin::clearCatalogIndex(DocumentationCatalogItem *item)
412 {
413  //clear indexes for catalog
414  TQValueList<IndexItemProto *> idx = indexes[item];
415  for (TQValueList<IndexItemProto *>::iterator it = idx.begin(); it != idx.end(); ++it)
416  {
417  delete *it;
418  }
419  indexes.remove(item);
420 }
421 
422 void DocumentationPlugin::loadIndex(IndexBox *index, DocumentationCatalogItem *item)
423 {
424  if (!indexEnabled(item))
425  return;
426  if (!needRefreshIndex(item) && loadCachedIndex(index, item))
427  return;
428  createIndex(index, item);
429  cacheIndex(item);
430 }
431 
432 TDEListViewItem* DocumentationPlugin::findCatalogPosition(const TQString &key, const TDEListView *contents) const
433 {
434  TDEListViewItem *curr_item = (TDEListViewItem*)(contents->firstChild());
435  if (!curr_item)
436  return NULL; // Empty listview
437 
438  TDEListViewItem *prev_item = NULL;
439  while (curr_item && curr_item->text(0) <= key)
440  {
441  prev_item = curr_item;
442  curr_item = (TDEListViewItem*)(curr_item->nextSibling());
443  }
444  return prev_item;
445 }
446 
447 void DocumentationPlugin::init(TDEListView *contents)
448 {
449  config->setGroup("Locations");
450  TQMap<TQString, TQString> entryMap = config->entryMap("Locations");
451 
452  for (TQMap<TQString, TQString>::const_iterator it = entryMap.begin();
453  it != entryMap.end(); ++it)
454  {
455  TQString cat_key = it.key();
456  if (catalogEnabled(cat_key))
457  {
458  // Keep the list in increasing sorted order. Given that the list is
459  // reasonably short, we can affort to scan through the list each time
460  // a new item is created
461  TDEListViewItem *afterItem = findCatalogPosition(cat_key, contents);
462  createCatalog(contents, afterItem, cat_key, config->readPathEntry(cat_key));
463  }
464  }
465 }
466 
467 void DocumentationPlugin::reinit(TDEListView *contents, IndexBox *index, TQStringList restrictions)
468 {
469  config->setGroup("Locations");
470  TQMap<TQString, TQString> entryMap = config->entryMap("Locations");
471 
472  //remove deleted in configuration catalogs
473  for (TQStringList::const_iterator it = deletedConfigurationItems.constBegin();
474  it != deletedConfigurationItems.constEnd(); ++it)
475  {
476  if (namedCatalogs.contains(*it))
477  delete namedCatalogs[*it];
478  }
479  deletedConfigurationItems.clear();
480 
481  //update configuration
482  for (TQMap<TQString, TQString>::const_iterator it = entryMap.begin();
483  it != entryMap.end(); ++it)
484  {
485  config->setGroup("Locations");
486  TQString cat_key = it.key();
487  if (restrictions.contains(cat_key) || (!catalogEnabled(cat_key)))
488  {
489  if (namedCatalogs.contains(cat_key))
490  delete namedCatalogs[cat_key];
491  }
492  else
493  {
494  kdDebug() << "updating 1" << endl;
495  if (!namedCatalogs.contains(cat_key)) //create catalog if it does not exist
496  {
497  TDEListViewItem *afterItem = findCatalogPosition(cat_key, contents);
498  DocumentationCatalogItem *item = createCatalog(contents, afterItem, cat_key, config->readPathEntry(cat_key));
499  loadIndex(index, item);
500  index->setDirty(true);
501 // index->refill(indexes[item]);
502  }
503  else if (!indexEnabled(namedCatalogs[cat_key])) //clear index if it is disabled in configuration
504  {
505  kdDebug() << " updating: clearCatalogIndex" << endl;
506  clearCatalogIndex(namedCatalogs[cat_key]);
507  }
508  else if ( (indexEnabled(namedCatalogs[cat_key])) //index is requested in configuration but does not yet exist
509  && (!indexes.contains(namedCatalogs[cat_key])) )
510  {
511  kdDebug() << " index requested " << endl;
512  loadIndex(index, namedCatalogs[cat_key]);
513  index->setDirty(true);
514  }
515  m_indexCreated = true;
516  }
517  }
518 }
519 
520 void DocumentationPlugin::loadCatalogConfiguration(TDEListView *configurationView)
521 {
522  config->setGroup("Locations");
523  TQMap<TQString, TQString> entryMap = config->entryMap("Locations");
524 
525  for (TQMap<TQString, TQString>::const_iterator it = entryMap.begin();
526  it != entryMap.end(); ++it)
527  {
528  if (namedCatalogs.contains(it.key())
529  && namedCatalogs[it.key()]->isProjectDocumentationItem())
530  continue;
531 
532  config->setGroup("Locations");
533  ConfigurationItem *item = new ConfigurationItem(configurationView, this, it.key(),
534  config->readPathEntry(it.key()),
535  hasCapability(Index), hasCapability(FullTextSearch));
536  config->setGroup("TOC Settings");
537  item->setContents(config->readBoolEntry(item->title(), true));
538  config->setGroup("Index Settings");
539  item->setIndex(config->readBoolEntry(item->title(), false));
540  config->setGroup("Search Settings");
541  item->setFullTextSearch(config->readBoolEntry(item->title(), false));
542  }
543 }
544 
545 void DocumentationPlugin::saveCatalogConfiguration(TDEListView *configurationView)
546 {
547 
548  for (TQStringList::const_iterator it = deletedConfigurationItems.constBegin();
549  it != deletedConfigurationItems.constEnd(); ++it)
550  {
551  config->setGroup("Locations");
552  config->deleteEntry(*it);
553  config->setGroup("TOC Settings");
554  config->deleteEntry(*it);
555  config->setGroup("Index Settings");
556  config->deleteEntry(*it);
557  config->setGroup("Search Settings");
558  config->deleteEntry(*it);
559  }
560 
561  TQListViewItemIterator it(configurationView);
562  while (it.current())
563  {
564  ConfigurationItem *confItem = dynamic_cast<ConfigurationItem*>(it.current());
565  if ( confItem->docPlugin() != this )
566  {
567  ++it;
568  continue;
569  }
570 
571  config->setGroup("Locations");
572  if (confItem->isChanged())
573  config->deleteEntry(confItem->origTitle());
574  config->writePathEntry(confItem->title(), confItem->url());
575 
576  config->setGroup("TOC Settings");
577  if (confItem->isChanged())
578  config->deleteEntry(confItem->origTitle());
579  config->writeEntry(confItem->title(), confItem->contents());
580 
581  config->setGroup("Index Settings");
582  if (confItem->isChanged())
583  config->deleteEntry(confItem->origTitle());
584  config->writeEntry(confItem->title(), confItem->index());
585 
586  config->setGroup("Search Settings");
587  if (confItem->isChanged())
588  config->deleteEntry(confItem->origTitle());
589  config->writeEntry(confItem->title(), confItem->fullTextSearch());
590 
591  ++it;
592  }
593  config->sync();
594 }
595 
596 void DocumentationPlugin::setIndexEnabled( DocumentationCatalogItem * item, bool e )
597 {
598  TQString group = config->group();
599  config->setGroup("Index Settings");
600  config->writeEntry(item->text(0), e);
601  config->setGroup(group);
602 }
603 
604 bool DocumentationPlugin::indexEnabled( DocumentationCatalogItem * item ) const
605 {
606  TQString group = config->group();
607  config->setGroup("Index Settings");
608  bool b = config->readBoolEntry(item->text(0), false);
609  config->setGroup(group);
610  return b;
611 }
612 
613 bool DocumentationPlugin::catalogEnabled(const TQString &name) const
614 {
615  TQString group = config->group();
616  config->setGroup("TOC Settings");
617  bool b = config->readBoolEntry(name, true);
618  config->setGroup(group);
619  return b;
620 }
621 
622 void DocumentationPlugin::setCatalogEnabled(const TQString &name, bool e)
623 {
624  TQString group = config->group();
625  config->setGroup("TOC Settings");
626  config->writeEntry(name, e);
627  config->setGroup(group);
628 }
629 
630 
631 //----------------------------------------------------
632 //class IndexBox
633 
634 IndexBox::IndexBox(TQWidget *parent, const char *name)
635  :TDEListBox(parent, name), m_dirty(false)
636 {
637 }
638 
639 void IndexBox::addIndexItem(IndexItemProto *item)
640 {
641  items[item->text()].append(item);
642 }
643 
644 void IndexBox::removeIndexItem(IndexItemProto *item)
645 {
646  TQString text = item->text();
647  items[text].remove(item);
648  if (items[text].count() == 0)
649  {
650  items.remove(text);
651  TQListBoxItem *item = findItem(text, TQt::CaseSensitive | TQt::ExactMatch);
652  if (item)
653  delete item;
654  }
655 }
656 
657 void IndexBox::fill()
658 {
659  for (TQMap<TQString, TQValueList<IndexItemProto*> >::const_iterator it = items.begin();
660  it != items.end(); ++it)
661  {
662  new IndexItem(this, it.key());
663  }
664 }
665 
666 void IndexBox::setDirty(bool dirty)
667 {
668  m_dirty = dirty;
669 }
670 
671 void IndexBox::refill()
672 {
673  if (m_dirty)
674  {
675  clear();
676  fill();
677  setDirty(false);
678  }
679 }
680 
681 
682 ProjectDocumentationPlugin::ProjectDocumentationPlugin(DocumentationPlugin *docPlugin, DocumentationPlugin::ProjectDocType type)
683  :TQObject(0, 0), m_docPlugin(docPlugin), m_catalog(0), m_type(type), m_contents(0), m_index(0)
684 {
685  kdDebug() << "ProjectDocumentationPlugin::ProjectDocumentationPlugin for type " << type << endl;
686 
687  m_watch = new KDirWatch(this);
688  connect(m_watch, TQT_SIGNAL(dirty(const TQString&)), this, TQT_SLOT(reinit()));
689  m_watch->startScan();
690 }
691 
692 ProjectDocumentationPlugin::~ProjectDocumentationPlugin()
693 {
694  deinit();
695 }
696 
697 TDEListViewItem* ProjectDocumentationPlugin::findCatalogPosition(const TQString &key, const TDEListView *contents) const
698 {
699  TDEListViewItem *curr_item = (TDEListViewItem*)(contents->firstChild());
700  if (!curr_item)
701  return NULL; // Empty listview
702 
703  TDEListViewItem *prev_item = NULL;
704  while (curr_item && curr_item->text(0) <= key)
705  {
706  prev_item = curr_item;
707  curr_item = (TDEListViewItem*)(curr_item->nextSibling());
708  }
709  return prev_item;
710 }
711 
712 void ProjectDocumentationPlugin::init(TDEListView *contents, IndexBox *index, const TQString &url)
713 {
714  m_contents = contents;
715  m_index = index;
716  m_url = url;
717 
718  if (m_catalog)
719  deinit();
720  TQString cat_key = (m_type == DocumentationPlugin::APIDocs ? i18n("Project API Documentation")
721  : i18n("Project User Manual"));
722  TDEListViewItem *afterItem = findCatalogPosition(cat_key, contents);
723  m_catalog = m_docPlugin->createCatalog(contents, afterItem, cat_key, url);
724  if (m_catalog)
725  {
726  m_catalog->setProjectDocumentationItem(true);
727  m_watch->addFile(url);
728  }
729 }
730 
731 void ProjectDocumentationPlugin::reinit()
732 {
733  deinit();
734  if (m_contents != 0 && m_index != 0 && m_url != 0)
735  init(m_contents, m_index, m_url);
736 }
737 
738 void ProjectDocumentationPlugin::deinit()
739 {
740  m_watch->removeFile(m_url);
741  if (m_catalog)
742  {
743  delete m_catalog;
744  m_catalog = 0;
745  }
746 }
747 
748 TQString ProjectDocumentationPlugin::pluginName() const
749 {
750  return m_docPlugin->pluginName();
751 }
752 
753 TQString ProjectDocumentationPlugin::catalogURL() const
754 {
755  return m_url;
756 }
757 
758 #include "kdevdocumentationplugin.moc"
DocumentationItem::Book
Book - a document with nested documents.
Definition: kdevdocumentationplugin.h:42
DocumentationPlugin::reinit
virtual void reinit(TDEListView *contents, IndexBox *index, TQStringList restrictions)
Reloads a list of catalogs.
Definition: kdevdocumentationplugin.cpp:467
DocumentationPlugin::addCatalogConfiguration
virtual void addCatalogConfiguration(TDEListView *configurationView, const TQString &title, const TQString &url)
Adds new catalog to a configuration.
Definition: kdevdocumentationplugin.cpp:392
DocumentationPlugin::setIndexEnabled
virtual void setIndexEnabled(DocumentationCatalogItem *item, bool e)
Enables or disables index for documentation catalog.
Definition: kdevdocumentationplugin.cpp:596
DocumentationPlugin::namedCatalogs
TQMap< TQString, DocumentationCatalogItem * > namedCatalogs
A map of names of loaded documentation catalogs.
Definition: kdevdocumentationplugin.h:351
DocumentationPlugin::setCatalogURL
virtual void setCatalogURL(DocumentationCatalogItem *item)=0
Sets the URL to the catalog.
DocumentationCatalogItem::activate
virtual void activate()
should return a short string that identifies the version of the catalog
Definition: kdevdocumentationplugin.cpp:129
IndexItem
Documentation index item.
Definition: kdevdocumentationplugin.h:123
DocumentationPlugin::loadIndex
void loadIndex(IndexBox *index, DocumentationCatalogItem *item)
Loads index from cache or creates and caches it if does not exist.
Definition: kdevdocumentationplugin.cpp:422
DocumentationPlugin::FullTextSearch
full text search is possible in catalog locations
Definition: kdevdocumentationplugin.h:224
DocumentationPlugin::config
TDEConfig * config
Configuration object used by a plugin.
Definition: kdevdocumentationplugin.h:370
DocumentationItem::Collection
Collection - a collection of catalogs, folder with catalogs.
Definition: kdevdocumentationplugin.h:40
DocumentationCatalogItem
Documentation catalog list item.
Definition: kdevdocumentationplugin.h:72
DocumentationPlugin::init
virtual void init(TDEListView *contents)
Initialize a list of catalogs.
Definition: kdevdocumentationplugin.cpp:447
DocumentationPlugin::clear
virtual void clear()
Clears documentation catalogs and indices.
Definition: kdevdocumentationplugin.cpp:267
ConfigurationItem
Documentation configuration item.
Definition: kdevdocumentationplugin.h:161
DocumentationPlugin::deleteCatalogConfiguration
virtual void deleteCatalogConfiguration(const ConfigurationItem *const configurationItem)
Removes catalog from configuration.
Definition: kdevdocumentationplugin.cpp:406
IndexItemProto
Prototype of index item.
Definition: kdevdocumentationplugin.h:103
DocumentationPlugin::clearCatalogIndex
virtual void clearCatalogIndex(DocumentationCatalogItem *item)
Clears index of given catalog.
Definition: kdevdocumentationplugin.cpp:411
DocumentationPlugin::createCatalog
virtual DocumentationCatalogItem * createCatalog(TDEListView *contents, TDEListViewItem *after, const TQString &title, const TQString &url)=0
Creates documentation catalog with given title and url.
DocumentationPlugin::autoSetup
virtual void autoSetup()
Initializes plugin configuration.
Definition: kdevdocumentationplugin.cpp:255
DocumentationPlugin::editCatalogConfiguration
virtual void editCatalogConfiguration(ConfigurationItem *configurationItem, const TQString &title, const TQString &url)
Edits catalog configuration.
Definition: kdevdocumentationplugin.cpp:399
DocumentationPlugin::setCatalogEnabled
virtual void setCatalogEnabled(const TQString &name, bool e)
Enables or disables documentation catalog.
Definition: kdevdocumentationplugin.cpp:622
DocumentationPlugin::catalogs
TQValueList< DocumentationCatalogItem * > catalogs
A list of loaded documentation catalogs.
Definition: kdevdocumentationplugin.h:349
DocumentationPlugin::needRefreshIndex
virtual bool needRefreshIndex(DocumentationCatalogItem *item)=0
Indicates if an index of given catalog should be rebuilt.
DocumentationPlugin::hasCapability
bool hasCapability(Capability cap) const
Checks if documentation plugin has given capability.
Definition: kdevdocumentationplugin.h:322
DocumentationPlugin::deletedConfigurationItems
TQStringList deletedConfigurationItems
Stores items deleted from configuration.
Definition: kdevdocumentationplugin.h:367
DocumentationPlugin::findCatalogPosition
TDEListViewItem * findCatalogPosition(const TQString &key, const TDEListView *contents) const
Find catalog insert position to maintain a sorted order.
Definition: kdevdocumentationplugin.cpp:432
DocumentationPlugin::createTOC
virtual void createTOC(DocumentationCatalogItem *item)=0
Creates a table of contents for given catalog.
DocumentationPlugin::indexes
TQMap< DocumentationCatalogItem *, TQValueList< IndexItemProto * > > indexes
A map of indices of loaded documentation catalogs.
Definition: kdevdocumentationplugin.h:353
DocumentationItem
Documentation list item.
Definition: kdevdocumentationplugin.h:35
DocumentationPlugin::loadCatalogConfiguration
virtual void loadCatalogConfiguration(TDEListView *configurationView)
Loads catalog configuration and fills configurationView with ConfigurationItem objects.
Definition: kdevdocumentationplugin.cpp:520
DocumentationPlugin::catalogEnabled
virtual bool catalogEnabled(const TQString &name) const
Indicates if a catalog with specified name is enabled.
Definition: kdevdocumentationplugin.cpp:613
IndexBox
Documentation index view.
Definition: kdevdocumentationplugin.h:137
DocumentationPlugin::cacheIndex
virtual void cacheIndex(DocumentationCatalogItem *item)
Caches index for documentation catalog.
Definition: kdevdocumentationplugin.cpp:322
DocumentationPlugin::createIndex
virtual void createIndex(IndexBox *index, DocumentationCatalogItem *item)=0
Builds index for given catalog.
ProjectDocumentationPlugin::reinit
virtual void reinit()
Performs reinitialization if project documentation has changed (after building api documentation)...
Definition: kdevdocumentationplugin.cpp:731
DocumentationPlugin::ProjectDocType
ProjectDocType
Possible project documentation types.
Definition: kdevdocumentationplugin.h:228
DocumentationPlugin
Documentation Plugin Interface.
Definition: kdevdocumentationplugin.h:217
ProjectDocumentationPlugin::init
virtual void init(TDEListView *contents, IndexBox *index, const TQString &url)
Initializes project documentation plugin - creates documentation catalog.
Definition: kdevdocumentationplugin.cpp:712
DocumentationItem::Type
Type
Type of documentation which is represented by this item.
Definition: kdevdocumentationplugin.h:39
DocumentationPlugin::Index
index can be built for catalogs
Definition: kdevdocumentationplugin.h:223
DocumentationPlugin::saveCatalogConfiguration
virtual void saveCatalogConfiguration(TDEListView *configurationView)
Saves catalog configuration basing on configurationView and deletedConfigurationItems contents...
Definition: kdevdocumentationplugin.cpp:545
DocumentationPlugin::autoSetupPlugin
virtual void autoSetupPlugin()=0
Plugin specific automatic setup code.
ProjectDocumentationPlugin::findCatalogPosition
TDEListViewItem * findCatalogPosition(const TQString &key, const TDEListView *contents) const
Find catalog insert position to maintain a sorted order.
Definition: kdevdocumentationplugin.cpp:697
DocumentationPlugin::loadCachedIndex
virtual bool loadCachedIndex(IndexBox *index, DocumentationCatalogItem *item)
Loads index from the cache.
Definition: kdevdocumentationplugin.cpp:347
DocumentationItem::Catalog
Catalog - a term which defines a document or a group of documents.
Definition: kdevdocumentationplugin.h:41
DocumentationPlugin::DocumentationPlugin
DocumentationPlugin(TDEConfig *pluginConfig, TQObject *parent=0, const char *name=0)
Constructor.
Definition: kdevdocumentationplugin.cpp:246
DocumentationPlugin::indexEnabled
virtual bool indexEnabled(DocumentationCatalogItem *item) const
Indicates if an index is enabled for given catalog.
Definition: kdevdocumentationplugin.cpp:604
ProjectDocumentationPlugin::deinit
virtual void deinit()
Deinitializes project documentation plugin - removes documentation catalog.
Definition: kdevdocumentationplugin.cpp:738

KDevelop Documentation Part Interfaces Library

Skip menu "KDevelop Documentation Part Interfaces Library"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDevelop Documentation Part Interfaces Library

Skip menu "KDevelop Documentation Part Interfaces Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Documentation Part Interfaces Library by doxygen 1.8.13
This website is maintained by Timothy Pearson.