Exemplo n.º 1
0
void FBReader::initWindow() {
	ZLApplication::initWindow();
	trackStylus(true);

	MigrationRunnable migration;
	if (migration.shouldMigrate()) {
		ZLDialogManager::instance().wait(ZLResourceKey("migrate"), migration);
	}

	if (!myBookAlreadyOpen) {
		BookDescriptionPtr description;
		if (!myBookToOpen.empty()) {
			createDescription(myBookToOpen, description);
		}
		if (description.isNull()) {
			ZLStringOption bookName(ZLCategoryKey::STATE, STATE, BOOK, "");
			description = BookDescription::getDescription(bookName.value());
		}
		if (description.isNull()) {
			description = BookDescription::getDescription(helpFileName(ZLibrary::Language()));
		}
		if (description.isNull()) {
			description = BookDescription::getDescription(helpFileName("en"));
		}
		openBook(description);
	}
	refreshWindow();

//	ZLTimeManager::instance().addTask(new TimeUpdater(*this), 1000);
}
Exemplo n.º 2
0
std::string KMLNetOutput::createPlacemark(FPType x1, FPType y1, FPType x2,
		FPType y2, StarLink* link){ 
	std::stringstream ss;

	int linkIndex = link->getIndex();
	std::string placemark;
	placemark.append(createStyleForLink(linkIndex, calcLineWidth(link)));

	placemark.append("<Placemark>\n");
	
	placemark.append(createDescription(link));

	ss << "\t<styleUrl>#style" << linkIndex << "</styleUrl>\n";
	placemark.append(ss.str());
    placemark.append("\t\t<LineString>\n");
    placemark.append("\t\t\t" + createCoordLine(x1, y1, x2, y2)); 
    placemark.append("\t\t</LineString> \n");
    placemark.append("</Placemark> \n");

    placemark.append("<Placemark>\n");
    ss.str("");
    placemark.append("\t<styleUrl>#styleEmpty</styleUrl>\n");
    placemark.append("<Point>\n");
    ss.str("");
    ss << "<coordinates> " << x1 << ", " << y1 << ", 0 </coordinates> \n";
    placemark.append(ss.str());
    placemark.append("</Point>\n");
	placemark.append("</Placemark> \n");    
    return placemark;
};
Exemplo n.º 3
0
void FBReader::openFile(const std::string &fileName) {
	BookDescriptionPtr description;
	createDescription(fileName, description);
	if (!description.isNull()) {
		openBook(description);
		refreshWindow();
	}
}
Exemplo n.º 4
0
bool FBReader::createDescription(const std::string& fileName, BookDescriptionPtr &description) {
	ZLFile bookFile = ZLFile(fileName);

	FormatPlugin *plugin = PluginCollection::instance().plugin(ZLFile(fileName), false);
	if (plugin != 0) {
		std::string error = plugin->tryOpen(fileName);
		if (!error.empty()) {
			ZLResourceKey boxKey("openBookErrorBox");
			ZLDialogManager::instance().errorBox(
				boxKey,
				ZLStringUtil::printf(ZLDialogManager::dialogMessage(boxKey), error)
			);
		} else {
			BookList().addFileName(bookFile.path());
			description = BookDescription::getDescription(bookFile.path());
		}
		return true;
	}

	if (!bookFile.isArchive()) {
		return false;
	}

	std::queue<std::string> archiveNames;
	archiveNames.push(bookFile.path());

	std::vector<std::string> items;

	while (!archiveNames.empty()) {
		shared_ptr<ZLDir> archiveDir = ZLFile(archiveNames.front()).directory();
		archiveNames.pop();
		if (archiveDir.isNull()) {
			continue;
		}
		archiveDir->collectFiles(items, true);
		for (std::vector<std::string>::const_iterator it = items.begin(); it != items.end(); ++it) {
			const std::string itemName = archiveDir->itemPath(*it);
			ZLFile subFile(itemName);
			if (subFile.isArchive()) {
				archiveNames.push(itemName);
			} else if (createDescription(itemName, description)) {
				return true;
			}
		}
		items.clear();
	}

	return 0;
}
Exemplo n.º 5
0
int main( int argc, char **argv )
{
    if ( argc < 2 )
	return -1;
    QString fn = argv[1];
    QFile f( fn );
    if ( !f.open( IO_WriteOnly ) )
	return -1;
    QTextStream ts( &f );
    QApplication a( argc, argv );

    QValueList<Widget> wl;

    // STEP2: Instantiate all widgets for which a description should
    // be created here and add them to the list wl. If your custom widget
    // is e.g. called MyCustomWidget you would write here
    //
    // Widget w;
    // w.w = new MyCustomWidget( 0, 0 );
    // w.include = "mycustomwidget.h";
    // w.location = "global";
    // wl.append( w );
    //
    // After that compile the program, link it with your custom widget
    // (library or object file) and run it like this:
    // (unix): ./createcw mywidgets.cw
    // (win32): createcw mywidgets.cw
    //
    // After that you can import this description file into the Qt
    // Designer using the Custom-Widget Dialog (See
    // Tools->Custom->Edit Custom Widgets... in the Qt Designer)
    // and use these custom widget there in your forms.



    // ----------------------------------------------

    createDescription( wl, ts );
    f.close();
    return 0;
}