Port to KDirModel::simplifiedUrlList

svn path=/trunk/KDE/kdebase/apps/; revision=894264
This commit is contained in:
David Faure 2008-12-08 11:20:08 +00:00
parent c318f8336b
commit 485d80cedc
3 changed files with 18 additions and 59 deletions

View file

@ -389,7 +389,7 @@ void DolphinView::setZoomLevel(int level)
} else if (level > ZoomLevelInfo::maximumLevel()) {
level = ZoomLevelInfo::maximumLevel();
}
if (level != zoomLevel()) {
m_controller->setZoomLevel(level);
m_previewGenerator->updatePreviews();
@ -522,7 +522,7 @@ QString DolphinView::statusBarText() const
int folderCount = 0;
int fileCount = 0;
KIO::filesize_t totalFileSize = 0;
if (hasSelection()) {
// give a summary of the status of the selected files
const KFileItemList list = selectedItems();
@ -544,7 +544,7 @@ QString DolphinView::statusBarText() const
}
++it;
}
if (folderCount + fileCount == 1) {
// if only one item is selected, show the filename
const QString name = list.first().name();
@ -610,7 +610,7 @@ void DolphinView::renameSelectedItems()
if (itemCount < 1) {
return;
}
if (itemCount > 1) {
// More than one item has been selected for renaming. Open
// a rename dialog and rename all items afterwards.
@ -650,7 +650,7 @@ void DolphinView::renameSelectedItems()
}
} else if (DolphinSettings::instance().generalSettings()->renameInline()) {
Q_ASSERT(itemCount == 1);
if (isColumnViewActive()) {
m_columnView->editItem(items.first());
} else {
@ -660,7 +660,7 @@ void DolphinView::renameSelectedItems()
}
} else {
Q_ASSERT(itemCount == 1);
RenameDialog dialog(this, items);
if (dialog.exec() == QDialog::Rejected) {
return;
@ -737,10 +737,10 @@ void DolphinView::setShowPreview(bool show)
m_showPreview = show;
m_previewGenerator->setPreviewShown(show);
const int oldZoomLevel = m_controller->zoomLevel();
emit showPreviewChanged();
// Enabling or disabling the preview might change the icon size of the view.
// As the view does not emit a signal when the icon size has been changed,
// the used zoom level of the controller must be adjusted manually:
@ -842,7 +842,7 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event)
m_controller->requestActivation();
}
break;
case QEvent::MouseButtonPress:
if ((watched == itemView()->viewport()) && (m_expandedViews.count() > 0)) {
// Listening to a mousebutton press event to delete expanded views is a
@ -853,13 +853,13 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event)
deleteExpandedViews();
}
break;
case QEvent::DragEnter:
if (watched == itemView()->viewport()) {
setActive(true);
}
break;
default:
break;
}
@ -1165,11 +1165,11 @@ void DolphinView::applyViewProperties(const KUrl& url)
const Mode mode = props.viewMode();
if (m_mode != mode) {
const int oldZoomLevel = m_controller->zoomLevel();
m_mode = mode;
createView();
emit modeChanged();
updateZoomLevel(oldZoomLevel);
}
if (itemView() == 0) {
@ -1213,10 +1213,10 @@ void DolphinView::applyViewProperties(const KUrl& url)
if (showPreview != m_showPreview) {
m_showPreview = showPreview;
m_previewGenerator->setPreviewShown(showPreview);
const int oldZoomLevel = m_controller->zoomLevel();
emit showPreviewChanged();
// Enabling or disabling the preview might change the icon size of the view.
// As the view does not emit a signal when the icon size has been changed,
// the used zoom level of the controller must be adjusted manually:
@ -1319,7 +1319,7 @@ void DolphinView::deleteView()
m_topLayout->removeWidget(view);
view->close();
disconnect(view);
m_controller->disconnect(view);
view->disconnect();
@ -1337,7 +1337,7 @@ void DolphinView::deleteView()
view->deleteLater();
}
view = 0;
m_iconsView = 0;
m_detailsView = 0;
m_columnView = 0;
@ -1403,7 +1403,7 @@ KUrl::List DolphinView::simplifiedSelectedUrls() const
{
KUrl::List list = selectedUrls();
if (itemsExpandable() ) {
list = KonqOperations::simplifiedUrlList(list);
list = KDirModel::simplifiedUrlList(list);
}
return list;
}

View file

@ -243,35 +243,6 @@ bool KonqOperations::askDeleteConfirmation( const KUrl::List & selectedUrls, int
return uiDelegate.askDeleteConfirmation(selectedUrls, deletionType, confirmationType);
}
bool lessThan( const KUrl &left, const KUrl &right )
{
return left.url().compare( right.url() ) < 0;
}
KUrl::List KonqOperations::simplifiedUrlList( const KUrl::List &urls )
{
if (!urls.count()) {
return urls;
}
KUrl::List ret( urls );
qSort( ret.begin(), ret.end(), lessThan );
KUrl::List::iterator it = ret.begin();
KUrl url = *it;
++it;
while ( it != ret.end() ) {
if ( url.isParentOf( *it ) ) {
it = ret.erase( it );
} else {
url = *it;
++it;
}
}
return ret;
}
void KonqOperations::doDrop( const KFileItem & destItem, const KUrl & dest, QDropEvent * ev, QWidget * parent )
{
kDebug(1203) << "doDrop: dest:" << dest;

View file

@ -149,18 +149,6 @@ public:
*/
static bool askDeleteConfirmation( const KUrl::List & selectedUrls, int method, ConfirmationType confirmation, QWidget* widget );
/**
* Remove urls from the list if an ancestor is present on the list. This can
* be used to delete only the ancestor url and skip a potential error of a non-existent url.
*
* For example, for a list of "/home/foo/a", "/home/foo/a/a.txt", "/home/foo/a/a/a.txt", "/home/foo/a/b/b.txt",
* "home/foo/b/b.txt", this method will return the list "/home/foo/a", "/home/foo/b/b.txt".
*
* @return the list @p urls without parented urls inside.
* @since 4.2
*/
static KUrl::List simplifiedUrlList( const KUrl::List & urls );
Q_SIGNALS:
void statFinished( const KFileItem & item );
void aboutToCreate(const QPoint &pos, const QList<KIO::CopyInfo> &files);