Changeset View
Changeset View
Standalone View
Standalone View
src/acbf/AcbfPage.cpp
Context not available. | |||||
23 | #include "AcbfTextlayer.h" | 23 | #include "AcbfTextlayer.h" | ||
---|---|---|---|---|---|
24 | #include "AcbfFrame.h" | 24 | #include "AcbfFrame.h" | ||
25 | #include "AcbfJump.h" | 25 | #include "AcbfJump.h" | ||
26 | #include "AcbfTextarea.h" | ||||
26 | 27 | | |||
27 | #include <QDebug> | 28 | #include <QDebug> | ||
28 | #include <QHash> | 29 | #include <QHash> | ||
Context not available. | |||||
50 | : QObject(parent) | 51 | : QObject(parent) | ||
51 | , d(new Private) | 52 | , d(new Private) | ||
52 | { | 53 | { | ||
54 | qRegisterMetaType<Page*>("Page*"); | ||||
53 | } | 55 | } | ||
54 | 56 | | |||
55 | Page::~Page() = default; | 57 | Page::~Page() = default; | ||
Context not available. | |||||
170 | void Page::setBgcolor(const QString& newColor) | 172 | void Page::setBgcolor(const QString& newColor) | ||
171 | { | 173 | { | ||
172 | d->bgcolor = newColor; | 174 | d->bgcolor = newColor; | ||
175 | emit bgcolorChanged(); | ||||
173 | } | 176 | } | ||
174 | 177 | | |||
175 | QString Page::transition() const | 178 | QString Page::transition() const | ||
Context not available. | |||||
180 | void Page::setTransition(const QString& transition) | 183 | void Page::setTransition(const QString& transition) | ||
181 | { | 184 | { | ||
182 | d->transition = transition; | 185 | d->transition = transition; | ||
186 | emit transitionChanged(); | ||||
183 | } | 187 | } | ||
184 | 188 | | |||
185 | QStringList Page::availableTransitions() | 189 | QStringList Page::availableTransitions() | ||
Context not available. | |||||
200 | 204 | | |||
201 | QString Page::title(const QString& language) const | 205 | QString Page::title(const QString& language) const | ||
202 | { | 206 | { | ||
203 | return d->title.value(language); | 207 | if (d->title.count()==0) { | ||
208 | return ""; | ||||
209 | } | ||||
210 | if (!d->title.keys().contains(language)) { | ||||
211 | d->title.values().at(0); | ||||
212 | } | ||||
213 | | ||||
214 | QString title = d->title.value(language); | ||||
215 | | ||||
216 | if (title.isEmpty()) { | ||||
217 | title = d->title.values().at(0); | ||||
218 | } | ||||
219 | | ||||
220 | return title; | ||||
204 | } | 221 | } | ||
205 | 222 | | |||
206 | void Page::setTitle(const QString& title, const QString& language) | 223 | void Page::setTitle(const QString& title, const QString& language) | ||
Context not available. | |||||
213 | { | 230 | { | ||
214 | d->title[language] = title; | 231 | d->title[language] = title; | ||
215 | } | 232 | } | ||
233 | emit titlesChanged(); | ||||
216 | } | 234 | } | ||
217 | 235 | | |||
218 | QString Page::imageHref() const | 236 | QString Page::imageHref() const | ||
Context not available. | |||||
232 | 250 | | |||
233 | Textlayer * Page::textLayer(const QString& language) const | 251 | Textlayer * Page::textLayer(const QString& language) const | ||
234 | { | 252 | { | ||
253 | if (!d->textLayers.keys().contains("") && language == QString()) { | ||||
254 | return d->textLayers.values().at(0); | ||||
255 | } | ||||
235 | return d->textLayers.value(language); | 256 | return d->textLayers.value(language); | ||
236 | } | 257 | } | ||
237 | 258 | | |||
Context not available. | |||||
245 | { | 266 | { | ||
246 | d->textLayers.remove(language); | 267 | d->textLayers.remove(language); | ||
247 | } | 268 | } | ||
269 | emit textLayerLanguagesChanged(); | ||||
270 | } | ||||
271 | | ||||
272 | void Page::addTextLayer(const QString &language) | ||||
273 | { | ||||
274 | Textlayer* textLayer = new Textlayer(this); | ||||
275 | textLayer->setLanguage(language); | ||||
276 | setTextLayer(textLayer, language); | ||||
277 | } | ||||
278 | | ||||
279 | void Page::removeTextLayer(const QString &language) | ||||
280 | { | ||||
281 | setTextLayer(nullptr, language); | ||||
282 | } | ||||
283 | | ||||
284 | void Page::duplicateTextLayer(const QString &languageFrom, const QString &languageTo) | ||||
285 | { | ||||
286 | Textlayer* to = new Textlayer(this); | ||||
287 | to->setLanguage(languageTo); | ||||
288 | if (d->textLayers[languageFrom]) { | ||||
289 | Textlayer* from = d->textLayers[languageFrom]; | ||||
290 | to->setBgcolor(from->bgcolor()); | ||||
291 | for (int i=0; i<from->textareaCount(); i++) { | ||||
292 | to->addTextarea(i); | ||||
293 | to->textarea(i)->setBgcolor(from->textarea(i)->bgcolor()); | ||||
294 | to->textarea(i)->setInverted(from->textarea(i)->inverted()); | ||||
295 | to->textarea(i)->setTransparent(from->textarea(i)->transparent()); | ||||
296 | to->textarea(i)->setTextRotation(from->textarea(i)->textRotation()); | ||||
297 | to->textarea(i)->setType(from->textarea(i)->type()); | ||||
298 | to->textarea(i)->setParagraphs(from->textarea(i)->paragraphs()); | ||||
299 | for (int p=0; p<from->textarea(i)->pointCount(); p++) { | ||||
300 | to->textarea(i)->addPoint(from->textarea(i)->point(p)); | ||||
301 | } | ||||
302 | } | ||||
303 | } | ||||
304 | setTextLayer(to); | ||||
305 | } | ||||
306 | | ||||
307 | QStringList Page::textLayerLanguages() const | ||||
308 | { | ||||
309 | if (d->textLayers.isEmpty()) { | ||||
310 | return QStringList(); | ||||
311 | } | ||||
312 | return d->textLayers.keys(); | ||||
248 | } | 313 | } | ||
249 | 314 | | |||
250 | QList<Frame *> Page::frames() const | 315 | QList<Frame *> Page::frames() const | ||
Context not available. | |||||
270 | else { | 335 | else { | ||
271 | d->frames.append(frame); | 336 | d->frames.append(frame); | ||
272 | } | 337 | } | ||
338 | emit frameCountChanged(); | ||||
273 | } | 339 | } | ||
274 | 340 | | |||
275 | void Page::removeFrame(Frame* frame) | 341 | void Page::removeFrame(Frame* frame) | ||
276 | { | 342 | { | ||
277 | d->frames.removeAll(frame); | 343 | d->frames.removeAll(frame); | ||
344 | emit frameCountChanged(); | ||||
345 | } | ||||
346 | | ||||
347 | void Page::removeFrame(int index) | ||||
348 | { | ||||
349 | removeFrame(frame(index)); | ||||
278 | } | 350 | } | ||
279 | 351 | | |||
280 | bool Page::swapFrames(Frame* swapThis, Frame* withThis) | 352 | void Page::addFrame(int index) | ||
281 | { | 353 | { | ||
282 | int index1 = d->frames.indexOf(swapThis); | 354 | Frame* frame = new Frame(this); | ||
283 | int index2 = d->frames.indexOf(withThis); | 355 | addFrame(frame, index); | ||
284 | if(index1 > -1 && index2 > -1) { | 356 | } | ||
285 | d->frames.swap(index1, index2); | 357 | | ||
358 | bool Page::swapFrames(int swapThis, int withThis) | ||||
359 | { | ||||
360 | if(swapThis > -1 && withThis > -1) { | ||||
361 | d->frames.swap(swapThis, withThis); | ||||
362 | emit frameCountChanged(); | ||||
286 | return true; | 363 | return true; | ||
287 | } | 364 | } | ||
288 | return false; | 365 | return false; | ||
289 | } | 366 | } | ||
290 | 367 | | |||
368 | int Page::frameCount() | ||||
369 | { | ||||
370 | return d->frames.size(); | ||||
371 | } | ||||
372 | | ||||
291 | QList<Jump *> Page::jumps() const | 373 | QList<Jump *> Page::jumps() const | ||
292 | { | 374 | { | ||
293 | return d->jumps; | 375 | return d->jumps; | ||
Context not available. | |||||
311 | else { | 393 | else { | ||
312 | d->jumps.append(jump); | 394 | d->jumps.append(jump); | ||
313 | } | 395 | } | ||
396 | emit jumpCountChanged(); | ||||
397 | } | ||||
398 | | ||||
399 | void Page::addJump(int pageIndex, int index) | ||||
400 | { | ||||
401 | Jump* jump = new Jump(this); | ||||
402 | jump->setPageIndex(pageIndex); | ||||
403 | addJump(jump, index); | ||||
314 | } | 404 | } | ||
315 | 405 | | |||
316 | void Page::removeJump(Jump* jump) | 406 | void Page::removeJump(Jump* jump) | ||
317 | { | 407 | { | ||
318 | d->jumps.removeAll(jump); | 408 | d->jumps.removeAll(jump); | ||
409 | emit jumpCountChanged(); | ||||
410 | } | ||||
411 | | ||||
412 | void Page::removeJump(int index) | ||||
413 | { | ||||
414 | removeJump(jump(index)); | ||||
319 | } | 415 | } | ||
320 | 416 | | |||
321 | bool Page::swapJumps(Jump* swapThis, Jump* withThis) | 417 | bool Page::swapJumps(int swapThis, int withThis) | ||
322 | { | 418 | { | ||
323 | int index1 = d->jumps.indexOf(swapThis); | 419 | if(swapThis > -1 && withThis > -1) { | ||
324 | int index2 = d->jumps.indexOf(withThis); | 420 | d->jumps.swap(swapThis, withThis); | ||
325 | if(index1 > -1 && index2 > -1) { | 421 | emit jumpCountChanged(); | ||
326 | d->jumps.swap(index1, index2); | | |||
327 | return true; | 422 | return true; | ||
328 | } | 423 | } | ||
329 | return false; | 424 | return false; | ||
330 | } | 425 | } | ||
331 | 426 | | |||
427 | int Page::jumpCount() | ||||
428 | { | ||||
429 | return d->jumps.size(); | ||||
430 | } | ||||
431 | | ||||
332 | bool Page::isCoverPage() const | 432 | bool Page::isCoverPage() const | ||
333 | { | 433 | { | ||
334 | return d->isCoverPage; | 434 | return d->isCoverPage; | ||
Context not available. |