X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/bfcf764b69b9375b1b458d0a0c8ee95f3cb650ac..e8686083b9de4e83a448ddfd36ea57de7b9e2cd8:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index dc46a9429..5183f993d 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -22,8 +22,6 @@ #include #include "dolphinmainwindow.h" -#include - #include "bookmarkssidebarpage.h" #include "dolphinapplication.h" #include "dolphinnewmenu.h" @@ -58,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -106,7 +105,7 @@ DolphinMainWindow::~DolphinMainWindow() void DolphinMainWindow::setActiveView(DolphinView* view) { - assert((view == m_view[PrimaryIdx]) || (view == m_view[SecondaryIdx])); + Q_ASSERT((view == m_view[PrimaryIdx]) || (view == m_view[SecondaryIdx])); if (m_activeView == view) { return; } @@ -203,6 +202,12 @@ void DolphinMainWindow::dropUrls(const KUrl::List& urls, } } +void DolphinMainWindow::rename(const KUrl& oldUrl, const KUrl& newUrl) +{ + KonqOperations::rename(this, oldUrl, newUrl); + m_undoCommandTypes.append(KonqUndoManager::RENAME); +} + void DolphinMainWindow::refreshViews() { const bool split = DolphinSettings::instance().generalSettings()->splitView(); @@ -232,7 +237,7 @@ void DolphinMainWindow::refreshViews() } m_activeView = isPrimaryViewActive ? m_view[PrimaryIdx] : m_view[SecondaryIdx]; - assert(m_activeView != 0); + Q_ASSERT(m_activeView != 0); updateViewActions(); emit activeViewChanged(); @@ -303,11 +308,40 @@ void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order) descending->setChecked(sortDescending); } +void DolphinMainWindow::slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info) +{ + QAction* action = 0; + switch (info) { + case KFileItemDelegate::FriendlyMimeType: + action = actionCollection()->action("show_mime_info"); + break; + case KFileItemDelegate::Size: + action = actionCollection()->action("show_size_info"); + break; + case KFileItemDelegate::ModificationTime: + action = actionCollection()->action("show_date_info"); + break; + case KFileItemDelegate::NoInformation: + default: + action = actionCollection()->action("clear_info"); + break; + } + + if (action != 0) { + KToggleAction* toggleAction = static_cast(action); + toggleAction->setChecked(true); + + QActionGroup* group = toggleAction->actionGroup(); + Q_ASSERT(group != 0); + group->setEnabled(m_activeView->mode() == DolphinView::IconsView); + } +} + void DolphinMainWindow::slotSelectionChanged() { updateEditActions(); - assert(m_view[PrimaryIdx] != 0); + Q_ASSERT(m_view[PrimaryIdx] != 0); int selectedUrlsCount = m_view[PrimaryIdx]->selectedUrls().count(); if (m_view[SecondaryIdx] != 0) { selectedUrlsCount += m_view[SecondaryIdx]->selectedUrls().count(); @@ -415,7 +449,7 @@ void DolphinMainWindow::moveToTrash() clearStatusBar(); const KUrl::List selectedUrls = m_activeView->selectedUrls(); KonqOperations::del(this, KonqOperations::TRASH, selectedUrls); - m_undoOperations.append(KonqOperations::TRASH); + m_undoCommandTypes.append(KonqUndoManager::TRASH); } void DolphinMainWindow::deleteItems() @@ -424,7 +458,7 @@ void DolphinMainWindow::deleteItems() KUrl::List list = m_activeView->selectedUrls(); const uint itemCount = list.count(); - assert(itemCount >= 1); + Q_ASSERT(itemCount >= 1); QString text; if (itemCount > 1) { @@ -485,26 +519,36 @@ void DolphinMainWindow::slotUndoAvailable(bool available) undoAction->setEnabled(available); } - if (available && (m_undoOperations.count() > 0)) { - const KonqOperations::Operation op = m_undoOperations.takeFirst(); + if (available && (m_undoCommandTypes.count() > 0)) { + const KonqUndoManager::CommandType command = m_undoCommandTypes.takeFirst(); DolphinStatusBar* statusBar = m_activeView->statusBar(); - switch (op) { - case KonqOperations::COPY: + switch (command) { + case KonqUndoManager::COPY: statusBar->setMessage(i18n("Copy operation completed."), DolphinStatusBar::OperationCompleted); break; - case KonqOperations::MOVE: + case KonqUndoManager::MOVE: statusBar->setMessage(i18n("Move operation completed."), DolphinStatusBar::OperationCompleted); break; - case KonqOperations::LINK: + case KonqUndoManager::LINK: statusBar->setMessage(i18n("Link operation completed."), DolphinStatusBar::OperationCompleted); break; - case KonqOperations::TRASH: + case KonqUndoManager::TRASH: statusBar->setMessage(i18n("Move to trash operation completed."), DolphinStatusBar::OperationCompleted); break; + case KonqUndoManager::RENAME: + statusBar->setMessage(i18n("Renaming operation completed."), + DolphinStatusBar::OperationCompleted); + break; + + case KonqUndoManager::MKDIR: + statusBar->setMessage(i18n("Created directory."), + DolphinStatusBar::OperationCompleted); + break; + default: break; } @@ -528,11 +572,32 @@ void DolphinMainWindow::undo() void DolphinMainWindow::cut() { + QClipboard* clipboard = QApplication::clipboard(); + const QMimeData* currentMimeData = clipboard->mimeData(); + const bool hadCutSelection = KonqMimeData::decodeIsCutSelection(currentMimeData); + QMimeData* mimeData = new QMimeData(); const KUrl::List kdeUrls = m_activeView->selectedUrls(); const KUrl::List mostLocalUrls; KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true); QApplication::clipboard()->setMimeData(mimeData); + + if (hadCutSelection) { + // If an old cut selection has been applied, the view must + // be reloaded to get the original icons of the items without an + // applied item effect. + m_view[PrimaryIdx]->reload(); + if (m_view[SecondaryIdx] != 0) { + m_view[SecondaryIdx]->reload(); + } + } + else { + // apply an item effect for the icons of all cut items + m_view[PrimaryIdx]->updateCutItems(); + if (m_view[SecondaryIdx] != 0) { + m_view[SecondaryIdx]->updateCutItems(); + } + } } void DolphinMainWindow::copy() @@ -595,13 +660,7 @@ void DolphinMainWindow::updatePasteAction() if (!urls.isEmpty()) { pasteAction->setEnabled(true); - const int count = urls.count(); - if (count == 1) { - pasteAction->setText(i18n("Paste 1 File")); - } - else { - pasteAction->setText(i18n("Paste %1 Files", count)); - } + pasteAction->setText(i18np("Paste One File", "Paste %1 Files", urls.count())); } else { pasteAction->setEnabled(false); @@ -689,6 +748,29 @@ void DolphinMainWindow::toggleSortOrder() m_activeView->setSortOrder(order); } +void DolphinMainWindow::clearInfo() +{ + m_activeView->setAdditionalInfo(KFileItemDelegate::NoInformation); +} + +void DolphinMainWindow::showMimeInfo() +{ + clearStatusBar(); + m_activeView->setAdditionalInfo(KFileItemDelegate::FriendlyMimeType); +} + +void DolphinMainWindow::showSizeInfo() +{ + clearStatusBar(); + m_activeView->setAdditionalInfo(KFileItemDelegate::Size); +} + +void DolphinMainWindow::showDateInfo() +{ + clearStatusBar(); + m_activeView->setAdditionalInfo(KFileItemDelegate::ModificationTime); +} + void DolphinMainWindow::toggleSplitView() { if (m_view[SecondaryIdx] == 0) { @@ -845,7 +927,7 @@ void DolphinMainWindow::compareFiles() // - both in the secondary view // - one in the primary view and the other in the secondary // view - assert(m_view[PrimaryIdx] != 0); + Q_ASSERT(m_view[PrimaryIdx] != 0); KUrl urlA; KUrl urlB; @@ -853,9 +935,9 @@ void DolphinMainWindow::compareFiles() switch (urls.count()) { case 0: { - assert(m_view[SecondaryIdx] != 0); + Q_ASSERT(m_view[SecondaryIdx] != 0); urls = m_view[SecondaryIdx]->selectedUrls(); - assert(urls.count() == 2); + Q_ASSERT(urls.count() == 2); urlA = urls[0]; urlB = urls[1]; break; @@ -863,9 +945,9 @@ void DolphinMainWindow::compareFiles() case 1: { urlA = urls[0]; - assert(m_view[SecondaryIdx] != 0); + Q_ASSERT(m_view[SecondaryIdx] != 0); urls = m_view[SecondaryIdx]->selectedUrls(); - assert(urls.count() == 1); + Q_ASSERT(urls.count() == 1); urlB = urls[0]; break; } @@ -879,7 +961,7 @@ void DolphinMainWindow::compareFiles() default: { // may not happen: compareFiles may only get invoked if 2 // files are selected - assert(false); + Q_ASSERT(false); } } @@ -916,7 +998,7 @@ void DolphinMainWindow::init() DolphinSettings& settings = DolphinSettings::instance(); KBookmarkManager* manager = settings.bookmarkManager(); - assert(manager != 0); + Q_ASSERT(manager != 0); KBookmarkGroup root = manager->root(); if (root.first().isNull()) { root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder-home"); @@ -1112,6 +1194,28 @@ void DolphinMainWindow::setupActions() sortDescending->setText(i18n("Descending")); connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); + KToggleAction* clearInfo = actionCollection()->add("clear_info"); + clearInfo->setText(i18n("No Information")); + connect(clearInfo, SIGNAL(triggered()), this, SLOT(clearInfo())); + + KToggleAction* showMimeInfo = actionCollection()->add("show_mime_info"); + showMimeInfo->setText(i18n("Type")); + connect(showMimeInfo, SIGNAL(triggered()), this, SLOT(showMimeInfo())); + + KToggleAction* showSizeInfo = actionCollection()->add("show_size_info"); + showSizeInfo->setText(i18n("Size")); + connect(showSizeInfo, SIGNAL(triggered()), this, SLOT(showSizeInfo())); + + KToggleAction* showDateInfo = actionCollection()->add("show_date_info"); + showDateInfo->setText(i18n("Date")); + connect(showDateInfo, SIGNAL(triggered()), this, SLOT(showDateInfo())); + + QActionGroup* infoGroup = new QActionGroup(this); + infoGroup->addAction(clearInfo); + infoGroup->addAction(showMimeInfo); + infoGroup->addAction(showSizeInfo); + infoGroup->addAction(showDateInfo); + KToggleAction* showPreview = actionCollection()->add("show_preview"); showPreview->setText(i18n("Preview")); showPreview->setIcon(KIcon("thumbnail-show")); @@ -1316,6 +1420,7 @@ void DolphinMainWindow::updateViewActions() slotSortingChanged(m_activeView->sorting()); slotSortOrderChanged(m_activeView->sortOrder()); + slotAdditionalInfoChanged(m_activeView->additionalInfo()); KToggleAction* showFilterBarAction = static_cast(actionCollection()->action("show_filter_bar")); @@ -1347,19 +1452,19 @@ void DolphinMainWindow::updateGoActions() void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest) { KonqOperations::copy(this, KonqOperations::COPY, source, dest); - m_undoOperations.append(KonqOperations::COPY); + m_undoCommandTypes.append(KonqUndoManager::COPY); } void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest) { KonqOperations::copy(this, KonqOperations::MOVE, source, dest); - m_undoOperations.append(KonqOperations::MOVE); + m_undoCommandTypes.append(KonqUndoManager::MOVE); } void DolphinMainWindow::linkUrls(const KUrl::List& source, const KUrl& dest) { KonqOperations::copy(this, KonqOperations::LINK, source, dest); - m_undoOperations.append(KonqOperations::LINK); + m_undoCommandTypes.append(KonqUndoManager::LINK); } void DolphinMainWindow::clearStatusBar() @@ -1380,6 +1485,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex) this, SLOT(slotSortingChanged(DolphinView::Sorting))); connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)), this, SLOT(slotSortOrderChanged(Qt::SortOrder))); + connect(view, SIGNAL(additionalInfoChanged(KFileItemDelegate::AdditionalInformation)), + this, SLOT(slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation))); connect(view, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged())); connect(view, SIGNAL(showFilterBarChanged(bool)), @@ -1397,7 +1504,7 @@ DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) KonqUndoManager::UiInterface(mainWin), m_mainWin(mainWin) { - assert(m_mainWin != 0); + Q_ASSERT(m_mainWin != 0); } DolphinMainWindow::UndoUiInterface::~UndoUiInterface()