diff options
| author | Peter Penz <[email protected]> | 2011-11-26 01:05:58 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-11-26 01:16:31 +0100 |
| commit | 362817d1834f2ada3ea4552a25fa39bbbb540f8c (patch) | |
| tree | 706f316224397b44f95516ba857bb8d380a0bb47 /src/panels/folders/treeviewcontextmenu.cpp | |
| parent | bf1a8f989e75a50c9a5c839e69573a87ab9ad934 (diff) | |
Folders Panel fixes
The following functionality from Dolphin 1.x has
been ported to the new view-engine:
- Allow expanding/collapsing of items
- Automatically select the current item
- Context menu for items
Related improvements to the view-engine:
- Make the expanding/collapsing interface already accessible
in the base classes KItemModelBase and KItemListView. If
no expanding/collapsing is supported at all by derived models
(which is usually the default case) simply not reimplementing
those 3 methods is sufficient and it does not introduce an
additional complexity like in QAbstractItemModel/QModelIndex.
- Automatically handle the expanding/collapsing in KItemListController.
This also includes the key-handling, which is quite special for
expandable items.
- Don't let KItemListView automatically scroll to the current item
if the current item got changed. The automatic scrolling should
only be done if the current item has been changed by the user.
Hence this functionality has been moved to the KItemListController
which currently only triggers the automatic scrolling if the current
item has been changed by the keyboard (we might extend the usecases
later if required).
Diffstat (limited to 'src/panels/folders/treeviewcontextmenu.cpp')
| -rw-r--r-- | src/panels/folders/treeviewcontextmenu.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp index 5db3e2c2a..daf14ab4a 100644 --- a/src/panels/folders/treeviewcontextmenu.cpp +++ b/src/panels/folders/treeviewcontextmenu.cpp @@ -39,7 +39,7 @@ TreeViewContextMenu::TreeViewContextMenu(FoldersPanel* parent, const KFileItem& fileInfo) : QObject(parent), m_parent(parent), - m_fileInfo(fileInfo) + m_fileItem(fileInfo) { } @@ -51,8 +51,8 @@ void TreeViewContextMenu::open() { KMenu* popup = new KMenu(m_parent); - if (!m_fileInfo.isNull()) { - KFileItemListProperties capabilities(KFileItemList() << m_fileInfo); + if (!m_fileItem.isNull()) { + KFileItemListProperties capabilities(KFileItemList() << m_fileItem); // insert 'Cut', 'Copy' and 'Paste' QAction* cutAction = new QAction(KIcon("edit-cut"), i18nc("@action:inmenu", "Cut"), this); @@ -85,7 +85,7 @@ void TreeViewContextMenu::open() KConfigGroup configGroup(globalConfig, "KDE"); bool showDeleteCommand = configGroup.readEntry("ShowDeleteCommand", false); - const KUrl url = m_fileInfo.url(); + const KUrl url = m_fileItem.url(); if (url.isLocalFile()) { QAction* moveToTrashAction = new QAction(KIcon("user-trash"), i18nc("@action:inmenu", "Move to Trash"), this); @@ -115,34 +115,40 @@ void TreeViewContextMenu::open() popup->addSeparator(); } - QAction* showHiddenFilesAction = new QAction(i18nc("@action:inmenu", "Show Hidden Files"), this); - showHiddenFilesAction->setCheckable(true); - showHiddenFilesAction->setChecked(m_parent->hiddenFilesShown()); - popup->addAction(showHiddenFilesAction); - connect(showHiddenFilesAction, SIGNAL(toggled(bool)), this, SLOT(setShowHiddenFiles(bool))); + if (m_fileItem.isNull()) { + QAction* showHiddenFilesAction = new QAction(i18nc("@action:inmenu", "Show Hidden Files"), this); + showHiddenFilesAction->setCheckable(true); + showHiddenFilesAction->setChecked(m_parent->hiddenFilesShown()); + popup->addAction(showHiddenFilesAction); + connect(showHiddenFilesAction, SIGNAL(toggled(bool)), this, SLOT(setShowHiddenFiles(bool))); - QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this); - autoScrollingAction->setCheckable(true); - autoScrollingAction->setChecked(m_parent->autoScrolling()); - popup->addAction(autoScrollingAction); - connect(autoScrollingAction, SIGNAL(toggled(bool)), this, SLOT(setAutoScrolling(bool))); + QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this); + autoScrollingAction->setCheckable(true); + autoScrollingAction->setChecked(m_parent->autoScrolling()); + // TODO: Temporary disabled. Horizontal autoscrolling will be implemented later either + // in KItemViews or manually as part of the FoldersPanel + //popup->addAction(autoScrollingAction); + connect(autoScrollingAction, SIGNAL(toggled(bool)), this, SLOT(setAutoScrolling(bool))); + } - popup->addSeparator(); foreach (QAction* action, m_parent->customContextMenuActions()) { popup->addAction(action); } + QWeakPointer<KMenu> popupPtr = popup; popup->exec(QCursor::pos()); - popup->deleteLater(); + if (popupPtr.data()) { + popupPtr.data()->deleteLater(); + } } void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut) { KUrl::List kdeUrls; - kdeUrls.append(m_fileInfo.url()); + kdeUrls.append(m_fileItem.url()); KUrl::List mostLocalUrls; bool dummy; - mostLocalUrls.append(m_fileInfo.mostLocalUrl(dummy)); + mostLocalUrls.append(m_fileItem.mostLocalUrl(dummy)); KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, cut); } @@ -166,7 +172,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_fileItem.url(); if (KonqMimeData::decodeIsCutSelection(mimeData)) { KonqOperations::copy(m_parent, KonqOperations::MOVE, source, dest); clipboard->clear(); @@ -177,22 +183,22 @@ void TreeViewContextMenu::paste() void TreeViewContextMenu::rename() { - m_parent->rename(m_fileInfo); + m_parent->rename(m_fileItem); } void TreeViewContextMenu::moveToTrash() { - KonqOperations::del(m_parent, KonqOperations::TRASH, m_fileInfo.url()); + KonqOperations::del(m_parent, KonqOperations::TRASH, m_fileItem.url()); } void TreeViewContextMenu::deleteItem() { - KonqOperations::del(m_parent, KonqOperations::DEL, m_fileInfo.url()); + KonqOperations::del(m_parent, KonqOperations::DEL, m_fileItem.url()); } void TreeViewContextMenu::showProperties() { - KPropertiesDialog* dialog = new KPropertiesDialog(m_fileInfo.url(), m_parent); + KPropertiesDialog* dialog = new KPropertiesDialog(m_fileItem.url(), m_parent); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); } |
