]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Make it (almost) possible to have more than one Dolphin KMainWindow
authorHolger Freyther <holger+kde@freyther.de>
Wed, 29 Nov 2006 00:02:19 +0000 (00:02 +0000)
committerHolger Freyther <holger+kde@freyther.de>
Wed, 29 Nov 2006 00:02:19 +0000 (00:02 +0000)
    Create a DolphinApplication, holding DolphinMainWindows and update
    the code to use the DolphinView to get the MainWindow, or get a ptr
    to the MainWindow directly. Or if all windows are effected go through
    the DolphinApplication to update every mainwindow.
    The UndowManager and ProgressIndicator have a rather strange relationship
    and will need some more attention but as UndoManager will be killed
    anyway I have skipped this.
    More cleanup, debugging and thinking is needed.

svn path=/trunk/playground/utils/dolphin/; revision=608945

35 files changed:
src/CMakeLists.txt
src/THOUGHTS.zecke [new file with mode: 0644]
src/bookmarkselector.cpp
src/bookmarkssidebarpage.cpp
src/bookmarkssidebarpage.h
src/dolphinapplication.cpp [new file with mode: 0644]
src/dolphinapplication.h [new file with mode: 0644]
src/dolphincontextmenu.cpp
src/dolphiniconsview.cpp
src/dolphinmainwindow.cpp [moved from src/dolphin.cpp with 91% similarity]
src/dolphinmainwindow.h [moved from src/dolphin.h with 95% similarity]
src/dolphinsettings.cpp
src/dolphinsettingsdialog.cpp
src/dolphinsettingsdialog.h
src/dolphinview.cpp
src/dolphinview.h
src/filterbar.cpp
src/filterbar.h
src/generalsettingspage.cpp
src/generalsettingspage.h
src/infosidebarpage.cpp
src/infosidebarpage.h
src/main.cpp
src/progressindicator.cpp
src/progressindicator.h
src/sidebar.cpp
src/sidebar.h
src/sidebarpage.cpp
src/sidebarpage.h
src/undomanager.cpp
src/undomanager.h
src/urlbutton.cpp
src/urlnavigator.cpp
src/urlnavigator.h
src/urlnavigatorbutton.cpp

