Exemplo n.º 1
0
/**
 * Handles the "Project->New..." command.
 * Prompts the user for the name and folder for the project, and then creates
 * the project.
 */
void KScope::slotCreateProject()
{
	NewProjectDlg dlg(true, this);
	ProjectBase::Options opt;
	QString sProjPath;
	
	// Prompt the user to close any active projects
	if (m_pProjMgr->curProject()) {
		if (KMessageBox::questionYesNo(0, 
			i18n("The current project needs to be closed before a new one is"
			" created.\nWould you like to close it now?")) != 
			KMessageBox::Yes) {
			return;
		}
		
		// Try to close the project.
		if (!slotCloseProject())
			return;
	}
	
	// Display the "New Project" dialog
	if (dlg.exec() != QDialog::Accepted)
		return;

	// Create and open the new project
	dlg.getOptions(opt);
	if (m_pProjMgr->create(dlg.getName(), dlg.getPath(), opt, sProjPath))
		openProject(sProjPath);
}
Exemplo n.º 2
0
void Project::slotNewProject()
{
    QString fileName = QFileDialog::getSaveFileName(this, tr("New Project"),
                                                    "", tr("Qucs Projects (*.xpro)"));
    if(!fileName.isEmpty()) {
        if(QString(QFileInfo(fileName).suffix()).isEmpty()) {
            fileName = fileName + ".xpro";
        }

        //First we create the folder structure where files are to be placed
        QFileInfo fileInfo = QFileInfo(fileName);
        QDir filePath = QDir(fileInfo.absolutePath() + "/" + fileInfo.baseName());
        if(!filePath.exists()) {
            filePath.setPath(fileInfo.absolutePath());
            filePath.mkdir(fileInfo.baseName());
        }
        fileName = fileInfo.absolutePath() + "/" + fileInfo.baseName() + "/" + fileInfo.fileName();

        //Then we create the library/project
        LibraryLoader *library = LibraryLoader::instance();

        if(library->newLibrary(fileName)) {
            slotCloseProject();
            setCurrentLibrary(fileName);
            projectLibrary = library->library(m_libraryName);
            projectLibrary->saveLibrary();
            qDebug() << "Succesfully created library!";
            m_projectsSidebar->plugLibrary(m_libraryName, "root");
        }
    }
}
Exemplo n.º 3
0
/**
 * Called when a request has been issued to close the main window.
 * Tries to close the active project.
 * @return	true if the main window can be closed, false otherwise
 */
bool KScope::queryClose()
{
	bool bResult;

	m_bUpdateGUI = false;
	bResult = slotCloseProject();
	m_bUpdateGUI = true;

	return bResult;
}
Exemplo n.º 4
0
void 
pcl::modeler::MainWindow::connectFileMenuActions()
{
  connect(this->ui_->actionOpenPointCloud, SIGNAL(triggered()), this, SLOT(slotOpenPointCloud()));
  connect(this->ui_->actionImportPointCloud, SIGNAL(triggered()), this, SLOT(slotImportPointCloud()));
  connect(this->ui_->actionSavePointCloud, SIGNAL(triggered()), this, SLOT(slotSavePointCloud()));
  connect(this->ui_->actionClosePointCloud, SIGNAL(triggered()), this, SLOT(slotClosePointCloud()));
  createRecentPointCloudActions();

  connect(this->ui_->actionOpenProject, SIGNAL(triggered()), this, SLOT(slotOpenProject()));
  connect(this->ui_->actionSaveProject, SIGNAL(triggered()), this, SLOT(slotSaveProject()));
  connect(this->ui_->actionCloseProject, SIGNAL(triggered()), this, SLOT(slotCloseProject()));
  createRecentProjectActions();

  connect(this->ui_->actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));
}
Exemplo n.º 5
0
void Project::slotOpenProject(QString fileName)
{
    if(fileName == 0) {
        fileName = QFileDialog::getOpenFileName(this, tr("Open Project"),
                                                "", tr("Qucs Projects (*.xpro)"));
    }

    if(!fileName.isEmpty()) {

        LibraryLoader *library = LibraryLoader::instance();

        if(library->load(fileName)) {
            slotCloseProject();
            setCurrentLibrary(fileName);
            projectLibrary = library->library(m_libraryName);
            qDebug() << "Succesfully loaded library!";
            m_projectsSidebar->plugLibrary(m_libraryName, "root");
        }
    }
}
Exemplo n.º 6
0
CMainWindow::CMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::CMainWindow)
  ,currentProject("")
{
    ui->setupUi(this);
    connect(ui->buildNetwork,SIGNAL(clicked()),this,SLOT(slotBuildNetwork()));
    connect(ui->testNetwork,SIGNAL(clicked()),this,SLOT(slotTestNetwork()));
    connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(slotNewProject()));
    connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(slotLoadProject()));
    connect(ui->actionClose,SIGNAL(triggered()),this,SLOT(slotCloseProject()));
    connect(ui->errorLevel,SIGNAL(sliderMoved(int)),this,SLOT(slotErrorLevelChanged(int)));
    connect(ui->errorPercent,SIGNAL(sliderMoved(int)),this,SLOT(slotErrorPercentChanged(int)));
    connect(ui->actionSettings,SIGNAL(triggered()),this,SLOT(slotSettings()));
    ui->buildNetwork->setEnabled(false);
    ui->testNetwork->setEnabled(false);
    slotErrorLevelChanged(10);
    slotErrorPercentChanged(10);
    network = 0;
    plotter = 0;
}
Exemplo n.º 7
0
/**
 * Opens a temporary project for a Cscope.out file.
 * @param	sFilePath	The full path of the Cscope.out file
 * @return	true if successful, false otherwise
 */
