Exemple #1
0
bool Workspace::ImportLibrary(Project * project, QString libPath, QString prefixPath)
{
	// first, find the library path
	if (libPath.indexOf("/") < 0) {
		QString libName = libPath;
		libPath = config.LocateFileUsingSearchPaths(libPath, "$(LIBRARIES)", true);
		if (libPath == "") {
			msg.Add("Error importing library '" + libName + "' to project. Please add it manually from toobar button", mtError);
			return false;
		}
	}

	ImportLibraryFilesRecursively(project, libPath, libPath);

	// Add the list of all .h files to the automatically generated header file	
	QString autoFileName = qApp->applicationDirPath() + "/templates/mariamole_auto_generated.h";// config.workspace + "/" + project->name + "/source/mariamole_auto_generated.h";
	QFile autoFile(autoFileName);
	autoFile.open(QFile::ReadOnly | QFile::Text);
    QTextStream stream(&autoFile);
	QString fileContent = stream.readAll();
	autoFile.close();

	// Remove the last #endif from the file
	while (fileContent.at(fileContent.length()-1) != '#') {
		fileContent.remove(fileContent.length()-1, 1);
	}
	fileContent.remove(fileContent.length()-1, 1);
	//fileContent; += "\n\n";

	// add all header files
	for (int i=0; i < project->files.size(); i++) {
		if (project->files.at(i).type == ptExternal) {
			QString name = QFileInfo(project->files.at(i).name).fileName();
			QString ext = QFileInfo(project->files.at(i).name).suffix().toUpper();
			if ( (ext == "H") || (ext == "HPPC") ) {
				fileContent += "#include <" + name + ">\n";
			}
		}
	}
	fileContent += "\n#endif\n";

	autoFileName = config.workspace + "/" + project->name + "/source/mariamole_auto_generated.h";
	QFile autoFileOutput(autoFileName);	
	autoFileOutput.open(QFile::WriteOnly);
	//autoFileOutput.setlin
	//setEolMode(QsciScintilla::EolUnix);
    QTextStream streamOutput(&autoFileOutput);	
	streamOutput << fileContent;
	autoFileOutput.close();

	modified = true;

	return true;
}
Exemple #2
0
void MainWindow::openFile( int argc, char *argv[] )
{
  QString file;
  qDebug() << "ARGC: " << argc;
  qDebug() << "ARGV: " << argv;

  bool res = false;
  if( argc > 1 ) {
    file = argv[1];
  } else {
    file = autoFile();
    qDebug() << "Auto-File found: " << file;
  }
  res = mController->loadFile( file );

  if( ! res ) {
    file = QFileDialog::getOpenFileName( this, tr("Pick a Zippl file to Open"),
                                         QDir::homePath(), tr("Zippl Files (*xml)"));
    res = mController->loadFile( file );
  }
  if( ! res ) exit(0);
}