set(dolphin_SRCS
main.cpp
- dolphin.cpp
+ dolphinapplication.cpp
+ dolphinmainwindow.cpp
dolphinview.cpp
urlnavigator.cpp
urlnavigatorbutton.cpp
--- /dev/null
+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
#include "bookmarkselector.h"
#include "dolphinsettings.h"
#include "dolphinview.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "urlnavigator.h"
BookmarkSelector::BookmarkSelector(UrlNavigator* parent) :
// 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);
#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);
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,
delete popup;
popup = 0;
- DolphinView* view = Dolphin::mainWin().activeView();
+ DolphinView* view = mainWindow()->activeView();
adjustSelection(view->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&)));
Q_OBJECT
public:
- BookmarksSidebarPage(QWidget* parent);
+ BookmarksSidebarPage(DolphinMainWindow *mainWindow, QWidget* parent);
virtual ~BookmarksSidebarPage();
protected:
--- /dev/null
+/***************************************************************************
+ * 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"
+
--- /dev/null
+/***************************************************************************
+ * 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
#include <kmenu.h>
#include <kstdaction.h>
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphinview.h"
#include "editbookmarkdialog.h"
#include "dolphinsettings.h"
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);
}
KAction* action = 0;
- Q3PtrListIterator<KAction> fileGrouptIt(dolphin.fileGroupActions());
+ Q3PtrListIterator<KAction> fileGrouptIt(dolphin->fileGroupActions());
while ((action = fileGrouptIt.current()) != 0) {
action->plug(createNewMenu);
++fileGrouptIt;
//
//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;
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);
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,
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);
}
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);
}
// 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);
#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 );
}
void DolphinIconsView::mouseReleaseEvent(QMouseEvent *e)
{
QListView::mouseReleaseEvent(e);
- Dolphin::mainWin().setActiveView(m_parentView);
+ m_parentView->declareViewActive();
}
#include "dolphiniconsview.moc"
* 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) {
emit activeViewChanged();
}
-void Dolphin::dropUrls(const KUrl::List& urls,
+void DolphinMainWindow::dropUrls(const KUrl::List& urls,
const KUrl& destination)
{
int selectedIndex = -1;
}
}
-void Dolphin::refreshViews()
+void DolphinMainWindow::refreshViews()
{
const bool split = DolphinSettings::instance().generalSettings()->splitView();
const bool isPrimaryViewActive = (m_activeView == m_view[PrimaryIdx]);
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());
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) {
}
}
-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();
emit selectionChanged();
}
-void Dolphin::closeEvent(QCloseEvent* event)
+void DolphinMainWindow::closeEvent(QCloseEvent* event)
{
// KDE4-TODO
//KConfig* config = KGlobal::config();
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());
}
}
-void Dolphin::readProperties(KConfig* config)
+void DolphinMainWindow::readProperties(KConfig* config)
{
config->setGroup("Primary view");
m_view[PrimaryIdx]->setUrl(config->readEntry("Url"));
}
}
-void Dolphin::createFolder()
+void DolphinMainWindow::createFolder()
{
// Parts of the following code have been taken
// from the class KonqPopupMenu located in
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 {
}
}
-void Dolphin::createFile()
+void DolphinMainWindow::createFile()
{
// Parts of the following code have been taken
// from the class KonqPopupMenu located in
KUrl::List list;
list.append(sourceUrl);
- DolphinCommand command(DolphinCommand::CreateFile, list, destUrl);
+ DolphinCommand command(DolphinCommand::CreateFile, list, destUrl, this);
UndoManager::instance().addCommand(command);
}
}
}
-void Dolphin::rename()
+void DolphinMainWindow::rename()
{
clearStatusBar();
m_activeView->renameSelectedItems();
}
-void Dolphin::moveToTrash()
+void DolphinMainWindow::moveToTrash()
{
clearStatusBar();
KUrl::List selectedUrls = m_activeView->selectedUrls();
addPendingUndoJob(job, DolphinCommand::Trash, selectedUrls, m_activeView->url());
}
-void Dolphin::deleteItems()
+void DolphinMainWindow::deleteItems()
{
clearStatusBar();
}
}
-void Dolphin::properties()
+void DolphinMainWindow::properties()
{
const KFileItemList* sourceList = m_activeView->selectedItems();
if (sourceList == 0) {
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(),
}
}
-void Dolphin::slotDeleteFileFinished(KJob* job)
+void DolphinMainWindow::slotDeleteFileFinished(KJob* job)
{
if (job->error() == 0) {
m_activeView->statusBar()->setMessage(i18n("Delete operation completed."),
}
}
-void Dolphin::slotUndoAvailable(bool available)
+void DolphinMainWindow::slotUndoAvailable(bool available)
{
KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
if (undoAction != 0) {
}
}
-void Dolphin::slotUndoTextChanged(const QString& text)
+void DolphinMainWindow::slotUndoTextChanged(const QString& text)
{
KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
if (undoAction != 0) {
}
}
-void Dolphin::slotRedoAvailable(bool available)
+void DolphinMainWindow::slotRedoAvailable(bool available)
{
KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
if (redoAction != 0) {
}
}
-void Dolphin::slotRedoTextChanged(const QString& text)
+void DolphinMainWindow::slotRedoTextChanged(const QString& text)
{
KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
if (redoAction != 0) {
}
}
-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
QApplication::clipboard()->setData(data);*/
}
-void Dolphin::copy()
+void DolphinMainWindow::copy()
{
m_clipboardContainsCutData = false;
/* KDE4-TODO:
QApplication::clipboard()->setData(data);*/
}
-void Dolphin::paste()
+void DolphinMainWindow::paste()
{
/* KDE4-TODO: - see KonqOperations::doPaste
QClipboard* clipboard = QApplication::clipboard();
}*/
}
-void Dolphin::updatePasteAction()
+void DolphinMainWindow::updatePasteAction()
{
KAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
if (pasteAction == 0) {
}
}
-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 :
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());
}
}
-void Dolphin::reloadView()
+void DolphinMainWindow::reloadView()
{
clearStatusBar();
m_activeView->reload();
}
-void Dolphin::stopLoading()
+void DolphinMainWindow::stopLoading()
{
}
-void Dolphin::showHiddenFiles()
+void DolphinMainWindow::showHiddenFiles()
{
clearStatusBar();
m_activeView->setShowHiddenFilesEnabled(show);
}
-void Dolphin::showFilterBar()
+void DolphinMainWindow::showFilterBar()
{
const KToggleAction* showFilterBarAction =
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
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();
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());
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:
}
-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);
}
}
-void Dolphin::toggleSidebar()
+void DolphinMainWindow::toggleSidebar()
{
if (m_sidebar == 0) {
openSidebar();
sidebarAction->setChecked(m_sidebar != 0);
}
-void Dolphin::closeSidebar()
+void DolphinMainWindow::closeSidebar()
{
if (m_sidebar == 0) {
// the sidebar has already been closed
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();
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());
}
}
-void Dolphin::loadSettings()
+void DolphinMainWindow::loadSettings()
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
updateViewActions();
}
-void Dolphin::setupActions()
+void DolphinMainWindow::setupActions()
{
// setup 'File' menu
KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder");
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
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;
}
//plugActionList("link_to_device", m_linkToDeviceActions);*/
}
-void Dolphin::updateHistory()
+void DolphinMainWindow::updateHistory()
{
int index = 0;
const Q3ValueList<UrlNavigator::HistoryElem> list = m_activeView->urlHistory(index);
}
}
-void Dolphin::updateEditActions()
+void DolphinMainWindow::updateEditActions()
{
const KFileItemList* list = m_activeView->selectedItems();
if ((list == 0) || (*list).isEmpty()) {
updatePasteAction();
}
-void Dolphin::updateViewActions()
+void DolphinMainWindow::updateViewActions()
{
KAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
if (zoomInAction != 0) {
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;
// 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());
}
}
-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)
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&)),
settings->setVisible(true);
}
-#include "dolphin.moc"
+#include "dolphinmainwindow.moc"
* 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>
class KAction;
class UrlNavigator;
class Sidebar;
+class DolphinApplication;
/**
* @short Main window for Dolphin.
*
* @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
/**
* Returns the currently active view. See
- * Dolphin::setActiveView() for more details.
+ * DolphinMainWindow::setActiveView() for more details.
*/
DolphinView* activeView() const { return m_activeView; }
void closeSidebar();
private:
- Dolphin();
+ DolphinMainWindow();
void init();
void loadSettings();
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
* 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
{
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;
};
#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;
#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"));
m_generalSettingsPage->applySettings();
m_viewSettingsPage->applySettings();
m_bookmarksSettingsPage->applySettings();
- Dolphin::mainWin().refreshViews();
+ DolphinApplication::app()->refreshMainWindows();
}
#include "dolphinsettingsdialog.moc"
class GeneralSettingsPage;
class ViewSettingsPage;
class BookmarksSettingsPage;
+class DolphinMainWindow;
/**
* @brief Settings dialog for Dolphin.
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;
#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),
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);
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&)));
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)
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."),
const int urlsCount = urls.count();
ProgressIndicator* progressIndicator =
- new ProgressIndicator(i18n("Renaming items..."),
+ new ProgressIndicator(mainWindow(),
+ i18n("Renaming items..."),
i18n("Renaming finished."),
urlsCount);
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);
}
}
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...
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 {
}
}
- 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)
// 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);
}
// 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);
}
}
void DolphinView::slotGrabActivation()
{
- Dolphin::mainWin().setActiveView(this);
+ mainWindow()->setActiveView(this);
}
void DolphinView::slotContentsMoving(int x, int y)
}
}
+void DolphinView::declareViewActive()
+{
+ mainWindow()->setActiveView( this );
+}
+
void DolphinView::slotChangeNameFilter(const QString& nameFilter)
{
// The name filter of KDirLister does a 'hard' filtering, which
class Q3ListViewItem;
class Q3VBoxLayout;
//class KFileView;
-class Dolphin;
+class DolphinMainWindow;
class DolphinDirLister;
class DolphinStatusBar;
class DolphinIconsView;
MaxSortEnum = SortByDate
};
- DolphinView(QWidget* parent,
+ DolphinView(DolphinMainWindow* mainwindow,
+ QWidget *parent,
const KUrl& url,
Mode mode = IconsView,
bool showHiddenFiles = false);
*/
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,
*/
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);
/**
* 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();
/** @see QWidget::mouseReleaseEvent */
virtual void mouseReleaseEvent(QMouseEvent* event);
+
private slots:
void slotUrlChanged(const KUrl& kurl);
void triggerIconsViewItem(Q3IconViewItem *item);
*/
void applyModeToView();
+ DolphinMainWindow *m_mainWindow;
bool m_refreshing;
bool m_showProgress;
Mode m_mode;
#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;
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()
QWidget::keyReleaseEvent(event);
if ((event->key() == Qt::Key_Escape)) {
hide();
- Dolphin::mainWin().slotShowFilterBarChanged();
+ m_mainWindow->slotShowFilterBarChanged();
}
}
class QLabel;
class QToolButton;
class KLineEdit;
+class DolphinMainWindow;
/**
* @brief Provides an input field for filtering the currently shown items.
Q_OBJECT
public:
- FilterBar(QWidget *parent = 0, const char *name = 0);
+ FilterBar(DolphinMainWindow* mainWindow, QWidget *parent = 0, const char *name = 0);
virtual ~FilterBar();
signals:
virtual void keyReleaseEvent(QKeyEvent* event);
private:
+ DolphinMainWindow *m_mainWindow;
QLabel* m_filter;
KLineEdit* m_filterInput;
QToolButton* m_close;
#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)
void GeneralSettingsPage::useCurrentLocation()
{
- const DolphinView* view = Dolphin::mainWin().activeView();
+ const DolphinView* view = m_mainWindow->activeView();
m_homeUrl->setText(view->url().prettyUrl());
}
class QLineEdit;
class QRadioButton;
class QCheckBox;
+class DolphinMainWindow;
/**
* @brief Page for the 'General' settings of the Dolphin settings dialog.
Q_OBJECT
public:
- GeneralSettingsPage(QWidget* parent);
+ GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
virtual ~GeneralSettingsPage();
void useDefaulLocation();
private:
+ DolphinMainWindow *m_mainWindow;
QLineEdit* m_homeUrl;
QRadioButton* m_iconsView;
QRadioButton* m_detailsView;
#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),
layout->addWidget(m_actionBox);
layout->addWidget(dummy);
- connect(&Dolphin::mainWin(), SIGNAL(selectionChanged()),
+ connect(mainWindow, SIGNAL(selectionChanged()),
this, SLOT(showItemInfo()));
connectToActiveView();
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;
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]);
{
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&)),
// 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();
// 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);
Q_OBJECT
public:
- InfoSidebarPage(QWidget* parent);
+ InfoSidebarPage(DolphinMainWindow* mainWindow, QWidget* parent);
virtual ~InfoSidebarPage();
protected:
* 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>
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)){
++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();
}
***************************************************************************/
#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);
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);
}
}
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;
}
}
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();
}
#include <qdatetime.h>
+class DolphinMainWindow;
+
/**
* Allows to show a progress of synchronous operations. Sample code:
* \code
{
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);
void execOperation();
private:
+ DolphinMainWindow *m_mainWindow;
bool m_showProgress;
int m_operationsCount;
int m_operationsIndex;
#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)
}
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;
}
class QComboBox;
class Q3VBoxLayout;
class SidebarPage;
+class DolphinMainWindow;
/**
* @brief The sidebar allows to access bookmarks, history items and TODO...
Q_OBJECT
public:
- Sidebar(QWidget* parent);
+ Sidebar(DolphinMainWindow* mainwindow, QWidget* parent);
virtual ~Sidebar();
virtual QSize sizeHint() const;
private:
int indexForName(const QString& name) const;
+ DolphinMainWindow *m_mainWindow;
QComboBox* m_pagesSelector;
SidebarPage* m_page;
QVBoxLayout* m_layout;
***************************************************************************/
#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()));
}
{
}
+DolphinMainWindow* SidebarPage::mainWindow() const {
+ return m_mainWindow;
+}
+
#include "sidebarpage.moc"
#include <qwidget.h>
+class DolphinMainWindow;
class Sidebar;
/**
Q_OBJECT
public:
- SidebarPage(QWidget* parent);
+ SidebarPage(DolphinMainWindow* mainwindow, QWidget* parent);
virtual ~SidebarPage();
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_
#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.
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)
{
}
m_type = command.m_type;
m_source = command.m_source;
m_dest = command.m_dest;
+ m_mainWindow = command.m_mainWindow;
return *this;
}
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);
case DolphinCommand::CreateFolder:
case DolphinCommand::CreateFile: {
- KIO::NetAccess::del(command.destination(), &Dolphin::mainWin());
+ KIO::NetAccess::del(command.destination(), command.mainWindow() );
break;
}
}
// 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();
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);
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();
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();
}
case DolphinCommand::CreateFolder: {
- KIO::NetAccess::mkdir(command.destination(), &dolphin);
+ KIO::NetAccess::mkdir(command.destination(), command.mainWindow());
break;
}
// 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;
#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.
};
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);
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
};
#include <klocale.h>
#include "urlnavigator.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
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()));
}
#include <kvbox.h>
#include "bookmarkselector.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
#include "dolphinsettings.h"
#include "dolphinstatusbar.h"
#include "dolphinview.h"
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()) {
int m_contentsY;
};
- UrlNavigator(const KUrl& url, DolphinView* dolphinView);;
+ UrlNavigator(const KUrl& url, DolphinView* dolphinView);
virtual ~UrlNavigator();
/**
#include "urlnavigator.h"
#include "dolphinview.h"
-#include "dolphin.h"
+#include "dolphinmainwindow.h"
UrlNavigatorButton::UrlNavigatorButton(int index, UrlNavigator* parent) :
UrlButton(parent),
// 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);