bool ProjectManager::setProjectObject(const QString &projectName, CProject *project) { if (!hasProject(projectName)) return false; if (project != 0 && project->name() == projectName && project->rootPath() == allProjectMap[projectName]) { deleteProjectObject(projectName); projectObjectMap[projectName] = project; connect(project, SIGNAL(update(const QString &)), this, SIGNAL(projectUpdated(const QString &))); return true; } else {
CProject* ProjectManager::projectObject(const QString &projectName) { if (!hasProject(projectName)) return 0; CProject *project = 0; if (projectObjectMap.contains(projectName)) { project = projectObjectMap[projectName]; if (!project->isValid()) project->update(); return project; } else { CProject *project = new CProject(projectPath(projectName)); connect(project, SIGNAL(updated(const QString &)), this, SIGNAL(projectUpdated(const QString &))); projectObjectMap[projectName] = project; return project; } }
void Project::slotAddDirectory(const KURL& p_dirURL, bool showDlg) { KURL dirURL = p_dirURL; if ( hasProject() && !dirURL.isEmpty() ) { dirURL.adjustPath(1); if ( !d->baseURL.isParentOf(dirURL) ) { KURL destination = d->baseURL; if (showDlg) { KURLRequesterDlg *urlRequesterDlg = new KURLRequesterDlg( d->baseURL.prettyURL(), d->m_mainWindow, ""); urlRequesterDlg->setCaption(i18n("%1: Copy to Project").arg(dirURL.prettyURL(0, KURL::StripFileProtocol))); urlRequesterDlg->urlRequester()->setMode( KFile::Directory | KFile::ExistingOnly); urlRequesterDlg->exec(); destination = urlRequesterDlg->selectedURL(); delete urlRequesterDlg; } if ( (showDlg == false) || (!destination.isEmpty()) ) { CopyTo *dlg = new CopyTo(d->baseURL); connect(dlg, SIGNAL(addFilesToProject(const KURL::List&)), SLOT (slotInsertFilesAfterCopying(const KURL::List&))); connect(dlg, SIGNAL(deleteDialog(CopyTo *)), d, SLOT (slotDeleteCopytoDlg(CopyTo *))); //if ( rdir.right(1) == "/" ) rdir.remove( rdir.length()-1,1); dirURL = dlg->copy(dirURL, destination); return; } else { return; } } d->insertFiles( dirURL, "*" ); //And again, insert now directly the directory name into the project. //It's important if rdir doesn't contain any files or subdirectories. d->insertFiles(dirURL); emit reloadTree( &(d->m_projectFiles), false, QStringList() ); } }