~ubuntu-branches/ubuntu/vivid/fbreader/vivid-proposed

« back to all changes in this revision

Viewing changes to fbreader/src/fbreader/BookInfoDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2007-12-04 12:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20071204125145-pw20qfyn0fx3h7jg
Tags: 0.8.8-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <ZLOptionsDialog.h>
26
26
#include <ZLOptionEntry.h>
27
27
#include <ZLFile.h>
 
28
#include <ZLLanguageList.h>
28
29
 
29
30
#include <optionEntries/ZLStringInfoEntry.h>
30
31
#include <optionEntries/ZLSimpleOptionEntry.h>
31
 
 
32
 
#include <ZLTextTeXHyphenator.h>
 
32
#include <optionEntries/ZLLanguageOptionEntry.h>
33
33
 
34
34
#include "BookInfoDialog.h"
35
35
 
67
67
friend class SeriesTitleEntry;
68
68
};
69
69
 
70
 
class LanguageEntry : public ZLComboOptionEntry {
71
 
 
72
 
public:
73
 
        LanguageEntry(ZLStringOption &encodingOption);
74
 
 
75
 
        const std::string &initialValue() const;
76
 
        const std::vector<std::string> &values() const;
77
 
        void onAccept(const std::string &value);
78
 
 
79
 
private:
80
 
        ZLStringOption &myLanguageOption;
81
 
};
82
 
 
83
70
class SeriesTitleEntry : public ZLComboOptionEntry {
84
71
 
85
72
public:
150
137
        myInfoDialog.myBookInfo.AuthorSortKeyOption.setValue(value);
151
138
}
152
139
 
153
 
LanguageEntry::LanguageEntry(ZLStringOption &encodingOption) : myLanguageOption(encodingOption) {
154
 
}
155
 
 
156
 
const std::string &LanguageEntry::initialValue() const {
157
 
        const std::vector<std::string> &codes = ZLTextTeXHyphenator::languageCodes();
158
 
        const std::vector<std::string> &names = ZLTextTeXHyphenator::languageNames();
159
 
        const size_t index = std::find(codes.begin(), codes.end(), myLanguageOption.value()) - codes.begin();
160
 
        return (index < names.size()) ? names[index] : names.back();
161
 
}
162
 
 
163
 
const std::vector<std::string> &LanguageEntry::values() const {
164
 
        return ZLTextTeXHyphenator::languageNames();
165
 
}
166
 
 
167
 
void LanguageEntry::onAccept(const std::string &value) {
168
 
        const std::vector<std::string> &codes = ZLTextTeXHyphenator::languageCodes();
169
 
        const std::vector<std::string> &names = ZLTextTeXHyphenator::languageNames();
170
 
        const size_t index = std::find(names.begin(), names.end(), value) - names.begin();
171
 
        myLanguageOption.setValue((index < codes.size()) ? codes[index] : codes.back());
172
 
}
173
 
 
174
140
SeriesTitleEntry::SeriesTitleEntry(BookInfoDialog &dialog) : ZLComboOptionEntry(true), myInfoDialog(dialog) {
175
141
        const std::vector<AuthorPtr> &authors = myInfoDialog.myCollection.authors();
176
142
        const std::string &authorName = myInfoDialog.myBookInfo.AuthorDisplayNameOption.value();
243
209
        myEncodingSetEntry =
244
210
                (myEncodingEntry->initialValue() != "auto") ?
245
211
                new EncodingSetEntry(*(EncodingEntry*)myEncodingEntry) : 0;
246
 
        myLanguageEntry = new LanguageEntry(myBookInfo.LanguageOption);
 
212
        std::vector<std::string> languageCodes = ZLLanguageList::languageCodes();
 
213
        languageCodes.push_back("de-traditional");
 
214
        myLanguageEntry = new ZLLanguageOptionEntry(myBookInfo.LanguageOption, languageCodes);
247
215
        mySeriesTitleEntry = new SeriesTitleEntry(*this);
248
216
        myBookNumberEntry = new ZLSimpleSpinOptionEntry(myBookInfo.NumberInSequenceOption, 1);
249
217
 
250
218
        commonTab.addOption(ZLResourceKey("authorDisplayName"), myAuthorDisplayNameEntry);
251
219
        commonTab.addOption(ZLResourceKey("authorSortKey"), myAuthorSortKeyEntry);
 
220
        commonTab.addOption(ZLResourceKey("language"), myLanguageEntry);
252
221
        if (myEncodingSetEntry != 0) {
253
222
                commonTab.addOption(ZLResourceKey("encodingSet"), myEncodingSetEntry);
254
223
        }
255
224
        commonTab.addOption(ZLResourceKey("encoding"), myEncodingEntry);
256
 
        commonTab.addOption(ZLResourceKey("lineBreaking"), myLanguageEntry);
257
225
 
258
226
        ZLDialogContent &seriesTab = myDialog->createTab(ZLResourceKey("Series"));
259
227
        seriesTab.addOption(ZLResourceKey("seriesTitle"), mySeriesTitleEntry);