bool KScope::openCscopeOut(const QString& sFilePath)
{
	ProjectBase* pProj;
	
	// Close the current project (may return false if the user clicks on the
	// "Cancel" button while prompted to save a file)
	if (!slotCloseProject())
		return false;

	// Open a temporary project for this cscope.out file
	if (!m_pProjMgr->openCscopeOut(sFilePath))
		return false;
	
	// Change main window title
	pProj = m_pProjMgr->curProject();
	setCaption(pProj->getName());
	
	// Set the root folder in the file tree
	m_pFileView->setRoot(pProj->getSourceRoot());
	
	// Initialise Cscope and create a builder object
	initCscope();
	
	// Create an initial query page
	m_pQueryWidget->addQueryPage();
	
	// Enable project-related actions
	m_pActions->slotEnableProjectActions(true);
	
	// Fill the file list with all files in the project. 
	m_pFileList->setUpdatesEnabled(false);
	pProj->loadFileList(m_pFileList);
	m_pFileList->setUpdatesEnabled(true);
	
	return true;
}
Exemplo n.º 8
0
/*! Constructor
 * \brief This class implements the project management
 *
 * This also handles the mouse and keyboad events, and sends
 * when appropiate, the file names to be opened by the parent.
 *
 * \param parent Parent of the widget.
 */
