BibleTime
cexportmanager.h
Go to the documentation of this file.
1 /*********
2 *
3 * In the name of the Father, and of the Son, and of the Holy Spirit.
4 *
5 * This file is part of BibleTime's source code, https://bibletime.info/
6 *
7 * Copyright 1999-2021 by the BibleTime developers.
8 * The BibleTime source code is licensed under the GNU General Public License
9 * version 2.0.
10 *
11 **********/
12 
13 #pragma once
14 
15 #include <memory>
16 #include <QList>
17 #include <QString>
18 #include "../backend/btglobal.h"
19 #include "../backend/config/btconfig.h"
20 #include "../backend/cswordmodulesearch.h"
21 #include "../backend/drivers/btmodulelist.h"
22 
23 
24 class CSwordKey;
25 class CSwordModuleInfo;
26 class QProgressDialog;
27 namespace Rendering {
28 class CTextRendering;
29 }
30 
32 
33 public: // types:
34 
35  /** The format the export actions should have. */
36  enum Format {
38  Text
39  };
40 
41 public: // methods:
42 
43  CExportManager(const bool showProgress = true,
44  const QString &progressLabel = QString(),
45  const FilterOptions &filterOptions = btConfig().getFilterOptions(),
46  const DisplayOptions &displayOptions = btConfig().getDisplayOptions());
48 
49  bool saveKey(CSwordKey const * const key,
50  Format const format,
51  bool const addText,
52  const BtConstModuleList& modules);
53 
55  CSwordModuleInfo const * const module,
56  Format const format,
57  bool const addText);
58 
59  bool saveKeyList(QList<CSwordKey *> const & list,
60  Format const format,
61  bool const addText);
62 
63  bool copyKey(CSwordKey const * const key,
64  Format const format,
65  bool const addText);
66 
68  CSwordModuleInfo const * const module,
69  Format const format,
70  bool const addText);
71 
72  bool copyKeyList(QList<CSwordKey *> const & list,
73  Format const format,
74  bool const addText);
75 
76  bool printKey(CSwordKey const * const key,
77  DisplayOptions const & displayOptions,
78  FilterOptions const & filterOptions);
79 
80  bool printKey(CSwordModuleInfo const * const module,
81  QString const & startKey,
82  QString const & stopKey,
83  DisplayOptions const & displayOptions,
84  FilterOptions const & filterOptions);
85 
86  /**
87  \brief Prints a key using the hyperlink created by CReferenceManager.
88  */
89  bool printByHyperlink(QString const & hyperlink,
90  DisplayOptions const & displayOptions,
91  FilterOptions const & filterOptions);
92 
94  CSwordModuleInfo const * const module,
95  DisplayOptions const & displayOptions,
96  FilterOptions const & filterOptions);
97 
98  bool printKeyList(QStringList const & list,
99  CSwordModuleInfo const * const module,
100  DisplayOptions const & displayOptions,
101  FilterOptions const & filterOptions);
102 
103 protected: // methods:
104 
105  /** \returns a filename to save a file. */
106  const QString getSaveFileName(Format const format);
107 
108 private: // methods:
109 
110  std::unique_ptr<Rendering::CTextRendering> newRenderer(Format const format,
111  bool const addText);
112 
113  /** \returns the CSS string used in HTML pages. */
114  void setProgressRange(int const items);
115 
116  /** \brief Increments the progress by one item. */
117  void incProgress();
118 
119  bool progressWasCancelled();
120 
121  /** \brief Closes the progress dialog immediately. */
122  void closeProgressDialog();
123 
124 private: // fields:
125 
128 
129  std::unique_ptr<QProgressDialog> const m_progressDialog;
130 
131 };
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
Definition: btconfig.h:305
QList< CSwordModuleInfo const * > BtConstModuleList
Definition: btmodulelist.h:21
std::unique_ptr< QProgressDialog > const m_progressDialog
bool progressWasCancelled()
bool printKey(CSwordKey const *const key, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
std::unique_ptr< Rendering::CTextRendering > newRenderer(Format const format, bool const addText)
void setProgressRange(int const items)
FilterOptions const m_filterOptions
bool printByHyperlink(QString const &hyperlink, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
Prints a key using the hyperlink created by CReferenceManager.
bool printKeyList(CSwordModuleSearch::ModuleResultList const &list, CSwordModuleInfo const *const module, DisplayOptions const &displayOptions, FilterOptions const &filterOptions)
bool copyKeyList(CSwordModuleSearch::ModuleResultList const &list, CSwordModuleInfo const *const module, Format const format, bool const addText)
void incProgress()
Increments the progress by one item.
const QString getSaveFileName(Format const format)
bool saveKey(CSwordKey const *const key, Format const format, bool const addText, const BtConstModuleList &modules)
CExportManager(const bool showProgress=true, const QString &progressLabel=QString(), const FilterOptions &filterOptions=btConfig().getFilterOptions(), const DisplayOptions &displayOptions=btConfig().getDisplayOptions())
bool saveKeyList(CSwordModuleSearch::ModuleResultList const &list, CSwordModuleInfo const *const module, Format const format, bool const addText)
void closeProgressDialog()
Closes the progress dialog immediately.
bool copyKey(CSwordKey const *const key, Format const format, bool const addText)
DisplayOptions const m_displayOptions
std::vector< std::shared_ptr< sword::SWKey const > > ModuleResultList