void Project::insertFile(const KURL& nameURL, bool repaint ) { if (d->excludeRx.exactMatch(nameURL.path())) return; KURL url = nameURL; if ( !d->baseURL.isParentOf(url) ) { KURLRequesterDlg *urlRequesterDlg = new KURLRequesterDlg( d->baseURL.prettyURL(), d->m_mainWindow, ""); urlRequesterDlg->setCaption(i18n("%1: Copy to Project").arg(nameURL.prettyURL(0, KURL::StripFileProtocol))); urlRequesterDlg->urlRequester()->setMode( KFile::Directory | KFile::ExistingOnly); urlRequesterDlg->exec(); KURL destination = urlRequesterDlg->selectedURL(); if (destination.isLocalFile()) { QDir dir(destination.path()); destination.setPath(dir.canonicalPath()); } delete urlRequesterDlg; if ( !destination.isEmpty() ) { CopyTo *dlg = new CopyTo(d->baseURL); connect(dlg, SIGNAL(deleteDialog(CopyTo*)), d, SLOT(slotDeleteCopytoDlg(CopyTo*))); url = dlg->copy( nameURL, destination ); } else // Copy canceled, addition aborted { return; } } QDomElement el; while ( d->baseURL.isParentOf(url) ) { if ( !d->m_projectFiles.contains(url) ) { el = d->dom.createElement("item"); el.setAttribute("url", QuantaCommon::qUrl( QExtFileInfo::toRelative(url, d->baseURL) )); d->dom.firstChild().firstChild().appendChild( el ); KURL u = url.upURL(); ProjectURL *parentURL = d->m_projectFiles.find(u); int uploadStatus = 1; if (parentURL) uploadStatus = parentURL->uploadStatus; d->m_projectFiles.insert( new ProjectURL(url, "", uploadStatus, false, el) ); } url.setPath(url.directory(false)); } emit eventHappened("after_project_add", url.url(), QString::null); setModified(); if ( repaint ) { emit reloadTree( &(d->m_projectFiles), false, QStringList()); emit newStatus(); } }
/** No descriptions */ void ProjectNewLocal::slotAddFiles() { QExtFileInfo::createDir(baseURL, this); KURL::List list = KFileDialog::getOpenURLs( baseURL.url(), i18n("*"), this, i18n("Insert Files in Project")); if ( !list.isEmpty() ) { KURL u = list.first(); u = QExtFileInfo::toRelative( u, baseURL, false ); if ( u.path().startsWith("..") || u.path().startsWith("/")) { KURLRequesterDlg *urlRequesterDlg = new KURLRequesterDlg( baseURL.prettyURL(), this, ""); urlRequesterDlg->setCaption(i18n("Files: Copy to Project")); urlRequesterDlg->urlRequester()->setMode( KFile::Directory | KFile::ExistingOnly); urlRequesterDlg->exec(); KURL destination = urlRequesterDlg->selectedURL(); delete urlRequesterDlg; if ( !destination.isEmpty()) { CopyTo *dlg = new CopyTo( baseURL); connect(dlg, SIGNAL(addFilesToProject(const KURL::List&)), SLOT (slotInsertFilesAfterCopying(const KURL::List&))); connect(dlg, SIGNAL(deleteDialog(CopyTo *)), SLOT (slotDeleteCopyToDialog(CopyTo *))); list = dlg->copy( list, destination ); return; } else { return; } } progressBar->setTotalSteps(list.count() - 1); progressBar->setTextEnabled(true); for (uint i = 0; i < list.count(); i++) { list[i] = QExtFileInfo::toRelative(list[i], baseURL, false); if (!fileList.contains(list[i])) { fileList.append(list[i]); QListViewItem *it = listView->addItem(list[i], KFileItem(KFileItem::Unknown, KFileItem::Unknown, KURL())); if (it) it->setSelected(true); progressBar->setValue(i); } } progressBar->setTotalSteps(1); progressBar->setValue(0); progressBar->setTextEnabled(false); } }
/** No descriptions */ void ProjectNewLocal::slotAddFolder() { //TODO/FIXME: This returns null if the selected directory is not on the local disk. //I think this is a KDE bug QExtFileInfo::createDir(baseURL, this); KURL dirURL ; dirURL = KFileDialog::getExistingURL( baseURL.url(), this, i18n("Insert Folder in Project")); if ( !dirURL.isEmpty() ) { dirURL.adjustPath(1); KURL sdir = dirURL; sdir = QExtFileInfo::toRelative( sdir, baseURL, false); if ( sdir.path().startsWith("..") || sdir.path().startsWith("/") ) { KURLRequesterDlg *urlRequesterDlg = new KURLRequesterDlg( baseURL.prettyURL(), this, ""); urlRequesterDlg->setCaption(i18n("%1: Copy to Project").arg(dirURL.prettyURL(0, KURL::StripFileProtocol))); urlRequesterDlg->urlRequester()->setMode( KFile::Directory | KFile::ExistingOnly); urlRequesterDlg->exec(); KURL destination = urlRequesterDlg->selectedURL(); delete urlRequesterDlg; if ( !destination.isEmpty()) { CopyTo *dlg = new CopyTo( baseURL); connect(dlg, SIGNAL(addFilesToProject(const KURL::List&)), SLOT (slotInsertFolderAfterCopying(const KURL::List&))); connect(dlg, SIGNAL(deleteDialog(CopyTo *)), SLOT (slotDeleteCopyToDialog(CopyTo *))); dirURL = dlg->copy(dirURL, destination); return; } else { return; } } slotInsertFolderAfterCopying(dirURL); } }
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() ); } }
void Sidebar_Widget::buttonPopupActivate(int id) { switch (id) { case 1: { KIconDialog kicd(this); // kicd.setStrictIconSize(true); QString iconname=kicd.selectIcon(KIcon::Small); kdDebug()<<"New Icon Name:"<<iconname<<endl; if (!iconname.isEmpty()) { KSimpleConfig ksc(m_path+m_currentButton->file); ksc.setGroup("Desktop Entry"); ksc.writeEntry("Icon",iconname); ksc.sync(); QTimer::singleShot(0,this,SLOT(updateButtons())); } break; } case 2: { KURLRequesterDlg * dlg = new KURLRequesterDlg( m_currentButton->URL, i18n("Enter a URL:"), this, "url_dlg" ); dlg->fileDialog()->setMode( KFile::Directory ); if (dlg->exec()) { KSimpleConfig ksc(m_path+m_currentButton->file); ksc.setGroup("Desktop Entry"); if ( !dlg->selectedURL().isValid()) { KMessageBox::error(this, i18n("<qt><b>%1</b> does not exist</qt>").arg(dlg->selectedURL().url())); } else { QString newurl= dlg->selectedURL().prettyURL(); //If we are going to set the name by 'set name', we don't set it here. //ksc.writeEntry("Name",newurl); ksc.writePathEntry("URL",newurl); ksc.sync(); QTimer::singleShot(0,this,SLOT(updateButtons())); } } delete dlg; break; } case 3: { if (KMessageBox::warningContinueCancel(this,i18n("<qt>Do you really want to remove the <b>%1</b> tab?</qt>").arg(m_currentButton->displayName), QString::null,KStdGuiItem::del())==KMessageBox::Continue) { QFile f(m_path+m_currentButton->file); if (!f.remove()) qDebug("Error, file not deleted"); QTimer::singleShot(0,this,SLOT(updateButtons())); } break; } case 4: // Set a name for this sidebar tab { bool ok; // Pop up the dialog asking the user for name. const QString name = KInputDialog::getText(i18n("Set Name"), i18n("Enter the name:"), m_currentButton->displayName, &ok, this); if(ok) { // Write the name in the .desktop file of this side button. KSimpleConfig ksc(m_path+m_currentButton->file); ksc.setGroup("Desktop Entry"); ksc.writeEntry("Name", name, true, false, true /*localized*/ ); ksc.sync(); // Update the buttons with a QTimer (why?) QTimer::singleShot(0,this,SLOT(updateButtons())); } break; } } }