* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#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 <q3valuelist.h>
-#include <q3ptrlist.h>
-#include <qstring.h>
-//Added by qt3to4:
-#include <QCloseEvent>
#include <ksortablelist.h>
-#include <kvbox.h>
+#include <konq_undo.h>
-#include "dolphinview.h"
-#include "undomanager.h"
+#include <QList>
+class KNewMenu;
class KPrinter;
class KUrl;
class QLineEdit;
-class KFileIconView;
class KHBox;
class Q3IconViewItem;
class QSplitter;
class KAction;
class UrlNavigator;
-class Sidebar;
class DolphinApplication;
/**
* @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);
- /**
- * Returns 'true', if the clipboard contains data
- * which has been cutted by the Cut action (Ctrl + X).
- */
- bool clipboardContainsCutData() const { return m_clipboardContainsCutData; }
-
- /**
- * 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.
- */
- const Q3PtrList<KAction>& fileGroupActions() const { return m_fileGroupActions; }
- //const QPtrList<KAction>& linkGroupActions() const { return m_linkGroupActions; }
- //const QPtrList<KAction>& linkToDeviceActions() const { return m_linkToDeviceActions; }
+ /** Renames the item represented by \a oldUrl to \a newUrl. */
+ void rename(const KUrl& oldUrl, const KUrl& newUrl);
/**
* Refreshs the views of the main window by recreating them dependent from
*/
void refreshViews();
-signals:
/**
- * Is send if the active view has been changed in
- * the split view mode.
+ * Returns the 'Create New...' sub menu which also can be shared
+ * with other menus (e. g. a context menu).
*/
- void activeViewChanged();
+ KNewMenu* newMenu() const { return m_newMenu; }
+public slots:
/**
- * Is send if the selection of the currently active view has
- * been changed.
+ * Returns the main windows ID, mainly used throught DBus.
*/
- void selectionChanged();
+ int getId() const { return m_id; }
-public slots:
/**
- * Updates the state of the 'Back' and 'Forward' menu
- * actions corresponding the the current history.
+ * Changes the URL of the current active DolphinView to \a url.
*/
- void slotHistoryChanged();
+ void changeUrl(const QString& url);
+
+ /** Stores all settings and quits Dolphin. */
+ void quit();
+signals:
/**
- * Updates the caption of the main window and the state
- * of all menu actions which depend from a changed Url.
+ * Is send if the active view has been changed in
+ * the split view mode.
*/
- void slotUrlChanged(const KUrl& url);
+ void activeViewChanged();
/**
- * Go to the given Url.
+ * Is send if the selection of the currently active view has
+ * been changed.
*/
- void slotUrlChangeRequest(const KUrl& url);
-
- /** Updates the state of all 'View' menu actions. */
- void slotViewModeChanged();
-
- /** Updates the state of the 'Show hidden files' menu action. */
- void slotShowHiddenFilesChanged();
-
- /** Updates the state of the 'Show filter bar' menu action. */
- void slotShowFilterBarChanged();
-
- /** 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 'Edit' menu actions. */
- void slotSelectionChanged();
-
- /** Executes Redo operation */
- void slotRedo();
-
- /** @see slotUndo() */
- void slotUndo();
-
- /** Open a new mainwindow */
- void slotNewMainWindow();
+ void selectionChanged();
protected:
/** @see QMainWindow::closeEvent */
void readProperties(KConfig*);
private slots:
- /** Opens an input dialog for creating a new folder. */
- void createFolder();
-
- /** Creates a file with the MIME type given by the sender. */
- void createFile();
+ /** Updates the 'Create New...' sub menu. */
+ void updateNewMenu();
- /** 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 current active view is switched to the details mode. */
void setDetailsView();
- /** The current active view is switched to the previews mode. */
- void setPreviewsView();
-
/** The sorting of the current view should be done by the name. */
void sortByName();
/** 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.
/** 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();
+
/**
* Switches between showing and hiding of hidden marked files dependent
* from the current state of the 'Show Hidden Files' menu toggle action.
*/
- void showHiddenFiles();
+ void toggleShowHiddenFiles();
/**
* Switches between showing and hiding of the filter bar dependent
*/
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();
- void toggleSidebar();
+ /** 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(KFileItemDelegate::AdditionalInformation info);
+
+ /** Updates the state of the 'Edit' menu actions. */
+ void slotSelectionChanged();
+
+ /**
+ * Updates the state of the 'Back' and 'Forward' menu
+ * actions corresponding the the current history.
+ */
+ void slotHistoryChanged();
/**
- * Stores the current sidebar width and closes
- * the sidebar.
+ * Updates the caption of the main window and the state
+ * of all menu actions which depend from a changed URL.
*/
- void closeSidebar();
+ void slotUrlChanged(const KUrl& url);
+
+ /** Updates the state of the 'Show filter bar' menu action. */
+ void updateFilterBarAction(bool show);
+
+ /** Open a new main window. */
+ void openNewMainWindow();
private:
- DolphinMainWindow();
+ DolphinMainWindow(int id);
void init();
void loadSettings();
void setupAccel();
void setupActions();
- void setupCreateNewMenuActions();
+ void setupDockWidgets();
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 openSidebar();
- QSplitter* m_splitter;
- Sidebar* m_sidebar;
- DolphinView* m_activeView;
+ /**
+ * Connects the signals from the created DolphinView with
+ * the index \a viewIndex with the corresponding slots of
+ * the DolphinMainWindow. This method must be invoked each
+ * time a DolphinView has been created.
+ */
+ void connectViewSignals(int viewIndex);
+private:
/**
* 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;
};
- Q3PtrList<KAction> 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.
- //QPtrList<KAction> m_linkGroupActions;
- //QPtrList<KAction> m_linkToDeviceActions;
+ /// remember pending undo operations until they are finished
+ QList<KonqUndoManager::CommandType> m_undoCommandTypes;
};
#endif // _DOLPHIN_H_