Factorize all the view-related action handling to DolphinViewActionHandler, to remove code duplication between mainwindow and part, and to remove my code-splitting with the static createFooAction methods in the view.
svn path=/trunk/KDE/kdebase/apps/; revision=773572
add_subdirectory( pics )
add_subdirectory( tests )
+macro_optional_find_package(Soprano)
+
include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${BLITZ_INCLUDES} )
if (Soprano_FOUND)
include_directories( ${SOPRANO_INCLUDE_DIR} )
dolphiniconsview.cpp
dolphincolumnview.cpp
dolphincolumnwidget.cpp
+ dolphindropcontroller.cpp
+ dolphinsortfilterproxymodel.cpp
draganddrophelper.cpp
- kcategorizedview.cpp
- kcategorydrawer.cpp
dolphinmodel.cpp
dolphinsettings.cpp
dolphincategorydrawer.cpp
- viewproperties.cpp
- dolphinsortfilterproxymodel.cpp
- renamedialog.cpp
dolphinview.cpp
+ dolphinviewactionhandler.cpp
+ iconmanager.cpp
ratingpainter.cpp
- dolphindropcontroller.cpp
+ renamedialog.cpp
+ selectiontoggle.cpp
+ selectionmanager.cpp
+ viewproperties.cpp
)
kde4_add_kcfg_files(dolphinprivate_LIB_SRCS
dolphinstatusbar.cpp
dolphindirlister.cpp
dolphincontextmenu.cpp
+ dolphinfileplacesview.cpp
dolphinsettingsdialog.cpp
draganddrophelper.cpp
filterbar.cpp
pixmapviewer.cpp
settingspagebase.cpp
sidebarpage.cpp
+ startupsettingspage.cpp
statusbarspaceinfo.cpp
statusbarmessagelabel.cpp
terminalsidebarpage.cpp
***************************************************************************/
#include "dolphinmainwindow.h"
+ #include "dolphinviewactionhandler.h"
#include "dolphindropcontroller.h"
#include <config-nepomuk.h>
#include "dolphinapplication.h"
+#include "dolphinfileplacesview.h"
#include "dolphinnewmenu.h"
#include "dolphinsettings.h"
#include "dolphinsettingsdialog.h"
#include "mainwindowadaptor.h"
#include "terminalsidebarpage.h"
#include "treeviewsidebarpage.h"
-#include "kurlnavigator.h"
#include "viewpropertiesdialog.h"
#include "viewproperties.h"
-#include "kfileplacesmodel.h"
-#include "kfileplacesview.h"
#include "dolphin_generalsettings.h"
#include "dolphin_iconsmodesettings.h"
#include <kdesktopfile.h>
#include <kdeversion.h>
#include <kfiledialog.h>
+#include <kfileplacesmodel.h>
#include <kglobal.h>
#include <kicon.h>
#include <kiconloader.h>
#include <kmenu.h>
#include <kmenubar.h>
#include <kmessagebox.h>
+#include <kurlnavigator.h>
#include <konqmimedata.h>
- #include <konq_operations.h>
#include <kpropertiesdialog.h>
#include <kprotocolinfo.h>
#include <ktoggleaction.h>
updateViewActions();
}
- void DolphinMainWindow::slotShowPreviewChanged()
- {
- // It is not enough to update the 'Show Preview' action, also
- // the 'Zoom In' and 'Zoom Out' actions must be adapted.
- updateViewActions();
- }
-
- void DolphinMainWindow::slotShowHiddenFilesChanged()
- {
- QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files");
- const DolphinView* view = m_activeViewContainer->view();
- showHiddenFilesAction->setChecked(view->showHiddenFiles());
- }
-
- void DolphinMainWindow::slotCategorizedSortingChanged()
- {
- QAction* showInGroupsAction = actionCollection()->action("show_in_groups");
- const DolphinView* view = m_activeViewContainer->view();
- showInGroupsAction->setChecked(view->categorizedSorting());
- showInGroupsAction->setEnabled(view->supportsCategorizedSorting());
- }
-
void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
{
QAction* action = 0;
}
}
- void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
- {
- QAction* descending = actionCollection()->action("descending");
- const bool sortDescending = (order == Qt::DescendingOrder);
- descending->setChecked(sortDescending);
- }
-
- void DolphinMainWindow::slotAdditionalInfoChanged()
- {
- DolphinView* view = m_activeViewContainer->view();
- view->updateAdditionalInfoActions(actionCollection());
- }
-
+void DolphinMainWindow::slotEditableStateChanged(bool editable)
+{
+ KToggleAction* editableLocationAction =
+ static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
+ editableLocationAction->setChecked(editable);
+}
+
void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection)
{
updateEditActions();
}
}
- void DolphinMainWindow::createDir()
- {
- const KUrl& url = m_activeViewContainer->view()->url();
- KonqOperations::newDir(this, url);
- }
-
void DolphinMainWindow::updateNewMenu()
{
m_newMenu->slotCheckUpToDate();
m_newMenu->setPopupFiles(activeViewContainer()->url());
}
- void DolphinMainWindow::rename()
- {
- clearStatusBar();
- m_activeViewContainer->view()->renameSelectedItems();
- }
-
- void DolphinMainWindow::moveToTrash()
- {
- clearStatusBar();
-
- DolphinView* view = m_activeViewContainer->view();
-
- if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
- view->deleteSelectedItems();
- } else {
- view->trashSelectedItems();
- }
- }
-
- void DolphinMainWindow::deleteItems()
- {
- clearStatusBar();
- m_activeViewContainer->view()->deleteSelectedItems();
- }
-
void DolphinMainWindow::properties()
{
const KFileItemList list = m_activeViewContainer->view()->selectedItems();
void DolphinMainWindow::slotUndoAvailable(bool available)
{
- QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
if (undoAction != 0) {
undoAction->setEnabled(available);
}
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
{
- QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo));
if (undoAction != 0) {
undoAction->setText(text);
}
void DolphinMainWindow::updatePasteAction()
{
- QAction* pasteAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste));
+ QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
if (pasteAction == 0) {
return;
}
#endif
}
- void DolphinMainWindow::toggleSortOrder()
- {
- m_activeViewContainer->view()->toggleSortOrder();
- }
-
- void DolphinMainWindow::toggleSortCategorization(bool categorizedSorting)
- {
- DolphinView* view = m_activeViewContainer->view();
- view->setCategorizedSorting(categorizedSorting);
- }
-
void DolphinMainWindow::toggleSplitView()
{
if (m_viewContainer[SecondaryView] == 0) {
setActiveViewContainer(m_viewContainer[PrimaryView]);
updateViewActions();
- emit activeViewChanged();
+ emit activeViewChanged(); // TODO unused; remove?
}
void DolphinMainWindow::reloadView()
{
}
- void DolphinMainWindow::togglePreview(bool show)
- {
- clearStatusBar();
- m_activeViewContainer->view()->setShowPreview(show);
- }
-
- void DolphinMainWindow::toggleShowHiddenFiles(bool show)
- {
- clearStatusBar();
- m_activeViewContainer->view()->setShowHiddenFiles(show);
- }
-
void DolphinMainWindow::toggleFilterBarVisibility(bool show)
{
m_activeViewContainer->showFilterBar(show);
}
- void DolphinMainWindow::zoomIn()
- {
- m_activeViewContainer->view()->zoomIn();
- updateViewActions();
- }
-
- void DolphinMainWindow::zoomOut()
- {
- m_activeViewContainer->view()->zoomOut();
- updateViewActions();
- }
-
void DolphinMainWindow::toggleEditLocation()
{
clearStatusBar();
const KUrl& homeUrl = settings.generalSettings()->homeUrl();
setCaption(homeUrl.fileName());
+ m_actionHandler = new DolphinViewActionHandler(actionCollection(), this);
+ connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar()));
ViewProperties props(homeUrl);
m_viewContainer[PrimaryView] = new DolphinViewContainer(this,
m_splitter,
m_activeViewContainer = m_viewContainer[PrimaryView];
connectViewSignals(PrimaryView);
- m_viewContainer[PrimaryView]->view()->reload();
+ DolphinView* view = m_viewContainer[PrimaryView]->view();
+ view->reload();
m_viewContainer[PrimaryView]->show();
+ m_actionHandler->setCurrentView(view);
setCentralWidget(m_splitter);
setupDockWidgets();
emit urlChanged(homeUrl);
}
- void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* view)
+ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContainer)
{
- Q_ASSERT(view != 0);
- Q_ASSERT((view == m_viewContainer[PrimaryView]) || (view == m_viewContainer[SecondaryView]));
- if (m_activeViewContainer == view) {
+ Q_ASSERT(viewContainer != 0);
+ Q_ASSERT((viewContainer == m_viewContainer[PrimaryView]) || (viewContainer == m_viewContainer[SecondaryView]));
+ if (m_activeViewContainer == viewContainer) {
return;
}
m_activeViewContainer->setActive(false);
- m_activeViewContainer = view;
+ m_activeViewContainer = viewContainer;
m_activeViewContainer->setActive(true);
updateHistory();
const KUrl& url = m_activeViewContainer->url();
setCaption(url.fileName());
- emit activeViewChanged();
+ m_actionHandler->setCurrentView(viewContainer->view());
+
+ emit activeViewChanged(); // TODO unused; remove?
emit urlChanged(url);
}
connect(menu, SIGNAL(aboutToShow()),
this, SLOT(updateNewMenu()));
- KAction* newDirAction = DolphinView::createNewDirAction(actionCollection());
- connect(newDirAction, SIGNAL(triggered()), SLOT(createDir()));
-
KAction* newWindow = actionCollection()->addAction("new_window");
newWindow->setIcon(KIcon("window-new"));
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
newWindow->setShortcut(Qt::CTRL | Qt::Key_N);
connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
- KAction* rename = DolphinView::createRenameAction(actionCollection());
- connect(rename, SIGNAL(triggered()), this, SLOT(rename()));
-
- KAction* moveToTrash = DolphinView::createMoveToTrashAction(actionCollection());
- connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash()));
-
- KAction* deleteAction = DolphinView::createDeleteAction(actionCollection());
- connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems()));
-
KAction* properties = actionCollection()->addAction("properties");
properties->setText(i18nc("@action:inmenu File", "Properties"));
properties->setShortcut(Qt::ALT | Qt::Key_Return);
SLOT(undo()),
actionCollection());
- //Need to remove shift+del from cut action, else the shortcut for deletejob
- //doesn't work
+ // need to remove shift+del from cut action, else the shortcut for deletejob
+ // doesn't work
KAction* cut = KStandardAction::cut(this, SLOT(cut()), actionCollection());
KShortcut cutShortcut = cut->shortcut();
cutShortcut.remove(Qt::SHIFT + Qt::Key_Delete, KShortcut::KeepEmpty);
connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
// setup 'View' menu
- KStandardAction::zoomIn(this,
- SLOT(zoomIn()),
- actionCollection());
-
- KStandardAction::zoomOut(this,
- SLOT(zoomOut()),
- actionCollection());
KToggleAction* iconsView = DolphinView::iconsModeAction(actionCollection());
KToggleAction* detailsView = DolphinView::detailsModeAction(actionCollection());
viewModeGroup->addAction(columnView);
connect(viewModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setViewMode(QAction*)));
+ //QActionGroup* sortActionGroup = DolphinView::createSortActionGroup(actionCollection());
+ //connect(sortActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(sortActionGroupTriggered(QAction*)));
+
// TODO use a QActionGroup
KToggleAction* sortByName = actionCollection()->add<KToggleAction>("sort_by_name");
//sortGroup->addAction(sortByRating);
//sortGroup->addAction(sortByTags);
- KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection());
- connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
-
- KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection());
- connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleSortCategorization(bool)));
-
- QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection());
- connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*)));
-
- KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection());
- connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool)));
-
- KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection());
- connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool)));
-
KAction* split = actionCollection()->addAction("split_view");
split->setShortcut(Qt::Key_F3);
updateSplitAction();
stop->setIcon(KIcon("process-stop"));
connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading()));
- // TODO: the URL navigator must emit a signal if the editable state has been
- // changed, so that the corresponding showFullLocation action is updated. Also
- // the naming "Show full Location" is currently confusing...
+ // TODO: the naming "Show full Location" is currently confusing...
KToggleAction* showFullLocation = actionCollection()->add<KToggleAction>("editable_location");
showFullLocation->setText(i18nc("@action:inmenu Navigation Bar", "Show Full Location"));
showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L);
QDockWidget* placesDock = new QDockWidget(i18nc("@title:window", "Places"));
placesDock->setObjectName("placesDock");
placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- KFilePlacesView* placesView = new KFilePlacesView(placesDock);
+
+ DolphinFilePlacesView* placesView = new DolphinFilePlacesView(placesDock);
placesDock->setWidget(placesView);
placesView->setModel(DolphinSettings::instance().placesModel());
placesView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
void DolphinMainWindow::updateViewActions()
{
- const DolphinView* view = m_activeViewContainer->view();
- QAction* zoomInAction = actionCollection()->action(KStandardAction::name(KStandardAction::ZoomIn));
- if (zoomInAction != 0) {
- zoomInAction->setEnabled(view->isZoomInPossible());
- }
-
- QAction* zoomOutAction = actionCollection()->action(KStandardAction::name(KStandardAction::ZoomOut));
- if (zoomOutAction != 0) {
- zoomOutAction->setEnabled(view->isZoomOutPossible());
- }
+ m_actionHandler->updateViewActions();
+ const DolphinView* view = m_activeViewContainer->view();
QAction* action = actionCollection()->action(view->currentViewModeActionName());
if (action != 0) {
action->setChecked(true);
}
slotSortingChanged(view->sorting());
- slotSortOrderChanged(view->sortOrder());
- slotCategorizedSortingChanged();
- slotAdditionalInfoChanged();
QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
- QAction* showPreviewAction = actionCollection()->action("show_preview");
- showPreviewAction->setChecked(view->showPreview());
-
- QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files");
- showHiddenFilesAction->setChecked(view->showHiddenFiles());
-
updateSplitAction();
QAction* editableLocactionAction = actionCollection()->action("editable_location");
void DolphinMainWindow::updateGoActions()
{
- QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Up));
+ QAction* goUpAction = actionCollection()->action(KStandardAction::name(KStandardAction::Up));
const KUrl& currentUrl = m_activeViewContainer->url();
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
}
DolphinView* view = container->view();
connect(view, SIGNAL(modeChanged()),
this, SLOT(slotViewModeChanged()));
- connect(view, SIGNAL(showPreviewChanged()),
- this, SLOT(slotShowPreviewChanged()));
- connect(view, SIGNAL(showHiddenFilesChanged()),
- this, SLOT(slotShowHiddenFilesChanged()));
- connect(view, SIGNAL(categorizedSortingChanged()),
- this, SLOT(slotCategorizedSortingChanged()));
connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),
this, SLOT(slotSortingChanged(DolphinView::Sorting)));
- connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
- this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
- connect(view, SIGNAL(additionalInfoChanged()),
- this, SLOT(slotAdditionalInfoChanged()));
connect(view, SIGNAL(selectionChanged(KFileItemList)),
this, SLOT(slotSelectionChanged(KFileItemList)));
connect(view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(changeUrl(const KUrl&)));
connect(navigator, SIGNAL(historyChanged()),
this, SLOT(slotHistoryChanged()));
+ connect(navigator, SIGNAL(editableStateChanged(bool)),
+ this, SLOT(slotEditableStateChanged(bool)));
}
void DolphinMainWindow::updateSplitAction()
}
}
- void DolphinMainWindow::toggleAdditionalInfo(QAction* action)
- {
- clearStatusBar();
- m_activeViewContainer->view()->toggleAdditionalInfo(action);
- }
-
DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :
KonqFileUndoManager::UiInterface(mainWin),
m_mainWin(mainWin)
#include <QtCore/QList>
+ class DolphinViewActionHandler;
class DolphinApplication;
class DolphinViewContainer;
class KNewMenu;
virtual void readProperties(const KConfigGroup& group);
private slots:
- /**
- * Opens the dialog for creating a directory. Is connected
- * with the key shortcut for "new directory" (F10).
- */
- void createDir();
+ void clearStatusBar();
/** Updates the 'Create New...' sub menu. */
void updateNewMenu();
- /**
- * Let the user input a name for the selected item(s) and trigger
- * a renaming afterwards.
- */
- void rename();
-
- /** Moves the selected items of the active view to the trash. */
- void moveToTrash();
-
- /** Deletes the selected items of the active view. */
- void deleteItems();
-
/**
* Opens the properties window for the selected items of the
* active view. The properties windows shows information
/** The sorting of the current view should be done by tags. */
void sortByTags();
- /** Switches between an ascending and descending sorting order. */
- void toggleSortOrder();
-
- /** Switches between sorting by categories or not. */
- void toggleSortCategorization(bool);
-
- /**
- * Switches on or off the displaying of additional information
- * as specified by \a action.
- */
- void toggleAdditionalInfo(QAction* action);
-
/**
* Switches between one and two views:
* If one view is visible, it will get split into two views.
/** Stops the loading process for the current active view. */
void stopLoading();
- /** Switches between showing a preview of the file content and showing the icon. */
- void togglePreview(bool);
-
- /**
- * Switches between showing and hiding of hidden marked files
- */
- void toggleShowHiddenFiles(bool);
-
/**
* Toggles between showing and hiding of the filter bar
*/
void toggleFilterBarVisibility(bool show);
- /** Increases the size of the current set view mode. */
- void zoomIn();
-
- /** Decreases the size of the current set view mode. */
- void zoomOut();
-
/**
- * Toggles between edit and brose mode of the navigation bar.
+ * Toggles between edit and browse mode of the navigation bar.
*/
void toggleEditLocation();
/** Updates the state of all 'View' menu actions. */
void slotViewModeChanged();
- /** Updates the state of the 'Show preview' menu action. */
- void slotShowPreviewChanged();
-
- /** Updates the state of the 'Show hidden files' menu action. */
- void slotShowHiddenFilesChanged();
-
- /** Updates the state of the 'Categorized sorting' menu action. */
- void slotCategorizedSortingChanged();
-
/** Updates the state of the 'Sort by' actions. */
void slotSortingChanged(DolphinView::Sorting sorting);
- /** Updates the state of the 'Sort Ascending/Descending' action. */
- void slotSortOrderChanged(Qt::SortOrder order);
-
- /** Updates the state of the 'Additional Information' actions. */
- void slotAdditionalInfoChanged();
-
+ /** Updates the state of the 'Show Full Location' action. */
+ void slotEditableStateChanged(bool editable);
+
/**
* Updates the state of the 'Edit' menu actions and emits
* the signal selectionChanged().
void updateEditActions();
void updateViewActions();
void updateGoActions();
- void clearStatusBar();
/**
* Connects the signals from the created DolphinView with
DolphinViewContainer* m_viewContainer[SecondaryView + 1];
+ DolphinViewActionHandler* m_actionHandler;
+
/// remember pending undo operations until they are finished
QList<KonqFileUndoManager::CommandType> m_undoCommandTypes;
};
#include <kcolorscheme.h>
#include <kdirlister.h>
#include <kfileitemdelegate.h>
-#include <klocale.h>
#include <kiconeffect.h>
+#include <klocale.h>
#include <kio/deletejob.h>
#include <kio/netaccess.h>
#include <kio/previewjob.h>
#include <kjob.h>
#include <kmenu.h>
#include <kmimetyperesolver.h>
-#include <konqmimedata.h>
#include <konq_operations.h>
+#include <konqmimedata.h>
#include <ktoggleaction.h>
#include <kurl.h>
#include "dolphinsortfilterproxymodel.h"
#include "dolphindetailsview.h"
#include "dolphiniconsview.h"
-#include "renamedialog.h"
-#include "viewproperties.h"
#include "dolphinsettings.h"
#include "dolphin_generalsettings.h"
+#include "iconmanager.h"
+#include "renamedialog.h"
+#include "viewproperties.h"
DolphinView::DolphinView(QWidget* parent,
const KUrl& url,
m_dolphinModel(dolphinModel),
m_dirLister(dirLister),
m_proxyModel(proxyModel),
- m_previewJob(0)
+ m_iconManager(0)
{
setFocusPolicy(Qt::StrongFocus);
m_topLayout = new QVBoxLayout(this);
m_topLayout->setSpacing(0);
m_topLayout->setMargin(0);
- QClipboard* clipboard = QApplication::clipboard();
- connect(clipboard, SIGNAL(dataChanged()),
- this, SLOT(updateCutItems()));
-
connect(m_dirLister, SIGNAL(completed()),
this, SLOT(updateCutItems()));
- connect(m_dirLister, SIGNAL(newItems(const KFileItemList&)),
- this, SLOT(generatePreviews(const KFileItemList&)));
m_controller = new DolphinController(this);
m_controller->setUrl(url);
DolphinView::~DolphinView()
{
- if (m_previewJob != 0) {
- m_previewJob->kill();
- m_previewJob = 0;
- }
}
const KUrl& DolphinView::url() const
m_mode = mode;
- if (isColumnViewActive()) {
- // When changing the mode in the column view, it makes sense
- // to go back to the root URL of the column view automatically.
- // Otherwise there it would not be possible to turn off the column view
- // without focusing the first column.
- const KUrl root = rootUrl();
- setUrl(root);
- m_controller->setUrl(root);
- }
-
deleteView();
const KUrl viewPropsUrl = viewPropertiesUrl();
props.setShowPreview(show);
m_showPreview = show;
-
+ m_iconManager->setShowPreview(show);
emit showPreviewChanged();
loadDirectory(viewPropsUrl, true);
void DolphinView::zoomIn()
{
m_controller->triggerZoomIn();
+ reload();
}
void DolphinView::zoomOut()
{
m_controller->triggerZoomOut();
+ reload();
}
bool DolphinView::isZoomInPossible() const
emit itemTriggered(item); // caught by DolphinViewContainer or DolphinPart
}
-void DolphinView::generatePreviews(const KFileItemList& items)
-{
- if (m_controller->dolphinView()->showPreview()) {
- if (m_previewJob != 0) {
- m_previewJob->kill();
- m_previewJob = 0;
- }
-
- m_previewJob = KIO::filePreview(items, 128);
- connect(m_previewJob, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
- this, SLOT(replaceIcon(const KFileItem&, const QPixmap&)));
- connect(m_previewJob, SIGNAL(finished(KJob*)),
- this, SLOT(slotPreviewJobFinished(KJob*)));
- }
-}
-
-void DolphinView::replaceIcon(const KFileItem& item, const QPixmap& pixmap)
-{
- Q_ASSERT(!item.isNull());
- if (!m_showPreview || (item.url().directory() != m_dirLister->url().path())) {
- // the preview has been deactivated in the meanwhile or the preview
- // job is still working on items of an older URL, hence
- // the item is not part of the directory model anymore
- return;
- }
-
- const QModelIndex idx = m_dolphinModel->indexForItem(item);
- if (idx.isValid() && (idx.column() == 0)) {
- const QMimeData* mimeData = QApplication::clipboard()->mimeData();
- if (KonqMimeData::decodeIsCutSelection(mimeData) && isCutItem(item)) {
- KIconEffect iconEffect;
- const QPixmap cutPixmap = iconEffect.apply(pixmap, KIconLoader::Desktop, KIconLoader::DisabledState);
- m_dolphinModel->setData(idx, QIcon(cutPixmap), Qt::DecorationRole);
- } else {
- m_dolphinModel->setData(idx, QIcon(pixmap), Qt::DecorationRole);
- }
- }
-}
-
void DolphinView::emitSelectionChangedSignal()
{
emit selectionChanged(DolphinView::selectedItems());
return;
}
- m_cutItemsCache.clear();
m_loadingDirectory = true;
m_dirLister->stop();
const bool showPreview = props.showPreview();
if (showPreview != m_showPreview) {
m_showPreview = showPreview;
+ m_iconManager->setShowPreview(showPreview);
emit showPreviewChanged();
}
}
m_fileItemDelegate->setShowInformation(info);
- emit additionalInfoChanged(); // will call updateAdditionalInfoActions just below
+ emit additionalInfoChanged();
}
void DolphinView::updateAdditionalInfoActions(KActionCollection* collection)
}
}
-void DolphinView::updateCutItems()
-{
- // restore the icons of all previously selected items to the
- // original state...
- QList<CutItem>::const_iterator it = m_cutItemsCache.begin();
- QList<CutItem>::const_iterator end = m_cutItemsCache.end();
- while (it != end) {
- const QModelIndex index = m_dolphinModel->indexForUrl((*it).url);
- if (index.isValid()) {
- m_dolphinModel->setData(index, QIcon((*it).pixmap), Qt::DecorationRole);
- }
- ++it;
- }
- m_cutItemsCache.clear();
-
- // ... and apply an item effect to all currently cut items
- applyCutItemEffect();
-}
-
void DolphinView::showHoverInformation(const KFileItem& item)
{
if (hasSelection() || !m_active) {
}
}
-
void DolphinView::createView()
{
deleteView();
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
new KMimeTypeResolver(view, m_dolphinModel);
+ m_iconManager = new IconManager(view, m_proxyModel);
+ m_iconManager->setShowPreview(m_showPreview);
+
m_topLayout->insertWidget(1, view);
connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
m_detailsView = 0;
m_columnView = 0;
m_fileItemDelegate = 0;
+ m_iconManager = 0;
}
}
return false;
}
-void DolphinView::applyCutItemEffect()
-{
- const QMimeData* mimeData = QApplication::clipboard()->mimeData();
- if (!KonqMimeData::decodeIsCutSelection(mimeData)) {
- return;
- }
-
- KFileItemList items(m_dirLister->items());
- KFileItemList::const_iterator it = items.begin();
- const KFileItemList::const_iterator end = items.end();
- while (it != end) {
- const KFileItem item = *it;
- if (isCutItem(item)) {
- const QModelIndex index = m_dolphinModel->indexForItem(item);
- const QVariant value = m_dolphinModel->data(index, Qt::DecorationRole);
- if (value.type() == QVariant::Icon) {
- const QIcon icon(qvariant_cast<QIcon>(value));
- QPixmap pixmap = icon.pixmap(128, 128);
-
- // remember current pixmap for the item to be able
- // to restore it when other items get cut
- CutItem cutItem;
- cutItem.url = item.url();
- cutItem.pixmap = pixmap;
- m_cutItemsCache.append(cutItem);
-
- // apply icon effect to the cut item
- KIconEffect iconEffect;
- pixmap = iconEffect.apply(pixmap, KIconLoader::Desktop, KIconLoader::DisabledState);
- m_dolphinModel->setData(index, QIcon(pixmap), Qt::DecorationRole);
- }
- }
- ++it;
- }
-}
-
KToggleAction* DolphinView::iconsModeAction(KActionCollection* actionCollection)
{
KToggleAction* iconsView = actionCollection->add<KToggleAction>("icons");
Q_ASSERT(newName.contains('#'));
// iterate through all selected items and rename them...
- const int replaceIndex = newName.indexOf('#');
- Q_ASSERT(replaceIndex >= 0);
int index = 1;
-
- KFileItemList::const_iterator it = items.begin();
- const KFileItemList::const_iterator end = items.end();
- while (it != end) {
- const KUrl& oldUrl = (*it).url();
+ foreach (KFileItem item, items) {
+ const KUrl& oldUrl = item.url();
QString number;
number.setNum(index++);
- QString name(newName);
- name.replace(replaceIndex, 1, number);
+ QString name = newName;
+ name.replace('#', number);
if (oldUrl.fileName() != name) {
KUrl newUrl = oldUrl;
KonqOperations::rename(this, oldUrl, newUrl);
emit doingOperation(KonqFileUndoManager::RENAME);
}
- ++it;
}
}
} else {
}
}
-void DolphinView::slotPreviewJobFinished(KJob* job)
-{
- Q_ASSERT(job == m_previewJob);
- m_previewJob = 0;
-}
-
void DolphinView::cutSelectedItems()
{
QMimeData* mimeData = new QMimeData();
return ret;
}
- KAction* DolphinView::createRenameAction(KActionCollection* collection)
- {
- KAction* rename = collection->addAction("rename");
- rename->setText(i18nc("@action:inmenu File", "Rename..."));
- rename->setShortcut(Qt::Key_F2);
- return rename;
- }
-
- KAction* DolphinView::createMoveToTrashAction(KActionCollection* collection)
- {
- KAction* moveToTrash = collection->addAction("move_to_trash");
- moveToTrash->setText(i18nc("@action:inmenu File", "Move to Trash"));
- moveToTrash->setIcon(KIcon("user-trash"));
- moveToTrash->setShortcut(QKeySequence::Delete);
- return moveToTrash;
- }
-
- KAction* DolphinView::createDeleteAction(KActionCollection* collection)
- {
- KAction* deleteAction = collection->addAction("delete");
- deleteAction->setIcon(KIcon("edit-delete"));
- deleteAction->setText(i18nc("@action:inmenu File", "Delete"));
- deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete);
- return deleteAction;
- }
-
- KAction* DolphinView::createNewDirAction(KActionCollection* collection)
- {
- // This action doesn't appear in the GUI, it's for the shortcut only.
- // KNewMenu takes care of the GUI stuff.
- KAction* newDirAction = collection->addAction("create_dir");
- newDirAction->setText(i18n("Create Folder..."));
- newDirAction->setShortcut(Qt::Key_F10);
- return newDirAction;
- }
-
- KAction* DolphinView::createSortDescendingAction(KActionCollection* collection)
- {
- KToggleAction* sortDescending = collection->add<KToggleAction>("descending");
- sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
- return sortDescending;
- }
-
- KAction* DolphinView::createShowPreviewAction(KActionCollection* collection)
- {
- KToggleAction* showPreview = collection->add<KToggleAction>("show_preview");
- showPreview->setText(i18nc("@action:intoolbar", "Preview"));
- showPreview->setIcon(KIcon("view-preview"));
- return showPreview;
- }
-
- KAction* DolphinView::createShowInGroupsAction(KActionCollection* collection)
- {
- KToggleAction* showInGroups = collection->add<KToggleAction>("show_in_groups");
- showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
- return showInGroups;
- }
-
- KAction* DolphinView::createShowHiddenFilesAction(KActionCollection* collection)
- {
- KToggleAction* showHiddenFiles = collection->add<KToggleAction>("show_hidden_files");
- showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
- showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);
- return showHiddenFiles;
- }
-
- QActionGroup* DolphinView::createAdditionalInformationActionGroup(KActionCollection* collection)
- {
- QActionGroup* showInformationGroup = new QActionGroup(collection);
- showInformationGroup->setExclusive(false);
-
- KToggleAction* showSizeInfo = collection->add<KToggleAction>("show_size_info");
- showSizeInfo->setText(i18nc("@action:inmenu Additional information", "Size"));
- showSizeInfo->setData(KFileItemDelegate::Size);
- showSizeInfo->setActionGroup(showInformationGroup);
-
- KToggleAction* showDateInfo = collection->add<KToggleAction>("show_date_info");
- showDateInfo->setText(i18nc("@action:inmenu Additional information", "Date"));
- showDateInfo->setData(KFileItemDelegate::ModificationTime);
- showDateInfo->setActionGroup(showInformationGroup);
-
- KToggleAction* showPermissionsInfo = collection->add<KToggleAction>("show_permissions_info");
- showPermissionsInfo->setText(i18nc("@action:inmenu Additional information", "Permissions"));
- showPermissionsInfo->setData(KFileItemDelegate::Permissions);
- showPermissionsInfo->setActionGroup(showInformationGroup);
-
- KToggleAction* showOwnerInfo = collection->add<KToggleAction>("show_owner_info");
- showOwnerInfo->setText(i18nc("@action:inmenu Additional information", "Owner"));
- showOwnerInfo->setData(KFileItemDelegate::Owner);
- showOwnerInfo->setActionGroup(showInformationGroup);
-
- KToggleAction* showGroupInfo = collection->add<KToggleAction>("show_group_info");
- showGroupInfo->setText(i18nc("@action:inmenu Additional information", "Group"));
- showGroupInfo->setData(KFileItemDelegate::OwnerAndGroup);
- showGroupInfo->setActionGroup(showInformationGroup);
-
- KToggleAction* showMimeInfo = collection->add<KToggleAction>("show_mime_info");
- showMimeInfo->setText(i18nc("@action:inmenu Additional information", "Type"));
- showMimeInfo->setData(KFileItemDelegate::FriendlyMimeType);
- showMimeInfo->setActionGroup(showInformationGroup);
-
- return showInformationGroup;
- }
-
#include "dolphinview.moc"
#include <QWidget>
class QActionGroup;
-class KAction;
-class KToggleAction;
class DolphinController;
-class KDirLister;
-class KFileItemDelegate;
-class KUrl;
-class DolphinModel;
class DolphinColumnView;
class DolphinDetailsView;
class DolphinIconsView;
class DolphinMainWindow;
+class DolphinModel;
class DolphinSortFilterProxyModel;
+class IconManager;
+class KAction;
+class KActionCollection;
+class KDirLister;
+class KFileItemDelegate;
+class KUrl;
+class KToggleAction;
class QModelIndex;
class ViewProperties;
-namespace KIO
-{
- class PreviewJob;
-}
/**
* @short Represents a view for the directory content.
*/
static KToggleAction* columnsModeAction(KActionCollection* collection);
- /**
- * Creates the rename action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createRenameAction(KActionCollection* collection);
-
- /**
- * Creates the "move to trash" action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createMoveToTrashAction(KActionCollection* collection);
-
- /**
- * Creates the delete action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createDeleteAction(KActionCollection* collection);
-
- /**
- * Creates the "new directory" action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createNewDirAction(KActionCollection* collection);
-
- /**
- * Creates the "sort descending" action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createSortDescendingAction(KActionCollection* collection);
-
- /**
- * Creates an action group with all the "show additional information" actions in it.
- * This code is here to share it between the mainwindow and the part
- */
- static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection);
-
- /**
- * Creates the "show preview" action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createShowPreviewAction(KActionCollection* collection);
-
- /**
- * Creates the "show in groups" action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createShowInGroupsAction(KActionCollection* collection);
-
- /**
- * Creates the "show hidden files" action.
- * This code is here to share it between the mainwindow and the part
- */
- static KAction* createShowHiddenFilesAction(KActionCollection* collection);
-
/**
* Updates the state of the 'Additional Information' actions in \a collection.
*/
*/
void triggerItem(const KFileItem& index);
- /**
- * Generates a preview image for each file item in \a items.
- * The current preview settings (maximum size, 'Show Preview' menu)
- * are respected.
- */
- void generatePreviews(const KFileItemList& items);
-
- /**
- * Replaces the icon of the item \a item by the preview pixmap
- * \a pixmap.
- */
- void replaceIcon(const KFileItem& item, const QPixmap& pixmap);
-
void emitSelectionChangedSignal();
/**
*/
void emitContentsMoved();
- /** Applies an item effect to all cut items of the clipboard. */
- void updateCutItems();
-
/**
* Updates the status bar to show hover information for the
* item \a item. If currently other items are selected,
*/
void slotDeleteFileFinished(KJob* job);
- /**
- * Is invoked when the preview job has been finished and
- * set m_previewJob to 0.
- */
- void slotPreviewJobFinished(KJob* job);
-
private:
void loadDirectory(const KUrl& url, bool reload = false);
*/
bool isCutItem(const KFileItem& item) const;
- /** Applies an item effect to all cut items. */
- void applyCutItemEffect();
-
/**
* Returns true, if the ColumnView is activated. As the column view
* requires some special handling for iterating through directories,
}
private:
- /**
- * Remembers the original pixmap for an item before
- * the cut effect is applied.
- */
- struct CutItem
- {
- KUrl url;
- QPixmap pixmap;
- };
-
bool m_active;
bool m_showPreview;
bool m_loadingDirectory;
KDirLister* m_dirLister;
DolphinSortFilterProxyModel* m_proxyModel;
- KIO::PreviewJob* m_previewJob;
-
- QList<CutItem> m_cutItemsCache;
+ IconManager* m_iconManager;
KUrl m_rootUrl;
};