Esempio n. 1
0
void FBReader::tryShowFootnoteView(const std::string &id, const std::string &type) {
	if (type == "external") {
		shared_ptr<ProgramCollection> collection = webBrowserCollection();
		if (!collection.isNull()) {
			shared_ptr<Program> program = collection->currentProgram();
			if (!program.isNull()) {
				program->run("openLink", id);
			}
		}
	} else if (type == "internal") {
		if (((myMode == BOOK_TEXT_MODE) || (myMode == FOOTNOTE_MODE) || (myMode == HYPERLINK_NAV_MODE)) && (myModel != 0)) {
			BookModel::Label label = myModel->label(id);
			if (!label.Model.isNull()) {
				if ((myMode != FOOTNOTE_MODE) && (label.Model == myModel->bookTextModel())) {
					bookTextView().gotoParagraph(label.ParagraphNumber);
				} else {
					FootnoteView &view = ((FootnoteView&)*myFootnoteView);
					view.setModel(label.Model, myModel->description()->language());
					setMode(FOOTNOTE_MODE);
					view.gotoParagraph(label.ParagraphNumber);
				}
				setHyperlinkCursor(false);
				refreshWindow();
			}
		}
	} else if (type == "book") {
		DownloadBookRunnable downloader(id);
		downloader.executeWithUI();
		if (downloader.hasErrors()) {
			downloader.showErrorMessage();
		} else {
			openFile(downloader.fileName());
		}
	}
}
Esempio n. 2
0
void FBReader::tryShowFootnoteView(const std::string &id, bool external) {
	if (external) {
		shared_ptr<ProgramCollection> collection = webBrowserCollection();
		if (!collection.isNull()) {
			shared_ptr<Program> program = collection->currentProgram();
			if (!program.isNull()) {
				program->run("openLink", id);
			}
		}
	} else {
		if ((myMode == BOOK_TEXT_MODE) && (myModel != 0)) {
			BookModel::Label label = myModel->label(id);
			if (!label.Model.isNull()) {
				if (label.Model == myModel->bookTextModel()) {
					bookTextView().gotoParagraph(label.ParagraphNumber);
				} else {
					FootnoteView &view = ((FootnoteView&)*myFootnoteView);
					view.setModel(label.Model);
					setMode(FOOTNOTE_MODE);
					view.gotoParagraph(label.ParagraphNumber);
				}
				setHyperlinkCursor(false);
				refreshWindow();
			}
		}
	}
}
Esempio n. 3
0
void FBReader::openLinkInBrowser(const std::string &url) const {
    if (url.empty()) {
        return;
    }
    shared_ptr<ProgramCollection> collection = webBrowserCollection();
    if (collection.isNull()) {
        return;
    }
    shared_ptr<Program> program = collection->currentProgram();
    if (program.isNull()) {
        return;
    }
    std::string copy = url;
    NetworkLinkCollection::Instance().rewriteUrl(copy, true);
    ZLLogger::Instance().println("URL", copy);
    program->run("openLink", copy);
}