void ImageImporter::slotUpdateMountStatus() { QString str = m_cmbSourceDevice->currentText(); QString mntDev = getCurrentMountDevice(); m_bCurrentDeviceMounted = false; //find out if the current selection is mounted const KMountPoint::List lst = KMountPoint::currentMountPoints(); for ( KMountPoint::List::ConstIterator it = lst.begin() ; it != lst.end() ; ++it ) { if ((*it)->mountedFrom() == mntDev) { m_bCurrentDeviceMounted = true; break; } } m_btnMountDevice->setEnabled(true); m_btnMountDevice->setOn(m_bCurrentDeviceMounted); if (m_bCurrentDeviceMounted) { insertItemTo(m_cmbSourceFolder, getCurrentMountPoint()); m_cmbSourceFolder->setCurrentText(getCurrentMountPoint()); } else { for (int i = 0; i < m_cmbSourceFolder->count(); ++i) { if (m_cmbSourceFolder->text(i) == getCurrentMountPoint()) { m_cmbSourceFolder->removeItem( i ); ///@todo set the Settings::blubb item current, if available break; } } } }
QString KDesktopFile::readURL() const { if(hasDeviceType()) { QString device = readDevice(); KMountPoint::List mountPoints = KMountPoint::possibleMountPoints(); for(KMountPoint::List::ConstIterator it = mountPoints.begin(); it != mountPoints.end(); ++it) { KMountPoint *mp = *it; if(mp->mountedFrom() == device) { KURL u; u.setPath(mp->mountPoint()); return u.url(); } } return QString::null; } else { QString url = readPathEntry("URL"); if(!url.isEmpty() && !QDir::isRelativePath(url)) { // Handle absolute paths as such (i.e. we need to escape them) KURL u; u.setPath(url); return u.url(); } return url; } }
void TrashImpl::scanTrashDirectories() const { const KMountPoint::List lst = KMountPoint::currentMountPoints(); for ( KMountPoint::List::ConstIterator it = lst.begin() ; it != lst.end() ; ++it ) { const TQCString str = (*it)->mountType().latin1(); // Skip pseudo-filesystems, there's no chance we'll find a .Trash on them :) // ## Maybe we should also skip readonly filesystems if ( str != "proc" && str != "devfs" && str != "usbdevfs" && str != "sysfs" && str != "devpts" && str != "subfs" /* #96259 */ && str != "autofs" /* #101116 */ ) { TQString topdir = (*it)->mountPoint(); TQString trashDir = trashForMountPoint( topdir, false ); if ( !trashDir.isEmpty() ) { // OK, trashDir is a valid trash directory. Ensure it's registered. int trashId = idForTrashDirectory( trashDir ); if ( trashId == -1 ) { // new trash dir found, register it m_trashDirectories.insert( ++m_lastId, trashDir ); kdDebug() << k_funcinfo << "found " << trashDir << " gave it id " << m_lastId << endl; if ( !topdir.endsWith( "/" ) ) topdir += '/'; m_topDirectories.insert( m_lastId, topdir ); } } } } m_trashDirectoriesScanned = true; }
void ImageImporter::initData() { const KMountPoint::List lst = KMountPoint::possibleMountPoints(KMountPoint::NeedMountOptions); for ( KMountPoint::List::ConstIterator it = lst.begin() ; it != lst.end() ; ++it ) { //so, I only show devices that are mountable by a user if (getuid() == 0 || (*it)->mountOptions().grep("user").size() > 0) { QString x = QString("%1 (%2)").arg((*it)->mountedFrom()).arg((*it)->mountPoint()); m_cmbSourceDevice->insertItem(x); } } //after adding all available mountpoints, check the status of the current slotUpdateMountStatus(); m_cmbSourceFolder->insertItem(Settings::imageImporterSourceFolder()); m_cmbSourceFolder->setCurrentText(Settings::imageImporterSourceFolder()); m_cmbSourceDevice->setCurrentText(Settings::imageImporterSourceDevice()); m_txtSourceFilename->setText(Settings::imageImporterSourceFilenameRegexp()); m_chkIgnoreCase->setChecked(Settings::imageImporterFilenameIgnoreCase()); m_chkSrcIncludeSubfolders->setChecked(Settings::imageImporterSourceIncludeSubfolders()); m_chkSrcRemoveFilesFromSrc->setChecked(Settings::imageImporterSourceRemoveAfterTransfer()); m_groupArchive->setChecked(Settings::imageImporterArchiveImages()); m_txtArchiveBaseFolder->setText(Settings::imageImporterArchiveBaseFolder()); m_txtArchiveSubfolders->setText(Settings::imageImporterArchiveSubfolders()); m_txtArchiveFilename->setText(Settings::imageImporterArchiveFilename()); m_chkArchiveLowercase->setChecked(Settings::imageImporterArchiveLowercaseFilenames()); //add all dirs from the album to the list of target folders Folder* sourceDir; for ( sourceDir = m_photobook->engine()->sourceDirs()->first(); sourceDir; sourceDir = m_photobook->engine()->sourceDirs()->next() ) { m_cmbDestBasefolder->insertItem(sourceDir->dir()->absPath()); } if (m_cmbDestBasefolder->count() == 0) { QMessageBox::information( this, "No Folders Available", "There are no Folders in your album!<br>" "Either create a new album and add Folders to " "it, or open another available album." ); } //m_cmbDestBasefolder->insertItem(Settings::imageImporterDestBaseFolder()); m_cmbDestBasefolder->setCurrentText(Settings::imageImporterDestBaseFolder()); m_txtDestSubfolders->setText(Settings::imageImporterDestSubfolders()); m_txtDestFilename->setText(Settings::imageImporterDestFilenames()); m_chkDestLowercase->setChecked(Settings::imageImporterDestLowercaseFilenames()); }
void RemovableBackend::handleMtabChange() { QStringList new_mtabIds; KMountPoint::List mtab = KMountPoint::currentMountPoints(); KMountPoint::List::iterator it = mtab.begin(); KMountPoint::List::iterator end = mtab.end(); for(; it != end; ++it) { QString dev = (*it)->mountedFrom(); QString mp = (*it)->mountPoint(); QString fs = (*it)->mountType(); QString id = generateId(dev); new_mtabIds += id; if(!m_mtabIds.contains(id) && m_removableIds.contains(id)) { m_mediaList.changeMediumState(id, dev, mp, fs, true, false, "media/removable_mounted"); } } QStringList::iterator it2 = m_mtabIds.begin(); QStringList::iterator end2 = m_mtabIds.end(); for(; it2 != end2; ++it2) { if(!new_mtabIds.contains(*it2) && m_removableIds.contains(*it2)) { m_mediaList.changeMediumState(*it2, false, false, "media/removable_unmounted"); } } m_mtabIds = new_mtabIds; }