┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/applyviewpropsjob.h1
-rw-r--r--src/dolphincolumnview.cpp14
-rw-r--r--src/dolphincontextmenu.cpp34
-rw-r--r--src/dolphincontextmenu.h6
-rw-r--r--src/dolphinitemcategorizer.cpp32
-rw-r--r--src/dolphinmainwindow.cpp35
-rw-r--r--src/dolphinmainwindow.h6
-rw-r--r--src/dolphinpart.cpp2
-rw-r--r--src/dolphinsortfilterproxymodel.cpp66
-rw-r--r--src/dolphinview.cpp84
-rw-r--r--src/dolphinview.h12
-rw-r--r--src/dolphinviewcontainer.cpp20
-rw-r--r--src/dolphinviewcontainer.h4
-rw-r--r--src/infosidebarpage.cpp20
-rw-r--r--src/infosidebarpage.h2
-rw-r--r--src/sidebarpage.cpp6
-rw-r--r--src/sidebarpage.h8
-rw-r--r--src/treeviewcontextmenu.cpp20
-rw-r--r--src/treeviewcontextmenu.h7
-rw-r--r--src/treeviewsidebarpage.cpp19
20 files changed, 197 insertions, 201 deletions
diff --git a/src/applyviewpropsjob.h b/src/applyviewpropsjob.h
index cdcf305b6..4ffc069a9 100644
--- a/src/applyviewpropsjob.h
+++ b/src/applyviewpropsjob.h
@@ -77,7 +77,6 @@ private slots:
private:
ViewProperties* m_viewProps;
- KFileItemList m_lstItems;
int m_currentItem;
int m_progress;
KUrl m_dir;
diff --git a/src/dolphincolumnview.cpp b/src/dolphincolumnview.cpp
index e8aa243d7..e4669442c 100644
--- a/src/dolphincolumnview.cpp
+++ b/src/dolphincolumnview.cpp
@@ -301,8 +301,8 @@ void ColumnWidget::mousePressEvent(QMouseEvent* event)
const QAbstractProxyModel* proxyModel = static_cast<const QAbstractProxyModel*>(m_view->model());
const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
const QModelIndex dirIndex = proxyModel->mapToSource(index);
- KFileItem* item = dirModel->itemForIndex(dirIndex);
- if (item != 0) {
+ KFileItem item = dirModel->itemForIndex(dirIndex);
+ if (!item.isNull()) {
QItemSelectionModel* selModel = selectionModel();
bool activate = true;
@@ -317,8 +317,8 @@ void ColumnWidget::mousePressEvent(QMouseEvent* event)
}
selModel->select(index, QItemSelectionModel::Toggle);
swallowMousePressEvent = true;
- } else if (item->isDir()) {
- m_childUrl = item->url();
+ } else if (item.isDir()) {
+ m_childUrl = item.url();
viewport()->update();
// Only request the activation if not the left button is pressed.
@@ -515,9 +515,9 @@ QAbstractItemView* DolphinColumnView::createColumn(const QModelIndex& index)
const KDirModel* dirModel = static_cast<const KDirModel*>(proxyModel->sourceModel());
const QModelIndex dirModelIndex = proxyModel->mapToSource(index);
- KFileItem* fileItem = dirModel->itemForIndex(dirModelIndex);
- if (fileItem != 0) {
- columnUrl = fileItem->url();
+ KFileItem fileItem = dirModel->itemForIndex(dirModelIndex);
+ if (!fileItem.isNull()) {
+ columnUrl = fileItem.url();
}
}
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp
index 821b315ef..7aa93dfc7 100644
--- a/src/dolphincontextmenu.cpp
+++ b/src/dolphincontextmenu.cpp
@@ -49,7 +49,7 @@
#include <Qt3Support/Q3ValueList>
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
- KFileItem* fileInfo,
+ const KFileItem& fileInfo,
const KUrl& baseUrl) :
m_mainWindow(parent),
m_fileInfo(fileInfo),
@@ -74,7 +74,7 @@ void DolphinContextMenu::open()
m_context |= TrashContext;
}
- if (m_fileInfo != 0) {
+ if (!m_fileInfo.isNull()) {
m_context |= ItemContext;
// TODO: handle other use cases like devices + desktop files
}
@@ -150,7 +150,7 @@ void DolphinContextMenu::openTrashItemContextMenu()
void DolphinContextMenu::openItemContextMenu()
{
- Q_ASSERT(m_fileInfo != 0);
+ Q_ASSERT(!m_fileInfo.isNull());
KMenu* popup = new KMenu(m_mainWindow);
insertDefaultItemActions(popup);
@@ -159,7 +159,7 @@ void DolphinContextMenu::openItemContextMenu()
// insert 'Bookmark This Folder' entry if exactly one item is selected
QAction* bookmarkAction = 0;
- if (m_fileInfo->isDir() && (m_selectedUrls.count() == 1)) {
+ if (m_fileInfo.isDir() && (m_selectedUrls.count() == 1)) {
bookmarkAction = popup->addAction(KIcon("bookmark-folder"),
i18nc("@action:inmenu", "Bookmark Folder..."));
}
@@ -180,7 +180,7 @@ void DolphinContextMenu::openItemContextMenu()
QAction* activatedAction = popup->exec(QCursor::pos());
if ((bookmarkAction != 0) && (activatedAction == bookmarkAction)) {
- const KUrl selectedUrl(m_fileInfo->url());
+ const KUrl selectedUrl(m_fileInfo.url());
if (selectedUrl.isValid()) {
DolphinSettings::instance().placesModel()->addPlace(selectedUrl.fileName(),
selectedUrl);
@@ -208,7 +208,7 @@ void DolphinContextMenu::openItemContextMenu()
void DolphinContextMenu::openViewportContextMenu()
{
- Q_ASSERT(m_fileInfo == 0);
+ Q_ASSERT(!m_fileInfo.isNull());
KMenu* popup = new KMenu(m_mainWindow);
// setup 'Create New' menu
@@ -311,18 +311,18 @@ QList<QAction*> DolphinContextMenu::insertOpenWithItems(KMenu* popup,
// attached which allows to select a custom application. If no applications are registered
// no sub menu is created at all, only "Open With..." will be offered.
bool insertOpenWithItems = true;
- const QString contextMimeType(m_fileInfo->mimetype());
+ const QString contextMimeType(m_fileInfo.mimetype());
- QListIterator<KFileItem*> mimeIt(m_selectedItems);
+ QListIterator<KFileItem> mimeIt(m_selectedItems);
while (insertOpenWithItems && mimeIt.hasNext()) {
- KFileItem* item = mimeIt.next();
- insertOpenWithItems = (contextMimeType == item->mimetype());
+ KFileItem item = mimeIt.next();
+ insertOpenWithItems = (contextMimeType == item.mimetype());
}
QList<QAction*> openWithActions;
if (insertOpenWithItems) {
// fill the 'Open with' sub menu with application types
- const KMimeType::Ptr mimePtr = KMimeType::findByUrl(m_fileInfo->url());
+ const KMimeType::Ptr mimePtr = KMimeType::findByUrl(m_fileInfo.url());
KService::List offers = KMimeTypeTrader::self()->query(mimePtr->name(),
"Application",
"Type == 'Application'");
@@ -401,11 +401,11 @@ QList<QAction*> DolphinContextMenu::insertActionItems(KMenu* popup,
if ((*it) == "all/allfiles") {
// The service type is valid for all files, but not for directories.
// Check whether the selected items only consist of files...
- QListIterator<KFileItem*> mimeIt(m_selectedItems);
+ QListIterator<KFileItem> mimeIt(m_selectedItems);
insert = true;
while (insert && mimeIt.hasNext()) {
- KFileItem* item = mimeIt.next();
- insert = !item->isDir();
+ KFileItem item = mimeIt.next();
+ insert = !item.isDir();
}
}
@@ -413,11 +413,11 @@ QList<QAction*> DolphinContextMenu::insertActionItems(KMenu* popup,
// Check whether the MIME types of all selected files match
// to the mimetype of the service action. As soon as one MIME
// type does not match, no service menu is shown at all.
- QListIterator<KFileItem*> mimeIt(m_selectedItems);
+ QListIterator<KFileItem> mimeIt(m_selectedItems);
insert = true;
while (insert && mimeIt.hasNext()) {
- KFileItem* item = mimeIt.next();
- const QString mimeType(item->mimetype());
+ KFileItem item = mimeIt.next();
+ const QString mimeType(item.mimetype());
const QString mimeGroup(mimeType.left(mimeType.indexOf('/')));
insert = (*it == mimeType) ||
diff --git a/src/dolphincontextmenu.h b/src/dolphincontextmenu.h
index b8920b7e2..3ace122d6 100644
--- a/src/dolphincontextmenu.h
+++ b/src/dolphincontextmenu.h
@@ -62,7 +62,7 @@ public:
* @viewType On which view type is the context menu shown.
*/
DolphinContextMenu(DolphinMainWindow* parent,
- KFileItem* fileInfo,
+ const KFileItem& fileInfo,
const KUrl& baseUrl);
virtual ~DolphinContextMenu();
@@ -127,9 +127,9 @@ private:
};
DolphinMainWindow* m_mainWindow;
- KFileItem* m_fileInfo;
+ KFileItem m_fileInfo;
KUrl m_baseUrl;
- KFileItemList m_selectedItems;
+ QList<KFileItem> m_selectedItems;
KUrl::List m_selectedUrls;
int m_context;
};
diff --git a/src/dolphinitemcategorizer.cpp b/src/dolphinitemcategorizer.cpp
index 2a25a8f12..1a8f93471 100644
--- a/src/dolphinitemcategorizer.cpp
+++ b/src/dolphinitemcategorizer.cpp
@@ -65,7 +65,7 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
}
const KDirModel *dirModel = qobject_cast<const KDirModel*>(index.model());
- KFileItem *item = dirModel->itemForIndex(index);
+ KFileItem item = dirModel->itemForIndex(index);
switch (sortRole)
{
@@ -84,17 +84,17 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
QVariant data = theIndex.model()->data(theIndex, Qt::DisplayRole);
if (data.toString().size())
{
- if (!item->isHidden() && data.toString().at(0).isLetter())
+ if (!item.isHidden() && data.toString().at(0).isLetter())
retString = data.toString().toUpper().at(0);
- else if (item->isHidden() && data.toString().at(0) == '.' &&
+ else if (item.isHidden() && data.toString().at(0) == '.' &&
data.toString().at(1).isLetter())
retString = data.toString().toUpper().at(1);
- else if (item->isHidden() && data.toString().at(0) == '.' &&
+ else if (item.isHidden() && data.toString().at(0) == '.' &&
!data.toString().at(1).isLetter())
retString = i18nc("@title:group Name", "Others");
- else if (item->isHidden() && data.toString().at(0) != '.')
+ else if (item.isHidden() && data.toString().at(0) != '.')
retString = data.toString().toUpper().at(0);
- else if (item->isHidden())
+ else if (item.isHidden())
retString = data.toString().toUpper().at(0);
else
{
@@ -122,7 +122,7 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
case DolphinView::SortByDate:
{
- KDateTime modifiedTime = item->time(KFileItem::ModificationTime);
+ KDateTime modifiedTime = item.time(KFileItem::ModificationTime);
modifiedTime = modifiedTime.toLocalZone();
if (modifiedTime.daysTo(KDateTime::currentLocalDateTime()) == 0)
@@ -141,20 +141,20 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
}
case DolphinView::SortByPermissions:
- retString = item->permissionsString();
+ retString = item.permissionsString();
break;
case DolphinView::SortByOwner:
- retString = item->user();
+ retString = item.user();
break;
case DolphinView::SortByGroup:
- retString = item->group();
+ retString = item.group();
break;
case DolphinView::SortBySize: {
- const int fileSize = item ? item->size() : -1;
- if (item && item->isDir()) {
+ const int fileSize = !item.isNull() ? item.size() : -1;
+ if (!item.isNull() && item.isDir()) {
retString = i18nc("@title:group Size", "Folders");
} else if (fileSize < 5242880) {
retString = i18nc("@title:group Size", "Small");
@@ -167,7 +167,7 @@ QString DolphinItemCategorizer::categoryForItem(const QModelIndex& index,
}
case DolphinView::SortByType:
- retString = item->mimeComment();
+ retString = item.mimeComment();
break;
#ifdef HAVE_NEPOMUK
@@ -199,7 +199,7 @@ void DolphinItemCategorizer::drawCategory(const QModelIndex &index,
{
QRect starRect = option.rect;
- int iconSize = KIconLoader::global()->currentSize(K3Icon::Small);
+ int iconSize = KIconLoader::global()->currentSize(K3Icon::Small);
const QString category = categoryForItem(index, sortRole);
QColor color = option.palette.color(QPalette::Text);
@@ -295,8 +295,8 @@ void DolphinItemCategorizer::drawCategory(const QModelIndex &index,
case DolphinView::SortByType: {
opt.rect.setTop(option.rect.top() + (option.rect.height() / 2) - (iconSize / 2));
const KDirModel *model = static_cast<const KDirModel*>(index.model());
- KFileItem *item = model->itemForIndex(index);
- icon = KIconLoader::global()->loadIcon(KMimeType::iconNameForUrl(item->url()),
+ KFileItem item = model->itemForIndex(index);
+ icon = KIconLoader::global()->loadIcon(KMimeType::iconNameForUrl(item.url()),
K3Icon::Small);
break;
}
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 3f1153340..5657a2c8c 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -237,7 +237,7 @@ void DolphinMainWindow::changeUrl(const KUrl& url)
}
}
-void DolphinMainWindow::changeSelection(const KFileItemList& selection)
+void DolphinMainWindow::changeSelection(const QList<KFileItem>& selection)
{
activeViewContainer()->view()->changeSelection(selection);
}
@@ -351,7 +351,7 @@ void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::AdditionalI
}
}
-void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
+void DolphinMainWindow::slotSelectionChanged(const QList<KFileItem>& selection)
{
updateEditActions();
@@ -490,8 +490,14 @@ void DolphinMainWindow::deleteItems()
void DolphinMainWindow::properties()
{
- const KFileItemList list = m_activeViewContainer->view()->selectedItems();
- KPropertiesDialog dialog(list, this);
+ QList<KFileItem> list = m_activeViewContainer->view()->selectedItems();
+ // ### KPropertiesDialog still uses pointer-based KFileItemList
+ KFileItemList lst;
+ // Can't be a const_iterator :(
+ for ( QList<KFileItem>::iterator it = list.begin(), end = list.end() ; it != end ; ++it ) {
+ lst << & *it; // ugly!
+ }
+ KPropertiesDialog dialog(lst, this);
dialog.exec();
}
@@ -1348,8 +1354,8 @@ void DolphinMainWindow::setupDockWidgets()
addDockWidget(Qt::RightDockWidgetArea, infoDock);
connect(this, SIGNAL(urlChanged(KUrl)),
infoWidget, SLOT(setUrl(KUrl)));
- connect(this, SIGNAL(selectionChanged(KFileItemList)),
- infoWidget, SLOT(setSelection(KFileItemList)));
+ connect(this, SIGNAL(selectionChanged(QList<KFileItem>)),
+ infoWidget, SLOT(setSelection(QList<KFileItem>)));
connect(this, SIGNAL(requestItemInfo(KFileItem)),
infoWidget, SLOT(requestDelayedItemInfo(KFileItem)));
@@ -1369,8 +1375,8 @@ void DolphinMainWindow::setupDockWidgets()
treeWidget, SLOT(setUrl(KUrl)));
connect(treeWidget, SIGNAL(changeUrl(KUrl)),
this, SLOT(changeUrl(KUrl)));
- connect(treeWidget, SIGNAL(changeSelection(KFileItemList)),
- this, SLOT(changeSelection(KFileItemList)));
+ connect(treeWidget, SIGNAL(changeSelection(QList<KFileItem>)),
+ this, SLOT(changeSelection(QList<KFileItem>)));
connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)),
this, SLOT(dropUrls(KUrl::List, KUrl)));
@@ -1432,7 +1438,7 @@ void DolphinMainWindow::updateHistory()
void DolphinMainWindow::updateEditActions()
{
- const KFileItemList list = m_activeViewContainer->view()->selectedItems();
+ const QList<KFileItem> list = m_activeViewContainer->view()->selectedItems();
if (list.isEmpty()) {
stateChanged("has_no_selection");
} else {
@@ -1445,11 +1451,10 @@ void DolphinMainWindow::updateEditActions()
bool enableMoveToTrash = true;
- KFileItemList::const_iterator it = list.begin();
- const KFileItemList::const_iterator end = list.end();
+ QList<KFileItem>::const_iterator it = list.begin();
+ const QList<KFileItem>::const_iterator end = list.end();
while (it != end) {
- KFileItem* item = *it;
- const KUrl& url = item->url();
+ const KUrl& url = (*it).url();
// only enable the 'Move to Trash' action for local files
if (!url.isLocalFile()) {
enableMoveToTrash = false;
@@ -1572,8 +1577,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex)
this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
connect(view, SIGNAL(additionalInfoChanged(KFileItemDelegate::AdditionalInformation)),
this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation)));
- connect(view, SIGNAL(selectionChanged(KFileItemList)),
- this, SLOT(slotSelectionChanged(KFileItemList)));
+ connect(view, SIGNAL(selectionChanged(QList<KFileItem>)),
+ this, SLOT(slotSelectionChanged(QList<KFileItem>)));
connect(view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(slotRequestItemInfo(KFileItem)));
connect(view, SIGNAL(activated()),
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index b23e34136..8c79200fa 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -122,7 +122,7 @@ public slots:
* Inform all affected dolphin components that a selection change is
* requested.
*/
- void changeSelection(const KFileItemList& selection);
+ void changeSelection(const QList<KFileItem>& selection);
/** Stores all settings and quits Dolphin. */
void quit();
@@ -138,7 +138,7 @@ signals:
* Is sent if the selection of the currently active view has
* been changed.
*/
- void selectionChanged(const KFileItemList& selection);
+ void selectionChanged(const QList<KFileItem>& selection);
/**
* Is sent if the url of the currently active view has
@@ -404,7 +404,7 @@ private slots:
* Updates the state of the 'Edit' menu actions and emits
* the signal selectionChanged().
*/
- void slotSelectionChanged(const KFileItemList& selection);
+ void slotSelectionChanged(const QList<KFileItem>& selection);
/** Emits the signal requestItemInfo(). */
void slotRequestItemInfo(const KFileItem&);
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
index 776cd024e..2a88fe6b8 100644
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -70,7 +70,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
connect(m_view, SIGNAL(errorMessage(QString)), this, SLOT(slotErrorMessage(QString)));
// TODO connect to urlsDropped
// TOOD connect to requestContextMenu
- connect(m_view, SIGNAL(selectionChanged(KFileItemList)), m_extension, SIGNAL(selectionInfo(KFileItemList)));
+ connect(m_view, SIGNAL(selectionChanged(QList<KFileItem>)), m_extension, SIGNAL(selectionInfo(QList<KFileItem>)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)), this, SLOT(slotRequestItemInfo(KFileItem)));
diff --git a/src/dolphinsortfilterproxymodel.cpp b/src/dolphinsortfilterproxymodel.cpp
index 6a9442a23..6ce218562 100644
--- a/src/dolphinsortfilterproxymodel.cpp
+++ b/src/dolphinsortfilterproxymodel.cpp
@@ -93,18 +93,18 @@ bool DolphinSortFilterProxyModel::lessThanGeneralPurpose(const QModelIndex &left
{
KDirModel* dirModel = static_cast<KDirModel*>(sourceModel());
- const KFileItem* leftFileItem = dirModel->itemForIndex(left);
- const KFileItem* rightFileItem = dirModel->itemForIndex(right);
+ const KFileItem leftFileItem = dirModel->itemForIndex(left);
+ const KFileItem rightFileItem = dirModel->itemForIndex(right);
//FIXME left.column() should be used instead!
switch (sortRole()) {
case DolphinView::SortByName: {
- QString leftFileName(leftFileItem->name());
+ QString leftFileName(leftFileItem.name());
if (leftFileName.at(0) == '.') {
leftFileName = leftFileName.mid(1);
}
- QString rightFileName(rightFileItem->name());
+ QString rightFileName(rightFileItem.name());
if (rightFileName.at(0) == '.') {
rightFileName = rightFileName.mid(1);
}
@@ -117,40 +117,40 @@ bool DolphinSortFilterProxyModel::lessThanGeneralPurpose(const QModelIndex &left
case DolphinView::SortBySize:
// If we are sorting by size, show folders first. We will sort them
// correctly later.
- return leftFileItem->isDir() && !rightFileItem->isDir();
+ return leftFileItem.isDir() && !rightFileItem.isDir();
case DolphinView::SortByDate: {
- KDateTime leftTime = leftFileItem->time(KFileItem::ModificationTime);
- KDateTime rightTime = rightFileItem->time(KFileItem::ModificationTime);
+ KDateTime leftTime = leftFileItem.time(KFileItem::ModificationTime);
+ KDateTime rightTime = rightFileItem.time(KFileItem::ModificationTime);
return leftTime > rightTime;
}
case DolphinView::SortByPermissions: {
- return naturalCompare(leftFileItem->permissionsString(),
- rightFileItem->permissionsString()) < 0;
+ return naturalCompare(leftFileItem.permissionsString(),
+ rightFileItem.permissionsString()) < 0;
}
case DolphinView::SortByOwner: {
- return naturalCompare(leftFileItem->user().toLower(),
- rightFileItem->user().toLower()) < 0;
+ return naturalCompare(leftFileItem.user().toLower(),
+ rightFileItem.user().toLower()) < 0;
}
case DolphinView::SortByGroup: {
- return naturalCompare(leftFileItem->group().toLower(),
- rightFileItem->group().toLower()) < 0;
+ return naturalCompare(leftFileItem.group().toLower(),
+ rightFileItem.group().toLower()) < 0;
}
case DolphinView::SortByType: {
// If we are sorting by size, show folders first. We will sort them
// correctly later.
- if (leftFileItem->isDir() && !rightFileItem->isDir()) {
+ if (leftFileItem.isDir() && !rightFileItem.isDir()) {
return true;
- } else if (!leftFileItem->isDir() && rightFileItem->isDir()) {
+ } else if (!leftFileItem.isDir() && rightFileItem.isDir()) {
return false;
}
- return naturalCompare(leftFileItem->mimeComment().toLower(),
- rightFileItem->mimeComment().toLower()) < 0;
+ return naturalCompare(leftFileItem.mimeComment().toLower(),
+ rightFileItem.mimeComment().toLower()) < 0;
}
#ifdef HAVE_NEPOMUK
case DolphinView::SortByRating: {
@@ -182,15 +182,15 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
#ifdef HAVE_NEPOMUK
KDirModel* dirModel = static_cast<KDirModel*>(sourceModel());
- const KFileItem* leftFileItem = dirModel->itemForIndex(left);
- const KFileItem* rightFileItem = dirModel->itemForIndex(right);
+ const KFileItem leftFileItem = dirModel->itemForIndex(left);
+ const KFileItem rightFileItem = dirModel->itemForIndex(right);
// Hidden elements go before visible ones, if they both are
// folders or files.
- if (leftFileItem->isHidden() && !rightFileItem->isHidden()) {
+ if (leftFileItem.isHidden() && !rightFileItem.isHidden()) {
return true;
- } else if (!leftFileItem->isHidden() && rightFileItem->isHidden()) {
+ } else if (!leftFileItem.isHidden() && rightFileItem.isHidden()) {
return false;
}
@@ -207,15 +207,15 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
// we know we are on the same category. On the check we do on the
// top of the method we don't know, so we remove that check when we
// are sorting by rating. (ereslibre)
- if (leftFileItem->isDir() && !rightFileItem->isDir()) {
+ if (leftFileItem.isDir() && !rightFileItem.isDir()) {
return true;
- } else if (!leftFileItem->isDir() && rightFileItem->isDir()) {
+ } else if (!leftFileItem.isDir() && rightFileItem.isDir()) {
return false;
}
return sortCaseSensitivity() ?
- (naturalCompare(leftFileItem->name(), rightFileItem->name()) < 0) :
- (naturalCompare(leftFileItem->name().toLower(), rightFileItem->name().toLower()) < 0);
+ (naturalCompare(leftFileItem.name(), rightFileItem.name()) < 0) :
+ (naturalCompare(leftFileItem.name().toLower(), rightFileItem.name().toLower()) < 0);
}
return leftRating > rightRating;
@@ -232,15 +232,15 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
// we know we are on the same category. On the check we do on the
// top of the method we don't know, so we remove that check when we
// are sorting by tags. (ereslibre)
- if (leftFileItem->isDir() && !rightFileItem->isDir()) {
+ if (leftFileItem.isDir() && !rightFileItem.isDir()) {
return true;
- } else if (!leftFileItem->isDir() && rightFileItem->isDir()) {
+ } else if (!leftFileItem.isDir() && rightFileItem.isDir()) {
return false;
}
return sortCaseSensitivity() ?
- (naturalCompare(leftFileItem->name(), rightFileItem->name()) < 0) :
- (naturalCompare(leftFileItem->name().toLower(), rightFileItem->name().toLower()) < 0);
+ (naturalCompare(leftFileItem.name(), rightFileItem.name()) < 0) :
+ (naturalCompare(leftFileItem.name().toLower(), rightFileItem.name().toLower()) < 0);
}
return naturalCompare(leftTags, rightTags) < 0;
@@ -257,8 +257,8 @@ quint32 DolphinSortFilterProxyModel::ratingForIndex(const QModelIndex& index)
quint32 rating = 0;
const KDirModel* dirModel = static_cast<const KDirModel*>(index.model());
- KFileItem* item = dirModel->itemForIndex(index);
- if (item != 0) {
+ KFileItem item = dirModel->itemForIndex(index);
+ if (!item.isNull()) {
const Nepomuk::Resource resource(item->url().url(), Nepomuk::NFO::File());
rating = resource.rating();
}
@@ -275,8 +275,8 @@ QString DolphinSortFilterProxyModel::tagsForIndex(const QModelIndex& index)
QString tagsString;
const KDirModel* dirModel = static_cast<const KDirModel*>(index.model());
- KFileItem* item = dirModel->itemForIndex(index);
- if (item != 0) {
+ KFileItem item = dirModel->itemForIndex(index);
+ if (!item.isNull()) {
const Nepomuk::Resource resource(item->url().url(), Nepomuk::NFO::File());
const QList<Nepomuk::Tag> tags = resource.tags();
QStringList stringList;
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 197b4d8f9..6053ac189 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -290,7 +290,7 @@ void DolphinView::clearSelection()
itemView()->selectionModel()->clear();
}
-KFileItemList DolphinView::selectedItems() const
+QList<KFileItem> DolphinView::selectedItems() const
{
const QAbstractItemView* view = itemView();
@@ -299,15 +299,15 @@ KFileItemList DolphinView::selectedItems() const
Q_ASSERT((view != 0) && (view->selectionModel() != 0));
const QItemSelection selection = m_proxyModel->mapSelectionToSource(view->selectionModel()->selection());
- KFileItemList itemList;
+ QList<KFileItem> itemList;
const QModelIndexList indexList = selection.indexes();
QModelIndexList::const_iterator end = indexList.end();
for (QModelIndexList::const_iterator it = indexList.begin(); it != end; ++it) {
Q_ASSERT((*it).isValid());
- KFileItem* item = m_dirModel->itemForIndex(*it);
- if (item != 0) {
+ KFileItem item = m_dirModel->itemForIndex(*it);
+ if (!item.isNull()) {
itemList.append(item);
}
}
@@ -318,20 +318,15 @@ KFileItemList DolphinView::selectedItems() const
KUrl::List DolphinView::selectedUrls() const
{
KUrl::List urls;
-
- const KFileItemList list = selectedItems();
- KFileItemList::const_iterator it = list.begin();
- const KFileItemList::const_iterator end = list.end();
- while (it != end) {
- KFileItem* item = *it;
- urls.append(item->url());
- ++it;
+ const QList<KFileItem> list = selectedItems();
+ for ( QList<KFileItem>::const_iterator it = list.begin(), end = list.end();
+ it != end; ++it ) {
+ urls.append((*it).url());
}
-
return urls;
}
-KFileItem* DolphinView::fileItem(const QModelIndex index) const
+KFileItem DolphinView::fileItem(const QModelIndex& index) const
{
const QModelIndex dirModelIndex = m_proxyModel->mapToSource(index);
return m_dirModel->itemForIndex(dirModelIndex);
@@ -468,8 +463,8 @@ void DolphinView::triggerItem(const QModelIndex& index)
return;
}
- KFileItem* item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
- if (item == 0) {
+ KFileItem item = m_dirModel->itemForIndex(m_proxyModel->mapToSource(index));
+ if (item.isNull()) {
return;
}
@@ -477,13 +472,13 @@ void DolphinView::triggerItem(const QModelIndex& index)
// Prefer the local path over the URL.
bool isLocal;
- KUrl url = item->mostLocalUrl(isLocal);
+ KUrl url = item.mostLocalUrl(isLocal);
- if (item->isDir()) {
+ if (item.isDir()) {
setUrl(url);
- } else if (item->isFile()) {
+ } else if (item.isFile()) {
// allow to browse through ZIP and tar files
- KMimeType::Ptr mime = item->mimeTypePtr();
+ KMimeType::Ptr mime = item.mimeTypePtr();
if (mime->is("application/zip")) {
url.setProtocol("zip");
setUrl(url);
@@ -495,23 +490,17 @@ void DolphinView::triggerItem(const QModelIndex& index)
url.setProtocol("tar");
setUrl(url);
} else {
- item->run();
+ item.run();
}
} else {
- item->run();
+ item.run();
}
}
-void DolphinView::generatePreviews(const KFileItemList& items)
+void DolphinView::generatePreviews(const QList<KFileItem>& items)
{
if (m_controller->showPreview()) {
-
- // Must turn QList<KFileItem *> to QList<KFileItem>...
- QList<KFileItem> itemsToPreview;
- foreach( KFileItem* it, items )
- itemsToPreview.append( *it );
-
- KIO::PreviewJob* job = KIO::filePreview(itemsToPreview, 128);
+ KIO::PreviewJob* job = KIO::filePreview(items, 128);
connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
}
@@ -687,7 +676,7 @@ void DolphinView::applyViewProperties(const KUrl& url)
}
}
-void DolphinView::changeSelection(const KFileItemList& selection)
+void DolphinView::changeSelection(const QList<KFileItem>& selection)
{
clearSelection();
if (selection.isEmpty()) {
@@ -696,10 +685,10 @@ void DolphinView::changeSelection(const KFileItemList& selection)
const KUrl& baseUrl = url();
KUrl url;
QItemSelection new_selection;
- foreach(KFileItem* item, selection) {
- url = item->url().upUrl();
+ foreach(const KFileItem& item, selection) {
+ url = item.url().upUrl();
if (baseUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
- QModelIndex index = m_proxyModel->mapFromSource(m_dirModel->indexForItem(*item));
+ QModelIndex index = m_proxyModel->mapFromSource(m_dirModel->indexForItem(item));
new_selection.select(index, index);
}
}
@@ -710,7 +699,7 @@ void DolphinView::changeSelection(const KFileItemList& selection)
void DolphinView::openContextMenu(const QPoint& pos)
{
- KFileItem* item = 0;
+ KFileItem item;
const QModelIndex index = itemView()->indexAt(pos);
if (isValidNameIndex(index)) {
@@ -724,24 +713,24 @@ void DolphinView::dropUrls(const KUrl::List& urls,
const QModelIndex& index,
QWidget* source)
{
- KFileItem* directory = 0;
+ KFileItem directory;
if (isValidNameIndex(index)) {
- KFileItem* item = fileItem(index);
- Q_ASSERT(item != 0);
- if (item->isDir()) {
+ KFileItem item = fileItem(index);
+ Q_ASSERT(!item.isNull());
+ if (item.isDir()) {
// the URLs are dropped above a directory
directory = item;
}
}
- if ((directory == 0) && (source == itemView())) {
+ if ((directory.isNull()) && (source == itemView())) {
// The dropping is done into the same viewport where
// the dragging has been started. Just ignore this...
return;
}
- const KUrl& destination = (directory == 0) ?
- url() : directory->url();
+ const KUrl& destination = (directory.isNull()) ?
+ url() : directory.url();
dropUrls(urls, destination);
}
@@ -809,9 +798,9 @@ void DolphinView::showHoverInformation(const QModelIndex& index)
return;
}
- const KFileItem* item = fileItem(index);
- if (item != 0) {
- emit requestItemInfo(*item);
+ const KFileItem item = fileItem(index);
+ if (!item.isNull()) {
+ emit requestItemInfo(item);
}
}
@@ -930,9 +919,10 @@ void DolphinView::applyCutItemEffect()
KFileItem* item = *it;
if (isCutItem(*item)) {
const QModelIndex index = m_dirModel->indexForItem(*item);
- const KFileItem* item = m_dirModel->itemForIndex(index);
+ // Huh? the item is already known
+ //const KFileItem item = m_dirModel->itemForIndex(index);
const QVariant value = m_dirModel->data(index, Qt::DecorationRole);
- if ((value.type() == QVariant::Icon) && (item != 0)) {
+ if (value.type() == QVariant::Icon) {
const QIcon icon(qvariant_cast<QIcon>(value));
QPixmap pixmap = icon.pixmap(128, 128);
diff --git a/src/dolphinview.h b/src/dolphinview.h
index a18b87d08..cd6bd977a 100644
--- a/src/dolphinview.h
+++ b/src/dolphinview.h
@@ -224,7 +224,7 @@ public:
* selected.
* @see DolphinView::selectedUrls()
*/
- KFileItemList selectedItems() const;
+ QList<KFileItem> selectedItems() const;
/**
* Returns a list of URLs for all selected items. An empty list
@@ -236,7 +236,7 @@ public:
/**
* Returns the file item for the given model index \a index.
*/
- KFileItem* fileItem(const QModelIndex index) const;
+ KFileItem fileItem(const QModelIndex& index) const;
/**
* Sets the upper left position of the view content
@@ -307,7 +307,7 @@ public slots:
* will actually get selected. The view will e.g. not select items which
* are not in the currently displayed folder.
*/
- void changeSelection(const KFileItemList& selection);
+ void changeSelection(const QList<KFileItem>& selection);
signals:
/**
@@ -354,14 +354,14 @@ signals:
/**
* Is emitted whenever the selection has been changed.
*/
- void selectionChanged(const KFileItemList& selection);
+ void selectionChanged(const QList<KFileItem>& selection);
/**
* Is emitted if a context menu is requested for the item \a item,
* which is part of \a url. If the item is 0, the context menu
* for the URL should be shown.
*/
- void requestContextMenu(KFileItem* item, const KUrl& url);
+ void requestContextMenu(const KFileItem& item, const KUrl& url);
/**
* Is emitted if the URLs \a are dropped to the destination URL
@@ -406,7 +406,7 @@ private slots:
* The current preview settings (maximum size, 'Show Preview' menu)
* are respected.
*/
- void generatePreviews(const KFileItemList& items);
+ void generatePreviews(const QList<KFileItem>& items);
/**
* Replaces the icon of the item \a item by the preview pixmap
diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp
index c53b77818..32d5a407f 100644
--- a/src/dolphinviewcontainer.cpp
+++ b/src/dolphinviewcontainer.cpp
@@ -127,8 +127,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
m_proxyModel);
connect(m_view, SIGNAL(urlChanged(const KUrl&)),
m_urlNavigator, SLOT(setUrl(const KUrl&)));
- connect(m_view, SIGNAL(requestContextMenu(KFileItem*, const KUrl&)),
- this, SLOT(openContextMenu(KFileItem*, const KUrl&)));
+ connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),
+ this, SLOT(openContextMenu(KFileItem, const KUrl&)));
connect(m_view, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&)),
m_mainWindow, SLOT(dropUrls(const KUrl::List&, const KUrl&)));
connect(m_view, SIGNAL(contentsMoved(int, int)),
@@ -266,7 +266,7 @@ bool DolphinViewContainer::isUrlEditable() const
return m_urlNavigator->isUrlEditable();
}
-KFileItem* DolphinViewContainer::fileItem(const QModelIndex index) const
+KFileItem DolphinViewContainer::fileItem(const QModelIndex& index) const
{
const QModelIndex dirModelIndex = m_proxyModel->mapToSource(index);
return m_dirModel->itemForIndex(dirModelIndex);
@@ -358,7 +358,7 @@ QString DolphinViewContainer::defaultStatusBarText() const
QString DolphinViewContainer::selectionStatusBarText() const
{
QString text;
- const KFileItemList list = m_view->selectedItems();
+ const QList<KFileItem> list = m_view->selectedItems();
if (list.isEmpty()) {
// when an item is triggered, it is temporary selected but selectedItems()
// will return an empty list
@@ -368,15 +368,15 @@ QString DolphinViewContainer::selectionStatusBarText() const
int fileCount = 0;
int folderCount = 0;
KIO::filesize_t byteSize = 0;
- KFileItemList::const_iterator it = list.begin();
- const KFileItemList::const_iterator end = list.end();
+ QList<KFileItem>::const_iterator it = list.begin();
+ const QList<KFileItem>::const_iterator end = list.end();
while (it != end) {
- KFileItem* item = *it;
- if (item->isDir()) {
+ const KFileItem& item = *it;
+ if (item.isDir()) {
++folderCount;
} else {
++fileCount;
- byteSize += item->size();
+ byteSize += item.size();
}
++it;
}
@@ -450,7 +450,7 @@ void DolphinViewContainer::changeNameFilter(const QString& nameFilter)
#endif
}
-void DolphinViewContainer::openContextMenu(KFileItem* item,
+void DolphinViewContainer::openContextMenu(const KFileItem& item,
const KUrl& url)
{
DolphinContextMenu contextMenu(m_mainWindow, item, url);
diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h
index b8715d804..95be9134c 100644
--- a/src/dolphinviewcontainer.h
+++ b/src/dolphinviewcontainer.h
@@ -97,7 +97,7 @@ public:
*/
void renameSelectedItems();
- KFileItem* fileItem(const QModelIndex index) const;
+ KFileItem fileItem(const QModelIndex& index) const;
inline const DolphinStatusBar* statusBar() const;
inline DolphinStatusBar* statusBar();
@@ -177,7 +177,7 @@ private slots:
* should be applied to \a url.
* @url URL which contains \a item.
*/
- void openContextMenu(KFileItem* item, const KUrl& url);
+ void openContextMenu(const KFileItem& item, const KUrl& url);
/**
* Saves the position of the contents to the
diff --git a/src/infosidebarpage.cpp b/src/infosidebarpage.cpp
index 37330bdc6..b1dee423f 100644
--- a/src/infosidebarpage.cpp
+++ b/src/infosidebarpage.cpp
@@ -118,7 +118,7 @@ void InfoSidebarPage::setUrl(const KUrl& url)
}
}
-void InfoSidebarPage::setSelection(const KFileItemList& selection)
+void InfoSidebarPage::setSelection(const QList<KFileItem>& selection)
{
SidebarPage::setSelection(selection);
m_timer->start(TimerDelay);
@@ -167,13 +167,13 @@ void InfoSidebarPage::showItemInfo()
cancelRequest();
- const KFileItemList& selectedItems = selection();
+ const QList<KFileItem>& selectedItems = selection();
KUrl file;
if (selectedItems.isEmpty()) {
file = m_shownUrl;
} else {
- file = selectedItems[0]->url();
+ file = selectedItems[0].url();
}
if (!file.isValid()) {
return;
@@ -273,7 +273,7 @@ void InfoSidebarPage::showMetaInfo()
{
QString text;
- const KFileItemList& selectedItems = selection();
+ const QList<KFileItem>& selectedItems = selection();
if (selectedItems.size() <= 1) {
KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
fileItem.refresh();
@@ -311,14 +311,18 @@ void InfoSidebarPage::showMetaInfo()
}
} else {
if (MetaDataWidget::metaDataAvailable()) {
- m_metadataWidget->setFiles(selectedItems.urlList());
+ KUrl::List urls;
+ foreach (const KFileItem& item, selectedItems) {
+ urls.append(item.url());
+ }
+ m_metadataWidget->setFiles(urls);
}
unsigned long int totalSize = 0;
- foreach (KFileItem* item, selectedItems) {
+ foreach (const KFileItem& item, selectedItems) {
// TODO: what to do with directories (same with the one-item-selected-code)?,
- // item->size() does not return the size of the content : not very instinctive for users
- totalSize += item->size();
+ // item.size() does not return the size of the content : not very instinctive for users
+ totalSize += item.size();
}
addInfoLine(text, i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
}
diff --git a/src/infosidebarpage.h b/src/infosidebarpage.h
index 08472a034..c78eaa093 100644
--- a/src/infosidebarpage.h
+++ b/src/infosidebarpage.h
@@ -59,7 +59,7 @@ public slots:
virtual void setUrl(const KUrl& url);
/** @see SidebarPage::setSelection() */
- virtual void setSelection(const KFileItemList& selection);
+ virtual void setSelection(const QList<KFileItem>& selection);
/**
* Does a delayed request of information for the item \a item.
diff --git a/src/sidebarpage.cpp b/src/sidebarpage.cpp
index cb0e516e7..1543c8c78 100644
--- a/src/sidebarpage.cpp
+++ b/src/sidebarpage.cpp
@@ -26,7 +26,7 @@
SidebarPage::SidebarPage(QWidget* parent) :
QWidget(parent),
m_url(KUrl()),
- m_currentSelection(KFileItemList())
+ m_currentSelection()
{
}
@@ -39,7 +39,7 @@ const KUrl& SidebarPage::url() const
return m_url;
}
-const KFileItemList& SidebarPage::selection() const
+const QList<KFileItem>& SidebarPage::selection() const
{
return m_currentSelection;
}
@@ -49,7 +49,7 @@ void SidebarPage::setUrl(const KUrl& url)
m_url = url;
}
-void SidebarPage::setSelection(const KFileItemList& selection)
+void SidebarPage::setSelection(const QList<KFileItem>& selection)
{
m_currentSelection = selection;
}
diff --git a/src/sidebarpage.h b/src/sidebarpage.h
index 697e8de58..90f0194d3 100644
--- a/src/sidebarpage.h
+++ b/src/sidebarpage.h
@@ -39,7 +39,7 @@ public:
const KUrl& url() const;
/** Returns the current selected items of the active Dolphin view. */
- const KFileItemList& selection() const;
+ const QList<KFileItem>& selection() const;
public slots:
/**
@@ -52,7 +52,7 @@ public slots:
* This is invoked to inform the sidebar that the user has selected a new
* set of items.
*/
- virtual void setSelection(const KFileItemList& selection);
+ virtual void setSelection(const QList<KFileItem>& selection);
signals:
/**
@@ -70,7 +70,7 @@ signals:
* e.g. the current folder. The new selection will be reported via the
* setSelection slot.
*/
- void changeSelection(const KFileItemList& selection);
+ void changeSelection(const QList<KFileItem>& selection);
/**
* This signal is emitted whenever a drop action on this widget needs the
@@ -80,7 +80,7 @@ signals:
private:
KUrl m_url;
- KFileItemList m_currentSelection;
+ QList<KFileItem> m_currentSelection;
};
#endif // _SIDEBARPAGE_H_
diff --git a/src/treeviewcontextmenu.cpp b/src/treeviewcontextmenu.cpp
index e9963073f..f4469776b 100644
--- a/src/treeviewcontextmenu.cpp
+++ b/src/treeviewcontextmenu.cpp
@@ -34,7 +34,7 @@
#include <QtGui/QClipboard>
TreeViewContextMenu::TreeViewContextMenu(QWidget* parent,
- KFileItem* fileInfo) :
+ const KFileItem& fileInfo) :
m_parent(parent),
m_fileInfo(fileInfo)
{
@@ -46,7 +46,7 @@ TreeViewContextMenu::~TreeViewContextMenu()
void TreeViewContextMenu::open()
{
- Q_ASSERT(m_fileInfo != 0);
+ Q_ASSERT(!m_fileInfo.isNull());
KMenu* popup = new KMenu(m_parent);
@@ -77,7 +77,7 @@ void TreeViewContextMenu::open()
const KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
const KConfigGroup kdeConfig(globalConfig, "KDE");
bool showDeleteCommand = kdeConfig.readEntry("ShowDeleteCommand", false);
- const KUrl& url = m_fileInfo->url();
+ const KUrl& url = m_fileInfo.url();
if (url.isLocalFile()) {
QAction* moveToTrashAction = new QAction(KIcon("edit-trash"),
i18nc("@action:inmenu", "Move To Trash"), this);
@@ -108,7 +108,7 @@ void TreeViewContextMenu::cut()
{
QMimeData* mimeData = new QMimeData();
KUrl::List kdeUrls;
- kdeUrls.append(m_fileInfo->url());
+ kdeUrls.append(m_fileInfo.url());
KonqMimeData::populateMimeData(mimeData, kdeUrls, KUrl::List(), true);
QApplication::clipboard()->setMimeData(mimeData);
}
@@ -117,7 +117,7 @@ void TreeViewContextMenu::copy()
{
QMimeData* mimeData = new QMimeData();
KUrl::List kdeUrls;
- kdeUrls.append(m_fileInfo->url());
+ kdeUrls.append(m_fileInfo.url());
KonqMimeData::populateMimeData(mimeData, kdeUrls, KUrl::List(), false);
QApplication::clipboard()->setMimeData(mimeData);
}
@@ -128,7 +128,7 @@ void TreeViewContextMenu::paste()
const QMimeData* mimeData = clipboard->mimeData();
const KUrl::List source = KUrl::List::fromMimeData(mimeData);
- const KUrl& dest = m_fileInfo->url();
+ const KUrl& dest = m_fileInfo.url();
if (KonqMimeData::decodeIsCutSelection(mimeData)) {
KonqOperations::copy(m_parent, KonqOperations::MOVE, source, dest);
clipboard->clear();
@@ -139,7 +139,7 @@ void TreeViewContextMenu::paste()
void TreeViewContextMenu::rename()
{
- const KUrl& oldUrl = m_fileInfo->url();
+ const KUrl& oldUrl = m_fileInfo.url();
RenameDialog dialog(oldUrl);
if (dialog.exec() == QDialog::Accepted) {
const QString& newName = dialog.newName();
@@ -153,17 +153,17 @@ void TreeViewContextMenu::rename()
void TreeViewContextMenu::moveToTrash()
{
- KonqOperations::del(m_parent, KonqOperations::TRASH, m_fileInfo->url());
+ KonqOperations::del(m_parent, KonqOperations::TRASH, m_fileInfo.url());
}
void TreeViewContextMenu::deleteItem()
{
- KonqOperations::del(m_parent, KonqOperations::DEL, m_fileInfo->url());
+ KonqOperations::del(m_parent, KonqOperations::DEL, m_fileInfo.url());
}
void TreeViewContextMenu::showProperties()
{
- KPropertiesDialog dialog(m_fileInfo->url());
+ KPropertiesDialog dialog(m_fileInfo.url());
dialog.exec();
}
diff --git a/src/treeviewcontextmenu.h b/src/treeviewcontextmenu.h
index 84a5f5209..a8dfac126 100644
--- a/src/treeviewcontextmenu.h
+++ b/src/treeviewcontextmenu.h
@@ -21,8 +21,7 @@
#define TREEVIEWCONTEXTMENU_H
#include <QtCore/QObject>
-
-class KFileItem;
+#include <KFileItem>
/**
* @brief Represents the context menu which appears when doing a right
@@ -41,7 +40,7 @@ public:
* is above the viewport.
*/
TreeViewContextMenu(QWidget* parent,
- KFileItem* fileInfo);
+ const KFileItem& fileInfo);
virtual ~TreeViewContextMenu();
@@ -72,7 +71,7 @@ private slots:
private:
QWidget* m_parent;
- KFileItem* m_fileInfo;
+ KFileItem m_fileInfo;
};
#endif
diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp
index 97db7480d..7b434a495 100644
--- a/src/treeviewsidebarpage.cpp
+++ b/src/treeviewsidebarpage.cpp
@@ -128,9 +128,9 @@ void TreeViewSidebarPage::contextMenuEvent(QContextMenuEvent* event)
}
const QModelIndex dirModelIndex = m_proxyModel->mapToSource(index);
- KFileItem* item = m_dirModel->itemForIndex(dirModelIndex);
+ KFileItem item = m_dirModel->itemForIndex(dirModelIndex);
- emit changeSelection(KFileItemList());
+ emit changeSelection(QList<KFileItem>());
TreeViewContextMenu contextMenu(this, item);
contextMenu.open();
}
@@ -166,10 +166,9 @@ void TreeViewSidebarPage::expandSelectionParent()
void TreeViewSidebarPage::updateActiveView(const QModelIndex& index)
{
const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
- const KFileItem* item = m_dirModel->itemForIndex(dirIndex);
- if (item != 0) {
- const KUrl& url = item->url();
- emit changeUrl(url);
+ const KFileItem item = m_dirModel->itemForIndex(dirIndex);
+ if (!item.isNull()) {
+ emit changeUrl(item.url());
}
}
@@ -178,10 +177,10 @@ void TreeViewSidebarPage::dropUrls(const KUrl::List& urls,
{
if (index.isValid()) {
const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
- KFileItem* item = m_dirModel->itemForIndex(dirIndex);
- Q_ASSERT(item != 0);
- if (item->isDir()) {
- emit urlsDropped(urls, item->url());
+ KFileItem item = m_dirModel->itemForIndex(dirIndex);
+ Q_ASSERT(!item.isNull());
+ if (item.isDir()) {
+ emit urlsDropped(urls, item.url());
}
}
}