#ifndef _DOLPHIN_MAINWINDOW_H_
#define _DOLPHIN_MAINWINDOW_H_
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "dolphinview.h"
-#include <kapplication.h>
#include <kmainwindow.h>
#include <ksortablelist.h>
-#include <kvbox.h>
-
-#include <q3valuelist.h>
-#include <q3ptrlist.h>
+#include <konq_undo.h>
-#include <QCloseEvent>
-#include <QString>
-
-#include "dolphinview.h"
-#include "undomanager.h"
+#include <QList>
+class KNewMenu;
class KPrinter;
class KUrl;
class QLineEdit;
-class KFileIconView;
class KHBox;
class Q3IconViewItem;
class QSplitter;
* @short Main window for Dolphin.
*
* Handles the menus, toolbars and Dolphin views.
- *
- * @author Peter Penz <peter.penz@gmx.at>
-*/
+ */
class DolphinMainWindow: public KMainWindow
{
Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
+ Q_PROPERTY(int id READ getId SCRIPTABLE true)
friend class DolphinApplication;
+
public:
virtual ~DolphinMainWindow();
DolphinView* activeView() const { return m_activeView; }
/**
- * Handles the dropping of Urls to the given
+ * Handles the dropping of URLs to the given
* destination. A context menu with the options
* 'Move Here', 'Copy Here', 'Link Here' and
* 'Cancel' is offered to the user.
- * @param urls List of Urls which have been
+ * @param urls List of URLs which have been
* dropped.
- * @param destination Destination Url, where the
- * list or Urls should be moved,
+ * @param destination Destination URL, where the
+ * list or URLs should be moved,
* copied or linked to.
*/
void dropUrls(const KUrl::List& urls,
const KUrl& destination);
+ /** Renames the item represented by \a oldUrl to \a newUrl. */
+ void rename(const KUrl& oldUrl, const KUrl& newUrl);
+
/**
- * Returns 'true', if the clipboard contains data
- * which has been cutted by the Cut action (Ctrl + X).
+ * Refreshs the views of the main window by recreating them dependent from
+ * the given Dolphin settings.
*/
- bool clipboardContainsCutData() const { return m_clipboardContainsCutData; }
+ void refreshViews();
/**
- * Returns the list of actions which are part of the file group
- * of the 'Create New...' sub menu. Usually the list contains actions
- * for creating folders, text files, HTML files etc.
+ * Returns the 'Create New...' sub menu which also can be shared
+ * with other menus (e. g. a context menu).
*/
- QLinkedList<QAction*> fileGroupActions() const { return m_fileGroupActions; }
- //QLinkedList<QAction*>& linkGroupActions() const { return m_linkGroupActions; }
- //QLinkedList<QAction*>& linkToDeviceActions() const { return m_linkToDeviceActions; }
+ KNewMenu* newMenu() const { return m_newMenu; }
+public slots:
/**
- * Refreshs the views of the main window by recreating them dependent from
- * the given Dolphin settings.
+ * Returns the main windows ID, mainly used throught DBus.
*/
- void refreshViews();
+ int getId() const { return m_id; }
+
+ /**
+ * Changes the URL of the current active DolphinView to \a url.
+ */
+ void changeUrl(const QString& url);
+
+ /** Stores all settings and quits Dolphin. */
+ void quit();
signals:
/**
void readProperties(KConfig*);
private slots:
- /** Opens an input dialog for creating a new folder. */
- void createFolder();
+ /** Updates the 'Create New...' sub menu. */
+ void updateNewMenu();
- /** Creates a file with the MIME type given by the sender. */
- void createFile();
-
- /** Renames the selected item of the active view. */
+ /**
+ * 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 properties();
- /** Stores all settings and quits Dolphin. */
- void quit();
-
/**
* Shows the error information of the job \a job
* in the status bar.
/** Sets the text of the 'Undo' menu action to \a text. */
void slotUndoTextChanged(const QString& text);
- /**
- * Updates the state of the 'Redo' menu action dependent
- * from the parameter \a available.
- */
- void slotRedoAvailable(bool available);
-
- /** Sets the text of the 'Redo' menu action to \a text. */
- void slotRedoTextChanged(const QString& text);
+ /** Performs the current undo operation. */
+ void undo();
/**
* Copies all selected items to the clipboard and marks
/** The sorting of the current view should be done by the date. */
void sortByDate();
+ /** The sorting of the current view should be done by the permissions. */
+ void sortByPermissions();
+
+ /** The sorting of the current view should be done by the owner. */
+ void sortByOwner();
+
+ /** The sorting of the current view should be done by the group. */
+ void sortByGroup();
+
/** Switches between an ascending and descending sorting order. */
void toggleSortOrder();
+ /**
+ * Clears any additional information for an item except for the
+ * name and the icon.
+ */
+ void clearInfo();
+
+ /** Shows the MIME type as additional information for the item. */
+ void showMimeInfo();
+
+ /** Shows the size as additional information for the item. */
+ void showSizeInfo();
+
+ /** Shows the date as additional information for the item. */
+ void showDateInfo();
+
/**
* Switches between one and two views:
* If one view is visible, it will get split into two views.
*/
void adjustViewProperties();
- /** Goes back on step of the Url history. */
+ /** Goes back on step of the URL history. */
void goBack();
- /** Goes forward one step of the Url history. */
+ /** Goes forward one step of the URL history. */
void goForward();
- /** Goes up one hierarchy of the current Url. */
+ /** Goes up one hierarchy of the current URL. */
void goUp();
- /** Goes to the home Url. */
+ /** Goes to the home URL. */
void goHome();
/** Opens a terminal for the current shown directory. */
/** Opens the settings dialog for Dolphin. */
void editSettings();
- /**
- * Adds the undo operation given by \a job
- * to the UndoManager.
- */
- void addUndoOperation(KJob* job);
-
/** 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 'Sort Ascending/Descending' action. */
void slotSortOrderChanged(Qt::SortOrder order);
+ /** Updates the state of the 'Additional Information' actions. */
+ void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info);
+
/** Updates the state of the 'Edit' menu actions. */
void slotSelectionChanged();
/**
* Updates the caption of the main window and the state
- * of all menu actions which depend from a changed Url.
+ * of all menu actions which depend from a changed URL.
*/
void slotUrlChanged(const KUrl& url);
/** Updates the state of the 'Show filter bar' menu action. */
void updateFilterBarAction(bool show);
- /** Executes the redo operation (see UndoManager::Redo ()). */
- void redo();
-
- /** Executes the undo operation (see UndoManager::Undo()). */
- void undo();
-
/** Open a new main window. */
void openNewMainWindow();
private:
- DolphinMainWindow();
+ DolphinMainWindow(int id);
void init();
void loadSettings();
void setupAccel();
void setupActions();
void setupDockWidgets();
- void setupCreateNewMenuActions();
void updateHistory();
void updateEditActions();
void updateViewActions();
void updateGoActions();
- void updateViewProperties(const KUrl::List& urls);
void copyUrls(const KUrl::List& source, const KUrl& dest);
void moveUrls(const KUrl::List& source, const KUrl& dest);
- void addPendingUndoJob(KIO::Job* job,
- DolphinCommand::Type commandType,
- const KUrl::List& source,
- const KUrl& dest);
+ void linkUrls(const KUrl::List& source, const KUrl& dest);
void clearStatusBar();
/**
void connectViewSignals(int viewIndex);
private:
- QSplitter* m_splitter;
- DolphinView* m_activeView;
-
/**
* DolphinMainWindowsupports only one or two views, which
* are handled internally as primary and secondary view.
PrimaryIdx = 0,
SecondaryIdx = 1
};
- DolphinView* m_view[SecondaryIdx + 1];
-
- /// If set to true, the clipboard contains data which should be cutted after pasting.
- bool m_clipboardContainsCutData;
/**
- * Asynchronous operations like 'Move' and 'Copy' may only be added as undo
- * operation after they have been finished successfully. When an asynchronous
- * operation is started, it is added to a pending undo jobs list in the meantime.
- * As soon as the job has been finished, the operation is added to the undo mangager.
- * @see UndoManager
- * @see DolphinMainWindow::addPendingUndoJob
- * @see DolphinMainWindow::addUndoOperation
+ * Implements a custom error handling for the undo manager. This
+ * assures that all errors are shown in the status bar of Dolphin
+ * instead as modal error dialog with an OK button.
*/
- struct UndoInfo
+ class UndoUiInterface : public KonqUndoManager::UiInterface
{
- int id;
- DolphinCommand command;
- };
- Q3ValueList<UndoInfo> m_pendingUndoJobs;
+ public:
+ UndoUiInterface(DolphinMainWindow* mainWin);
+ virtual ~UndoUiInterface();
+ virtual void jobError(KIO::Job* job);
- /** Contains meta information for creating files. */
- struct CreateFileEntry
- {
- QString name;
- QString filePath;
- QString templatePath;
- QString icon;
- QString comment;
+ private:
+ DolphinMainWindow* m_mainWin;
};
- QLinkedList<QAction*> m_fileGroupActions;
- KSortableList<CreateFileEntry,QString> m_createFileTemplates;
+ KNewMenu* m_newMenu;
+ QSplitter* m_splitter;
+ DolphinView* m_activeView;
+ int m_id;
+
+ DolphinView* m_view[SecondaryIdx + 1];
- // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
- // and DolphinMainWindow::linkToDeviceActions() in for details.
- //QLinkedList<QAction*> m_linkGroupActions;
- //QLinkedList<QAction*> m_linkToDeviceActions;
+ /// remember pending undo operations until they are finished
+ QList<KonqUndoManager::CommandType> m_undoCommandTypes;
};
#endif // _DOLPHIN_H_