index c701e14a75100c837ce467ae164dc860c42e6726..7ea5426bb907cb0a76db4c3e1b652b82e297a0e2 100644 (file)
@@ -9,7 +9,8 @@ include_directories( ${KDE4_INCLUDE_DIR} ${QT_INCLUDES}  )
 
 set(dolphin_SRCS
    main.cpp
-   dolphin.cpp
+   dolphinapplication.cpp
+   dolphinmainwindow.cpp
    dolphinview.cpp
    urlnavigator.cpp
    urlnavigatorbutton.cpp
diff --git a/src/THOUGHTS.zecke b/src/THOUGHTS.zecke
new file mode 100644 (file)
index 0000000..3b9f383
--- /dev/null
@@ -0,0 +1,36 @@
+Zecke's Implementation Thoughts
+
+
+Task:       Kill the Dolphin Singleton
+Reasoning:  Have more than one Dolphin TLW
+Approach: 
+    1. Create DolphinApplication to hold all TLW's.
+    2. Make dolphin.h dolphomainwindow.h
+    3. Change the Views to have a DolphinMainWindow
+       parameter
+
+Reasoning:
+    I find it more natural that the DolphinApplication
+    holds and controls the list of managed MainWindows and
+    will control the life time of them, specially deleting
+    them on exit.
+    The downside is that DolphinApplication and DolphinMainWindow
+    need to work together but this is managable
+
+    Making DolphinView::mainWindow() public. Most users of the
+    current Dolphin::mainView have a pointer to the current view
+    already. We could pass a second pointer for the mainwindow each
+    time but the same can be achieved by using the appropriate
+    DolphinView::mainWindow.
+    Another approach would be to ask the DolphinView to execute
+    actions on the MainWindow like it is done with declareViewActive
+    in DolphinView. I'm not entirely sure which one wins but currently
+    using mainWindow() does not show any negative impact.
+
+    2 times Dolphin::mainWin was used to check if the view is current.
+    this can be made a method of of the view
+
+    1 time we want the viewChanged signal of our mainwindow to update,
+    the UrlNavigator could connect a signal to a signal to allow this
+
+    12 times this was used to access the actionCollection
index 73e063fdaa66dee97c5c61452baa1a16bce81a11..7b489b8faac5f57a7b5d04d7e896b7e381a580bc 100644 (file)
@@ -31,7 +31,7 @@
 #include "bookmarkselector.h"
 #include "dolphinsettings.h"
 #include "dolphinview.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "urlnavigator.h"
 
 BookmarkSelector::BookmarkSelector(UrlNavigator* parent) :
@@ -134,9 +134,9 @@ void BookmarkSelector::paintEvent(QPaintEvent* event)
 
     // dimm the colors if the parent view does not have the focus
     const DolphinView* parentView = urlNavigator()->dolphinView();
-    const Dolphin& dolphin = Dolphin::mainWin();
+    const DolphinMainWindow* dolphin = parentView->mainWindow();
 
-    const bool isActive = (dolphin.activeView() == parentView);
+    const bool isActive = (dolphin->activeView() == parentView);
     if (!isActive) {
         QColor dimmColor(colorGroup().background());
         foregroundColor = mixColors(foregroundColor, dimmColor);
index b3861aa2f42193e6dac46ef83fd84a3052faa56b..7eced5a010f93bb20a8a605c8351f7c3bf4a83c2 100644 (file)
 #include <klocale.h>
 
 #include "dolphinsettings.h"
-#include "dolphin.h"
-#include "dolphinview.h"
+#include "dolphinmainwindow.h"
 #include "editbookmarkdialog.h"
 
-BookmarksSidebarPage::BookmarksSidebarPage(QWidget* parent) :
-    SidebarPage(parent)
+BookmarksSidebarPage::BookmarksSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) :
+    SidebarPage(mainWindow, parent)
 {
     Q3VBoxLayout* layout = new Q3VBoxLayout(this);
     m_bookmarksList = new BookmarksListBox(this);
@@ -98,7 +97,7 @@ void BookmarksSidebarPage::slotMouseButtonClicked(int button, Q3ListBoxItem* ite
 
     const int index = m_bookmarksList->index(item);
     KBookmark bookmark = DolphinSettings::instance().bookmark(index);
-    Dolphin::mainWin().activeView()->setUrl(bookmark.url());
+    mainWindow()->activeView()->setUrl(bookmark.url());
 }
 
 void BookmarksSidebarPage::slotContextMenuRequested(Q3ListBoxItem* item,
@@ -187,7 +186,7 @@ void BookmarksSidebarPage::slotContextMenuRequested(Q3ListBoxItem* item,
     delete popup;
     popup = 0;
 
-    DolphinView* view = Dolphin::mainWin().activeView();
+    DolphinView* view = mainWindow()->activeView();
     adjustSelection(view->url());
 }
 
@@ -241,7 +240,7 @@ void BookmarksSidebarPage::slotUrlChanged(const KUrl& url)
 
 void BookmarksSidebarPage::connectToActiveView()
 {
-    DolphinView* view = Dolphin::mainWin().activeView();
+    DolphinView* view = mainWindow()->activeView();
     adjustSelection(view->url());
     connect(view, SIGNAL(signalUrlChanged(const KUrl&)),
             this, SLOT(slotUrlChanged(const KUrl&)));
index 37a50098734f97bce6d1b7fef6862bd6b7034826..95375539974886675f1b09b363046b9b0393345a 100644 (file)
@@ -41,7 +41,7 @@ class BookmarksSidebarPage : public SidebarPage
         Q_OBJECT
 
 public:
-    BookmarksSidebarPage(QWidget* parent);
+    BookmarksSidebarPage(DolphinMainWindow *mainWindow, QWidget* parent);
     virtual ~BookmarksSidebarPage();
 
 protected:
diff --git a/src/dolphinapplication.cpp b/src/dolphinapplication.cpp
new file mode 100644 (file)
index 0000000..a27a4cb
--- /dev/null
@@ -0,0 +1,64 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org>      *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   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.             *
+ ***************************************************************************/
+
+#include "dolphinapplication.h"
+#include "dolphinmainwindow.h"
+
+DolphinApplication::DolphinApplication()
+{
+}
+
+/*
+ * cleanup what ever is left from the MainWindows
+ */
+DolphinApplication::~DolphinApplication()
+{
+    while( m_mainWindows.count() != 0 )
+        delete m_mainWindows.takeFirst();
+}
+
+DolphinApplication* DolphinApplication::app()
+{
+    return qobject_cast<DolphinApplication*>(qApp);
+}
+
+DolphinMainWindow* DolphinApplication::createMainWindow()
+{
+    DolphinMainWindow* mainwindow = new DolphinMainWindow;
+    mainwindow->init();
+    
+    m_mainWindows.append( mainwindow );
+    return mainwindow;
+}
+
+void DolphinApplication::removeMainWindow( DolphinMainWindow *mainwindow )
+{
+    m_mainWindows.remove( mainwindow );
+}
+
+void DolphinApplication::refreshMainWindows()
+{
+    for( int i = 0; i < m_mainWindows.count(); ++i ) {
+        m_mainWindows[i]->refreshViews();
+    }
+}
+
+#include "dolphinapplication.moc"
+
diff --git a/src/dolphinapplication.h b/src/dolphinapplication.h
new file mode 100644 (file)
index 0000000..a8474bd
--- /dev/null
@@ -0,0 +1,64 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2006 by Holger 'zecke' Freyther <freyther@kde.org>      *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   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.             *
+ ***************************************************************************/
+
+
+#ifndef _DOLPHIN_APPLICATION_H
+#define _DOLPHIN_APPLICATION_H
+
+#include <kapplication.h>
+
+class DolphinMainWindow;
+
+/**
+ * 
+ * DolphinApplication will hold application wide data which
+ * can be accessed.
+ * At first this will hold a list of DolphinMainWindows which
+ * we will delete on application exit. 
+ */
+
+class DolphinApplication : public KApplication {
+    Q_OBJECT
+    friend class DolphinMainWindow;
+public:
+    DolphinApplication();
+    ~DolphinApplication();
+
+    static DolphinApplication* app();
+
+    /**
+     * Construct a new mainwindow which is owned
+     * by the application.
+     */
+    DolphinMainWindow* createMainWindow();
+    void refreshMainWindows();
+
+protected:
+    /**
+     * called by the MainWindow to deregister
+     */
+    void removeMainWindow( DolphinMainWindow* );
+
+private:
+    QList<DolphinMainWindow*> m_mainWindows;
+};
+
+
+#endif
index d53aa3f17519733bb2097b02bdb298fa3813f793..1da2443dbe7336e8d5e9aa0d4c2e9182831efe63 100644 (file)
@@ -40,7 +40,7 @@
 #include <kmenu.h>
 #include <kstdaction.h>
 
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "dolphinview.h"
 #include "editbookmarkdialog.h"
 #include "dolphinsettings.h"
@@ -79,12 +79,12 @@ void DolphinContextMenu::openViewportContextMenu()
     assert(m_fileInfo == 0);
 
     KMenu* popup = new KMenu(m_dolphinView);
-    Dolphin& dolphin = Dolphin::mainWin();
+    DolphinMainWindow *dolphin = m_dolphinView->mainWindow();
 
     // setup 'Create New' menu
     KMenu* createNewMenu = new KMenu();
 
-    KAction* createFolderAction = dolphin.actionCollection()->action("create_folder");
+    KAction* createFolderAction = dolphin->actionCollection()->action("create_folder");
     if (createFolderAction != 0) {
         createFolderAction->plug(createNewMenu);
     }
@@ -93,7 +93,7 @@ void DolphinContextMenu::openViewportContextMenu()
 
     KAction* action = 0;
 
-    Q3PtrListIterator<KAction> fileGrouptIt(dolphin.fileGroupActions());
+    Q3PtrListIterator<KAction> fileGrouptIt(dolphin->fileGroupActions());
     while ((action = fileGrouptIt.current()) != 0) {
         action->plug(createNewMenu);
         ++fileGrouptIt;
@@ -104,14 +104,14 @@ void DolphinContextMenu::openViewportContextMenu()
     //
     //createNewMenu->insertSeparator();
     //
-    //QPtrListIterator<KAction> linkGroupIt(dolphin.linkGroupActions());
+    //QPtrListIterator<KAction> linkGroupIt(dolphin->linkGroupActions());
     //while ((action = linkGroupIt.current()) != 0) {
     //    action->plug(createNewMenu);
     //    ++linkGroupIt;
     //}
     //
     //KMenu* linkToDeviceMenu = new KMenu();
-    //QPtrListIterator<KAction> linkToDeviceIt(dolphin.linkToDeviceActions());
+    //QPtrListIterator<KAction> linkToDeviceIt(dolphin->linkToDeviceActions());
     //while ((action = linkToDeviceIt.current()) != 0) {
     //    action->plug(linkToDeviceMenu);
     //    ++linkToDeviceIt;
@@ -122,19 +122,19 @@ void DolphinContextMenu::openViewportContextMenu()
     popup->insertItem(SmallIcon("filenew"), i18n("Create New"), createNewMenu);
     popup->insertSeparator();
 
-    KAction* pasteAction = dolphin.actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
+    KAction* pasteAction = dolphin->actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
     pasteAction->plug(popup);
 
     // setup 'View Mode' menu
     KMenu* viewModeMenu = new KMenu();
 
-    KAction* iconsMode = dolphin.actionCollection()->action("icons");
+    KAction* iconsMode = dolphin->actionCollection()->action("icons");
     iconsMode->plug(viewModeMenu);
 
-    KAction* detailsMode = dolphin.actionCollection()->action("details");
+    KAction* detailsMode = dolphin->actionCollection()->action("details");
     detailsMode->plug(viewModeMenu);
 
-    KAction* previewsMode = dolphin.actionCollection()->action("previews");
+    KAction* previewsMode = dolphin->actionCollection()->action("previews");
     previewsMode->plug(viewModeMenu);
 
     popup->insertItem(i18n("View Mode"), viewModeMenu);
@@ -147,10 +147,10 @@ void DolphinContextMenu::openViewportContextMenu()
 
     QAction *activatedAction = popup->exec(m_pos);
     if (activatedAction == propertiesAction) {
-        new KPropertiesDialog(dolphin.activeView()->url());
+        new KPropertiesDialog(dolphin->activeView()->url());
     }
     else if (activatedAction == bookmarkAction) {
-        const KUrl& url = dolphin.activeView()->url();
+        const KUrl& url = dolphin->activeView()->url();
         KBookmark bookmark = EditBookmarkDialog::getBookmark(i18n("Add folder as bookmark"),
                                                              url.fileName(),
                                                              url,
@@ -176,14 +176,14 @@ void DolphinContextMenu::openItemContextMenu()
     assert(m_fileInfo != 0);
 
     KMenu* popup = new KMenu(m_dolphinView);
-    Dolphin& dolphin = Dolphin::mainWin();
+    DolphinMainWindow* dolphin = m_dolphinView->mainWindow();
     const KUrl::List urls = m_dolphinView->selectedUrls();
 
     // insert 'Cut', 'Copy' and 'Paste'
     const KStdAction::StdAction actionNames[] = { KStdAction::Cut, KStdAction::Copy, KStdAction::Paste };
     const int count = sizeof(actionNames) / sizeof(KStdAction::StdAction);
     for (int i = 0; i < count; ++i) {
-        KAction* action = dolphin.actionCollection()->action(KStdAction::stdName(actionNames[i]));
+        KAction* action = dolphin->actionCollection()->action(KStdAction::stdName(actionNames[i]));
         if (action != 0) {
             action->plug(popup);
         }
@@ -191,17 +191,17 @@ void DolphinContextMenu::openItemContextMenu()
     popup->insertSeparator();
 
     // insert 'Rename'
-    KAction* renameAction = dolphin.actionCollection()->action("rename");
+    KAction* renameAction = dolphin->actionCollection()->action("rename");
     renameAction->plug(popup);
 
     // insert 'Move to Trash' for local Urls, otherwise insert 'Delete'
-    const KUrl& url = dolphin.activeView()->url();
+    const KUrl& url = dolphin->activeView()->url();
     if (url.isLocalFile()) {
-        KAction* moveToTrashAction = dolphin.actionCollection()->action("move_to_trash");
+        KAction* moveToTrashAction = dolphin->actionCollection()->action("move_to_trash");
         moveToTrashAction->plug(popup);
     }
     else {
-        KAction* deleteAction = dolphin.actionCollection()->action("delete");
+        KAction* deleteAction = dolphin->actionCollection()->action("delete");
         deleteAction->plug(popup);
     }
 
@@ -225,7 +225,7 @@ void DolphinContextMenu::openItemContextMenu()
 
     // insert 'Properties...' entry
     popup->insertSeparator();
-    KAction* propertiesAction = dolphin.actionCollection()->action("properties");
+    KAction* propertiesAction = dolphin->actionCollection()->action("properties");
     propertiesAction->plug(popup);
 
     QAction *activatedAction = popup->exec(m_pos);
index 7cbe3297d4c50c091ebbfdd9b2dace48524fad85..9372ae9e0443ecba360d524d37c065eb12439323 100644 (file)
 
 #include "dolphiniconsview.h"
 #include "dolphinview.h"
-#include "dolphin.h"
 
 DolphinIconsView::DolphinIconsView(DolphinView* parent) :
-    QListView(parent)
-    m_parentView( parent )
+    QListView(parent),
+    m_parentView( parent )
 {
     setResizeMode( QListView::Adjust );
 }
@@ -36,7 +35,7 @@ DolphinIconsView::~DolphinIconsView()
 void DolphinIconsView::mouseReleaseEvent(QMouseEvent *e)
 {
     QListView::mouseReleaseEvent(e);
-    Dolphin::mainWin().setActiveView(m_parentView);
+    m_parentView->declareViewActive();
 }
 
 #include "dolphiniconsview.moc"
similarity index 91%
rename from src/dolphin.cpp
rename to src/dolphinmainwindow.cpp
index db4f468890d5da720041f21d64e909a045a6864e..0d4667db705b4fd19c3ad7e95f340bc55e162116 100644 (file)
@@ -19,7 +19,7 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 
 #include <assert.h>
 
 #include "dolphinsettings.h"
 #include "dolphinsettingsdialog.h"
 #include "dolphinstatusbar.h"
+#include "dolphinapplication.h"
 #include "undomanager.h"
 #include "progressindicator.h"
 #include "dolphinsettings.h"
 #include "sidebar.h"
 #include "sidebarsettings.h"
 #include "generalsettings.h"
+#include "dolphinapplication.h"
 
-Dolphin& Dolphin::mainWin()
+
+DolphinMainWindow::DolphinMainWindow() :
+    KMainWindow(0, "Dolphin"),
+    m_splitter(0),
+    m_sidebar(0),
+    m_activeView(0),
+    m_clipboardContainsCutData(false)
 {
-    static Dolphin* instance = 0;
-    if (instance == 0) {
-        instance = new Dolphin();
-        instance->init();
-    }
-    return *instance;
+    m_view[PrimaryIdx] = 0;
+    m_view[SecondaryIdx] = 0;
+
+    m_fileGroupActions.setAutoDelete(true);
+
+    // TODO: the following members are not used yet. See documentation
+    // of DolphinMainWindow::linkGroupActions() and DolphinMainWindow::linkToDeviceActions()
+    // in the header file for details.
+    //m_linkGroupActions.setAutoDelete(true);
+    //m_linkToDeviceActions.setAutoDelete(true);
 }
 
-Dolphin::~Dolphin()
+DolphinMainWindow::~DolphinMainWindow()
 {
+    /*
+     * bye, bye managed window
+     */
+    DolphinApplication::app()->removeMainWindow( this );
 }
 
-void Dolphin::setActiveView(DolphinView* view)
+void DolphinMainWindow::setActiveView(DolphinView* view)
 {
     assert((view == m_view[PrimaryIdx]) || (view == m_view[SecondaryIdx]));
     if (m_activeView == view) {
@@ -105,7 +121,7 @@ void Dolphin::setActiveView(DolphinView* view)
     emit activeViewChanged();
 }
 
-void Dolphin::dropUrls(const KUrl::List& urls,
+void DolphinMainWindow::dropUrls(const KUrl::List& urls,
                        const KUrl& destination)
 {
     int selectedIndex = -1;
@@ -178,7 +194,7 @@ void Dolphin::dropUrls(const KUrl::List& urls,
     }
 }
 
-void Dolphin::refreshViews()
+void DolphinMainWindow::refreshViews()
 {
     const bool split = DolphinSettings::instance().generalSettings()->splitView();
     const bool isPrimaryViewActive = (m_activeView == m_view[PrimaryIdx]);
@@ -196,7 +212,8 @@ void Dolphin::refreshViews()
         if (split || (i == PrimaryIdx)) {
             // ... and recreate it
             ViewProperties props(url);
-            m_view[i] = new DolphinView(m_splitter,
+            m_view[i] = new DolphinView(this,
+                                        m_splitter,
                                         url,
                                         props.viewMode(),
                                         props.isShowHiddenFilesEnabled());
@@ -211,44 +228,44 @@ void Dolphin::refreshViews()
     emit activeViewChanged();
 }
 
-void Dolphin::slotHistoryChanged()
+void DolphinMainWindow::slotHistoryChanged()
 {
     updateHistory();
 }
 
-void Dolphin::slotUrlChanged(const KUrl& url)
+void DolphinMainWindow::slotUrlChanged(const KUrl& url)
 {
     updateEditActions();
     updateGoActions();
     setCaption(url.fileName());
 }
 
-void Dolphin::slotUrlChangeRequest(const KUrl& url)
+void DolphinMainWindow::slotUrlChangeRequest(const KUrl& url)
 {
        clearStatusBar();
        m_activeView->setUrl(url);
 }
 
-void Dolphin::slotViewModeChanged()
+void DolphinMainWindow::slotViewModeChanged()
 {
     updateViewActions();
 }
 
-void Dolphin::slotShowHiddenFilesChanged()
+void DolphinMainWindow::slotShowHiddenFilesChanged()
 {
     KToggleAction* showHiddenFilesAction =
         static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
     showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled());
 }
 
-void Dolphin::slotShowFilterBarChanged()
+void DolphinMainWindow::slotShowFilterBarChanged()
 {
     KToggleAction* showFilterBarAction =
         static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
     showFilterBarAction->setChecked(m_activeView->isFilterBarVisible());
 }
 
-void Dolphin::slotSortingChanged(DolphinView::Sorting sorting)
+void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
 {
     KAction* action = 0;
     switch (sorting) {
@@ -271,14 +288,14 @@ void Dolphin::slotSortingChanged(DolphinView::Sorting sorting)
     }
 }
 
-void Dolphin::slotSortOrderChanged(Qt::SortOrder order)
+void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
 {
     KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
     const bool sortDescending = (order == Qt::Descending);
     descending->setChecked(sortDescending);
 }
 
-void Dolphin::slotSelectionChanged()
+void DolphinMainWindow::slotSelectionChanged()
 {
     updateEditActions();
 
@@ -296,7 +313,7 @@ void Dolphin::slotSelectionChanged()
     emit selectionChanged();
 }
 
-void Dolphin::closeEvent(QCloseEvent* event)
+void DolphinMainWindow::closeEvent(QCloseEvent* event)
 {
     // KDE4-TODO
     //KConfig* config = KGlobal::config();
@@ -319,7 +336,7 @@ void Dolphin::closeEvent(QCloseEvent* event)
     KMainWindow::closeEvent(event);
 }
 
-void Dolphin::saveProperties(KConfig* config)
+void DolphinMainWindow::saveProperties(KConfig* config)
 {
     config->setGroup("Primary view");
     config->writeEntry("Url", m_view[PrimaryIdx]->url().url());
@@ -331,7 +348,7 @@ void Dolphin::saveProperties(KConfig* config)
     }
 }
 
-void Dolphin::readProperties(KConfig* config)
+void DolphinMainWindow::readProperties(KConfig* config)
 {
     config->setGroup("Primary view");
     m_view[PrimaryIdx]->setUrl(config->readEntry("Url"));
@@ -349,7 +366,7 @@ void Dolphin::readProperties(KConfig* config)
     }
 }
 
-void Dolphin::createFolder()
+void DolphinMainWindow::createFolder()
 {
     // Parts of the following code have been taken
     // from the class KonqPopupMenu located in
@@ -400,7 +417,7 @@ void Dolphin::createFolder()
         statusBar->setMessage(i18n("Created folder %1.",url.path()),
                               DolphinStatusBar::OperationCompleted);
 
-        DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url);
+        DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url, this);
         UndoManager::instance().addCommand(command);
     }
     else {
@@ -418,7 +435,7 @@ void Dolphin::createFolder()
     }
 }
 
-void Dolphin::createFile()
+void DolphinMainWindow::createFile()
 {
     // Parts of the following code have been taken
     // from the class KonqPopupMenu located in
@@ -507,7 +524,7 @@ void Dolphin::createFile()
 
         KUrl::List list;
         list.append(sourceUrl);
-        DolphinCommand command(DolphinCommand::CreateFile, list, destUrl);
+        DolphinCommand command(DolphinCommand::CreateFile, list, destUrl, this);
         UndoManager::instance().addCommand(command);
 
     }
@@ -517,13 +534,13 @@ void Dolphin::createFile()
     }
 }
 
-void Dolphin::rename()
+void DolphinMainWindow::rename()
 {
     clearStatusBar();
     m_activeView->renameSelectedItems();
 }
 
-void Dolphin::moveToTrash()
+void DolphinMainWindow::moveToTrash()
 {
     clearStatusBar();
     KUrl::List selectedUrls = m_activeView->selectedUrls();
@@ -531,7 +548,7 @@ void Dolphin::moveToTrash()
     addPendingUndoJob(job, DolphinCommand::Trash, selectedUrls, m_activeView->url());
 }
 
-void Dolphin::deleteItems()
+void DolphinMainWindow::deleteItems()
 {
     clearStatusBar();
 
@@ -562,7 +579,7 @@ void Dolphin::deleteItems()
     }
 }
 
-void Dolphin::properties()
+void DolphinMainWindow::properties()
 {
     const KFileItemList* sourceList = m_activeView->selectedItems();
     if (sourceList == 0) {
@@ -581,12 +598,12 @@ void Dolphin::properties()
     new KPropertiesDialog(list, this);
 }
 
-void Dolphin::quit()
+void DolphinMainWindow::quit()
 {
     close();
 }
 
-void Dolphin::slotHandleJobError(KJob* job)
+void DolphinMainWindow::slotHandleJobError(KJob* job)
 {
     if (job->error() != 0) {
         m_activeView->statusBar()->setMessage(job->errorString(),
@@ -594,7 +611,7 @@ void Dolphin::slotHandleJobError(KJob* job)
     }
 }
 
-void Dolphin::slotDeleteFileFinished(KJob* job)
+void DolphinMainWindow::slotDeleteFileFinished(KJob* job)
 {
     if (job->error() == 0) {
         m_activeView->statusBar()->setMessage(i18n("Delete operation completed."),
@@ -608,7 +625,7 @@ void Dolphin::slotDeleteFileFinished(KJob* job)
     }
 }
 
-void Dolphin::slotUndoAvailable(bool available)
+void DolphinMainWindow::slotUndoAvailable(bool available)
 {
     KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
     if (undoAction != 0) {
@@ -616,7 +633,7 @@ void Dolphin::slotUndoAvailable(bool available)
     }
 }
 
-void Dolphin::slotUndoTextChanged(const QString& text)
+void DolphinMainWindow::slotUndoTextChanged(const QString& text)
 {
     KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
     if (undoAction != 0) {
@@ -624,7 +641,7 @@ void Dolphin::slotUndoTextChanged(const QString& text)
     }
 }
 
-void Dolphin::slotRedoAvailable(bool available)
+void DolphinMainWindow::slotRedoAvailable(bool available)
 {
     KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
     if (redoAction != 0) {
@@ -632,7 +649,7 @@ void Dolphin::slotRedoAvailable(bool available)
     }
 }
 
-void Dolphin::slotRedoTextChanged(const QString& text)
+void DolphinMainWindow::slotRedoTextChanged(const QString& text)
 {
     KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
     if (redoAction != 0) {
@@ -640,7 +657,7 @@ void Dolphin::slotRedoTextChanged(const QString& text)
     }
 }
 
-void Dolphin::cut()
+void DolphinMainWindow::cut()
 {
     // TODO: this boolean doesn't work between instances of dolphin or with konqueror or with other
     // apps. The "application/x-kde-cutselection" mimetype should be used instead, see KonqMimeData
@@ -651,7 +668,7 @@ void Dolphin::cut()
     QApplication::clipboard()->setData(data);*/
 }
 
-void Dolphin::copy()
+void DolphinMainWindow::copy()
 {
     m_clipboardContainsCutData = false;
     /* KDE4-TODO:
@@ -660,7 +677,7 @@ void Dolphin::copy()
     QApplication::clipboard()->setData(data);*/
 }
 
-void Dolphin::paste()
+void DolphinMainWindow::paste()
 {
     /* KDE4-TODO:   - see KonqOperations::doPaste
     QClipboard* clipboard = QApplication::clipboard();
@@ -703,7 +720,7 @@ void Dolphin::paste()
     }*/
 }
 
-void Dolphin::updatePasteAction()
+void DolphinMainWindow::updatePasteAction()
 {
     KAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
     if (pasteAction == 0) {
@@ -754,48 +771,48 @@ void Dolphin::updatePasteAction()
     }
 }
 
-void Dolphin::selectAll()
+void DolphinMainWindow::selectAll()
 {
     clearStatusBar();
     m_activeView->selectAll();
 }
 
-void Dolphin::invertSelection()
+void DolphinMainWindow::invertSelection()
 {
     clearStatusBar();
     m_activeView->invertSelection();
 }
-void Dolphin::setIconsView()
+void DolphinMainWindow::setIconsView()
 {
     m_activeView->setMode(DolphinView::IconsView);
 }
 
-void Dolphin::setDetailsView()
+void DolphinMainWindow::setDetailsView()
 {
     m_activeView->setMode(DolphinView::DetailsView);
 }
 
-void Dolphin::setPreviewsView()
+void DolphinMainWindow::setPreviewsView()
 {
     m_activeView->setMode(DolphinView::PreviewsView);
 }
 
-void Dolphin::sortByName()
+void DolphinMainWindow::sortByName()
 {
     m_activeView->setSorting(DolphinView::SortByName);
 }
 
-void Dolphin::sortBySize()
+void DolphinMainWindow::sortBySize()
 {
     m_activeView->setSorting(DolphinView::SortBySize);
 }
 
-void Dolphin::sortByDate()
+void DolphinMainWindow::sortByDate()
 {
     m_activeView->setSorting(DolphinView::SortByDate);
 }
 
-void Dolphin::toggleSortOrder()
+void DolphinMainWindow::toggleSortOrder()
 {
     const Qt::SortOrder order = (m_activeView->sortOrder() == Qt::Ascending) ?
                                 Qt::Descending :
@@ -803,11 +820,12 @@ void Dolphin::toggleSortOrder()
     m_activeView->setSortOrder(order);
 }
 
-void Dolphin::toggleSplitView()
+void DolphinMainWindow::toggleSplitView()
 {
     if (m_view[SecondaryIdx] == 0) {
         // create a secondary view
-        m_view[SecondaryIdx] = new DolphinView(m_splitter,
+        m_view[SecondaryIdx] = new DolphinView(this,
+                                               m_splitter,
                                                m_view[PrimaryIdx]->url(),
                                                m_view[PrimaryIdx]->mode(),
                                                m_view[PrimaryIdx]->isShowHiddenFilesEnabled());
@@ -835,17 +853,17 @@ void Dolphin::toggleSplitView()
     }
 }
 
-void Dolphin::reloadView()
+void DolphinMainWindow::reloadView()
 {
     clearStatusBar();
     m_activeView->reload();
 }
 
-void Dolphin::stopLoading()
+void DolphinMainWindow::stopLoading()
 {
 }
 
-void Dolphin::showHiddenFiles()
+void DolphinMainWindow::showHiddenFiles()
 {
     clearStatusBar();
 
@@ -855,7 +873,7 @@ void Dolphin::showHiddenFiles()
     m_activeView->setShowHiddenFilesEnabled(show);
 }
 
-void Dolphin::showFilterBar()
+void DolphinMainWindow::showFilterBar()
 {
     const KToggleAction* showFilterBarAction =
         static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
@@ -863,19 +881,19 @@ void Dolphin::showFilterBar()
     m_activeView->slotShowFilterBar(show);
 }
 
-void Dolphin::zoomIn()
+void DolphinMainWindow::zoomIn()
 {
     m_activeView->zoomIn();
     updateViewActions();
 }
 
-void Dolphin::zoomOut()
+void DolphinMainWindow::zoomOut()
 {
     m_activeView->zoomOut();
     updateViewActions();
 }
 
-void Dolphin::toggleEditLocation()
+void DolphinMainWindow::toggleEditLocation()
 {
     clearStatusBar();
 
@@ -886,45 +904,45 @@ void Dolphin::toggleEditLocation()
     m_activeView->setUrlEditable(editOrBrowse);
 }
 
-void Dolphin::editLocation()
+void DolphinMainWindow::editLocation()
 {
     KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
     action->setChecked(true);
     m_activeView->setUrlEditable(true);
 }
 
-void Dolphin::adjustViewProperties()
+void DolphinMainWindow::adjustViewProperties()
 {
     clearStatusBar();
     ViewPropertiesDialog dlg(m_activeView);
     dlg.exec();
 }
 
-void Dolphin::goBack()
+void DolphinMainWindow::goBack()
 {
     clearStatusBar();
     m_activeView->goBack();
 }
 
-void Dolphin::goForward()
+void DolphinMainWindow::goForward()
 {
     clearStatusBar();
     m_activeView->goForward();
 }
 
-void Dolphin::goUp()
+void DolphinMainWindow::goUp()
 {
     clearStatusBar();
     m_activeView->goUp();
 }
 
-void Dolphin::goHome()
+void DolphinMainWindow::goHome()
 {
     clearStatusBar();
     m_activeView->goHome();
 }
 
-void Dolphin::openTerminal()
+void DolphinMainWindow::openTerminal()
 {
     QString command("konsole --workdir \"");
     command.append(m_activeView->url().path());
@@ -933,12 +951,12 @@ void Dolphin::openTerminal()
     KRun::runCommand(command, "Konsole", "konsole");
 }
 
-void Dolphin::findFile()
+void DolphinMainWindow::findFile()
 {
     KRun::run("kfind", m_activeView->url());
 }
 
-void Dolphin::compareFiles()
+void DolphinMainWindow::compareFiles()
 {
     // The method is only invoked if exactly 2 files have
     // been selected. The selected files may be:
@@ -993,14 +1011,14 @@ void Dolphin::compareFiles()
 
 }
 
-void Dolphin::editSettings()
+void DolphinMainWindow::editSettings()
 {
     // TODO: make a static method for opening the settings dialog
-    DolphinSettingsDialog dlg;
+    DolphinSettingsDialog dlg(this);
     dlg.exec();
 }
 
-void Dolphin::addUndoOperation(KJob* job)
+void DolphinMainWindow::addUndoOperation(KJob* job)
 {
     if (job->error() != 0) {
         slotHandleJobError(job);
@@ -1074,7 +1092,7 @@ void Dolphin::addUndoOperation(KJob* job)
     }
 }
 
-void Dolphin::toggleSidebar()
+void DolphinMainWindow::toggleSidebar()
 {
     if (m_sidebar == 0) {
         openSidebar();
@@ -1087,7 +1105,7 @@ void Dolphin::toggleSidebar()
     sidebarAction->setChecked(m_sidebar != 0);
 }
 
-void Dolphin::closeSidebar()
+void DolphinMainWindow::closeSidebar()
 {
     if (m_sidebar == 0) {
         // the sidebar has already been closed
@@ -1103,29 +1121,11 @@ void Dolphin::closeSidebar()
     m_sidebar = 0;
 }
 
-Dolphin::Dolphin() :
-    KMainWindow(0, "Dolphin"),
-    m_splitter(0),
-    m_sidebar(0),
-    m_activeView(0),
-    m_clipboardContainsCutData(false)
-{
-    m_view[PrimaryIdx] = 0;
-    m_view[SecondaryIdx] = 0;
-
-    m_fileGroupActions.setAutoDelete(true);
-
-    // TODO: the following members are not used yet. See documentation
-    // of Dolphin::linkGroupActions() and Dolphin::linkToDeviceActions()
-    // in the header file for details.
-    //m_linkGroupActions.setAutoDelete(true);
-    //m_linkToDeviceActions.setAutoDelete(true);
-}
 
-void Dolphin::init()
+void DolphinMainWindow::init()
 {
     // Check whether Dolphin runs the first time. If yes then
-    // a proper default window size is given at the end of Dolphin::init().
+    // a proper default window size is given at the end of DolphinMainWindow::init().
     GeneralSettings* generalSettings = DolphinSettings::instance().generalSettings();
     const bool firstRun = generalSettings->firstRun();
 
@@ -1152,7 +1152,8 @@ void Dolphin::init()
     const KUrl& homeUrl = root.first().url();
     setCaption(homeUrl.fileName());
     ViewProperties props(homeUrl);
-    m_view[PrimaryIdx] = new DolphinView(m_splitter,
+    m_view[PrimaryIdx] = new DolphinView(this,
+                                         m_splitter,
                                          homeUrl,
                                          props.viewMode(),
                                          props.isShowHiddenFilesEnabled());
@@ -1189,7 +1190,7 @@ void Dolphin::init()
     }
 }
 
-void Dolphin::loadSettings()
+void DolphinMainWindow::loadSettings()
 {
     GeneralSettings* settings = DolphinSettings::instance().generalSettings();
 
@@ -1202,7 +1203,7 @@ void Dolphin::loadSettings()
     updateViewActions();
 }
 
-void Dolphin::setupActions()
+void DolphinMainWindow::setupActions()
 {
     // setup 'File' menu
     KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder");
@@ -1369,7 +1370,7 @@ void Dolphin::setupActions()
     KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
 }
 
-void Dolphin::setupCreateNewMenuActions()
+void DolphinMainWindow::setupCreateNewMenuActions()
 {
     // Parts of the following code have been taken
     // from the class KNewMenu located in
@@ -1448,15 +1449,15 @@ void Dolphin::setupCreateNewMenuActions()
 
             case '3':
             case '4': {
-                // TODO: not used yet. See documentation of Dolphin::linkGroupActions()
-                // and Dolphin::linkToDeviceActions() in the header file for details.
+                // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
+                // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
                 //m_linkGroupActions.append(action);
                 break;
             }
 
             case '5': {
-                // TODO: not used yet. See documentation of Dolphin::linkGroupActions()
-                // and Dolphin::linkToDeviceActions() in the header file for details.
+                // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
+                // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
                 //m_linkToDeviceActions.append(action);
                 break;
             }
@@ -1471,7 +1472,7 @@ void Dolphin::setupCreateNewMenuActions()
     //plugActionList("link_to_device", m_linkToDeviceActions);*/
 }
 
-void Dolphin::updateHistory()
+void DolphinMainWindow::updateHistory()
 {
     int index = 0;
     const Q3ValueList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
@@ -1487,7 +1488,7 @@ void Dolphin::updateHistory()
     }
 }
 
-void Dolphin::updateEditActions()
+void DolphinMainWindow::updateEditActions()
 {
     const KFileItemList* list = m_activeView->selectedItems();
     if ((list == 0) || (*list).isEmpty()) {
@@ -1521,7 +1522,7 @@ void Dolphin::updateEditActions()
     updatePasteAction();
 }
 
-void Dolphin::updateViewActions()
+void DolphinMainWindow::updateViewActions()
 {
     KAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
     if (zoomInAction != 0) {
@@ -1571,14 +1572,14 @@ void Dolphin::updateViewActions()
     sidebarAction->setChecked(m_sidebar != 0);
 }
 
-void Dolphin::updateGoActions()
+void DolphinMainWindow::updateGoActions()
 {
     KAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up));
     const KUrl& currentUrl = m_activeView->url();
     goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
 }
 
-void Dolphin::updateViewProperties(const KUrl::List& urls)
+void DolphinMainWindow::updateViewProperties(const KUrl::List& urls)
 {
     if (urls.isEmpty()) {
         return;
@@ -1588,7 +1589,8 @@ void Dolphin::updateViewProperties(const KUrl::List& urls)
     // when dragging several thousand Urls. Writing a KIO slave for this
     // use case is not worth the effort, but at least the main widget
     // must be disabled and a progress should be shown.
-    ProgressIndicator progressIndicator(i18n("Updating view properties..."),
+    ProgressIndicator progressIndicator(this,
+                                        i18n("Updating view properties..."),
                                         QString::null,
                                         urls.count());
 
@@ -1601,19 +1603,19 @@ void Dolphin::updateViewProperties(const KUrl::List& urls)
     }
 }
 
-void Dolphin::copyUrls(const KUrl::List& source, const KUrl& dest)
+void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest)
 {
     KIO::Job* job = KIO::copy(source, dest);
     addPendingUndoJob(job, DolphinCommand::Copy, source, dest);
 }
 
-void Dolphin::moveUrls(const KUrl::List& source, const KUrl& dest)
+void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest)
 {
     KIO::Job* job = KIO::move(source, dest);
     addPendingUndoJob(job, DolphinCommand::Move, source, dest);
 }
 
-void Dolphin::addPendingUndoJob(KIO::Job* job,
+void DolphinMainWindow::addPendingUndoJob(KIO::Job* job,
                                 DolphinCommand::Type commandType,
                                 const KUrl::List& source,
                                 const KUrl& dest)
@@ -1623,23 +1625,23 @@ void Dolphin::addPendingUndoJob(KIO::Job* job,
 
     UndoInfo undoInfo;
     undoInfo.id = job->progressId();
-    undoInfo.command = DolphinCommand(commandType, source, dest);
+    undoInfo.command = DolphinCommand(commandType, source, dest, this);
     m_pendingUndoJobs.append(undoInfo);
 }
 
-void Dolphin::clearStatusBar()
+void DolphinMainWindow::clearStatusBar()
 {
     m_activeView->statusBar()->clear();
 }
 
-void Dolphin::openSidebar()
+void DolphinMainWindow::openSidebar()
 {
     if (m_sidebar != 0) {
         // the sidebar is already open
         return;
     }
 
-    m_sidebar = new Sidebar(m_splitter);
+    m_sidebar = new Sidebar(this, m_splitter);
     m_sidebar->show();
 
     connect(m_sidebar, SIGNAL(urlChanged(const KUrl&)),
@@ -1652,4 +1654,4 @@ void Dolphin::openSidebar()
     settings->setVisible(true);
 }
 
-#include "dolphin.moc"
+#include "dolphinmainwindow.moc"
similarity index 95%
rename from src/dolphin.h
rename to src/dolphinmainwindow.h
index 0013b4de8c29e8a290dbbeed4fd7f73075967795..6e9f75b7fa88bfa7152bbe55c631c5b98bcda993 100644 (file)
@@ -19,8 +19,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#ifndef _DOLPHIN_H_
-#define _DOLPHIN_H_
+#ifndef _DOLPHIN_MAINWINDOW_H_
+#define _DOLPHIN_MAINWINDOW_H_
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -49,6 +49,7 @@ class QSplitter;
 class KAction;
 class UrlNavigator;
 class Sidebar;
+class DolphinApplication;
 
 /**
  * @short Main window for Dolphin.
@@ -57,18 +58,12 @@ class Sidebar;
  *
  * @author Peter Penz <peter.penz@gmx.at>
 */
-class Dolphin : public KMainWindow
+class DolphinMainWindow: public KMainWindow
 {
     Q_OBJECT
-
+    friend class DolphinApplication;
 public:
-    /**
-     * Returns the instance for the Dolphin main window.
-     */
-    // KXMLGUIClient::instance() already in use :-(
-    static Dolphin& mainWin();
-
-    virtual ~Dolphin();
+    virtual ~DolphinMainWindow();
 
        /**
      * Activates the given view, which means that
@@ -80,7 +75,7 @@ public:
 
     /**
      * Returns the currently active view. See
-     * Dolphin::setActiveView() for more details.
+     * DolphinMainWindow::setActiveView() for more details.
      */
     DolphinView* activeView() const { return m_activeView; }
 
@@ -378,7 +373,7 @@ private slots:
     void closeSidebar();
 
 private:
-    Dolphin();
+    DolphinMainWindow();
     void init();
     void loadSettings();
 
@@ -404,7 +399,7 @@ private:
     DolphinView* m_activeView;
 
     /**
-     * Dolphin supports only one or two views, which
+     * DolphinMainWindowsupports only one or two views, which
      * are handled internally as primary and secondary view.
      */
     enum ViewIndex
@@ -423,8 +418,8 @@ private:
      * 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 Dolphin::addPendingUndoJob
-     * @see Dolphin::addUndoOperation
+     * @see DolphinMainWindow::addPendingUndoJob
+     * @see DolphinMainWindow::addUndoOperation
      */
     struct UndoInfo
     {
@@ -446,8 +441,8 @@ private:
     Q3PtrList<KAction> m_fileGroupActions;
     KSortableList<CreateFileEntry,QString> m_createFileTemplates;
 
-    // TODO: not used yet. See documentation of Dolphin::linkGroupActions()
-    // and Dolphin::linkToDeviceActions() in for details.
+    // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
+    // and DolphinMainWindow::linkToDeviceActions() in for details.
     //QPtrList<KAction> m_linkGroupActions;
     //QPtrList<KAction> m_linkToDeviceActions;
 };
index ccb9442d25f934ce2752b6e8f86c796814c39794..f197d36f030c6d1b2caa3c8759ffbf83a5ebf5cd 100644 (file)
 #include <klocale.h>
 #include <kstandarddirs.h>
 
-#include "dolphin.h"
 #include "generalsettings.h"
 #include "iconsmodesettings.h"
 #include "previewsmodesettings.h"
 #include "detailsmodesettings.h"
 #include "sidebarsettings.h"
 
+#include <Q3IconView>
+
 DolphinSettings& DolphinSettings::instance()
 {
     static DolphinSettings* instance = 0;
index e3561af48543894d20f4f70f8290cd8d799bb6b0..9cfee7d4edf4ddd71e66ac0ef8ce121bc2229009 100644 (file)
 #include "generalsettingspage.h"
 #include "viewsettingspage.h"
 #include "bookmarkssettingspage.h"
-#include "dolphin.h"
+#include "dolphinapplication.h"
+#include "dolphinmainwindow.h"
 //Added by qt3to4:
 #include <QFrame>
 
-DolphinSettingsDialog::DolphinSettingsDialog() :
-    KPageDialog()
+DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
+    KPageDialog(),
+    m_mainWindow(mainWindow)
 {
     setFaceType( List);
     setCaption(i18n("Dolphin Preferences"));
     setButtons(Ok|Apply|Cancel);
     setDefaultButton(Ok);
 
-    m_generalSettingsPage = new GeneralSettingsPage(this);
+    m_generalSettingsPage = new GeneralSettingsPage(mainWindow, this);
     KPageWidgetItem* generalSettingsFrame = addPage(m_generalSettingsPage, i18n("General"));
     generalSettingsFrame->setIcon(KIcon("exec"));
 
@@ -66,7 +68,7 @@ void DolphinSettingsDialog::applySettings()
     m_generalSettingsPage->applySettings();
     m_viewSettingsPage->applySettings();
     m_bookmarksSettingsPage->applySettings();
-    Dolphin::mainWin().refreshViews();
+    DolphinApplication::app()->refreshMainWindows();
 }
 
 #include "dolphinsettingsdialog.moc"
index f3e8da5c35079652eca9158f1498ba8f7447a903..23072188e20c4ed281cedd9143af5bc56443a557 100644 (file)
@@ -25,6 +25,7 @@
 class GeneralSettingsPage;
 class ViewSettingsPage;
 class BookmarksSettingsPage;
+class DolphinMainWindow;
 
 /**
  * @brief Settings dialog for Dolphin.
@@ -38,13 +39,14 @@ class DolphinSettingsDialog : public KPageDialog {
     Q_OBJECT
 
 public:
-    DolphinSettingsDialog();
+    DolphinSettingsDialog(DolphinMainWindow* mainWindow);
     virtual ~DolphinSettingsDialog();
 
 protected slots:
     virtual void slotButtonClicked(int button);
 
 private:
+    DolphinMainWindow* m_mainWindow;
     GeneralSettingsPage* m_generalSettingsPage;
     ViewSettingsPage* m_viewSettingsPage;
     BookmarksSettingsPage* m_bookmarksSettingsPage;
index abc27167d9a8c2ed01f42398ed62739162581190..7dbebeab588ffec8cbbb1b2f46fbab61e4c0e285 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "urlnavigator.h"
 #include "dolphinstatusbar.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "dolphindirlister.h"
 #include "viewproperties.h"
 #include "dolphindetailsview.h"
 
 #include "filterbar.h"
 
-DolphinView::DolphinView(QWidget *parent,
+DolphinView::DolphinView(DolphinMainWindow *mainWindow,
+                         QWidget *parent,
                          const KUrl& url,
                          Mode mode,
                          bool showHiddenFiles) :
     QWidget(parent),
+    m_mainWindow(mainWindow),
     m_refreshing(false),
     m_showProgress(false),
     m_mode(mode),
@@ -67,24 +69,22 @@ DolphinView::DolphinView(QWidget *parent,
     setFocusPolicy(Qt::StrongFocus);
     m_topLayout = new Q3VBoxLayout(this);
 
-    Dolphin& dolphin = Dolphin::mainWin();
-
     connect(this, SIGNAL(signalModeChanged()),
-            &dolphin, SLOT(slotViewModeChanged()));
+            mainWindow, SLOT(slotViewModeChanged()));
     connect(this, SIGNAL(signalShowHiddenFilesChanged()),
-            &dolphin, SLOT(slotShowHiddenFilesChanged()));
+            mainWindow, SLOT(slotShowHiddenFilesChanged()));
     connect(this, SIGNAL(signalSortingChanged(DolphinView::Sorting)),
-            &dolphin, SLOT(slotSortingChanged(DolphinView::Sorting)));
+            mainWindow, SLOT(slotSortingChanged(DolphinView::Sorting)));
     connect(this, SIGNAL(signalSortOrderChanged(Qt::SortOrder)),
-            &dolphin, SLOT(slotSortOrderChanged(Qt::SortOrder)));
+            mainWindow, SLOT(slotSortOrderChanged(Qt::SortOrder)));
 
     m_urlNavigator = new UrlNavigator(url, this);
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
             this, SLOT(slotUrlChanged(const KUrl&)));
     connect(m_urlNavigator, SIGNAL(urlChanged(const KUrl&)),
-            &dolphin, SLOT(slotUrlChanged(const KUrl&)));
+            mainWindow, SLOT(slotUrlChanged(const KUrl&)));
     connect(m_urlNavigator, SIGNAL(historyChanged()),
-            &dolphin, SLOT(slotHistoryChanged()));
+            mainWindow, SLOT(slotHistoryChanged()));
 
     m_statusBar = new DolphinStatusBar(this);
 
@@ -119,7 +119,7 @@ DolphinView::DolphinView(QWidget *parent,
 
     m_iconSize = K3Icon::SizeMedium;
 
-    m_filterBar = new FilterBar(this);
+    m_filterBar = new FilterBar(mainWindow, this);
     m_filterBar->hide();
     connect(m_filterBar, SIGNAL(signalFilterChanged(const QString&)),
            this, SLOT(slotChangeNameFilter(const QString&)));
@@ -150,12 +150,12 @@ const KUrl& DolphinView::url() const
 
 void DolphinView::requestActivation()
 {
-    Dolphin::mainWin().setActiveView(this);
+    mainWindow()->setActiveView(this);
 }
 
 bool DolphinView::isActive() const
 {
-    return (Dolphin::mainWin().activeView() == this);
+    return (mainWindow()->activeView() == this);
 }
 
 void DolphinView::setMode(Mode mode)
@@ -221,7 +221,7 @@ void DolphinView::renameSelectedItems()
             return;
         }
 
-        DolphinView* view = Dolphin::mainWin().activeView();
+        DolphinView* view = mainWindow()->activeView();
         const QString& newName = dialog.newName();
         if (newName.isEmpty()) {
             view->statusBar()->setMessage(i18n("The new item name is invalid."),
@@ -235,7 +235,8 @@ void DolphinView::renameSelectedItems()
 
             const int urlsCount = urls.count();
             ProgressIndicator* progressIndicator =
-                new  ProgressIndicator(i18n("Renaming items..."),
+                new  ProgressIndicator(mainWindow(),
+                                       i18n("Renaming items..."),
                                        i18n("Renaming finished."),
                                        urlsCount);
 
@@ -262,7 +263,7 @@ void DolphinView::renameSelectedItems()
                     else if (KIO::NetAccess::file_move(source, dest)) {
                         // TODO: From the users point of view he executed one 'rename n files' operation,
                         // but internally we store it as n 'rename 1 file' operations for the undo mechanism.
-                        DolphinCommand command(DolphinCommand::Rename, source, dest);
+                        DolphinCommand command(DolphinCommand::Rename, source, dest, mainWindow());
                         undoMan.addCommand(command);
                     }
                 }
@@ -530,7 +531,7 @@ void DolphinView::rename(const KUrl& source, const QString& newName)
 
     const bool destExists = KIO::NetAccess::exists(dest,
                                                    false,
-                                                   Dolphin::mainWin().activeView());
+                                                   mainWindow()->activeView());
     if (destExists) {
         // the destination already exists, hence ask the user
         // how to proceed...
@@ -568,7 +569,7 @@ void DolphinView::rename(const KUrl& source, const QString& newName)
         m_statusBar->setMessage(i18n("Renamed file '%1' to '%2'.",source.fileName(), dest.fileName()),
                                 DolphinStatusBar::OperationCompleted);
 
-        DolphinCommand command(DolphinCommand::Rename, source, dest);
+        DolphinCommand command(DolphinCommand::Rename, source, dest, mainWindow());
         UndoManager::instance().addCommand(command);
     }
     else {
@@ -601,13 +602,18 @@ void DolphinView::slotUrlListDropped(QDropEvent* /* event */,
         }
     }
 
-    Dolphin::mainWin().dropUrls(urls, destination);
+    mainWindow()->dropUrls(urls, destination);
 }
 
 void DolphinView::mouseReleaseEvent(QMouseEvent* event)
 {
     QWidget::mouseReleaseEvent(event);
-    Dolphin::mainWin().setActiveView(this);
+    mainWindow()->setActiveView(this);
+}
+
+DolphinMainWindow* DolphinView::mainWindow() const
+{
+    return m_mainWindow;
 }
 
 void DolphinView::slotUrlChanged(const KUrl& url)
@@ -628,7 +634,7 @@ void DolphinView::slotUrlChanged(const KUrl& url)
     // created. The application does not care whether a view is represented by a
     // different instance, hence inform the application that the selection might have
     // changed so that it can update it's actions.
-    Dolphin::mainWin().slotSelectionChanged();
+    mainWindow()->slotSelectionChanged();
 
     emit signalUrlChanged(url);
 }
@@ -644,7 +650,7 @@ void DolphinView::triggerIconsViewItem(Q3IconViewItem* item)
         // Updating the Url must be done outside the scope of this slot,
         // as iconview items will get deleted.
         QTimer::singleShot(0, this, SLOT(updateUrl()));
-        Dolphin::mainWin().setActiveView(this);
+        mainWindow()->setActiveView(this);
     }
 }
 
@@ -795,7 +801,7 @@ void DolphinView::slotErrorMessage(const QString& msg)
 
 void DolphinView::slotGrabActivation()
 {
-    Dolphin::mainWin().setActiveView(this);
+    mainWindow()->setActiveView(this);
 }
 
 void DolphinView::slotContentsMoving(int x, int y)
@@ -969,6 +975,11 @@ void DolphinView::slotShowFilterBar(bool show)
     }
 }
 
+void DolphinView::declareViewActive()
+{
+    mainWindow()->setActiveView( this );
+}
+
 void DolphinView::slotChangeNameFilter(const QString& nameFilter)
 {
     // The name filter of KDirLister does a 'hard' filtering, which
index 5c7fb5c2cf555aa0bb22d6b93d0c18952bd45541..69b0022d8f71d9862929b2f956f48236cece331a 100644 (file)
@@ -46,7 +46,7 @@ class Q3IconViewItem;
 class Q3ListViewItem;
 class Q3VBoxLayout;
 //class KFileView;
-class Dolphin;
+class DolphinMainWindow;
 class DolphinDirLister;
 class DolphinStatusBar;
 class DolphinIconsView;
@@ -115,7 +115,8 @@ public:
         MaxSortEnum = SortByDate
     };
 
-    DolphinView(QWidget* parent,
+    DolphinView(DolphinMainWindow* mainwindow,
+                QWidget *parent,
                 const KUrl& url,
                 Mode mode = IconsView,
                 bool showHiddenFiles = false);
@@ -326,6 +327,12 @@ public:
      */
     bool isFilterBarVisible();
 
+    /**
+     * Return the DolphinMainWindow this View belongs to. It is guranteed
+     * that we have one.
+     */
+    DolphinMainWindow* mainWindow() const ;
+
 public slots:
     void reload();
     void slotUrlListDropped(QDropEvent* event,
@@ -337,6 +344,11 @@ public slots:
      */
     void slotShowFilterBar(bool show);
 
+    /**
+     * Declare this View as the activeview of the mainWindow()
+     */
+    void declareViewActive();
+
 signals:
     /** Is emitted if Url of the view has been changed to \a url. */
     void signalUrlChanged(const KUrl& url);
@@ -367,8 +379,8 @@ signals:
 
     /**
      * Is emitted whenever the selection has been changed. The current selection can
-     * be retrieved by Dolphin::mainWin().activeView()->selectedItems() or by
-     * Dolphin::mainWin().activeView()->selectedUrls().
+     * be retrieved by mainWindow()->activeView()->selectedItems() or by
+     * mainWindow()->activeView()->selectedUrls().
      */
     void signalSelectionChanged();
 
@@ -381,6 +393,7 @@ protected:
     /** @see QWidget::mouseReleaseEvent */
     virtual void mouseReleaseEvent(QMouseEvent* event);
 
+
 private slots:
     void slotUrlChanged(const KUrl& kurl);
     void triggerIconsViewItem(Q3IconViewItem *item);
@@ -440,6 +453,7 @@ private:
      */
     void applyModeToView();
 
+    DolphinMainWindow *m_mainWindow;
     bool m_refreshing;
     bool m_showProgress;
     Mode m_mode;
index 0982a61c74b529cbd35e7a830db81037382e3d4b..f05d0d77d1e159e7938731b79b12f58c0fd7343a 100644 (file)
 #include <klineedit.h>
 #include <kiconloader.h>
 
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 
-FilterBar::FilterBar(QWidget *parent, const char *name) :
-    QWidget(parent, name)
+FilterBar::FilterBar(DolphinMainWindow* mainWindow, QWidget *parent, const char *name) :
+    QWidget(parent, name),
+    m_mainWindow(mainWindow)
 {
     const int gap = 3;
 
@@ -62,7 +63,7 @@ FilterBar::FilterBar(QWidget *parent, const char *name) :
             this, SIGNAL(signalFilterChanged(const QString&)));
     connect(m_close, SIGNAL(clicked()), this, SLOT(hide()));
     connect(m_close, SIGNAL(clicked()),
-            &Dolphin::mainWin(), SLOT(slotShowFilterBarChanged()));
+            mainWindow, SLOT(slotShowFilterBarChanged()));
 }
 
 FilterBar::~FilterBar()
@@ -89,7 +90,7 @@ void FilterBar::keyReleaseEvent(QKeyEvent* event)
     QWidget::keyReleaseEvent(event);
     if ((event->key() == Qt::Key_Escape)) {
         hide();
-        Dolphin::mainWin().slotShowFilterBarChanged();
+        m_mainWindow->slotShowFilterBarChanged();
     }
 }
 
index 3f5c3cbfd92e2537f50768982435940a2185b433..ef8bd52b7202371e152587ae354c0f296956c9ea 100644 (file)
@@ -25,6 +25,7 @@
 class QLabel;
 class QToolButton;
 class KLineEdit;
+class DolphinMainWindow;
 
 /**
  * @brief Provides an input field for filtering the currently shown items.
@@ -36,7 +37,7 @@ class FilterBar : public QWidget
     Q_OBJECT
 
 public:
-    FilterBar(QWidget *parent = 0, const char *name = 0);
+    FilterBar(DolphinMainWindow* mainWindow, QWidget *parent = 0, const char *name = 0);
     virtual ~FilterBar();
 
 signals:
@@ -52,6 +53,7 @@ protected:
     virtual void keyReleaseEvent(QKeyEvent* event);
 
 private:
+    DolphinMainWindow *m_mainWindow;
     QLabel* m_filter;
     KLineEdit* m_filterInput;
     QToolButton* m_close;
index d7b72aa6ac7b6744496ec2a3d0fc7e33efdef767..d858906cbf706e31271fbbd6c513229a095108d7 100644 (file)
 #include <kvbox.h>
 
 #include "dolphinsettings.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "dolphinview.h"
 #include "generalsettings.h"
 
-GeneralSettingsPage::GeneralSettingsPage(QWidget* parent) :
+GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* parent) :
     SettingsPageBase(parent),
+    m_mainWindow(mainWin),
     m_homeUrl(0),
     m_startSplit(0),
     m_startEditable(0)
@@ -158,7 +159,7 @@ void GeneralSettingsPage::selectHomeUrl()
 
 void GeneralSettingsPage::useCurrentLocation()
 {
-    const DolphinView* view = Dolphin::mainWin().activeView();
+    const DolphinView* view = m_mainWindow->activeView();
     m_homeUrl->setText(view->url().prettyUrl());
 }
 
index 246b150edcd92b19b54fb897e226d7c5c9486aa8..f5e952b2f196918041b5dcb4b7a46aad16bc933b 100644 (file)
@@ -24,6 +24,7 @@
 class QLineEdit;
 class QRadioButton;
 class QCheckBox;
+class DolphinMainWindow;
 
 /**
  * @brief Page for the 'General' settings of the Dolphin settings dialog.
@@ -38,7 +39,7 @@ class GeneralSettingsPage : public SettingsPageBase
     Q_OBJECT
 
 public:
-    GeneralSettingsPage(QWidget* parent);
+    GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
 
     virtual ~GeneralSettingsPage();
 
@@ -51,6 +52,7 @@ private slots:
     void useDefaulLocation();
 
 private:
+    DolphinMainWindow *m_mainWindow;
     QLineEdit* m_homeUrl;
     QRadioButton* m_iconsView;
     QRadioButton* m_detailsView;
index bf3d5f4fc1b203d5320258de352d4cb745002d3b..296be528bc9d9f20467272381ce21f1875825f9d 100644 (file)
 #include <kfilemetainfo.h>
 #include <kvbox.h>
 
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "pixmapviewer.h"
 #include "dolphinsettings.h"
 
-InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
-    SidebarPage(parent),
+InfoSidebarPage::InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent) :
+    SidebarPage(mainWindow, parent),
     m_multipleSelection(false),
     m_pendingPreview(false),
     m_timer(0),
@@ -111,7 +111,7 @@ InfoSidebarPage::InfoSidebarPage(QWidget* parent) :
     layout->addWidget(m_actionBox);
     layout->addWidget(dummy);
 
-    connect(&Dolphin::mainWin(), SIGNAL(selectionChanged()),
+    connect(mainWindow, SIGNAL(selectionChanged()),
             this, SLOT(showItemInfo()));
 
     connectToActiveView();
@@ -153,7 +153,7 @@ void InfoSidebarPage::showItemInfo()
     m_multipleSelection = false;
 
     // show the preview...
-    DolphinView* view = Dolphin::mainWin().activeView();
+    DolphinView* view = mainWindow()->activeView();
     const KFileItemList* selectedItems = view->selectedItems();
     if ((selectedItems != 0) && selectedItems->count() > 1) {
         m_multipleSelection = true;
@@ -218,7 +218,7 @@ void InfoSidebarPage::gotPreview(const KFileItem* /* item */,
 
 void InfoSidebarPage::startService(int index)
 {
-    DolphinView* view = Dolphin::mainWin().activeView();
+    DolphinView* view = mainWindow()->activeView();
     if (view->hasSelection()) {
         KUrl::List selectedUrls = view->selectedUrls();
         KDEDesktopMimeType::executeService(selectedUrls, m_actionsVector[index]);
@@ -232,7 +232,7 @@ void InfoSidebarPage::connectToActiveView()
 {
     cancelRequest();
 
-    DolphinView* view = Dolphin::mainWin().activeView();
+    DolphinView* view = mainWindow()->activeView();
     connect(view, SIGNAL(signalRequestItemInfo(const KUrl&)),
             this, SLOT(requestDelayedItemInfo(const KUrl&)));
     connect(view, SIGNAL(signalUrlChanged(const KUrl&)),
@@ -279,7 +279,7 @@ void InfoSidebarPage::createMetaInfo()
     // The methods beginInfoLines(), addInfoLine() and endInfoLines()
     // take care of this.
     beginInfoLines();
-    DolphinView* view = Dolphin::mainWin().activeView();
+    DolphinView* view = mainWindow()->activeView();
     if (!view->hasSelection()) {
         KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
         fileItem.refresh();
@@ -430,7 +430,7 @@ void InfoSidebarPage::insertActions()
     // by the given Url 'url' is created and added to the list.
     KFileItem fileItem(S_IFDIR, KFileItem::Unknown, m_shownUrl);
     KFileItemList localList;
-    const KFileItemList* itemList = Dolphin::mainWin().activeView()->selectedItems();
+    const KFileItemList* itemList = mainWindow()->activeView()->selectedItems();
     if ((itemList == 0) || itemList->isEmpty()) {
         fileItem.refresh();
         localList.append(&fileItem);
index 8f2efcc7389631854693bef5da4bf7c56c64c8d7..edd43229e12d3300f8d58cb5a89796d35a880093 100644 (file)
@@ -59,7 +59,7 @@ class InfoSidebarPage : public SidebarPage
        Q_OBJECT
 
 public:
-    InfoSidebarPage(QWidget* parent);
+    InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent);
     virtual ~InfoSidebarPage();
 
 protected:
index eacff0cba5f97262b4039bf0be7bc9d7fbe1a95c..6d71bd7209eb4c4e86981b52769f8a5c52ae5fca 100644 (file)
@@ -18,7 +18,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include "dolphin.h"
+#include "dolphinapplication.h"
+#include "dolphinmainwindow.h"
 #include <kapplication.h>
 #include <kaboutdata.h>
 #include <kcmdlineargs.h>
@@ -54,11 +55,11 @@ int main(int argc, char **argv)
     KCmdLineArgs::init(argc, argv, &about);
     KCmdLineArgs::addCmdLineOptions(options);
 
-    KApplication app;
+    DolphinApplication app;
 
-    Dolphin& mainWin = Dolphin::mainWin();
-    mainWin.show();
 
+#warning TODO, SessionManagement
+#if 0
     if (false /* KDE4-TODO: app.isSessionRestored() */) {
         int n = 1;
         while (KMainWindow::canBeRestored(n)){
@@ -66,16 +67,20 @@ int main(int argc, char **argv)
             ++n;
         }
     } else {
+#endif
+
         KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
         if (args->count() > 0) {
-            mainWin.activeView()->setUrl(args->url(0));
-
-            for (int i = 1; i < args->count(); ++i) {
-                KRun::run("dolphin", args->url(i));
+            for (int i = 0; i < args->count(); ++i) {
+                DolphinMainWindow *win = app.createMainWindow();
+                win->activeView()->setUrl(args->url(i));
+                win->show();
             }
+        } else {
+            DolphinMainWindow* mainWin = app.createMainWindow();
+            mainWin->show();
         }
         args->clear();
-    }
-
+    
     return app.exec();
 }
index a09552c066c54f6d73111521020802997c1521e6..b42bc2ea5dcdd1b002599deee28c0319bca2a53e 100644 (file)
  ***************************************************************************/
 
 #include "progressindicator.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "dolphinstatusbar.h"
 
-ProgressIndicator::ProgressIndicator(const QString& progressText,
+ProgressIndicator::ProgressIndicator(DolphinMainWindow* mainWindow,
+                                     const QString& progressText,
                                      const QString& finishedText,
                                      int operationsCount)
- :  m_showProgress(false),
+ :  m_mainWindow(mainWindow),
+    m_showProgress(false),
     m_operationsCount(operationsCount),
     m_operationsIndex(0),
     m_startTime(QTime::currentTime()),
     m_finishedText(finishedText)
 {
-    DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
+    DolphinStatusBar* statusBar = mainWindow->activeView()->statusBar();
     statusBar->clear();
     statusBar->setProgressText(progressText);
     statusBar->setProgress(0);
@@ -40,13 +42,13 @@ ProgressIndicator::ProgressIndicator(const QString& progressText,
 
 ProgressIndicator::~ProgressIndicator()
 {
-    DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
+    DolphinStatusBar* statusBar = m_mainWindow->activeView()->statusBar();
     statusBar->setProgressText(QString::null);
     statusBar->setProgress(100);
     statusBar->setMessage(m_finishedText, DolphinStatusBar::OperationCompleted);
 
     if (m_showProgress) {
-        Dolphin::mainWin().setEnabled(true);
+        m_mainWindow->setEnabled(true);
     }
 }
 
@@ -59,7 +61,7 @@ void ProgressIndicator::execOperation()
         if (elapsed > 500) {
             // the operations took already more than 500 milliseconds,
             // therefore show a progress indication
-            Dolphin::mainWin().setEnabled(false);
+            m_mainWindow->setEnabled(false);
             m_showProgress = true;
         }
     }
@@ -69,8 +71,9 @@ void ProgressIndicator::execOperation()
         if (m_startTime.msecsTo(currentTime) > 100) {
             m_startTime = currentTime;
 
-            DolphinStatusBar* statusBar = Dolphin::mainWin().activeView()->statusBar();
+            DolphinStatusBar* statusBar = m_mainWindow->activeView()->statusBar();
             statusBar->setProgress((m_operationsIndex * 100) / m_operationsCount);
+#warning "EVIL, DANGER, FIRE"
             kapp->processEvents();
             statusBar->repaint();
         }
index cc5c64ad458c16d4d69fc004276132f08e66c92d..637ca10eca6ae60cf5a10a88f4cdb3641352e36a 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <qdatetime.h>
 
+class DolphinMainWindow;
+
 /**
  * Allows to show a progress of synchronous operations. Sample code:
  * \code
@@ -46,12 +48,14 @@ class ProgressIndicator
 {
 public:
     /**
+     * @param mainWindow        The mainwindow this statusbar should operate on
      * @param progressText      Text for the progress bar (e. g. "Loading...").
      * @param finishedText      Text which is displayed after the operations have been finished
      *                          (e. g. "Loading finished.").
      * @param operationsCount   Number of operations.
      */
-    ProgressIndicator(const QString& progressText,
+    ProgressIndicator(DolphinMainWindow *mainWindow,
+                      const QString& progressText,
                       const QString& finishedText,
                       int operationsCount);
 
@@ -68,6 +72,7 @@ public:
     void execOperation();
 
 private:
+    DolphinMainWindow *m_mainWindow;
     bool m_showProgress;
     int m_operationsCount;
     int m_operationsIndex;
index d67f681805fa98ae502656ec5ac1478d5fc42011..26cfa0c462dd56690029af6029f26395536e8931 100644 (file)
@@ -30,8 +30,9 @@
 #include "bookmarkssidebarpage.h"
 #include "infosidebarpage.h"
 
-Sidebar::Sidebar(QWidget* parent) :
+Sidebar::Sidebar(DolphinMainWindow* mainWindow, QWidget* parent) :
     QWidget(parent),
+    m_mainWindow(mainWindow),
     m_pagesSelector(0),
     m_page(0),
     m_layout(0)
@@ -83,8 +84,8 @@ void Sidebar::createPage(int index)
     }
 
     switch (index) {
-        case 0: m_page = new InfoSidebarPage(this); break;
-        case 1: m_page = new BookmarksSidebarPage(this); break;
+        case 0: m_page = new InfoSidebarPage(m_mainWindow, this); break;
+        case 1: m_page = new BookmarksSidebarPage(m_mainWindow, this); break;
         default: break;
     }
 
index 772d2d4f9a234f6660e8314db4dbbd0fa2670d31..6c7abab3483829d3a4ff50e48558af461f37fe9b 100644 (file)
@@ -28,6 +28,7 @@ class KUrl;
 class QComboBox;
 class Q3VBoxLayout;
 class SidebarPage;
+class DolphinMainWindow;
 
 /**
  * @brief The sidebar allows to access bookmarks, history items and TODO...
@@ -39,7 +40,7 @@ class Sidebar : public QWidget
        Q_OBJECT
 
 public:
-    Sidebar(QWidget* parent);
+    Sidebar(DolphinMainWindow* mainwindow, QWidget* parent);
     virtual ~Sidebar();
 
     virtual QSize sizeHint() const;
@@ -57,6 +58,7 @@ private slots:
 private:
     int indexForName(const QString& name) const;
 
+    DolphinMainWindow *m_mainWindow;
     QComboBox* m_pagesSelector;
     SidebarPage* m_page;
     QVBoxLayout* m_layout;
index 0b633335bb6b7f76c13a7ffd863b0c64e17ad072..5a57ad2824bdb4df6a58955c25250efae0115c41 100644 (file)
  ***************************************************************************/
 
 #include "sidebarpage.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 
-SidebarPage::SidebarPage(QWidget* parent) :
-    QWidget(parent)
+SidebarPage::SidebarPage(DolphinMainWindow *mainWindow, QWidget* parent) :
+    QWidget(parent),
+    m_mainWindow(mainWindow)
 {
-    connect(&Dolphin::mainWin(), SIGNAL(activeViewChanged()),
+    connect(mainWindow, SIGNAL(activeViewChanged()),
             this, SLOT(activeViewChanged()));
 }
 
@@ -35,4 +36,8 @@ void SidebarPage::activeViewChanged()
 {
 }
 
+DolphinMainWindow* SidebarPage::mainWindow() const {
+    return m_mainWindow;
+}
+
 #include "sidebarpage.moc"
index 50a7b598f31092fa34a39da02de382e4f437db7a..e97b0c9cf25f74f20eb5e59dbc834c1c9b558943 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <qwidget.h>
 
+class DolphinMainWindow;
 class Sidebar;
 
 /**
@@ -35,7 +36,7 @@ class SidebarPage : public QWidget
        Q_OBJECT
 
 public:
-    SidebarPage(QWidget* parent);
+    SidebarPage(DolphinMainWindow* mainwindow, QWidget* parent);
     virtual ~SidebarPage();
 
 protected slots:
@@ -44,6 +45,12 @@ protected slots:
      * The active view can be retrieved by Dolphin::mainWin().activeView();
      */
     virtual void activeViewChanged();
+
+protected:
+    DolphinMainWindow* mainWindow() const;
+
+private:
+    DolphinMainWindow *m_mainWindow;
 };
 
 #endif // _SIDEBARPAGE_H_
index 4e3ec054bed4093320dc2669e5edb01b0a9f08fd..7d21896e1ce121fe0913f058096f711f17c455d3 100644 (file)
 #include <qtimer.h>
 #include <assert.h>
 
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "dolphinstatusbar.h"
 #include "progressindicator.h"
 
 DolphinCommand::DolphinCommand() :
     m_type(Copy),
-    m_macroIndex(-1)
+    m_macroIndex(-1),
+    m_mainWindow(0)
 {
     // Implementation note: DolphinCommands are stored in a QValueList, whereas
     // QValueList requires a default constructor of the added class.
@@ -43,11 +44,13 @@ DolphinCommand::DolphinCommand() :
 
 DolphinCommand::DolphinCommand(Type type,
                               const KUrl::List& source,
-                              const KUrl& dest) :
+                              const KUrl& dest,
+                              DolphinMainWindow* mainWindow) :
     m_type(type),
     m_macroIndex(-1),
     m_source(source),
-    m_dest(dest)
+    m_dest(dest),
+    m_mainWindow(mainWindow)
 {
 }
 
@@ -60,6 +63,7 @@ DolphinCommand& DolphinCommand::operator = (const DolphinCommand& command)
     m_type = command.m_type;
     m_source = command.m_source;
     m_dest = command.m_dest;
+    m_mainWindow = command.m_mainWindow;
     return *this;
 }
 
@@ -124,7 +128,7 @@ void UndoManager::undo()
     int macroCount = 1;
     calcStepsCount(macroCount, progressCount);
 
-    m_progressIndicator = new ProgressIndicator(i18n("Executing undo operation..."),
+    m_progressIndicator = new ProgressIndicator(0, i18n("Executing undo operation..."),
                                                 i18n("Executed undo operation."),
                                                 progressCount);
 
@@ -201,7 +205,7 @@ void UndoManager::undo()
 
             case DolphinCommand::CreateFolder:
             case DolphinCommand::CreateFile: {
-                KIO::NetAccess::del(command.destination(), &Dolphin::mainWin());
+                KIO::NetAccess::del(command.destination(), command.mainWindow() );
                 break;
             }
         }
@@ -211,7 +215,7 @@ void UndoManager::undo()
             // information to the Dolphin statusbar.
             connect(job, SIGNAL(percent(KIO::Job*, unsigned long)),
                     this, SLOT(slotPercent(KIO::Job*, unsigned long)));
-            KIO::NetAccess::synchronousRun(job, &Dolphin::mainWin());
+            KIO::NetAccess::synchronousRun(job, command.mainWindow() );
         }
 
         m_progressIndicator->execOperation();
@@ -237,7 +241,8 @@ void UndoManager::redo()
     int macroCount = 1;
     calcStepsCount(macroCount, progressCount);
 
-    m_progressIndicator = new ProgressIndicator(i18n("Executing redo operation..."),
+#warning "TOUGH"
+    m_progressIndicator = new ProgressIndicator(0, i18n("Executing redo operation..."),
                                                 i18n("Executed redo operation."),
                                                 progressCount);
 
@@ -254,8 +259,6 @@ void UndoManager::redo()
         emit undoAvailable(true);
         emit undoTextChanged(i18n("Undo: %1",commandText(command)));
 
-        Dolphin& dolphin = Dolphin::mainWin();
-
         KUrl::List sourceUrls = command.source();
         KUrl::List::Iterator it = sourceUrls.begin();
         const KUrl::List::Iterator end = sourceUrls.end();
@@ -286,7 +289,7 @@ void UndoManager::redo()
                     const QString originalFileName((*it).fileName().section('-', 1));
                     KUrl originalSourceUrl(destUrl + "/" + originalFileName);
                     KIO::Job* moveToTrashJob = KIO::trash(originalSourceUrl);
-                    KIO::NetAccess::synchronousRun(moveToTrashJob, &dolphin);
+                    KIO::NetAccess::synchronousRun(moveToTrashJob, command.mainWindow() );
                     ++it;
 
                     m_progressIndicator->execOperation();
@@ -295,7 +298,7 @@ void UndoManager::redo()
             }
 
             case DolphinCommand::CreateFolder: {
-                KIO::NetAccess::mkdir(command.destination(), &dolphin);
+                KIO::NetAccess::mkdir(command.destination(), command.mainWindow());
                 break;
             }
 
@@ -315,7 +318,7 @@ void UndoManager::redo()
             // information to the Dolphin statusbar.
             connect(job, SIGNAL(percent(KJob*, unsigned long)),
                     this, SLOT(slotPercent(KJob*, unsigned long)));
-            KIO::NetAccess::synchronousRun(job, &dolphin);
+            KIO::NetAccess::synchronousRun(job, command.mainWindow());
         }
 
         ++m_historyIndex;
index ac2c2bb37c7ab0d52adf8e06103c24acffa5c46e..bf9a80c90da3633cbc0a63db9bb54c3c8f4968f2 100644 (file)
 #define UNDOMANAGER_H
 
 #include <qobject.h>
+#include <QPointer>
 #include <q3valuelist.h>
 #include <kurl.h>
 #include <kio/jobclasses.h>
 
 class ProgressIndicator;
+class DolphinMainWindow;
 
 /**
  * @short Represents a file manager command which can be undone and redone.
@@ -54,7 +56,7 @@ public:
     };
 
     DolphinCommand();
-    DolphinCommand(Type type, const KUrl::List& source, const KUrl& dest);
+    DolphinCommand(Type type, const KUrl::List& source, const KUrl& dest, DolphinMainWindow* mainWindow);
     ~DolphinCommand(); // non-virtual
 
     DolphinCommand& operator = (const DolphinCommand& command);
@@ -62,12 +64,14 @@ public:
     void setSource(const KUrl::List source) { m_source = source; }
     const KUrl::List& source() const { return m_source; }
     const KUrl& destination() const { return m_dest; }
+    DolphinMainWindow* mainWindow() const { return m_mainWindow; }
 
 private:
     Type m_type;
     int m_macroIndex;
     KUrl::List m_source;
     KUrl m_dest;
+    QPointer<DolphinMainWindow> m_mainWindow;
 
     friend class UndoManager;   // allow to modify m_macroIndex
 };
index a4415707a34a7998c89a0d2ef88527ac9e16f260..f2bf8ccdac643b43c0d1b8cd2ec12044b1dbe852 100644 (file)
@@ -29,7 +29,7 @@
 #include <klocale.h>
 
 #include "urlnavigator.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 
 
 UrlButton::UrlButton(UrlNavigator* parent)
@@ -42,7 +42,7 @@ UrlButton::UrlButton(UrlNavigator* parent)
     setMinimumHeight(parent->minimumHeight());
 
     connect(this, SIGNAL(clicked()), parent, SLOT(slotRequestActivation()));
-    connect(&Dolphin::mainWin(), SIGNAL(activeViewChanged()),
+    connect(parent->dolphinView()->mainWindow(), SIGNAL(activeViewChanged()),
             this, SLOT(update()));
 }
 
index ae2e06cbd73ba4abab43e054ee7173b6ef1e5f67..bc2c5914e3b0fd2808c0f14351dce6ed5c4131e2 100644 (file)
@@ -51,7 +51,7 @@
 #include <kvbox.h>
 
 #include "bookmarkselector.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 #include "dolphinsettings.h"
 #include "dolphinstatusbar.h"
 #include "dolphinview.h"
@@ -470,7 +470,7 @@ void UrlNavigator::updateContent()
 
     QToolTip::remove(m_toggleButton);
     QString path(url().pathOrUrl());
-    const KAction* action = Dolphin::mainWin().actionCollection()->action("editable_location");
+    const KAction* action = dolphinView()->mainWindow()->actionCollection()->action("editable_location");
     // TODO: registry of default shortcuts
     QString shortcut = action? action->shortcut().toString() : "Ctrl+L";
     if (m_toggleButton->isChecked()) {
index 0b25e136dd07ff0273624845cb55f5ccd59eea23..1ae1dc04015d09dd9384895a95f7508dd9fefe6e 100644 (file)
@@ -103,7 +103,7 @@ public:
         int m_contentsY;
     };
 
-    UrlNavigator(const KUrl& url, DolphinView* dolphinView);;
+    UrlNavigator(const KUrl& url, DolphinView* dolphinView);
     virtual ~UrlNavigator();
 
     /**
index f9c5b407b68b7bcb8ead7c0cd883aa4d4b4f71c9..5e800c1a2c3c0f64f0ea75b3a5a6989305e92568 100644 (file)
@@ -40,7 +40,7 @@
 
 #include "urlnavigator.h"
 #include "dolphinview.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
 
 UrlNavigatorButton::UrlNavigatorButton(int index, UrlNavigator* parent) :
     UrlButton(parent),
@@ -117,9 +117,9 @@ void UrlNavigatorButton::paintEvent(QPaintEvent* event)
 
     // dimm the colors if the parent view does not have the focus
     const DolphinView* parentView = urlNavigator()->dolphinView();
-    const Dolphin& dolphin = Dolphin::mainWin();
+    const DolphinMainWindow* dolphin = parentView->mainWindow();
 
-    const bool isActive = (dolphin.activeView() == parentView);
+    const bool isActive = (dolphin->activeView() == parentView);
     if (!isActive) {
         QColor dimmColor(colorGroup().background());
         foregroundColor = mixColors(foregroundColor, dimmColor);