Subversion Repositories Scribus

Rev

Rev 16180 | Rev 19267 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4430 cbradney 1
/*
2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
6
*/
564 cbradney 7
/***************************************************************************
8
*   Copyright (C) 2004 by Craig Bradney                                   *
9
*   cbradney@zip.com.au                                                   *
2052 subik 10
*   Copyright (C) 2005 by Petr Vanek                                      *
11
*   petr@yarpen.cz                                                        *
564 cbradney 12
*                                                                         *
13
*   This program is free software; you can redistribute it and/or modify  *
14
*   it under the terms of the GNU General Public License as published by  *
15
*   the Free Software Foundation; either version 2 of the License, or     *
16
*   (at your option) any later version.                                   *
17
*                                                                         *
18
*   This program is distributed in the hope that it will be useful,       *
19
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
20
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
21
*   GNU General Public License for more details.                          *
22
*                                                                         *
23
*   You should have received a copy of the GNU General Public License     *
24
*   along with this program; if not, write to the                         *
25
*   Free Software Foundation, Inc.,                                       *
18122 mrdocs 26
*   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
564 cbradney 27
***************************************************************************/
560 cbradney 28
 
3 paul 29
#ifndef HELPBROWSER_H
30
#define HELPBROWSER_H
31
 
10108 cbradney 32
#include <QAction>
33
#include <QItemSelection>
34
#include <QList>
35
#include <QMainWindow>
36
#include <QMenu>
37
#include <QMenuBar>
38
#include <QPair>
13530 pierre 39
#include <QProgressBar>
10006 cbradney 40
#include <QString>
10108 cbradney 41
#include <QToolBar>
13530 pierre 42
#include <QTreeWidgetItem>
10108 cbradney 43
#include <QUrl>
44
#include <QVariant>
45
#include <QWidget>
46
 
10859 cbradney 47
class QEvent;
48
 
10108 cbradney 49
#include "ui_helpbrowser.h"
2969 craig 50
#include "scribusapi.h"
10108 cbradney 51
#include "util.h"
52
#include "scconfig.h"
53
#include "scpaths.h"
54
#include "prefsmanager.h"
55
#include "prefsfile.h"
56
#include "schelptreemodel.h"
2969 craig 57
 
13530 pierre 58
class HelpNavigation;
59
 
4519 subik 60
//! \brief A structure holding title/file url reference.
10108 cbradney 61
struct histd2 {
2052 subik 62
        QString url;
63
        QString title;
64
};
65
 
