1 /*
2     SPDX-FileCopyrightText: 1999 Matthias Elter <me@kde.org>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifndef KHC_NAVIGATOR_H
8 #define KHC_NAVIGATOR_H
9 
10 #include "glossary.h"
11 #include "docentry.h"
12 
13 #include <QProcess>
14 #include <QTimer>
15 #include <QUrl>
16 
17 class QProgressBar;
18 class QTabWidget;
19 class QTreeWidget;
20 class QTreeWidgetItem;
21 class KLineEdit;
22 class KProcess;
23 
24 namespace KHC {
25 
26 class NavigatorItem;
27 class Navigator;
28 class View;
29 class SearchEngine;
30 class SearchWidget;
31 
32 class Navigator : public QWidget
33 {
34     Q_OBJECT
35   public:
36     explicit Navigator(View *, QWidget *parent= nullptr);
37     virtual ~Navigator();
38 
39     QUrl homeURL();
40 
41     SearchEngine *searchEngine() const;
42 
glossEntry(const QString & term)43     const GlossaryEntry &glossEntry(const QString &term) const { return mGlossaryTree->entry( term ); }
44 
45     void insertParentAppDocs( const QString &name, NavigatorItem *parent );
46     void insertScrollKeeperDocs( NavigatorItem *parent );
47     void insertInfoDocs( NavigatorItem *parentItem );
48     void insertKCMDocs(const QString &, NavigatorItem*parent, const QString &);
49     void insertIOSlaveDocs(const QString &, NavigatorItem*parent);
50 
51     void createItemFromDesktopFile( NavigatorItem *item, const QString &name );
52 
53     void clearSelection();
54 
55     void showOverview( NavigatorItem *item, const QUrl &url );
56 
57     void readConfig();
58     void writeConfig();
59 
60   public Q_SLOTS:
61     void openInternalUrl( const QUrl &url );
62     void slotItemSelected(QTreeWidgetItem* index);
63     void slotItemExpanded( QTreeWidgetItem *item );
64     void slotItemCollapsed( QTreeWidgetItem *item );
65     void slotSearch();
66     void slotShowSearchResult( const QString & );
67     void slotSelectGlossEntry( const QString &id );
68     void selectItem( const QUrl &url );
69 
70   Q_SIGNALS:
71     void itemSelected(const QString& itemURL);
72     void glossSelected(const GlossaryEntry &entry);
73     void setStatusBarText(const QString &text);
74 
75   protected Q_SLOTS:
76     void slotSearchFinished();
77     void checkSearchEdit();
78 
79     void clearSearch();
80 
81     void slotDelayedIndexingStart();
82     void slotDoIndexWork();
83     void slotProcessExited( int exitCode, QProcess::ExitStatus exitStatus );
84     void slotShowIndexingProgressBar();
85 
86   protected:
87     static QString createChildrenList( QTreeWidgetItem *child, int level );
88 
89   private:
90     void setupContentsTab();
91     void setupSearchTab();
92     void setupGlossaryTab();
93 
94     void insertPlugins();
95     void hideSearch();
96 
97     QTreeWidget *mContentsTree = nullptr;
98     Glossary *mGlossaryTree = nullptr;
99 
100     SearchWidget *mSearchWidget = nullptr;
101 
102     QTabWidget *mTabWidget = nullptr;
103 
104     KLineEdit *mSearchEdit = nullptr;
105 
106     SearchEngine *mSearchEngine = nullptr;
107 
108     View *mView = nullptr;
109 
110     QUrl mHomeUrl;
111 
112     bool mSelected = false;
113 
114     DocEntry::List mIndexingQueue;
115     KProcess *mIndexingProc = nullptr;
116     QProgressBar *mIndexingBar = nullptr;
117     QTimer mIndexingTimer;
118 };
119 
120 }
121 
122 #endif //KHC_NAVIGATOR_H
123 // vim:ts=2:sw=2:et
124