void FBView::doTapScrolling(int y) { if (2 * y < context().height()) { fbreader().doAction(ActionCode::TAP_SCROLL_BACKWARD); } else { fbreader().doAction(ActionCode::TAP_SCROLL_FORWARD); } }
bool NetLibraryView::_onStylusMove(int x, int y) { if (!model().isNull()) { const ZLTextElementArea *imageArea = elementByCoordinates(x, y); if ((imageArea != 0) && (imageArea->Kind == ZLTextElement::IMAGE_ELEMENT)) { fbreader().setHyperlinkCursor(true); return true; } } fbreader().setHyperlinkCursor(false); return false; }
bool RecentBooksView::_onStylusPress(int x, int y) { const Books &books = myLastBooks.books(); int index = paragraphIndexByCoordinate(y); if ((index == -1) || (index >= (int)books.size())) { return false; } fbreader().openBook(books[index]); fbreader().showBookTextView(); return true; }
bool BookTextView::onStylusMove(int x, int y) { const ZLTextElementArea *area = elementByCoordinates(x, y); std::string id; std::string type; if ((area != 0) && getHyperlinkInfo(*area, id, type)) { fbreader().setHyperlinkCursor(true); return (type == "internal" ? true : false); } fbreader().setHyperlinkCursor(false); return false; }
bool RecentBooksView::onStylusPress(int x, int y) { if (TextView::onStylusPress(x, y)) { return true; } const Books &books = myLastBooks.books(); const ParagraphPosition *position = paragraphByCoordinate(y); if ((position == 0) || (position->ParagraphNumber >= (int)books.size())) { return false; } fbreader().openBook(books[position->ParagraphNumber]); fbreader().showBookTextView(); return true; }
bool BookTextView::onStylusMove(int x, int y) { const ZLTextElementArea *area = elementByCoordinates(x, y); std::string id; bool isExternal; fbreader().setHyperlinkCursor((area != 0) && getHyperlinkId(*area, id, isExternal)); return true; }
bool BookTextView::_onStylusMove(int x, int y) { const ZLTextElementArea *area = elementByCoordinates(x, y); std::string id; std::string type; fbreader().setHyperlinkCursor((area != 0) && getHyperlinkInfo(*area, id, type)); return true; }
bool CollectionView::_onStylusPress(int x, int y) { fbreader().setHyperlinkCursor(false); const ZLTextElementArea *imageArea = elementByCoordinates(x, y); if ((imageArea != 0) && (imageArea->Kind == ZLTextElement::IMAGE_ELEMENT)) { ZLTextWordCursor cursor = startCursor(); cursor.moveToParagraph(imageArea->ParagraphIndex); cursor.moveTo(imageArea->ElementIndex, 0); const ZLTextElement &element = cursor.element(); if (element.kind() != ZLTextElement::IMAGE_ELEMENT) { return false; } const ZLTextImageElement &imageElement = (ZLTextImageElement&)element; const std::string &id = imageElement.id(); if (id == CollectionModel::BookInfoImageId) { editBookInfo(collectionModel().bookByParagraphIndex(imageArea->ParagraphIndex)); return true; } else if (id == CollectionModel::RemoveBookImageId) { removeBook(collectionModel().bookByParagraphIndex(imageArea->ParagraphIndex)); return true; } else if (id == CollectionModel::RemoveTagImageId) { removeTag(collectionModel().tagByParagraphIndex(imageArea->ParagraphIndex)); return true; } else if (id == CollectionModel::TagInfoImageId) { editTagInfo(collectionModel().tagByParagraphIndex(imageArea->ParagraphIndex)); return true; } else { return false; } } int index = paragraphIndexByCoordinates(x, y); if (index == -1) { return false; } BookDescriptionPtr book = collectionModel().bookByParagraphIndex(index); if (!book.isNull()) { fbreader().openBook(book); fbreader().showBookTextView(); return true; } return false; }
bool ContentsView::_onStylusPress(int x, int y) { int index = paragraphIndexByCoordinate(y); if ((index < 0) || ((int)model()->paragraphsNumber() <= index)) { return false; } const ContentsModel &contentsModel = (const ContentsModel&)*model(); const ZLTextTreeParagraph *paragraph = (const ZLTextTreeParagraph*)contentsModel[index]; int reference = contentsModel.reference(paragraph); if (reference != -1) { fbreader().bookTextView().gotoParagraph(reference); fbreader().showBookTextView(); } return true; }
void NetLibraryView::search() { const std::string pattern = fbreader().visualParameter(NetLibraryView::SEARCH_PARAMETER_ID); if (pattern.empty()) { return; } SimpleSearchRunnable runnable(pattern); search(runnable); }
bool ContentsView::onStylusPress(int x, int y) { if (TextView::onStylusPress(x, y)) { return true; } const ParagraphPosition *position = paragraphByCoordinate(y); if (position == 0) { return false; } int paragraphNumber = position->ParagraphNumber; if ((paragraphNumber < 0) || ((int)model()->paragraphsNumber() < paragraphNumber)) { return false; } const ParagraphWithReference *paragraph = (const ParagraphWithReference*)(*model())[paragraphNumber]; fbreader().bookTextView().gotoParagraph(paragraph->reference()); fbreader().showBookTextView(); return true; }
void BookTextView::scrollToHome() { if (!startCursor().isNull() && startCursor().isStartOfParagraph() && startCursor().paragraphCursor().index() == 0) { return; } gotoParagraph(0, false); fbreader().refreshWindow(); }
bool CollectionView::_onStylusMove(int x, int y) { const ZLTextElementArea *imageArea = elementByCoordinates(x, y); if ((imageArea != 0) && (imageArea->Kind == ZLTextElement::IMAGE_ELEMENT)) { fbreader().setHyperlinkCursor(true); return true; } int index = paragraphIndexByCoordinates(x, y); if (index != -1) { BookDescriptionPtr book = collectionModel().bookByParagraphIndex(index); if (!book.isNull()) { fbreader().setHyperlinkCursor(true); return true; } } fbreader().setHyperlinkCursor(false); return false; }
bool FBView::onStylusPress(int x, int y) { if (ZLTextView::onStylusPress(x, y)) { return true; } if (_onStylusPress(x, y)) { return true; } if (fbreader().EnableTapScrollingOption.value() && (!ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::FINGER_TAP_DETECTABLE, false).value() || !fbreader().TapScrollingOnFingerOnlyOption.value())) { doTapScrolling(y); return true; } activateSelection(x, y); return true; }
bool FBView::onStylusRelease(int x, int y) { if (ZLTextView::onStylusRelease(x, y)) { return true; } if (_onStylusRelease(x, y)) { return true; } myIsReleasedWithoutMotion = myIsReleasedWithoutMotion && (abs(x - pressedX()) <= 5) && (abs(y - pressedY()) <= 5); if (isReleasedWithoutMotion() && fbreader().EnableTapScrollingOption.value() && (!ZLBooleanOption(ZLCategoryKey::EMPTY, ZLOption::PLATFORM_GROUP, ZLOption::FINGER_TAP_DETECTABLE, false).value() || !fbreader().TapScrollingOnFingerOnlyOption.value())) { doTapScrolling(y); return true; } return false; }
bool BookTextView::_onStylusPress(int x, int y) { const ZLTextElementArea *area = elementByCoordinates(x, y); if (area != 0) { std::string id; bool isExternal; if (getHyperlinkId(*area, id, isExternal)) { fbreader().tryShowFootnoteView(id, isExternal); return true; } if (fbreader().isDictionarySupported() && fbreader().EnableSingleClickDictionaryOption.value()) { const std::string txt = word(*area); if (!txt.empty()) { fbreader().openInDictionary(txt); return true; } } } return false; }
void ContentsView::gotoReference() { const WordCursor &cursor = fbreader().bookTextView().endCursor(); if (!cursor.isNull()) { long reference = cursor.paragraphCursor().index(); size_t selected = model()->paragraphsNumber() - 1; for (size_t i = 1; i < model()->paragraphsNumber(); ++i) { if (((const ParagraphWithReference*)(*model())[i])->reference() >= reference) { selected = i - 1; break; } } selectParagraph(selected); gotoParagraph(selected); if (selected != model()->paragraphsNumber() - 1) { scrollPage(false, TextView::SCROLL_PERCENTAGE, 40); } } }
size_t ContentsView::currentTextViewParagraph(bool includeStart) const { const ZLTextWordCursor &cursor = fbreader().bookTextView().startCursor(); if (!cursor.isNull()) { long reference = cursor.paragraphCursor().index(); bool startOfParagraph = cursor.wordNumber() == 0; if (cursor.isEndOfParagraph()) { ++reference; startOfParagraph = true; } size_t length = model()->paragraphsNumber(); const ContentsModel &contentsModel = (const ContentsModel&)*model(); for (size_t i = 1; i < length; ++i) { long contentsReference = contentsModel.reference(((const ZLTextTreeParagraph*)contentsModel[i])); if ((contentsReference > reference) || (!includeStart && startOfParagraph && (contentsReference == reference))) { return i - 1; } } return length - 1; } return (size_t)-1; }
void FBView::scrollAndUpdatePage(bool forward, ScrollingMode mode, unsigned int value) { scrollPage(forward, mode, value); preparePaintInfo(); fbreader().refreshWindow(); }
void BookTextView::paint() { FBView::paint(); std::string pn; ZLStringUtil::appendNumber(pn, pageIndex()); fbreader().setVisualParameter(FBReader::PageIndexParameter, pn); }
void BooksOrderAction::run() { fbreader().refreshWindow(); }
bool NetLibraryView::_onStylusPress(int x, int y) { fbreader().setHyperlinkCursor(false); if (model().isNull()) { return false; } const ZLTextElementArea *imageArea = elementByCoordinates(x, y); if ((imageArea == 0) || (imageArea->Kind != ZLTextElement::IMAGE_ELEMENT)) { return false; } ZLTextWordCursor cursor = startCursor(); cursor.moveToParagraph(imageArea->ParagraphIndex); cursor.moveTo(imageArea->ElementIndex, 0); const ZLTextElement &element = cursor.element(); if (element.kind() != ZLTextElement::IMAGE_ELEMENT) { return false; } const ZLTextImageElement &imageElement = (ZLTextImageElement&)element; const std::string &id = imageElement.id(); shared_ptr<NetworkBookInfo> book = myParagraphToBookMap[imageArea->ParagraphIndex]; if (book.isNull()) { return false; } if ((id == DownloadEpub) || (id == DownloadMobi)) { if (!ZLNetworkManager::instance().connect()) { NetworkOperationRunnable::showErrorMessage( ZLResource::resource("dialog") ["networkError"] ["couldntConnectToNetworkMessage"].value() ); return false; } NetworkBookInfo::URLType format = (id == DownloadEpub) ? NetworkBookInfo::BOOK_EPUB : NetworkBookInfo::BOOK_MOBIPOCKET; DownloadBookRunnable downloader(*book, format); downloader.executeWithUI(); if (downloader.hasErrors()) { downloader.showErrorMessage(); } else { BookDescriptionPtr description = BookDescription::getDescription(downloader.fileName()); WritableBookDescription wDescription(*description); wDescription.clearAuthor(); wDescription.addAuthor(book->Author.DisplayName, book->Author.SortKey); wDescription.title() = book->Title; wDescription.language() = book->Language; for (std::vector<std::string>::const_iterator it = book->Tags.begin(); it != book->Tags.end(); ++it) { wDescription.addTag(*it); } wDescription.saveInfo(); fbreader().openBook(description); fbreader().setMode(FBReader::BOOK_TEXT_MODE); rebuildModel(); } return true; } else if ((id == ReadLocalEpub) || (id == ReadLocalMobi)) { NetworkBookInfo::URLType format = (id == DownloadEpub) ? NetworkBookInfo::BOOK_EPUB : NetworkBookInfo::BOOK_MOBIPOCKET; fbreader().openFile(NetworkLinkCollection::instance().bookFileName(book->URLByType[format])); fbreader().setMode(FBReader::BOOK_TEXT_MODE); return true; } else if (id == OpenInBrowser) { std::string url = book->URLByType[NetworkBookInfo::LINK_HTTP]; shared_ptr<ProgramCollection> collection = fbreader().webBrowserCollection(); if (!url.empty() && !collection.isNull()) { shared_ptr<Program> program = collection->currentProgram(); if (!program.isNull()) { program->run("openLink", url); } } return true; } return false; }