Project::Project(QWidget *parent) : QWidget(parent)
{
    projectLibrary = 0;
    m_libraryFileName = "";
    m_libraryName = "";

    QVBoxLayout *layout = new QVBoxLayout(this);

    QToolBar *toolbar = new QToolBar;

    QToolButton *projNew = new QToolButton();
    projNew->setIcon(QIcon(Qucs::bitmapDirectory() + "project-new.png"));
    projNew->setStatusTip(tr("Creates a new project"));
    projNew->setToolTip(tr("Creates a new project"));
    projNew->setWhatsThis(tr("New Project\n\nCreates a new project"));

    QToolButton *projOpen = new QToolButton();
    projOpen->setIcon(QIcon(Qucs::bitmapDirectory() + "fileopen.png"));
    projOpen->setStatusTip(tr("Opens an existing project"));
    projOpen->setToolTip(tr("Opens an existing project"));
    projOpen->setWhatsThis(tr("Open Project\n\nOpens an existing project"));

    QToolButton *addToProj = new QToolButton();
    addToProj->setIcon(QIcon(Qucs::bitmapDirectory() + "filenew.png"));
    addToProj->setStatusTip(tr("Adds a file to current project"));
    addToProj->setToolTip(tr("Adds a file to current project"));
    addToProj->setWhatsThis(tr("Add File to Project\n\nAdds a file to current project"));

    QToolButton *projDel = new QToolButton();
    projDel->setIcon(QIcon(Qucs::bitmapDirectory() + "fileclose.png"));
    projDel->setStatusTip(tr("Removes a file from current project"));
    projDel->setToolTip(tr("Removes a file from current project"));
    projDel->setWhatsThis(tr("Remove from Project\n\nRemoves a file from current project"));

    QToolButton *projClose = new QToolButton();
    projClose->setIcon(QIcon(Qucs::bitmapDirectory() + "project-close.png"));
    projClose->setStatusTip(tr("Closes the current project"));
    projClose->setToolTip(tr("Closes the current project"));
    projClose->setWhatsThis(tr("Close Project\n\nCloses the current project"));

    connect(projNew, SIGNAL(clicked()), this, SLOT(slotNewProject()));
    connect(projOpen, SIGNAL(clicked()), this, SLOT(slotOpenProject()));
    connect(addToProj, SIGNAL(clicked()), this, SLOT(slotAddToProject()));
    connect(projDel, SIGNAL(clicked()), this, SLOT(slotRemoveFromProject()));
    connect(projClose, SIGNAL(clicked()), this, SLOT(slotCloseProject()));

    toolbar->addWidget(projNew);
    toolbar->addWidget(projOpen);
    toolbar->addWidget(addToProj);
    toolbar->addWidget(projDel);
    toolbar->addWidget(projClose);

    m_projectsSidebar = new ComponentsSidebar(this);
    connect(m_projectsSidebar, SIGNAL(itemClicked(const QString&, const QString&)), this,
            SLOT(slotOnClicked(const QString&, const QString&)));
    connect(m_projectsSidebar, SIGNAL(itemDoubleClicked(const QString&, const QString&)), this,
            SLOT(slotOnDoubleClicked(const QString&, const QString&)));


    layout->addWidget(toolbar);
    layout->addWidget(m_projectsSidebar);

    setWindowTitle(tr("Project View"));
}
Exemplo n.º 9
0
/**
 * Opens a project.
 * If another project is currently active, it is closed first.
 * @param	sDir	The directory of the project to open.
 */
void KScope::openProject(const QString& sDir)
{
	QString sProjDir;
	ProjectBase* pProj;
	QStringList slQueryFiles;
	QStringList slCallTreeFiles;
	QStringList slArgs;
	ProjectBase::Options opt;
	
	// Close the current project (may return false if the user clicks on the
	// "Cancel" button while prompted to save a file)
	if (!slotCloseProject())
		return;

	// Open the project in the project manager
	sProjDir = QDir::cleanDirPath(sDir);
	if (!m_pProjMgr->open(sProjDir))
		return;
	
	// Change main window title
	pProj = m_pProjMgr->curProject();
	setCaption(pProj->getName());

	// Set the root of the file tree
	m_pFileView->setRoot(pProj->getSourceRoot());
	
	// Initialise Cscope and create a builder object
	initCscope();
	
	// Set auto-completion parameters
	pProj->getOptions(opt);
	SymbolCompletion::initAutoCompletion(opt.bACEnabled, opt.nACMinChars,
		opt.nACDelay, opt.nACMaxEntries);
	
	// Set per-project command-line arguments for Ctags
	CtagsFrontend::setExtraArgs(opt.sCtagsCmd);
	
	// Create an initial query page
	m_pQueryWidget->addQueryPage();
	
	// Enable project-related actions
	m_pActions->slotEnableProjectActions(true);
	
	// If this is a new project (i.e., no source files are yet included), 
	// display the project files dialogue
	if (pProj->isEmpty()) {
		slotProjectFiles();
		return;
	}
	
	// Fill the file list with all files in the project. 
	m_pFileList->setUpdatesEnabled(false);
	pProj->loadFileList(m_pFileList);
	m_pFileList->setUpdatesEnabled(true);
	
	// Restore the last session
	restoreSession();
	
	// Rebuild the cross-reference database
	if (isAutoRebuildEnabled()) {
		// If Cscope installation was not yet verified, postpone the build
		// process
		if (m_bCscopeVerified)
		slotRebuildDB();
		else
			m_bRebuildDB = true;
	}
}