Пример #1
0
QFFCCSFileSetsModel::QFFCCSFileSetsModel(QFFCCSFitEvaluationItem *parent) :
    QAbstractListModel(parent)
{
    FCCSfit=parent;
    qRegisterMetaType<QList<QFRawDataRecord*> >("QList<QFRawDataRecord*>");
    rebuildModel();
}
Пример #2
0
void NetLibraryView::search(SearchRunnable &runnable) {
	if (!ZLNetworkManager::instance().connect()) {
		NetworkOperationRunnable::showErrorMessage(
			ZLResource::resource("dialog")
				["networkError"]
				["couldntConnectToNetworkMessage"].value()
		);
		return;
	}

	runnable.executeWithUI();

	runnable.showErrorMessage();

	const NetworkBookList &bookList = runnable.bookList();
	if (!bookList.empty()) {
		myBookList = bookList;
		rebuildModel();
	} else if (myBookList.empty()) {
		ZLTextPlainModel *resultsModel = new ZLTextPlainModel(8192);
		resultsModel->createParagraph(ZLTextParagraph::TEXT_PARAGRAPH);
		resultsModel->addControl(LIBRARY_ENTRY, true);
		resultsModel->addText(myResource["notFound"].value());
		setModel(resultsModel, ZLibrary::Language());
	}
}
Пример #3
0
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;
}
Пример #4
0
void ptImageSpotModel::appendSpot(ptImageSpot *ANewSpot) {
  FSpotList->append(ANewSpot);
  rebuildModel();
}