10108 cbradney 66
class SCRIBUS_API HelpBrowser : public QMainWindow, Ui::HelpBrowser
4519 subik 67
{
10108 cbradney 68
    Q_OBJECT
4519 subik 69
 
4676 cbradney 70
public:
10108 cbradney 71
        HelpBrowser(QWidget* parent);
72
        HelpBrowser(QWidget* parent, const QString& caption, const QString& guiLangage="en", const QString& jumpToSection="", const QString& jumpToFile="");
560 cbradney 73
        ~HelpBrowser();
10859 cbradney 74
 
75
 
76
        virtual void changeEvent(QEvent *e);
3 paul 77
 
4458 subik 78
        /*! \brief History menu. It's public because of history reader - separate class */
10006 cbradney 79
        QMenu* histMenu;
4458 subik 80
        /*! \brief Mapping the documents for history. */
10108 cbradney 81
        QMap<QAction*, histd2> mHistory;
4458 subik 82
        /*! \brief Set text to the browser
83
        \param str a QString with text (html) */
10108 cbradney 84
        void setText(const QString& str);
10887 cbradney 85
 
86
        static bool firstRun;
2052 subik 87
 
16180 craig 88
public slots:
89
        void jumpToHelpSection(const QString& jumpToSection, const QString& jumpToFile="", bool dontChangeIfAlreadyLoaded=false);
90
 
786 cbradney 91
protected:
10108 cbradney 92
        void closeEvent(QCloseEvent * event);
560 cbradney 93
 
10108 cbradney 94
        void setupLocalUI();
95
        /*! \brief Reads saved bookmarks from external file */
96
        void readBookmarks();
2006 subik 97
        /*! \brief Search in doc files in spec. dir.
98
        It uses directory-recursion. I hope that the documentation will have
99
        only 2-3 level dir structure so it doesn't matter.
100
        \author Petr Vanek <petr@yarpen.cz> */
10108 cbradney 101
        void searchingInDirectory(const QString&);
2006 subik 102
 
4458 subik 103
        /*! \brief Reads saved history of browsing. */
2052 subik 104
        void readHistory();
105
 
10676 cbradney 106
        /*! \brief Tell the user there is no help available */
107
        void displayNoHelp();
13530 pierre 108
 
109
        HelpNavigation * helpNav;
10676 cbradney 110
 
10108 cbradney 111
        QMenu* fileMenu;
112
        QMenu* editMenu;
113
        QMenu* bookMenu;
114
        QAction* filePrint;
115
        QAction* fileExit;
116
        QAction* editFind;
117
        QAction* editFindNext;
118
        QAction* editFindPrev;
119
        QAction* bookAdd;
120
        QAction* bookDel;
121
        QAction* bookDelAll;
122
        QAction* goHome;
123
        QAction* goBack;
124
        QAction* goFwd;
125
 
13530 pierre 126
        QProgressBar * progressBar;
127
 
10108 cbradney 128
        //! \brief Selected language is here. If there is no docs for this language, "en" is used.
129
        QString language;
10676 cbradney 130
        //! \brief QString holding location of menu.xml we are using, we load the help files from here
131
        QString finalBaseDir;
10108 cbradney 132
        /*! \brief Text to be found in document */
133
        QString findText;
134
        /** \brief Configuration structure */
135
        PrefsContext* prefs;
136
        ScHelpTreeModel* menuModel;
137
        QMap<QString, QString> quickHelpIndex;
138
        QMap<QString, QPair<QString, QString> > bookmarkIndex;
10887 cbradney 139
 
560 cbradney 140
protected slots:
141
        virtual void languageChange();
10108 cbradney 142
        void histChosen(QAction* i);
143
        void loadHelp(const QString& filename);
144
        void loadMenu();
13530 pierre 145
//      void showLinkContents(const QString &link);
10108 cbradney 146
        QString bookmarkFile();
147
        QString historyFile();
2006 subik 148
 
13530 pierre 149
        void loadStart();
150
        void loadProcess(int);
151
        void loadEnd(bool);
152
 
4458 subik 153
        /*! \brief Load doc file when user select filename in content view. */
10108 cbradney 154
        void itemSelected(const QItemSelection & selected, const QItemSelection & deselected);
2006 subik 155
 
10108 cbradney 156
        /*! \brief Load doc file when user select filename in search view. */
157
        void itemSearchSelected(QTreeWidgetItem *, int);
2006 subik 158
 
10108 cbradney 159
        /*! \brief Load doc file when user select filename in bookmark view. */
160
        void itemBookmarkSelected(QTreeWidgetItem *, int);
161
 
2006 subik 162
        /*! \brief Performs searching in documentation.
163
        It walks through installed documentation and searching in all text files
164
        \author Petr Vanek <petr@yarpen.cz> */
165
        void searchingButton_clicked();
166
 
167
        /*! \brief Find text in one document.
168
        Classical ctrl+f searching.
169
        \author Petr Vanek <petr@yarpen.cz> */
170
        void find();
171
 
172
        /*! \brief Find next occurences of the text in one document.
173
        \author Petr Vanek <petr@yarpen.cz> */
174
        void findNext();
2023 subik 175
 
176
        /*! \brief Find previous occurences of the text in one document.
177
        \author Petr Vanek <petr@yarpen.cz> */
178
        void findPrevious();
179
 
180
        /*! \brief Print the documentation.
181
        Based on the Qt example.
182
        */
183
        void print();
184
 
4458 subik 185
        /*! \brief Add document into bookmarks. */
2048 subik 186
        void bookmarkButton_clicked();
187
 
4458 subik 188
        /*! \brief Delete selected document from bookmarks. */
2048 subik 189
        void deleteBookmarkButton_clicked();
190
 
4458 subik 191
        /*! \brief Delete all bookmarks */
2048 subik 192
        void deleteAllBookmarkButton_clicked();
193
 
10108 cbradney 194
signals:
195
        void closed();
196
 
3 paul 197
};
198
 
199
#endif // HELPBROWSER_H
2023 subik 200