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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/***************************************************************************
File: swordoptions.cpp
Project: Kio-Sword -- An ioslave for SWORD and KDE
Copyright: Copyright (C) 2004-2005 Luke Plant
***************************************************************************/
/***************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
// Internal
#include "swordoptions.h"
#include "option.h"
// Std C/C++
#include <vector>
#include <stdlib.h>
using std::vector;
namespace KioSword
{
SwordOptions::SwordOptions()
{
init();
}
void SwordOptions::init()
{
// Setup all the options
propagate.setup (true, "PropagateOptions", "p", "propagate", true);
verseNumbers.setup (true, "VerseNumbers", "vn", "versenumbers", true);
verseLineBreaks.setup (true, "VerseLineBreaks", "lb", "linebreaks", true);
redWords.setup (true, "RedWords", "rw", "redwords", true);
footnotes.setup (false, "Footnotes", "fn", "footnotes", true);
headings.setup (true, "Headings", "hd", "headings", true);
strongs.setup (false, "StrongsNumbers", "st", "strongs", true);
morph.setup (false, "MorphologicalTags", "mt", "morph", true);
cantillation.setup (true, "Cantillation", "hc", "cantillation", true);
hebrewVowelPoints.setup (true, "HebrewVowelPoints", "hvp", "vowelpoints", true);
greekAccents.setup (true, "GreekAccents", "ga", "accents", true);
styleSheet.setup ("default.css", "StyleSheet", "ss", "stylesheet", true);
variants.setup (0, "Variants", "vr", "variants", true);
wholeBook.setup (false, "WholeBook", "wb", "wholebook", false);
doBibleIndex.setup (true, "BibleIndex", "bi", "bibleindex", false);
doDictIndex.setup (false, TQString::null, "di", "dictindex", false);
doFullTreeIndex.setup (false, "FullTreeIndex", "fi", "fullindex", false);
doOtherIndex.setup (false, TQString::null, "oi", "otherindex", false);
defaultBible.setup ("", "DefaultBible", "dfb", "defaultbible", true);
defaultGreekStrongs.setup ("", "DefaultGreekStrongs", "dfgs", "defaultgreekstrongs", true);
defaultHebrewStrongs.setup ("", "DefaultHebrewStrongs", "dfhs", "defaulthebrewstrongs", true);
defaultGreekMorph.setup ("", "DefaultGreekMorph", "dfgm", "defaultgreekmorph", true);
defaultHebrewMorph.setup ("", "DefaultHebrewMorph", "dfhm", "defaulthebrewmorph", true);
locale.setup ("", "Locale", "l", "locale", true);
m_optionList.push_back(&propagate);
m_optionList.push_back(&verseNumbers);
m_optionList.push_back(&verseLineBreaks);
m_optionList.push_back(&redWords);
m_optionList.push_back(&footnotes);
m_optionList.push_back(&headings);
m_optionList.push_back(&strongs);
m_optionList.push_back(&morph);
m_optionList.push_back(&cantillation);
m_optionList.push_back(&hebrewVowelPoints);
m_optionList.push_back(&greekAccents);
m_optionList.push_back(&styleSheet);
m_optionList.push_back(&variants);
m_optionList.push_back(&wholeBook);
m_optionList.push_back(&doBibleIndex);
m_optionList.push_back(&doDictIndex);
m_optionList.push_back(&doFullTreeIndex);
m_optionList.push_back(&doOtherIndex);
m_optionList.push_back(&defaultBible);
m_optionList.push_back(&defaultGreekStrongs);
m_optionList.push_back(&defaultHebrewStrongs);
m_optionList.push_back(&defaultGreekMorph);
m_optionList.push_back(&defaultHebrewMorph);
m_optionList.push_back(&locale);
}
/** Copy constuctor */
SwordOptions::SwordOptions(const SwordOptions& other)
{
init();
vector<OptionBase*>::const_iterator it_other;
vector<OptionBase*>::const_iterator it_end = other.m_optionList.end();
vector<OptionBase*>::const_iterator it_this = m_optionList.begin();
for(it_other = other.m_optionList.begin(); it_other != it_end; )
{
(*it_this)->copy((*it_other));
++it_this;
++it_other;
}
}
SwordOptions::~SwordOptions()
{
}
/** Set all (appropriate) options from the query string */
void SwordOptions::readFromQueryString(TQMap<TQString, TQString> items)
{
vector<OptionBase*>::const_iterator it;
vector<OptionBase*>::const_iterator it_end = m_optionList.end();
for(it = m_optionList.begin(); it != it_end; ++it)
{
(*it)->readFromQueryString(items, propagate());
}
}
/** Read all options in from the config file/defaults */
void SwordOptions::readFromConfig(const TDEConfig* config)
{
vector<OptionBase*>::const_iterator it;
vector<OptionBase*>::const_iterator it_end = m_optionList.end();
for(it = m_optionList.begin(); it != it_end; ++it)
{
(*it)->readFromConfig(config);
}
}
/** Save all options to the config file */
void SwordOptions::saveToConfig(TDEConfig* config)
{
vector<OptionBase*>::const_iterator it;
vector<OptionBase*>::const_iterator it_end = m_optionList.end();
for(it = m_optionList.begin(); it != it_end; ++it)
{
(*it)->saveToConfig(config);
}
}
/** Get the values that should be used for building a query string */
TQMap<TQString, TQString> SwordOptions::getQueryStringParams() const
{
TQMap<TQString, TQString> result;
vector<OptionBase*>::const_iterator it;
vector<OptionBase*>::const_iterator it_end = m_optionList.end();
for(it = m_optionList.begin(); it != it_end; ++it)
{
TQString name = TQString::null;
TQString value = TQString::null;
(*it)->getQueryStringPair(name, value);
if (!name.isNull() && !name.isEmpty())
{
result[name] = value;
}
}
return result;
}
}
|