X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b1d5b6b7467d15417131c8df8fdecb22b2008db4..07e07fd522cc278dffccc3b8b6faded0f6f5df20:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 938d41cbc..de81af06d 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -16,90 +16,85 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "dolphinmainwindow.h" #include +#include "dolphinapplication.h" +#include "dolphinsettings.h" +#include "dolphinsettingsdialog.h" +#include "dolphinstatusbar.h" +#include "dolphinapplication.h" +#include "urlnavigator.h" +#include "dolphinsettings.h" +#include "bookmarkssidebarpage.h" +#include "infosidebarpage.h" +#include "generalsettings.h" +#include "viewpropertiesdialog.h" +#include "viewproperties.h" + +#include #include -#include #include +#include +#include +#include +#include #include -#include #include #include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include -#include +#include +#include #include -#include -#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include +#include -#include -#include -//Added by qt3to4: -#include +#include // TODO #include +#include #include #include -#include "urlnavigator.h" -#include "viewpropertiesdialog.h" -#include "viewproperties.h" -#include "dolphinsettings.h" -#include "dolphinsettingsdialog.h" -#include "dolphinstatusbar.h" -#include "dolphinapplication.h" -#include "undomanager.h" -#include "progressindicator.h" -#include "dolphinsettings.h" -#include "bookmarkssidebarpage.h" -#include "infosidebarpage.h" -#include "generalsettings.h" -#include "dolphinapplication.h" - - DolphinMainWindow::DolphinMainWindow() : - KMainWindow(0, "Dolphin"), + KMainWindow(0), m_splitter(0), - m_activeView(0), - m_clipboardContainsCutData(false) + m_activeView(0) { + setObjectName("Dolphin"); m_view[PrimaryIdx] = 0; m_view[SecondaryIdx] = 0; - m_fileGroupActions.setAutoDelete(true); + KonqUndoManager::incRef(); - // 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); + connect(KonqUndoManager::self(), SIGNAL(undoAvailable(bool)), + this, SLOT(slotUndoAvailable(bool))); + connect(KonqUndoManager::self(), SIGNAL(undoTextChanged(const QString&)), + this, SLOT(slotUndoTextChanged(const QString&))); } DolphinMainWindow::~DolphinMainWindow() { - /* - * bye, bye managed window - */ - DolphinApplication::app()->removeMainWindow( this ); + KonqUndoManager::decRef(); + + qDeleteAll(m_fileGroupActions); + m_fileGroupActions.clear(); + + DolphinApplication::app()->removeMainWindow(this); } void DolphinMainWindow::setActiveView(DolphinView* view) @@ -122,9 +117,10 @@ void DolphinMainWindow::setActiveView(DolphinView* view) } void DolphinMainWindow::dropUrls(const KUrl::List& urls, - const KUrl& destination) + const KUrl& destination) { - int selectedIndex = -1; + m_dropDestination = destination; + m_droppedUrls = urls; /* KDE4-TODO const ButtonState keyboardState = KApplication::keyboardMouseState(); @@ -149,49 +145,22 @@ void DolphinMainWindow::dropUrls(const KUrl::List& urls, // no shortcut is used, hence open a popup menu KMenu popup(this); - popup.insertItem(SmallIcon("goto"), i18n("&Move Here") + "\t" /* KDE4-TODO: + KKey::modFlagLabel(KKey::SHIFT)*/, 0); - popup.insertItem(SmallIcon("editcopy"), i18n( "&Copy Here" ) /* KDE4-TODO + "\t" + KKey::modFlagLabel(KKey::CTRL)*/, 1); - popup.insertItem(i18n("&Link Here") /* KDE4-TODO + "\t" + KKey::modFlagLabel((KKey::ModFlag)(KKey::CTRL|KKey::SHIFT)) */, 2); - popup.insertSeparator(); - popup.insertItem(SmallIcon("stop"), i18n("Cancel"), 3); - popup.setAccel(i18n("Escape"), 3); + QAction* moveAction = popup.addAction(SmallIcon("goto"), i18n("&Move Here")); + connect(moveAction, SIGNAL(triggered()), this, SLOT(moveDroppedItems())); - /* KDE4-TODO: selectedIndex = popup.exec(QCursor::pos()); */ - popup.exec(QCursor::pos()); - selectedIndex = 0; // KD4-TODO: use QAction instead of switch below - // See libkonq/konq_operations.cc: KonqOperations::doDropFileCopy() (and doDrop, the main method) - } + QAction* copyAction = popup.addAction(SmallIcon("editcopy"), i18n( "&Copy Here" )); + connect(copyAction, SIGNAL(triggered()), this, SLOT(copyDroppedItems())); - if (selectedIndex < 0) { - return; - } + QAction* linkAction = popup.addAction(i18n("&Link Here")); + connect(linkAction, SIGNAL(triggered()), this, SLOT(linkDroppedItems())); - switch (selectedIndex) { - case 0: { - // 'Move Here' has been selected - updateViewProperties(urls); - moveUrls(urls, destination); - break; - } + QAction* cancelAction = popup.addAction(SmallIcon("stop"), i18n("Cancel")); + popup.insertSeparator(cancelAction); - case 1: { - // 'Copy Here' has been selected - updateViewProperties(urls); - copyUrls(urls, destination); - break; - } - - case 2: { - // 'Link Here' has been selected - KIO::Job* job = KIO::link(urls, destination); - addPendingUndoJob(job, DolphinCommand::Link, urls, destination); - break; - } - - default: - // 'Cancel' has been selected - break; + popup.exec(QCursor::pos()); } + + m_droppedUrls.clear(); } void DolphinMainWindow::refreshViews() @@ -216,7 +185,8 @@ void DolphinMainWindow::refreshViews() m_splitter, url, props.viewMode(), - props.isShowHiddenFilesEnabled()); + props.showHiddenFiles()); + connectViewSignals(i); m_view[i]->show(); } } @@ -228,24 +198,6 @@ void DolphinMainWindow::refreshViews() emit activeViewChanged(); } -void DolphinMainWindow::slotHistoryChanged() -{ - updateHistory(); -} - -void DolphinMainWindow::slotUrlChanged(const KUrl& url) -{ - updateEditActions(); - updateGoActions(); - setCaption(url.fileName()); -} - -void DolphinMainWindow::slotUrlChangeRequest(const KUrl& url) -{ - clearStatusBar(); - m_activeView->setUrl(url); -} - void DolphinMainWindow::slotViewModeChanged() { updateViewActions(); @@ -255,19 +207,12 @@ void DolphinMainWindow::slotShowHiddenFilesChanged() { KToggleAction* showHiddenFilesAction = static_cast(actionCollection()->action("show_hidden_files")); - showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled()); -} - -void DolphinMainWindow::slotShowFilterBarChanged() -{ - KToggleAction* showFilterBarAction = - static_cast(actionCollection()->action("show_filter_bar")); - showFilterBarAction->setChecked(m_activeView->isFilterBarVisible()); + showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles()); } void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting) { - KAction* action = 0; + QAction* action = 0; switch (sorting) { case DolphinView::SortByName: action = actionCollection()->action("by_name"); @@ -305,7 +250,7 @@ void DolphinMainWindow::slotSelectionChanged() selectedUrlsCount += m_view[SecondaryIdx]->selectedUrls().count(); } - KAction* compareFilesAction = actionCollection()->action("compare_files"); + QAction* compareFilesAction = actionCollection()->action("compare_files"); compareFilesAction->setEnabled(selectedUrlsCount == 2); m_activeView->updateStatusBar(); @@ -313,34 +258,65 @@ void DolphinMainWindow::slotSelectionChanged() emit selectionChanged(); } -void DolphinMainWindow::slotRedo() +void DolphinMainWindow::slotHistoryChanged() { - UndoManager::instance().redo(this); + updateHistory(); } -void DolphinMainWindow::slotUndo() +void DolphinMainWindow::slotUrlChanged(const KUrl& url) { - UndoManager::instance().undo(this); + updateEditActions(); + updateGoActions(); + setCaption(url.fileName()); +} + +void DolphinMainWindow::updateFilterBarAction(bool show) +{ + KToggleAction* showFilterBarAction = + static_cast(actionCollection()->action("show_filter_bar")); + showFilterBarAction->setChecked(show); } -void DolphinMainWindow::slotNewMainWindow() +void DolphinMainWindow::openNewMainWindow() { DolphinApplication::app()->createMainWindow()->show(); } -void DolphinMainWindow::closeEvent(QCloseEvent* event) +void DolphinMainWindow::moveDroppedItems() +{ + moveUrls(m_droppedUrls, m_dropDestination); +} + +void DolphinMainWindow::copyDroppedItems() +{ + copyUrls(m_droppedUrls, m_dropDestination); +} + +void DolphinMainWindow::linkDroppedItems() { - // KDE4-TODO - //KConfig* config = KGlobal::config(); - //config->setGroup("General"); - //config->writeEntry("First Run", false); + KonqOperations::copy(this, KonqOperations::LINK, m_droppedUrls, m_dropDestination); + m_undoOperations.append(KonqOperations::LINK); +} +void DolphinMainWindow::closeEvent(QCloseEvent* event) +{ DolphinSettings& settings = DolphinSettings::instance(); GeneralSettings* generalSettings = settings.generalSettings(); generalSettings->setFirstRun(false); settings.save(); + // TODO: I assume there will be a generic way in KDE 4 to store the docks + // of the main window. In the meantime they are stored manually: + QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName()); + filename.append("/panels_layout"); + QFile file(filename); + if (file.open(QIODevice::WriteOnly)) { + QByteArray data = saveState(); + file.write(data); + file.close(); + } + KMainWindow::closeEvent(event); } @@ -360,14 +336,14 @@ void DolphinMainWindow::readProperties(KConfig* config) { config->setGroup("Primary view"); m_view[PrimaryIdx]->setUrl(config->readEntry("Url")); - m_view[PrimaryIdx]->setUrlEditable(config->readBoolEntry("Editable Url")); + m_view[PrimaryIdx]->setUrlEditable(config->readEntry("Editable Url", false)); if (config->hasGroup("Secondary view")) { config->setGroup("Secondary view"); if (m_view[SecondaryIdx] == 0) { toggleSplitView(); } m_view[SecondaryIdx]->setUrl(config->readEntry("Url")); - m_view[SecondaryIdx]->setUrlEditable(config->readBoolEntry("Editable Url")); + m_view[SecondaryIdx]->setUrlEditable(config->readEntry("Editable Url", false)); } else if (m_view[SecondaryIdx] != 0) { toggleSplitView(); @@ -392,7 +368,7 @@ void DolphinMainWindow::createFolder() if (baseUrl.isLocalFile() && QFileInfo(baseUrl.path(KUrl::AddTrailingSlash) + name).exists()) { - name = KIO::RenameDlg::suggestName(baseUrl, i18n("New Folder")); + name = KIO::RenameDialog::suggestName(baseUrl, i18n("New Folder")); } bool ok = false; @@ -418,29 +394,26 @@ void DolphinMainWindow::createFolder() url = baseUrl; url.addPath(name); } - ok = KIO::NetAccess::mkdir(url, this); - // TODO: provide message type hint - if (ok) { + KonqOperations::mkdir(this, url); + + // TODO: is there a possability to check whether the mkdir operation + // has been successful? + //if (ok) { statusBar->setMessage(i18n("Created folder %1.",url.path()), DolphinStatusBar::OperationCompleted); - - DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url); - UndoManager::instance().addCommand(command); - } - else { - // Creating of the folder has been failed. Check whether the creating - // has been failed because a folder with the same name exists... - if (KIO::NetAccess::exists(url, true, this)) { - statusBar->setMessage(i18n("A folder named %1 already exists.",url.path()), - DolphinStatusBar::Error); - } - else { - statusBar->setMessage(i18n("Creating of folder %1 failed.",url.path()), - DolphinStatusBar::Error); - } - - } + //} + //else { + // // Creating of the folder has been failed. Check whether the creating + // // has been failed because a folder with the same name exists... + // if (KIO::NetAccess::exists(url, true, this)) { + // statusBar->setMessage(i18n("A folder named %1 already exists.",url.path()), + // DolphinStatusBar::Error); + // } + // else { + // statusBar->setMessage(i18n("Creating of folder %1 failed.",url.path()), + // DolphinStatusBar::Error); + // } } void DolphinMainWindow::createFile() @@ -454,15 +427,15 @@ void DolphinMainWindow::createFile() clearStatusBar(); // TODO: const Entry& entry = m_createFileTemplates[QString(sender->name())]; - // should be enough. Anyway: the implemantation of [] does a linear search internally too. + // should be enough. Anyway: the implementation of [] does a linear search internally too. KSortableList::ConstIterator it = m_createFileTemplates.begin(); KSortableList::ConstIterator end = m_createFileTemplates.end(); - const QString senderName(sender()->name()); + const QString senderName(sender()->objectName()); bool found = false; CreateFileEntry entry; while (!found && (it != end)) { - if ((*it).index() == senderName) { + if ((*it).key() == senderName) { entry = (*it).value(); found = true; } @@ -479,17 +452,17 @@ void DolphinMainWindow::createFile() // Get the source path of the template which should be copied. // The source path is part of the Url entry of the desktop file. - const int pos = entry.templatePath.findRev('/'); + const int pos = entry.templatePath.lastIndexOf('/'); QString sourcePath(entry.templatePath.left(pos + 1)); sourcePath += KDesktopFile(entry.templatePath, true).readPathEntry("Url"); - QString name(i18n(entry.name.ascii())); + QString name(i18n(entry.name.toAscii())); // Most entry names end with "..." (e. g. "HTML File..."), which is ok for // menus but no good choice for a new file name -> remove the dots... name.replace("...", QString::null); // add the file extension to the name - name.append(sourcePath.right(sourcePath.length() - sourcePath.findRev('.'))); + name.append(sourcePath.right(sourcePath.length() - sourcePath.lastIndexOf('.'))); // Check whether a file with the current name already exists. If yes suggest automatically // a unique file name (e. g. "HTML File" will be replaced by "HTML File_1"). @@ -497,7 +470,7 @@ void DolphinMainWindow::createFile() const bool fileExists = viewUrl.isLocalFile() && QFileInfo(viewUrl.path(KUrl::AddTrailingSlash) + KIO::encodeFileName(name)).exists(); if (fileExists) { - name = KIO::RenameDlg::suggestName(viewUrl, name); + name = KIO::RenameDialog::suggestName(viewUrl, name); } // let the user change the suggested file name @@ -532,8 +505,10 @@ void DolphinMainWindow::createFile() KUrl::List list; list.append(sourceUrl); - DolphinCommand command(DolphinCommand::CreateFile, list, destUrl); - UndoManager::instance().addCommand(command); + + // TODO: use the KonqUndoManager/KonqOperations instead. + //DolphinCommand command(DolphinCommand::CreateFile, list, destUrl); + //UndoManager::instance().addCommand(command); } else { @@ -551,9 +526,12 @@ void DolphinMainWindow::rename() void DolphinMainWindow::moveToTrash() { clearStatusBar(); - KUrl::List selectedUrls = m_activeView->selectedUrls(); - KIO::Job* job = KIO::trash(selectedUrls); - addPendingUndoJob(job, DolphinCommand::Trash, selectedUrls, m_activeView->url()); + const KUrl::List selectedUrls = m_activeView->selectedUrls(); + // TODO: per default a message box is opened which asks whether the item + // should really be moved to the trash. This does not make sense, as the + // action can be undone anyway by the user. + KonqOperations::del(this, KonqOperations::TRASH, selectedUrls); + m_undoOperations.append(KonqOperations::TRASH); } void DolphinMainWindow::deleteItems() @@ -576,7 +554,7 @@ void DolphinMainWindow::deleteItems() const bool del = KMessageBox::warningContinueCancel(this, text, QString::null, - KGuiItem(i18n("Delete"), SmallIcon("editdelete")) + KGuiItem(i18n("Delete"), KIcon("editdelete")) ) == KMessageBox::Continue; if (del) { KIO::Job* job = KIO::del(list); @@ -589,20 +567,7 @@ void DolphinMainWindow::deleteItems() void DolphinMainWindow::properties() { - const KFileItemList* sourceList = m_activeView->selectedItems(); - if (sourceList == 0) { - return; - } - - KFileItemList list; - KFileItemList::const_iterator it = sourceList->begin(); - const KFileItemList::const_iterator end = sourceList->end(); - KFileItem* item = 0; - while (it != end) { - list.append(item); - ++it; - } - + const KFileItemList list = m_activeView->selectedItems(); new KPropertiesDialog(list, this); } @@ -635,69 +600,73 @@ void DolphinMainWindow::slotDeleteFileFinished(KJob* job) void DolphinMainWindow::slotUndoAvailable(bool available) { - KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo)); + QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo)); if (undoAction != 0) { undoAction->setEnabled(available); } -} -void DolphinMainWindow::slotUndoTextChanged(const QString& text) -{ - KAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo)); - if (undoAction != 0) { - undoAction->setText(text); - } -} + if (available && (m_undoOperations.count() > 0)) { + const KonqOperations::Operation op = m_undoOperations.takeFirst(); + DolphinStatusBar* statusBar = m_activeView->statusBar(); + switch (op) { + case KonqOperations::COPY: + statusBar->setMessage(i18n("Copy operation completed."), + DolphinStatusBar::OperationCompleted); + break; + case KonqOperations::MOVE: + statusBar->setMessage(i18n("Move operation completed."), + DolphinStatusBar::OperationCompleted); + break; + case KonqOperations::LINK: + statusBar->setMessage(i18n("Link operation completed."), + DolphinStatusBar::OperationCompleted); + break; + case KonqOperations::TRASH: + statusBar->setMessage(i18n("Move to trash operation completed."), + DolphinStatusBar::OperationCompleted); + break; + default: + break; + } -void DolphinMainWindow::slotRedoAvailable(bool available) -{ - KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo)); - if (redoAction != 0) { - redoAction->setEnabled(available); } } -void DolphinMainWindow::slotRedoTextChanged(const QString& text) +void DolphinMainWindow::slotUndoTextChanged(const QString& text) { - KAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo)); - if (redoAction != 0) { - redoAction->setText(text); + QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo)); + if (undoAction != 0) { + undoAction->setText(text); } } 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 - // in libkonq - m_clipboardContainsCutData = true; - /* KDE4-TODO: Q3DragObject* data = new KUrlDrag(m_activeView->selectedUrls(), - widget()); - QApplication::clipboard()->setData(data);*/ + QMimeData* mimeData = new QMimeData(); + const KUrl::List kdeUrls = m_activeView->selectedUrls(); + const KUrl::List mostLocalUrls; + KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true); + QApplication::clipboard()->setMimeData(mimeData); } void DolphinMainWindow::copy() { - m_clipboardContainsCutData = false; - /* KDE4-TODO: - Q3DragObject* data = new KUrlDrag(m_activeView->selectedUrls(), - widget()); - QApplication::clipboard()->setData(data);*/ + QMimeData* mimeData = new QMimeData(); + const KUrl::List kdeUrls = m_activeView->selectedUrls(); + const KUrl::List mostLocalUrls; + KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false); + + QApplication::clipboard()->setMimeData(mimeData); } void DolphinMainWindow::paste() { - /* KDE4-TODO: - see KonqOperations::doPaste QClipboard* clipboard = QApplication::clipboard(); - QMimeSource* data = clipboard->data(); - if (!KUrlDrag::canDecode(data)) { - return; - } + const QMimeData* mimeData = clipboard->mimeData(); clearStatusBar(); - KUrl::List sourceUrls; - KUrlDrag::decode(data, sourceUrls); + const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData); // per default the pasting is done into the current Url of the view KUrl destUrl(m_activeView->url()); @@ -716,34 +685,30 @@ void DolphinMainWindow::paste() } } - - updateViewProperties(sourceUrls); - if (m_clipboardContainsCutData) { + if (KonqMimeData::decodeIsCutSelection(mimeData)) { moveUrls(sourceUrls, destUrl); - m_clipboardContainsCutData = false; clipboard->clear(); } else { copyUrls(sourceUrls, destUrl); - }*/ + } } void DolphinMainWindow::updatePasteAction() { - KAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste)); + QAction* pasteAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste)); if (pasteAction == 0) { return; } QString text(i18n("Paste")); QClipboard* clipboard = QApplication::clipboard(); - QMimeSource* data = clipboard->data(); - /* KDE4-TODO: - if (KUrlDrag::canDecode(data)) { + const QMimeData* mimeData = clipboard->mimeData(); + + KUrl::List urls = KUrl::List::fromMimeData(mimeData); + if (!urls.isEmpty()) { pasteAction->setEnabled(true); - KUrl::List urls; - KUrlDrag::decode(data, urls); const int count = urls.count(); if (count == 1) { pasteAction->setText(i18n("Paste 1 File")); @@ -752,10 +717,10 @@ void DolphinMainWindow::updatePasteAction() pasteAction->setText(i18n("Paste %1 Files").arg(count)); } } - else {*/ + else { pasteAction->setEnabled(false); pasteAction->setText(i18n("Paste")); - //} + } if (pasteAction->isEnabled()) { KUrl::List urls = m_activeView->selectedUrls(); @@ -800,11 +765,6 @@ void DolphinMainWindow::setDetailsView() m_activeView->setMode(DolphinView::DetailsView); } -void DolphinMainWindow::setPreviewsView() -{ - m_activeView->setMode(DolphinView::PreviewsView); -} - void DolphinMainWindow::sortByName() { m_activeView->setSorting(DolphinView::SortByName); @@ -831,12 +791,16 @@ void DolphinMainWindow::toggleSortOrder() void DolphinMainWindow::toggleSplitView() { if (m_view[SecondaryIdx] == 0) { + const int newWidth = (m_view[PrimaryIdx]->width() - m_splitter->handleWidth()) / 2; // create a secondary view m_view[SecondaryIdx] = new DolphinView(this, - m_splitter, + 0, m_view[PrimaryIdx]->url(), m_view[PrimaryIdx]->mode(), - m_view[PrimaryIdx]->isShowHiddenFilesEnabled()); + m_view[PrimaryIdx]->showHiddenFiles()); + connectViewSignals(SecondaryIdx); + m_splitter->addWidget(m_view[SecondaryIdx]); + m_splitter->setSizes(QList() << newWidth << newWidth); m_view[SecondaryIdx]->show(); } else { @@ -853,7 +817,7 @@ void DolphinMainWindow::toggleSplitView() // From an implementation point of view it is more efficient to close // the primary view and exchange the internal pointers afterwards. m_view[PrimaryIdx]->close(); - m_view[PrimaryIdx]->deleteLater(); + delete m_view[PrimaryIdx]; m_view[PrimaryIdx] = m_view[SecondaryIdx]; m_view[SecondaryIdx] = 0; setActiveView(m_view[PrimaryIdx]); @@ -871,14 +835,24 @@ void DolphinMainWindow::stopLoading() { } -void DolphinMainWindow::showHiddenFiles() +void DolphinMainWindow::togglePreview() +{ + clearStatusBar(); + + const KToggleAction* showPreviewAction = + static_cast(actionCollection()->action("show_preview")); + const bool show = showPreviewAction->isChecked(); + m_activeView->setShowPreview(show); +} + +void DolphinMainWindow::toggleShowHiddenFiles() { clearStatusBar(); const KToggleAction* showHiddenFilesAction = static_cast(actionCollection()->action("show_hidden_files")); const bool show = showHiddenFilesAction->isChecked(); - m_activeView->setShowHiddenFilesEnabled(show); + m_activeView->setShowHiddenFiles(show); } void DolphinMainWindow::showFilterBar() @@ -1026,80 +1000,6 @@ void DolphinMainWindow::editSettings() dlg.exec(); } -void DolphinMainWindow::addUndoOperation(KJob* job) -{ - if (job->error() != 0) { - slotHandleJobError(job); - } - else { - const int id = job->progressId(); - - // set iterator to the executed command with the current id... - Q3ValueList::Iterator it = m_pendingUndoJobs.begin(); - const Q3ValueList::Iterator end = m_pendingUndoJobs.end(); - bool found = false; - while (!found && (it != end)) { - if ((*it).id == id) { - found = true; - } - else { - ++it; - } - } - - if (found) { - DolphinCommand command = (*it).command; - if (command.type() == DolphinCommand::Trash) { - // To be able to perform an undo for the 'Move to Trash' operation - // all source Urls must be updated with the trash Url. E. g. when moving - // a file "test.txt" and a second file "test.txt" to the trash, - // then the filenames in the trash are "0-test.txt" and "1-test.txt". - QMap metaData; - KIO::Job *kiojob = qobject_cast( job ); - if ( kiojob ) - { - metaData = kiojob->metaData(); - } - KUrl::List newSourceUrls; - - KUrl::List sourceUrls = command.source(); - KUrl::List::Iterator sourceIt = sourceUrls.begin(); - const KUrl::List::Iterator sourceEnd = sourceUrls.end(); - - while (sourceIt != sourceEnd) { - QMap::ConstIterator metaIt = metaData.find("trashUrl-" + (*sourceIt).path()); - if (metaIt != metaData.end()) { - newSourceUrls.append(KUrl(metaIt.data())); - } - ++sourceIt; - } - command.setSource(newSourceUrls); - } - - UndoManager::instance().addCommand(command); - m_pendingUndoJobs.erase(it); - - DolphinStatusBar* statusBar = m_activeView->statusBar(); - switch (command.type()) { - case DolphinCommand::Copy: - statusBar->setMessage(i18n("Copy operation completed."), - DolphinStatusBar::OperationCompleted); - break; - case DolphinCommand::Move: - statusBar->setMessage(i18n("Move operation completed."), - DolphinStatusBar::OperationCompleted); - break; - case DolphinCommand::Trash: - statusBar->setMessage(i18n("Move to trash operation completed."), - DolphinStatusBar::OperationCompleted); - break; - default: - break; - } - } - } -} - void DolphinMainWindow::init() { // Check whether Dolphin runs the first time. If yes then @@ -1133,7 +1033,9 @@ void DolphinMainWindow::init() m_splitter, homeUrl, props.viewMode(), - props.isShowHiddenFilesEnabled()); + props.showHiddenFiles()); + connectViewSignals(PrimaryIdx); + m_view[PrimaryIdx]->show(); m_activeView = m_view[PrimaryIdx]; @@ -1173,105 +1075,112 @@ void DolphinMainWindow::loadSettings() } updateViewActions(); + + // TODO: I assume there will be a generic way in KDE 4 to restore the docks + // of the main window. In the meantime they are restored manually (see also + // DolphinMainWindow::closeEvent() for more details): + QString filename = KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName()); + filename.append("/panels_layout"); + QFile file(filename); + if (file.open(QIODevice::ReadOnly)) { + QByteArray data = file.readAll(); + restoreState(data); + file.close(); + } } void DolphinMainWindow::setupActions() { // setup 'File' menu - KAction *action = new KAction(KIcon("window_new"), i18n( "New &Window" ), actionCollection(), "new_window" ); - connect(action, SIGNAL(triggered()), this, SLOT(slotNewMainWindow())); + QAction *action = actionCollection()->addAction("new_window"); + action->setIcon(KIcon("window_new")); + action->setText(i18n("New &Window")); + connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow())); - KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder"); + QAction* createFolder = actionCollection()->addAction("create_folder"); + createFolder->setText(i18n("Folder...")); createFolder->setIcon(KIcon("folder")); createFolder->setShortcut(Qt::Key_N); connect(createFolder, SIGNAL(triggered()), this, SLOT(createFolder())); - KAction* rename = new KAction(i18n("Rename"), actionCollection(), "rename"); + QAction* rename = actionCollection()->addAction("rename"); + rename->setText(i18n("Rename")); rename->setShortcut(Qt::Key_F2); connect(rename, SIGNAL(triggered()), this, SLOT(rename())); - KAction* moveToTrash = new KAction(i18n("Move to Trash"), actionCollection(), "move_to_trash"); + QAction* moveToTrash = actionCollection()->addAction("move_to_trash"); + moveToTrash->setText(i18n("Move to Trash")); moveToTrash->setIcon(KIcon("edittrash")); moveToTrash->setShortcut(QKeySequence::Delete); connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash())); - KAction* deleteAction = new KAction(i18n("Delete"), actionCollection(), "delete"); + QAction* deleteAction = actionCollection()->addAction("delete"); + deleteAction->setText(i18n("Delete")); deleteAction->setShortcut(Qt::ALT | Qt::Key_Delete); deleteAction->setIcon(KIcon("editdelete")); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems())); - KAction* properties = new KAction(i18n("Propert&ies"), actionCollection(), "properties"); + QAction* properties = actionCollection()->addAction("properties"); + properties->setText(i18n("Propert&ies")); properties->setShortcut(Qt::Key_Alt | Qt::Key_Return); connect(properties, SIGNAL(triggered()), this, SLOT(properties())); - KStdAction::quit(this, SLOT(quit()), actionCollection()); + KStandardAction::quit(this, SLOT(quit()), actionCollection()); // setup 'Edit' menu - UndoManager& undoManager = UndoManager::instance(); - KStdAction::undo(this, - SLOT(slotUndo()), - actionCollection()); - connect(&undoManager, SIGNAL(undoAvailable(bool)), - this, SLOT(slotUndoAvailable(bool))); - connect(&undoManager, SIGNAL(undoTextChanged(const QString&)), - this, SLOT(slotUndoTextChanged(const QString&))); + KStandardAction::undo(KonqUndoManager::self(), + SLOT(undo()), + actionCollection()); - KStdAction::redo(this, - SLOT(slotRedo()), - actionCollection()); - connect(&undoManager, SIGNAL(redoAvailable(bool)), - this, SLOT(slotRedoAvailable(bool))); - connect(&undoManager, SIGNAL(redoTextChanged(const QString&)), - this, SLOT(slotRedoTextChanged(const QString&))); + KStandardAction::cut(this, SLOT(cut()), actionCollection()); + KStandardAction::copy(this, SLOT(copy()), actionCollection()); + KStandardAction::paste(this, SLOT(paste()), actionCollection()); - KStdAction::cut(this, SLOT(cut()), actionCollection()); - KStdAction::copy(this, SLOT(copy()), actionCollection()); - KStdAction::paste(this, SLOT(paste()), actionCollection()); - - KAction* selectAll = new KAction(i18n("Select All"), actionCollection(), "select_all"); + QAction* selectAll = actionCollection()->addAction("select_all"); + selectAll->setText(i18n("Select All")); selectAll->setShortcut(Qt::CTRL + Qt::Key_A); connect(selectAll, SIGNAL(triggered()), this, SLOT(selectAll())); - KAction* invertSelection = new KAction(i18n("Invert Selection"), actionCollection(), "invert_selection"); + QAction* invertSelection = actionCollection()->addAction("invert_selection"); + invertSelection->setText(i18n("Invert Selection")); invertSelection->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_A); connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection())); // setup 'View' menu - KStdAction::zoomIn(this, + KStandardAction::zoomIn(this, SLOT(zoomIn()), actionCollection()); - KStdAction::zoomOut(this, + KStandardAction::zoomOut(this, SLOT(zoomOut()), actionCollection()); - KToggleAction* iconsView = new KToggleAction(i18n("Icons"), actionCollection(), "icons"); + KToggleAction* iconsView = actionCollection()->add("icons"); + iconsView->setText(i18n("Icons")); iconsView->setShortcut(Qt::CTRL | Qt::Key_1); iconsView->setIcon(KIcon("view_icon")); connect(iconsView, SIGNAL(triggered()), this, SLOT(setIconsView())); - KToggleAction* detailsView = new KToggleAction(i18n("Details"), actionCollection(), "details"); + KToggleAction* detailsView = actionCollection()->add("details"); + detailsView->setText(i18n("Details")); detailsView->setShortcut(Qt::CTRL | Qt::Key_2); detailsView->setIcon(KIcon("view_text")); connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView())); - KToggleAction* previewsView = new KToggleAction(i18n("Previews"), actionCollection(), "previews"); - previewsView->setShortcut(Qt::CTRL | Qt::Key_3); - previewsView->setIcon(KIcon("gvdirpart")); - connect(previewsView, SIGNAL(triggered()), this, SLOT(setPreviewsView())); - QActionGroup* viewModeGroup = new QActionGroup(this); viewModeGroup->addAction(iconsView); viewModeGroup->addAction(detailsView); - viewModeGroup->addAction(previewsView); - KToggleAction* sortByName = new KToggleAction(i18n("By Name"), actionCollection(), "by_name"); + KToggleAction* sortByName = actionCollection()->add("by_name"); + sortByName->setText(i18n("By Name")); connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName())); - KToggleAction* sortBySize = new KToggleAction(i18n("By Size"), actionCollection(), "by_size"); + KToggleAction* sortBySize = actionCollection()->add("by_size"); + sortBySize->setText(i18n("By Size")); connect(sortBySize, SIGNAL(triggered()), this, SLOT(sortBySize())); - KToggleAction* sortByDate = new KToggleAction(i18n("By Date"), actionCollection(), "by_date"); + KToggleAction* sortByDate = actionCollection()->add("by_date"); + sortByDate->setText(i18n("By Date")); connect(sortByDate, SIGNAL(triggered()), this, SLOT(sortByDate())); QActionGroup* sortGroup = new QActionGroup(this); @@ -1279,66 +1188,105 @@ void DolphinMainWindow::setupActions() sortGroup->addAction(sortBySize); sortGroup->addAction(sortByDate); - KToggleAction* sortDescending = new KToggleAction(i18n("Descending"), actionCollection(), "descending"); + KToggleAction* sortDescending = actionCollection()->add("descending"); + sortDescending->setText(i18n("Descending")); connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); - KToggleAction* showHiddenFiles = new KToggleAction(i18n("Show Hidden Files"), actionCollection(), "show_hidden_files"); + KToggleAction* showPreview = actionCollection()->add("show_preview"); + showPreview->setText(i18n("Show Preview")); + connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview())); + + KToggleAction* showHiddenFiles = actionCollection()->add("show_hidden_files"); + showHiddenFiles->setText(i18n("Show Hidden Files")); //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'? - connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(showHiddenFiles())); + connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles())); - KToggleAction* split = new KToggleAction(i18n("Split View"), actionCollection(), "split_view"); + KToggleAction* split = actionCollection()->add("split_view"); + split->setText(i18n("Split View")); split->setShortcut(Qt::Key_F10); split->setIcon(KIcon("view_left_right")); connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView())); - KAction* reload = new KAction(i18n("Reload"), "F5", actionCollection(), "reload"); + QAction* reload = actionCollection()->addAction("reload"); + reload->setText(i18n("Reload")); reload->setShortcut(Qt::Key_F5); reload->setIcon(KIcon("reload")); connect(reload, SIGNAL(triggered()), this, SLOT(reloadView())); - KAction* stop = new KAction(i18n("Stop"), actionCollection(), "stop"); + QAction* stop = actionCollection()->addAction("stop"); + stop->setText(i18n("Stop")); stop->setIcon(KIcon("stop")); connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading())); - KToggleAction* showFullLocation = new KToggleAction(i18n("Show Full Location"), actionCollection(), "editable_location"); + KToggleAction* showFullLocation = actionCollection()->add("editable_location"); + showFullLocation->setText(i18n("Show Full Location")); showFullLocation->setShortcut(Qt::CTRL | Qt::Key_L); connect(showFullLocation, SIGNAL(triggered()), this, SLOT(toggleEditLocation())); - KToggleAction* editLocation = new KToggleAction(i18n("Edit Location"), actionCollection(), "edit_location"); + KToggleAction* editLocation = actionCollection()->add("edit_location"); + editLocation->setText(i18n("Edit Location")); editLocation->setShortcut(Qt::Key_F6); connect(editLocation, SIGNAL(triggered()), this, SLOT(editLocation())); - KAction* adjustViewProps = new KAction(i18n("Adjust View Properties..."), actionCollection(), "view_properties"); + QAction* adjustViewProps = actionCollection()->addAction("view_properties"); + adjustViewProps->setText(i18n("Adjust View Properties...")); connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties())); // setup 'Go' menu - KStdAction::back(this, SLOT(goBack()), actionCollection()); - KStdAction::forward(this, SLOT(goForward()), actionCollection()); - KStdAction::up(this, SLOT(goUp()), actionCollection()); - KStdAction::home(this, SLOT(goHome()), actionCollection()); + KStandardAction::back(this, SLOT(goBack()), actionCollection()); + KStandardAction::forward(this, SLOT(goForward()), actionCollection()); + KStandardAction::up(this, SLOT(goUp()), actionCollection()); + KStandardAction::home(this, SLOT(goHome()), actionCollection()); // setup 'Tools' menu - KAction* openTerminal = new KAction(i18n("Open Terminal"), actionCollection(), "open_terminal"); + QAction* openTerminal = actionCollection()->addAction("open_terminal"); + openTerminal->setText(i18n("Open Terminal")); openTerminal->setShortcut(Qt::Key_F4); openTerminal->setIcon(KIcon("konsole")); connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal())); - KAction* findFile = new KAction(i18n("Find File..."), actionCollection(), "find_file"); + QAction* findFile = actionCollection()->addAction("find_file"); + findFile->setText(i18n("Find File...")); findFile->setShortcut(Qt::Key_F); findFile->setIcon(KIcon("filefind")); connect(findFile, SIGNAL(triggered()), this, SLOT(findFile())); - KToggleAction* showFilterBar = new KToggleAction(i18n("Show Filter Bar"), actionCollection(), "show_filter_bar"); + KToggleAction* showFilterBar = actionCollection()->add("show_filter_bar"); + showFilterBar->setText(i18n("Show Filter Bar")); showFilterBar->setShortcut(Qt::Key_Slash); connect(showFilterBar, SIGNAL(triggered()), this, SLOT(showFilterBar())); - KAction* compareFiles = new KAction(i18n("Compare Files"), actionCollection(), "compare_files"); + QAction* compareFiles = actionCollection()->addAction("compare_files"); + compareFiles->setText(i18n("Compare Files")); compareFiles->setIcon(KIcon("kompare")); compareFiles->setEnabled(false); connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles())); // setup 'Settings' menu - KStdAction::preferences(this, SLOT(editSettings()), actionCollection()); + KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); +} + +void DolphinMainWindow::setupDockWidgets() +{ + QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks")); + shortcutsDock->setObjectName("bookmarksDock"); + shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + shortcutsDock->setWidget(new BookmarksSidebarPage(this)); + + shortcutsDock->toggleViewAction()->setText(i18n("Show Bookmarks Panel")); + actionCollection()->addAction("show_bookmarks_panel", shortcutsDock->toggleViewAction()); + + addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock); + + QDockWidget* infoDock = new QDockWidget(i18n("Information")); + infoDock->setObjectName("infoDock"); + infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + infoDock->setWidget(new InfoSidebarPage(this)); + + infoDock->toggleViewAction()->setText(i18n("Show Information Panel")); + actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction()); + + addDockWidget(Qt::RightDockWidgetArea, infoDock); } void DolphinMainWindow::setupCreateNewMenuActions() @@ -1448,12 +1396,12 @@ void DolphinMainWindow::updateHistory() int index = 0; const Q3ValueList list = m_activeView->urlHistory(index); - KAction* backAction = actionCollection()->action("go_back"); + QAction* backAction = actionCollection()->action("go_back"); if (backAction != 0) { backAction->setEnabled(index < static_cast(list.count()) - 1); } - KAction* forwardAction = actionCollection()->action("go_forward"); + QAction* forwardAction = actionCollection()->action("go_forward"); if (forwardAction != 0) { forwardAction->setEnabled(index > 0); } @@ -1461,22 +1409,22 @@ void DolphinMainWindow::updateHistory() void DolphinMainWindow::updateEditActions() { - const KFileItemList* list = m_activeView->selectedItems(); - if ((list == 0) || (*list).isEmpty()) { + const KFileItemList list = m_activeView->selectedItems(); + if (list.isEmpty()) { stateChanged("has_no_selection"); } else { stateChanged("has_selection"); - KAction* renameAction = actionCollection()->action("rename"); + QAction* renameAction = actionCollection()->action("rename"); if (renameAction != 0) { - renameAction->setEnabled(list->count() >= 1); + renameAction->setEnabled(list.count() >= 1); } bool enableMoveToTrash = true; - KFileItemList::const_iterator it = list->begin(); - const KFileItemList::const_iterator end = list->end(); + KFileItemList::const_iterator it = list.begin(); + const KFileItemList::const_iterator end = list.end(); while (it != end) { KFileItem* item = *it; const KUrl& url = item->url(); @@ -1487,7 +1435,7 @@ void DolphinMainWindow::updateEditActions() ++it; } - KAction* moveToTrashAction = actionCollection()->action("move_to_trash"); + QAction* moveToTrashAction = actionCollection()->action("move_to_trash"); moveToTrashAction->setEnabled(enableMoveToTrash); } updatePasteAction(); @@ -1495,17 +1443,17 @@ void DolphinMainWindow::updateEditActions() void DolphinMainWindow::updateViewActions() { - KAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn)); + QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn)); if (zoomInAction != 0) { zoomInAction->setEnabled(m_activeView->isZoomInPossible()); } - KAction* zoomOutAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomOut)); + QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut)); if (zoomOutAction != 0) { zoomOutAction->setEnabled(m_activeView->isZoomOutPossible()); } - KAction* action = 0; + QAction* action = 0; switch (m_activeView->mode()) { case DolphinView::IconsView: action = actionCollection()->action("icons"); @@ -1513,9 +1461,9 @@ void DolphinMainWindow::updateViewActions() case DolphinView::DetailsView: action = actionCollection()->action("details"); break; - case DolphinView::PreviewsView: - action = actionCollection()->action("previews"); - break; + //case DolphinView::PreviewsView: + // action = actionCollection()->action("previews"); + // break; default: break; } @@ -1534,7 +1482,7 @@ void DolphinMainWindow::updateViewActions() KToggleAction* showHiddenFilesAction = static_cast(actionCollection()->action("show_hidden_files")); - showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled()); + showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles()); KToggleAction* splitAction = static_cast(actionCollection()->action("split_view")); splitAction->setChecked(m_view[SecondaryIdx] != 0); @@ -1542,59 +1490,21 @@ void DolphinMainWindow::updateViewActions() void DolphinMainWindow::updateGoActions() { - KAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up)); + QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Up)); const KUrl& currentUrl = m_activeView->url(); goUpAction->setEnabled(currentUrl.upUrl() != currentUrl); } -void DolphinMainWindow::updateViewProperties(const KUrl::List& urls) -{ - if (urls.isEmpty()) { - return; - } - - // Updating the view properties might take up to several seconds - // 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(this, - i18n("Updating view properties..."), - QString::null, - urls.count()); - - KUrl::List::ConstIterator end = urls.end(); - for(KUrl::List::ConstIterator it = urls.begin(); it != end; ++it) { - progressIndicator.execOperation(); - - ViewProperties props(*it); - props.save(); - } -} - void DolphinMainWindow::copyUrls(const KUrl::List& source, const KUrl& dest) { - KIO::Job* job = KIO::copy(source, dest); - addPendingUndoJob(job, DolphinCommand::Copy, source, dest); + KonqOperations::copy(this, KonqOperations::COPY, source, dest); + m_undoOperations.append(KonqOperations::COPY); } void DolphinMainWindow::moveUrls(const KUrl::List& source, const KUrl& dest) { - KIO::Job* job = KIO::move(source, dest); - addPendingUndoJob(job, DolphinCommand::Move, source, dest); -} - -void DolphinMainWindow::addPendingUndoJob(KIO::Job* job, - DolphinCommand::Type commandType, - const KUrl::List& source, - const KUrl& dest) -{ - connect(job, SIGNAL(result(KJob*)), - this, SLOT(addUndoOperation(KJob*))); - - UndoInfo undoInfo; - undoInfo.id = job->progressId(); - undoInfo.command = DolphinCommand(commandType, source, dest); - m_pendingUndoJobs.append(undoInfo); + KonqOperations::copy(this, KonqOperations::MOVE, source, dest); + m_undoOperations.append(KonqOperations::MOVE); } void DolphinMainWindow::clearStatusBar() @@ -1602,19 +1512,28 @@ void DolphinMainWindow::clearStatusBar() m_activeView->statusBar()->clear(); } -void DolphinMainWindow::setupDockWidgets() -{ - QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts")); - shortcutsDock->setObjectName("shortcutsDock"); - shortcutsDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); - shortcutsDock->setWidget(new BookmarksSidebarPage(this)); - addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock); +void DolphinMainWindow::connectViewSignals(int viewIndex) +{ + DolphinView* view = m_view[viewIndex]; + connect(view, SIGNAL(modeChanged()), + this, SLOT(slotViewModeChanged())); + connect(view, SIGNAL(showHiddenFilesChanged()), + this, SLOT(slotShowHiddenFilesChanged())); + connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)), + this, SLOT(slotSortingChanged(DolphinView::Sorting))); + connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)), + this, SLOT(slotSortOrderChanged(Qt::SortOrder))); + connect(view, SIGNAL(selectionChanged()), + this, SLOT(slotSelectionChanged())); + connect(view, SIGNAL(showFilterBarChanged(bool)), + this, SLOT(updateFilterBarAction(bool))); + + const UrlNavigator* navigator = view->urlNavigator(); + connect(navigator, SIGNAL(urlChanged(const KUrl&)), + this, SLOT(slotUrlChanged(const KUrl&))); + connect(navigator, SIGNAL(historyChanged()), + this, SLOT(slotHistoryChanged())); - QDockWidget *infoDock = new QDockWidget(i18n("Information")); - infoDock->setObjectName("infoDock"); - infoDock->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); - infoDock->setWidget(new InfoSidebarPage(this)); - addDockWidget(Qt::RightDockWidgetArea, infoDock); } #include "dolphinmainwindow.moc"