Changeset View
Changeset View
Standalone View
Standalone View
navigatorappitem.cpp
Show All 23 Lines | |||||
24 | #include "view.h" | 24 | #include "view.h" | ||
25 | #include "khc_debug.h" | 25 | #include "khc_debug.h" | ||
26 | 26 | | |||
27 | #include <QMetaObject> | 27 | #include <QMetaObject> | ||
28 | #include <QUrl> | 28 | #include <QUrl> | ||
29 | 29 | | |||
30 | using namespace KHC; | 30 | using namespace KHC; | ||
31 | 31 | | |||
32 | QMap< QString,NavigatorAppItem* > NavigatorAppItem::s_menuItemsMap; | ||||
33 | | ||||
32 | NavigatorAppItem::NavigatorAppItem( DocEntry *entry, QTreeWidgetItem *parent ) | 34 | NavigatorAppItem::NavigatorAppItem( DocEntry *entry, QTreeWidgetItem *parent ) | ||
33 | : NavigatorItem( entry, parent ), | 35 | : NavigatorItem( entry, parent ), | ||
34 | mToc( nullptr ) | 36 | mToc( nullptr ) | ||
35 | { | 37 | { | ||
38 | auto iter = s_menuItemsMap.find(entry->url()); | ||||
39 | if (iter == s_menuItemsMap.end()) | ||||
40 | { | ||||
41 | s_menuItemsMap.insert(entry->url(), this); | ||||
42 | } | ||||
36 | } | 43 | } | ||
37 | 44 | | |||
38 | NavigatorAppItem::NavigatorAppItem( DocEntry *entry, QTreeWidget *parent, | 45 | NavigatorAppItem::NavigatorAppItem( DocEntry *entry, QTreeWidget *parent, | ||
39 | QTreeWidgetItem *after ) | 46 | QTreeWidgetItem *after ) | ||
40 | : NavigatorItem( entry, parent, after ), | 47 | : NavigatorItem( entry, parent, after ), | ||
41 | mToc( nullptr ) | 48 | mToc( nullptr ) | ||
42 | { | 49 | { | ||
50 | auto iter = s_menuItemsMap.find(entry->url()); | ||||
51 | if (iter == s_menuItemsMap.end()) | ||||
52 | { | ||||
53 | s_menuItemsMap.insert(entry->url(), this); | ||||
54 | } | ||||
43 | } | 55 | } | ||
44 | 56 | | |||
45 | NavigatorAppItem::NavigatorAppItem( DocEntry *entry, QTreeWidgetItem *parent, | 57 | NavigatorAppItem::NavigatorAppItem( DocEntry *entry, QTreeWidgetItem *parent, | ||
46 | QTreeWidgetItem *after ) | 58 | QTreeWidgetItem *after ) | ||
47 | : NavigatorItem( entry, parent, after ), | 59 | : NavigatorItem( entry, parent, after ), | ||
48 | mToc( nullptr ) | 60 | mToc( nullptr ) | ||
49 | { | 61 | { | ||
62 | auto iter = s_menuItemsMap.find(entry->url()); | ||||
63 | if (iter == s_menuItemsMap.end()) | ||||
64 | { | ||||
65 | s_menuItemsMap.insert(entry->url(), this); | ||||
66 | } | ||||
50 | } | 67 | } | ||
51 | 68 | | |||
52 | NavigatorAppItem::~NavigatorAppItem() | 69 | NavigatorAppItem::~NavigatorAppItem() | ||
53 | { | 70 | { | ||
71 | auto iter = s_menuItemsMap.find(entry()->url()); | ||||
72 | if ((iter != s_menuItemsMap.end()) && (iter.value() == this)) | ||||
73 | { | ||||
74 | s_menuItemsMap.erase(iter); | ||||
75 | } | ||||
76 | | ||||
54 | delete mToc; | 77 | delete mToc; | ||
55 | } | 78 | } | ||
56 | 79 | | |||
57 | void NavigatorAppItem::itemExpanded( bool open ) | 80 | void NavigatorAppItem::itemExpanded( bool open ) | ||
58 | { | 81 | { | ||
59 | if ( open ) { | 82 | if ( open ) { | ||
83 | QUrl expanded_url(entry()->url()); | ||||
84 | expanded_url.setFragment(QString()); | ||||
85 | | ||||
86 | auto iter = s_menuItemsMap.find(expanded_url.toString()); | ||||
87 | if (iter != s_menuItemsMap.end()) | ||||
88 | { | ||||
89 | iter.value()->scheduleTOCBuild(); | ||||
90 | } | ||||
91 | else | ||||
92 | { | ||||
60 | scheduleTOCBuild(); | 93 | scheduleTOCBuild(); | ||
61 | } | 94 | } | ||
62 | } | 95 | } | ||
96 | } | ||||
63 | 97 | | |||
64 | void NavigatorAppItem::scheduleTOCBuild() | 98 | void NavigatorAppItem::scheduleTOCBuild() | ||
65 | { | 99 | { | ||
66 | if ( mToc ) { | 100 | if ( mToc ) { | ||
67 | return; | 101 | return; | ||
68 | } | 102 | } | ||
69 | 103 | | |||
70 | const QUrl url(entry()->url()); | 104 | const QUrl url(entry()->url()); | ||
Show All 23 Lines |