本文整理汇总了C++中KUrl::adjustPath方法的典型用法代码示例。如果您正苦于以下问题:C++ KUrl::adjustPath方法的具体用法?C++ KUrl::adjustPath怎么用?C++ KUrl::adjustPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KUrl
的用法示例。
在下文中一共展示了KUrl::adjustPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotUrlsDropped
void ScanGallery::slotUrlsDropped(QDropEvent *ev, FileTreeViewItem *item)
{
KUrl::List urls = ev->mimeData()->urls();
if (urls.isEmpty()) return;
kDebug() << "onto" << (item==NULL ? "NULL" : item->url().prettyUrl())
<< "srcs" << urls.count() << "first" << urls.first();
if (item==NULL) return;
KUrl dest = item->url();
// Check whether the drop is on top of a directory (in which case we
// want to move/copy into it) or a file (move/copy into its containing
// directory).
if (!item->isDir()) dest.setFileName(QString::null);
dest.adjustPath(KUrl::AddTrailingSlash);
kDebug() << "resolved destination" << dest;
// Make the last URL to copy the one to select next
KUrl nextSel = dest;
nextSel.addPath(urls.back().fileName(KUrl::ObeyTrailingSlash));
m_nextUrlToShow = nextSel;
KIO::Job *job;
// TODO: top level window as 3rd parameter?
if (ev->dropAction()==Qt::MoveAction) job = KIO::move(urls, dest);
else job = KIO::copy(urls, dest);
connect(job, SIGNAL(result(KJob *)), SLOT(slotJobResult(KJob *)));
}
示例2: findCachedPath
QString Cache::findCachedPath(KUrl &url)
{
url.adjustPath(KUrl::RemoveTrailingSlash);
if (m_pathCache.contains(url))
return m_pathCache[url];
return QString::null;
}
示例3: listDir
void ApplicationsProtocol::listDir(const KUrl& url)
{
QString groupPath = url.path( KUrl::AddTrailingSlash );
groupPath.remove(0, 1); // remove starting '/'
KServiceGroup::Ptr grp = KServiceGroup::group(groupPath);
if (!grp || !grp->isValid()) {
error(KIO::ERR_DOES_NOT_EXIST, groupPath);
return;
}
unsigned int count = 0;
KIO::UDSEntry entry;
foreach (const KSycocaEntry::Ptr &e, grp->entries(true, true)) {
if (e->isType(KST_KServiceGroup)) {
KServiceGroup::Ptr g(KServiceGroup::Ptr::staticCast(e));
QString groupCaption = g->caption();
kDebug() << "ADDING SERVICE GROUP WITH PATH " << g->relPath();
// Avoid adding empty groups.
KServiceGroup::Ptr subMenuRoot = KServiceGroup::group(g->relPath());
if (subMenuRoot->childCount() == 0)
continue;
// Ignore dotfiles.
if ((g->name().at(0) == '.'))
continue;
QString relPath = g->relPath();
KUrl dirUrl = url; // preserve protocol, whether that's programs:/ or applications:/
dirUrl.setPath('/' + relPath);
dirUrl.adjustPath(KUrl::RemoveTrailingSlash);
kDebug() << "ApplicationsProtocol: adding entry" << dirUrl;
createDirEntry(entry, groupCaption, dirUrl.url(), "inode/directory", g->icon());
} else {
KService::Ptr service(KService::Ptr::staticCast(e));
kDebug() << "the entry name is" << service->desktopEntryName()
<< "with path" << service->entryPath();
if (!service->isApplication()) // how could this happen?
continue;
createFileEntry(entry, service, url);
}
listEntry(entry, false);
count++;
}
totalSize(count);
listEntry(entry, true);
finished();
}
示例4: slotTargetFolderSelected
void QuantaProjectPart::slotTargetFolderSelected(QAction *action, const KUrl& url)
{
Q_UNUSED(action);
KUrl u = url;
u.adjustPath(KUrl::AddTrailingSlash);
QuantaNetAccess::dircopy(m_fileContextURLs, u, this, false);
m_browserMenu->deleteLater();
m_browserMenu = 0L;
}
示例5: findCached
DirectoryListing Cache::findCached(KUrl &url)
{
url.adjustPath(KUrl::RemoveTrailingSlash);
if (m_listingCache.contains(url))
return m_listingCache[url];
DirectoryListing invalid;
invalid.setValid(false);
return invalid;
}
示例6: updateDirectoryEntry
void Cache::updateDirectoryEntry(Socket *socket, KUrl &path, filesize_t filesize)
{
KUrl url = socket->getCurrentUrl();
url.setPath(path.directory());
url.adjustPath(KUrl::RemoveTrailingSlash);
if (m_listingCache.contains(url)) {
DirectoryListing listing = m_listingCache[url];
listing.updateEntry(path.fileName(), filesize);
m_listingCache.insert(url, listing);
}
}
示例7: itemDirectory
/* The absolute URL of the item (if it is a directory), or its parent (if
it is a file).
*/
KUrl ScanGallery::itemDirectory(const FileTreeViewItem *item) const
{
if (item==NULL)
{
kDebug() << "no item";
return (KUrl());
}
KUrl u = item->url();
if (!item->isDir()) u.setFileName(""); // not a directory, remove file name
else u.adjustPath(KUrl::AddTrailingSlash); // is a directory, ensure ends with "/"
return (u);
}
示例8: addUrlToRecentFolders
void GvCore::addUrlToRecentFolders(KUrl url)
{
if (!GwenviewConfig::historyEnabled()) {
return;
}
if (!url.isValid()) {
return;
}
if (url.path() != "") { // This check is a workaraound for bug #312060
url.adjustPath(KUrl::AddTrailingSlash);
}
recentFoldersModel();
d->mRecentFoldersModel->addUrl(url);
}
示例9: trigger
bool FavoritePlacesModel::trigger(int row, const QString &actionId, const QVariant &actionArgument)
{
QModelIndex idx = index(row, 0);
KUrl theUrl = idx.data(Fixes::KFilePlacesModel::UrlRole).value<QUrl>();
if (actionId.isEmpty()) {
theUrl.adjustPath(KUrl::AddTrailingSlash);
QString rootName = idx.data(Qt::DisplayRole).toString();
openSourceRequested("Dir", DirModel::sourceArguments(theUrl, rootName, theUrl));
return false;
}
bool close;
KFileItem item(KFileItem::Unknown, KFileItem::Unknown, theUrl);
if (ActionList::handleFileItemAction(item, actionId, actionArgument, &close)) {
return close;
}
return false;
}
示例10: slotInsertFolder
void QuantaProjectPart::slotInsertFolder()
{
KUrl url = KUrl();
url = KFileDialog::getExistingUrl(m_projectBase, Koncrete::Core::mainWindow(), i18n("Insert Folder in Project"));
if (!url.isEmpty())
{
if (!m_projectBase.isParentOf(url))
{
KUrlRequesterDialog urlRequesterDlg(m_projectBase.pathOrUrl(), Koncrete::Core::mainWindow());
urlRequesterDlg.setWindowTitle(i18n("%1: Copy to Project", url.pathOrUrl()));
urlRequesterDlg.urlRequester()->setMode(KFile::Directory | KFile::ExistingOnly);
urlRequesterDlg.exec();
KUrl destination = urlRequesterDlg.selectedUrl();
if (!destination.isEmpty())
{
destination.adjustPath(KUrl::AddTrailingSlash);
QuantaNetAccess::dircopy(url, destination, this, false);
}
} else
{
KUrl::List urls = ExtFileInfo::allFilesRelative(url, "*");
QStringList filenames;
KUrl u = KUrl::relativeUrl(m_projectBase, url);
QStringList sections = u.path(KUrl::AddTrailingSlash).split('/', QString::SkipEmptyParts);
QString section;
for (int i = 0 ; i < sections.count(); i++)
{
section += sections[i] + '/';
filenames += section;
}
KUrl::List::ConstIterator end = urls.constEnd();
for (KUrl::List::ConstIterator it = urls.begin(); it != end; ++it)
{
filenames += url.fileName() + '/' + (*it).path();
}
addFiles(filenames);
}
}
}
示例11: downloadButtonClicked
void MagnatuneDownloadDialog::downloadButtonClicked( )
{
if (m_currentDownloadInfo == 0) return;
QString format = formatComboBox->currentText();
QString path = downloadTargetURLRequester->url().url();;
//store to config for next download:
KConfigGroup config = Amarok::config("Service_Magnatune");
config.writeEntry( "Download Format", format );
config.writeEntry( "Download Path", path );
m_currentDownloadInfo->setFormatSelection( format );
KUrl unpackLocation = downloadTargetURLRequester->url();
unpackLocation.adjustPath( KUrl::AddTrailingSlash );
m_currentDownloadInfo->setUnpackUrl( unpackLocation.directory( KUrl::ObeyTrailingSlash ) );
emit( downloadAlbum( m_currentDownloadInfo ) );
close();
}
示例12: addPath
void Cache::addPath(KUrl &url, const QString &target)
{
url.adjustPath(KUrl::RemoveTrailingSlash);
m_pathCache[url] = target;
}
示例13: invalidatePath
void Cache::invalidatePath(KUrl &url)
{
url.adjustPath(KUrl::RemoveTrailingSlash);
m_pathCache.remove(url);
}
示例14: invalidateEntry
void Cache::invalidateEntry(KUrl &url)
{
url.adjustPath(KUrl::RemoveTrailingSlash);
m_listingCache.remove(url);
}
示例15: foreach
void KUrlNavigator::Private::updateButtonVisibility()
{
if (m_editable) {
return;
}
const int buttonsCount = m_navButtons.count();
if (buttonsCount == 0) {
m_dropDownButton->hide();
return;
}
// Subtract all widgets from the available width, that must be shown anyway
int availableWidth = q->width() - m_toggleEditableMode->minimumWidth();
if ((m_placesSelector != 0) && m_placesSelector->isVisible()) {
availableWidth -= m_placesSelector->width();
}
if ((m_protocols != 0) && m_protocols->isVisible()) {
availableWidth -= m_protocols->width();
}
// Check whether buttons must be hidden at all...
int requiredButtonWidth = 0;
foreach (const KUrlNavigatorButton* button, m_navButtons) {
requiredButtonWidth += button->minimumWidth();
}
if (requiredButtonWidth > availableWidth) {
// At least one button must be hidden. This implies that the
// drop-down button must get visible, which again decreases the
// available width.
availableWidth -= m_dropDownButton->width();
}
// Hide buttons...
QList<KUrlNavigatorButton*>::const_iterator it = m_navButtons.constEnd();
const QList<KUrlNavigatorButton*>::const_iterator itBegin = m_navButtons.constBegin();
bool isLastButton = true;
bool hasHiddenButtons = false;
QLinkedList<KUrlNavigatorButton*> buttonsToShow;
while (it != itBegin) {
--it;
KUrlNavigatorButton* button = (*it);
availableWidth -= button->minimumWidth();
if ((availableWidth <= 0) && !isLastButton) {
button->hide();
hasHiddenButtons = true;
}
else {
// Don't show the button immediately, as setActive()
// might change the size and a relayout gets triggered
// after showing the button. So the showing of all buttons
// is postponed until all buttons have the correct
// activation state.
buttonsToShow.append(button);
}
isLastButton = false;
}
// All buttons have the correct activation state and
// can be shown now
foreach (KUrlNavigatorButton* button, buttonsToShow) {
button->show();
}
if (hasHiddenButtons) {
m_dropDownButton->show();
} else {
// Check whether going upwards is possible. If this is the case, show the drop-down button.
KUrl url = m_navButtons.front()->url();
url.adjustPath(KUrl::AddTrailingSlash);
const bool visible = !url.equals(url.upUrl());
m_dropDownButton->setVisible(visible);
}
}