summaryrefslogtreecommitdiff
path: root/src/frontend/cexportmanager.h
blob: 528647744b5734d297dcca02af738fef581d9364 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*********
*
* In the name of the Father, and of the Son, and of the Holy Spirit.
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2016 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#ifndef CEXPORTMANAGER_H
#define CEXPORTMANAGER_H

#include <memory>
#include <QList>
#include <QString>
#include "backend/btglobal.h"
#include "backend/config/btconfig.h"


class CSwordKey;
class CSwordModuleInfo;
class ListKey;
class QProgressDialog;
namespace Rendering {
class CTextRendering;
}

class CExportManager {

public: /* Types: */

    /** The format the export actions should have. */
    enum Format {
        HTML,
        Text
    };

public: /* Methods: */

    CExportManager(const bool showProgress = true,
                   const QString &progressLabel = QString::null,
                   const FilterOptions &filterOptions = btConfig().getFilterOptions(),
                   const DisplayOptions &displayOptions = btConfig().getDisplayOptions());
    ~CExportManager();

    bool saveKey(CSwordKey const * const key,
                 Format const format,
                 bool const addText);

    bool saveKeyList(sword::ListKey const & list,
                     CSwordModuleInfo const * const module,
                     Format const format,
                     bool const addText);

    bool saveKeyList(QList<CSwordKey *> const & list,
                     Format const format,
                     bool const addText);

    bool copyKey(CSwordKey const * const key,
                 Format const format,
                 bool const addText);

    bool copyKeyList(sword::ListKey const & list,
                     CSwordModuleInfo const * const module,
                     Format const format,
                     bool const addText);

    bool copyKeyList(QList<CSwordKey *> const & list,
                     Format const format,
                     bool const addText);

    bool printKey(CSwordKey const * const key,
                  DisplayOptions const & displayOptions,
                  FilterOptions const & filterOptions);

    bool printKey(CSwordModuleInfo const * const module,
                  QString const & startKey,
                  QString const & stopKey,
                  DisplayOptions const & displayOptions,
                  FilterOptions const & filterOptions);

    /**
      \brief Prints a key using the hyperlink created by CReferenceManager.
    */
    bool printByHyperlink(QString const & hyperlink,
                          DisplayOptions const & displayOptions,
                          FilterOptions const & filterOptions);

    bool printKeyList(sword::ListKey const & list,
                      CSwordModuleInfo const * const module,
                      DisplayOptions const & displayOptions,
                      FilterOptions const & filterOptions);

    bool printKeyList(QStringList const & list,
                      CSwordModuleInfo const * const module,
                      DisplayOptions const & displayOptions,
                      FilterOptions const & filterOptions);

protected: /* Methods: */

    /** \returns the string for the filedialogs to show the correct files.*/
    const QString filterString(Format const format);

    /** \returns a filename to save a file. */
    const QString getSaveFileName(Format const format);

private: /* Methods: */

    std::unique_ptr<Rendering::CTextRendering> newRenderer(Format const format,
                                                           bool const addText);

    /** \returns the CSS string used in HTML pages. */
    void setProgressRange(int const items);

    /** \brief Increments the progress by one item. */
    void incProgress();

    bool progressWasCancelled();

    /** \brief Closes the progress dialog immediately. */
    void closeProgressDialog();

private: /* Fields: */

    FilterOptions m_filterOptions;
    DisplayOptions m_displayOptions;

    QProgressDialog * m_progressDialog;

};

#endif