]>
cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
22 #include "dolphinmainwindow.h"
26 #include <kactioncollection.h>
27 #include <ktoggleaction.h>
28 #include <kbookmarkmanager.h>
30 #include <kpropertiesdialog.h>
32 #include <kiconloader.h>
33 #include <kdeversion.h>
34 #include <kstatusbar.h>
35 #include <kio/netaccess.h>
36 #include <kfiledialog.h>
40 #include <kstandardaction.h>
42 #include <kio/renamedialog.h>
43 #include <kinputdialog.h>
45 #include <kdesktopfile.h>
46 #include <kstandarddirs.h>
47 #include <kprotocolinfo.h>
48 #include <kmessagebox.h>
50 #include <kstandarddirs.h>
53 #include <konqmimedata.h>
55 #include <qclipboard.h>
56 #include <q3dragobject.h>
58 #include <Q3ValueList>
59 #include <QCloseEvent>
61 #include <QDockWidget>
63 #include "urlnavigator.h"
64 #include "viewpropertiesdialog.h"
65 #include "viewproperties.h"
66 #include "dolphinsettings.h"
67 #include "dolphinsettingsdialog.h"
68 #include "dolphinstatusbar.h"
69 #include "dolphinapplication.h"
70 #include "undomanager.h"
71 #include "progressindicator.h"
72 #include "dolphinsettings.h"
73 #include "bookmarkssidebarpage.h"
74 #include "infosidebarpage.h"
75 #include "generalsettings.h"
76 #include "dolphinapplication.h"
79 DolphinMainWindow::DolphinMainWindow() :
84 setObjectName("Dolphin");
85 m_view
[PrimaryIdx
] = 0;
86 m_view
[SecondaryIdx
] = 0;
89 DolphinMainWindow::~DolphinMainWindow()
91 qDeleteAll(m_fileGroupActions
);
92 m_fileGroupActions
.clear();
94 DolphinApplication::app()->removeMainWindow(this);
97 void DolphinMainWindow::setActiveView(DolphinView
* view
)
99 assert((view
== m_view
[PrimaryIdx
]) || (view
== m_view
[SecondaryIdx
]));
100 if (m_activeView
== view
) {
111 setCaption(m_activeView
->url().fileName());
113 emit
activeViewChanged();
116 void DolphinMainWindow::dropUrls(const KUrl::List
& urls
,
117 const KUrl
& destination
)
119 m_dropDestination
= destination
;
120 m_droppedUrls
= urls
;
123 const ButtonState keyboardState = KApplication::keyboardMouseState();
124 const bool shiftPressed = (keyboardState & ShiftButton) > 0;
125 const bool controlPressed = (keyboardState & ControlButton) > 0;
129 if (shiftPressed && controlPressed) {
130 // shortcut for 'Linke Here' is used
133 else if (controlPressed) {
134 // shortcut for 'Copy Here' is used
137 else if (shiftPressed) {
138 // shortcut for 'Move Here' is used
142 // no shortcut is used, hence open a popup menu
145 QAction
* moveAction
= popup
.addAction(SmallIcon("goto"), i18n("&Move Here"));
146 connect(moveAction
, SIGNAL(triggered()), this, SLOT(moveDroppedItems()));
148 QAction
* copyAction
= popup
.addAction(SmallIcon("editcopy"), i18n( "&Copy Here" ));
149 connect(copyAction
, SIGNAL(triggered()), this, SLOT(copyDroppedItems()));
151 QAction
* linkAction
= popup
.addAction(i18n("&Link Here"));
152 connect(linkAction
, SIGNAL(triggered()), this, SLOT(linkDroppedItems()));
154 QAction
* cancelAction
= popup
.addAction(SmallIcon("stop"), i18n("Cancel"));
155 popup
.insertSeparator(cancelAction
);
157 popup
.exec(QCursor::pos());
160 m_droppedUrls
.clear();
163 void DolphinMainWindow::refreshViews()
165 const bool split
= DolphinSettings::instance().generalSettings()->splitView();
166 const bool isPrimaryViewActive
= (m_activeView
== m_view
[PrimaryIdx
]);
168 for (int i
= PrimaryIdx
; i
<= SecondaryIdx
; ++i
) {
169 if (m_view
[i
] != 0) {
170 url
= m_view
[i
]->url();
172 // delete view instance...
174 m_view
[i
]->deleteLater();
178 if (split
|| (i
== PrimaryIdx
)) {
179 // ... and recreate it
180 ViewProperties
props(url
);
181 m_view
[i
] = new DolphinView(this,
185 props
.showHiddenFiles());
186 connectViewSignals(i
);
191 m_activeView
= isPrimaryViewActive
? m_view
[PrimaryIdx
] : m_view
[SecondaryIdx
];
192 assert(m_activeView
!= 0);
195 emit
activeViewChanged();
198 void DolphinMainWindow::slotViewModeChanged()
203 void DolphinMainWindow::slotShowHiddenFilesChanged()
205 KToggleAction
* showHiddenFilesAction
=
206 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
207 showHiddenFilesAction
->setChecked(m_activeView
->showHiddenFiles());
210 void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting
)
214 case DolphinView::SortByName
:
215 action
= actionCollection()->action("by_name");
217 case DolphinView::SortBySize
:
218 action
= actionCollection()->action("by_size");
220 case DolphinView::SortByDate
:
221 action
= actionCollection()->action("by_date");
228 KToggleAction
* toggleAction
= static_cast<KToggleAction
*>(action
);
229 toggleAction
->setChecked(true);
233 void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order
)
235 KToggleAction
* descending
= static_cast<KToggleAction
*>(actionCollection()->action("descending"));
236 const bool sortDescending
= (order
== Qt::Descending
);
237 descending
->setChecked(sortDescending
);
240 void DolphinMainWindow::slotSelectionChanged()
244 assert(m_view
[PrimaryIdx
] != 0);
245 int selectedUrlsCount
= m_view
[PrimaryIdx
]->selectedUrls().count();
246 if (m_view
[SecondaryIdx
] != 0) {
247 selectedUrlsCount
+= m_view
[SecondaryIdx
]->selectedUrls().count();
250 QAction
* compareFilesAction
= actionCollection()->action("compare_files");
251 compareFilesAction
->setEnabled(selectedUrlsCount
== 2);
253 m_activeView
->updateStatusBar();
255 emit
selectionChanged();
258 void DolphinMainWindow::slotHistoryChanged()
263 void DolphinMainWindow::slotUrlChanged(const KUrl
& url
)
267 setCaption(url
.fileName());
270 void DolphinMainWindow::updateFilterBarAction(bool show
)
272 KToggleAction
* showFilterBarAction
=
273 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
274 showFilterBarAction
->setChecked(show
);
277 void DolphinMainWindow::redo()
279 UndoManager::instance().redo(this);
282 void DolphinMainWindow::undo()
284 UndoManager::instance().undo(this);
287 void DolphinMainWindow::openNewMainWindow()
289 DolphinApplication::app()->createMainWindow()->show();
292 void DolphinMainWindow::moveDroppedItems()
294 moveUrls(m_droppedUrls
, m_dropDestination
);
297 void DolphinMainWindow::copyDroppedItems()
299 copyUrls(m_droppedUrls
, m_dropDestination
);
302 void DolphinMainWindow::linkDroppedItems()
304 KIO::Job
* job
= KIO::link(m_droppedUrls
, m_dropDestination
);
305 addPendingUndoJob(job
, DolphinCommand::Link
, m_droppedUrls
, m_dropDestination
);
308 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
311 //KConfig* config = KGlobal::config();
312 //config->setGroup("General");
313 //config->writeEntry("First Run", false);
315 DolphinSettings
& settings
= DolphinSettings::instance();
316 GeneralSettings
* generalSettings
= settings
.generalSettings();
317 generalSettings
->setFirstRun(false);
321 KMainWindow::closeEvent(event
);
324 void DolphinMainWindow::saveProperties(KConfig
* config
)
326 config
->setGroup("Primary view");
327 config
->writeEntry("Url", m_view
[PrimaryIdx
]->url().url());
328 config
->writeEntry("Editable Url", m_view
[PrimaryIdx
]->isUrlEditable());
329 if (m_view
[SecondaryIdx
] != 0) {
330 config
->setGroup("Secondary view");
331 config
->writeEntry("Url", m_view
[SecondaryIdx
]->url().url());
332 config
->writeEntry("Editable Url", m_view
[SecondaryIdx
]->isUrlEditable());
336 void DolphinMainWindow::readProperties(KConfig
* config
)
338 config
->setGroup("Primary view");
339 m_view
[PrimaryIdx
]->setUrl(config
->readEntry("Url"));
340 m_view
[PrimaryIdx
]->setUrlEditable(config
->readEntry("Editable Url", false));
341 if (config
->hasGroup("Secondary view")) {
342 config
->setGroup("Secondary view");
343 if (m_view
[SecondaryIdx
] == 0) {
346 m_view
[SecondaryIdx
]->setUrl(config
->readEntry("Url"));
347 m_view
[SecondaryIdx
]->setUrlEditable(config
->readEntry("Editable Url", false));
349 else if (m_view
[SecondaryIdx
] != 0) {
354 void DolphinMainWindow::createFolder()
356 // Parts of the following code have been taken
357 // from the class KonqPopupMenu located in
358 // libqonq/konq_popupmenu.h of Konqueror.
359 // (Copyright (C) 2000 David Faure <faure@kde.org>,
360 // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
364 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
365 const KUrl
baseUrl(m_activeView
->url());
367 QString
name(i18n("New Folder"));
368 baseUrl
.path(KUrl::AddTrailingSlash
);
371 if (baseUrl
.isLocalFile() && QFileInfo(baseUrl
.path(KUrl::AddTrailingSlash
) + name
).exists()) {
372 name
= KIO::RenameDialog::suggestName(baseUrl
, i18n("New Folder"));
376 name
= KInputDialog::getText(i18n("New Folder"),
377 i18n("Enter folder name:" ),
383 // the user has pressed 'Cancel'
387 assert(!name
.isEmpty());
390 if ((name
[0] == '/') || (name
[0] == '~')) {
391 url
.setPath(KShell::tildeExpand(name
));
394 name
= KIO::encodeFileName(name
);
398 ok
= KIO::NetAccess::mkdir(url
, this);
400 // TODO: provide message type hint
402 statusBar
->setMessage(i18n("Created folder %1.",url
.path()),
403 DolphinStatusBar::OperationCompleted
);
405 DolphinCommand
command(DolphinCommand::CreateFolder
, KUrl::List(), url
);
406 UndoManager::instance().addCommand(command
);
409 // Creating of the folder has been failed. Check whether the creating
410 // has been failed because a folder with the same name exists...
411 if (KIO::NetAccess::exists(url
, true, this)) {
412 statusBar
->setMessage(i18n("A folder named %1 already exists.",url
.path()),
413 DolphinStatusBar::Error
);
416 statusBar
->setMessage(i18n("Creating of folder %1 failed.",url
.path()),
417 DolphinStatusBar::Error
);
423 void DolphinMainWindow::createFile()
425 // Parts of the following code have been taken
426 // from the class KonqPopupMenu located in
427 // libqonq/konq_popupmenu.h of Konqueror.
428 // (Copyright (C) 2000 David Faure <faure@kde.org>,
429 // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
433 // TODO: const Entry& entry = m_createFileTemplates[QString(sender->name())];
434 // should be enough. Anyway: the implemantation of [] does a linear search internally too.
435 KSortableList
<CreateFileEntry
, QString
>::ConstIterator it
= m_createFileTemplates
.begin();
436 KSortableList
<CreateFileEntry
, QString
>::ConstIterator end
= m_createFileTemplates
.end();
438 const QString
senderName(sender()->objectName());
440 CreateFileEntry entry
;
441 while (!found
&& (it
!= end
)) {
442 if ((*it
).key() == senderName
) {
443 entry
= (*it
).value();
451 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
452 if (!found
|| !QFile::exists(entry
.templatePath
)) {
453 statusBar
->setMessage(i18n("Could not create file."), DolphinStatusBar::Error
);
457 // Get the source path of the template which should be copied.
458 // The source path is part of the Url entry of the desktop file.
459 const int pos
= entry
.templatePath
.lastIndexOf('/');
460 QString
sourcePath(entry
.templatePath
.left(pos
+ 1));
461 sourcePath
+= KDesktopFile(entry
.templatePath
, true).readPathEntry("Url");
463 QString
name(i18n(entry
.name
.toAscii()));
464 // Most entry names end with "..." (e. g. "HTML File..."), which is ok for
465 // menus but no good choice for a new file name -> remove the dots...
466 name
.replace("...", QString::null
);
468 // add the file extension to the name
469 name
.append(sourcePath
.right(sourcePath
.length() - sourcePath
.lastIndexOf('.')));
471 // Check whether a file with the current name already exists. If yes suggest automatically
472 // a unique file name (e. g. "HTML File" will be replaced by "HTML File_1").
473 const KUrl
viewUrl(m_activeView
->url());
474 const bool fileExists
= viewUrl
.isLocalFile() &&
475 QFileInfo(viewUrl
.path(KUrl::AddTrailingSlash
) + KIO::encodeFileName(name
)).exists();
477 name
= KIO::RenameDialog::suggestName(viewUrl
, name
);
480 // let the user change the suggested file name
482 name
= KInputDialog::getText(entry
.name
,
488 // the user has pressed 'Cancel'
492 // before copying the template to the destination path check whether a file
493 // with the given name already exists
494 const QString
destPath(viewUrl
.pathOrUrl() + "/" + KIO::encodeFileName(name
));
495 const KUrl
destUrl(destPath
);
496 if (KIO::NetAccess::exists(destUrl
, false, this)) {
497 statusBar
->setMessage(i18n("A file named %1 already exists.",name
),
498 DolphinStatusBar::Error
);
502 // copy the template to the destination path
503 const KUrl
sourceUrl(sourcePath
);
504 KIO::CopyJob
* job
= KIO::copyAs(sourceUrl
, destUrl
);
505 job
->setDefaultPermissions(true);
506 if (KIO::NetAccess::synchronousRun(job
, this)) {
507 statusBar
->setMessage(i18n("Created file %1.",name
),
508 DolphinStatusBar::OperationCompleted
);
511 list
.append(sourceUrl
);
512 DolphinCommand
command(DolphinCommand::CreateFile
, list
, destUrl
);
513 UndoManager::instance().addCommand(command
);
517 statusBar
->setMessage(i18n("Creating of file %1 failed.",name
),
518 DolphinStatusBar::Error
);
522 void DolphinMainWindow::rename()
525 m_activeView
->renameSelectedItems();
528 void DolphinMainWindow::moveToTrash()
531 KUrl::List selectedUrls
= m_activeView
->selectedUrls();
532 KIO::Job
* job
= KIO::trash(selectedUrls
);
533 addPendingUndoJob(job
, DolphinCommand::Trash
, selectedUrls
, m_activeView
->url());
536 void DolphinMainWindow::deleteItems()
540 KUrl::List list
= m_activeView
->selectedUrls();
541 const uint itemCount
= list
.count();
542 assert(itemCount
>= 1);
546 text
= i18n("Do you really want to delete the %1 selected items?",itemCount
);
549 const KUrl
& url
= list
.first();
550 text
= i18n("Do you really want to delete '%1'?",url
.fileName());
553 const bool del
= KMessageBox::warningContinueCancel(this,
556 KGuiItem(i18n("Delete"), KIcon("editdelete"))
557 ) == KMessageBox::Continue
;
559 KIO::Job
* job
= KIO::del(list
);
560 connect(job
, SIGNAL(result(KJob
*)),
561 this, SLOT(slotHandleJobError(KJob
*)));
562 connect(job
, SIGNAL(result(KJob
*)),
563 this, SLOT(slotDeleteFileFinished(KJob
*)));
567 void DolphinMainWindow::properties()
569 const KFileItemList list
= m_activeView
->selectedItems();
570 new KPropertiesDialog(list
, this);
573 void DolphinMainWindow::quit()
578 void DolphinMainWindow::slotHandleJobError(KJob
* job
)
580 if (job
->error() != 0) {
581 m_activeView
->statusBar()->setMessage(job
->errorString(),
582 DolphinStatusBar::Error
);
586 void DolphinMainWindow::slotDeleteFileFinished(KJob
* job
)
588 if (job
->error() == 0) {
589 m_activeView
->statusBar()->setMessage(i18n("Delete operation completed."),
590 DolphinStatusBar::OperationCompleted
);
592 // TODO: In opposite to the 'Move to Trash' operation in the class KFileIconView
593 // no rearranging of the item position is done when a file has been deleted.
594 // This is bypassed by reloading the view, but it might be worth to investigate
595 // deeper for the root of this issue.
596 m_activeView
->reload();
600 void DolphinMainWindow::slotUndoAvailable(bool available
)
602 QAction
* undoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo
));
603 if (undoAction
!= 0) {
604 undoAction
->setEnabled(available
);
608 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
610 QAction
* undoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo
));
611 if (undoAction
!= 0) {
612 undoAction
->setText(text
);
616 void DolphinMainWindow::slotRedoAvailable(bool available
)
618 QAction
* redoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Redo
));
619 if (redoAction
!= 0) {
620 redoAction
->setEnabled(available
);
624 void DolphinMainWindow::slotRedoTextChanged(const QString
& text
)
626 QAction
* redoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Redo
));
627 if (redoAction
!= 0) {
628 redoAction
->setText(text
);
632 void DolphinMainWindow::cut()
634 QMimeData
* mimeData
= new QMimeData();
635 const KUrl::List kdeUrls
= m_activeView
->selectedUrls();
636 const KUrl::List mostLocalUrls
;
637 KonqMimeData::populateMimeData(mimeData
, kdeUrls
, mostLocalUrls
, true);
638 QApplication::clipboard()->setMimeData(mimeData
);
641 void DolphinMainWindow::copy()
643 QMimeData
* mimeData
= new QMimeData();
644 const KUrl::List kdeUrls
= m_activeView
->selectedUrls();
645 const KUrl::List mostLocalUrls
;
646 KonqMimeData::populateMimeData(mimeData
, kdeUrls
, mostLocalUrls
, false);
648 QApplication::clipboard()->setMimeData(mimeData
);
651 void DolphinMainWindow::paste()
653 QClipboard
* clipboard
= QApplication::clipboard();
654 const QMimeData
* mimeData
= clipboard
->mimeData();
658 const KUrl::List sourceUrls
= KUrl::List::fromMimeData(mimeData
);
660 // per default the pasting is done into the current Url of the view
661 KUrl
destUrl(m_activeView
->url());
663 // check whether the pasting should be done into a selected directory
664 KUrl::List selectedUrls
= m_activeView
->selectedUrls();
665 if (selectedUrls
.count() == 1) {
666 const KFileItem
fileItem(S_IFDIR
,
668 selectedUrls
.first(),
670 if (fileItem
.isDir()) {
671 // only one item is selected which is a directory, hence paste
672 // into this directory
673 destUrl
= selectedUrls
.first();
677 if (KonqMimeData::decodeIsCutSelection(mimeData
)) {
678 moveUrls(sourceUrls
, destUrl
);
682 copyUrls(sourceUrls
, destUrl
);
686 void DolphinMainWindow::updatePasteAction()
688 QAction
* pasteAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste
));
689 if (pasteAction
== 0) {
693 QString
text(i18n("Paste"));
694 QClipboard
* clipboard
= QApplication::clipboard();
695 const QMimeData
* mimeData
= clipboard
->mimeData();
697 KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
698 if (!urls
.isEmpty()) {
699 pasteAction
->setEnabled(true);
701 const int count
= urls
.count();
703 pasteAction
->setText(i18n("Paste 1 File"));
706 pasteAction
->setText(i18n("Paste %1 Files").arg(count
));
710 pasteAction
->setEnabled(false);
711 pasteAction
->setText(i18n("Paste"));
714 if (pasteAction
->isEnabled()) {
715 KUrl::List urls
= m_activeView
->selectedUrls();
716 const uint count
= urls
.count();
718 // pasting should not be allowed when more than one file
720 pasteAction
->setEnabled(false);
722 else if (count
== 1) {
723 // Only one file is selected. Pasting is only allowed if this
724 // file is a directory.
725 // TODO: this doesn't work with remote protocols; instead we need a
726 // m_activeView->selectedFileItems() to get the real KFileItems
727 const KFileItem
fileItem(S_IFDIR
,
731 pasteAction
->setEnabled(fileItem
.isDir());
736 void DolphinMainWindow::selectAll()
739 m_activeView
->selectAll();
742 void DolphinMainWindow::invertSelection()
745 m_activeView
->invertSelection();
747 void DolphinMainWindow::setIconsView()
749 m_activeView
->setMode(DolphinView::IconsView
);
752 void DolphinMainWindow::setDetailsView()
754 m_activeView
->setMode(DolphinView::DetailsView
);
757 void DolphinMainWindow::sortByName()
759 m_activeView
->setSorting(DolphinView::SortByName
);
762 void DolphinMainWindow::sortBySize()
764 m_activeView
->setSorting(DolphinView::SortBySize
);
767 void DolphinMainWindow::sortByDate()
769 m_activeView
->setSorting(DolphinView::SortByDate
);
772 void DolphinMainWindow::toggleSortOrder()
774 const Qt::SortOrder order
= (m_activeView
->sortOrder() == Qt::Ascending
) ?
777 m_activeView
->setSortOrder(order
);
780 void DolphinMainWindow::toggleSplitView()
782 if (m_view
[SecondaryIdx
] == 0) {
783 const int newWidth
= (m_view
[PrimaryIdx
]->width() - m_splitter
->handleWidth()) / 2;
784 // create a secondary view
785 m_view
[SecondaryIdx
] = new DolphinView(this,
787 m_view
[PrimaryIdx
]->url(),
788 m_view
[PrimaryIdx
]->mode(),
789 m_view
[PrimaryIdx
]->showHiddenFiles());
790 connectViewSignals(SecondaryIdx
);
791 m_splitter
->addWidget(m_view
[SecondaryIdx
]);
792 m_splitter
->setSizes(QList
<int>() << newWidth
<< newWidth
);
793 m_view
[SecondaryIdx
]->show();
796 // remove secondary view
797 if (m_activeView
== m_view
[PrimaryIdx
]) {
798 m_view
[SecondaryIdx
]->close();
799 m_view
[SecondaryIdx
]->deleteLater();
800 m_view
[SecondaryIdx
] = 0;
801 setActiveView(m_view
[PrimaryIdx
]);
804 // The secondary view is active, hence from the users point of view
805 // the content of the secondary view should be moved to the primary view.
806 // From an implementation point of view it is more efficient to close
807 // the primary view and exchange the internal pointers afterwards.
808 m_view
[PrimaryIdx
]->close();
809 delete m_view
[PrimaryIdx
];
810 m_view
[PrimaryIdx
] = m_view
[SecondaryIdx
];
811 m_view
[SecondaryIdx
] = 0;
812 setActiveView(m_view
[PrimaryIdx
]);
817 void DolphinMainWindow::reloadView()
820 m_activeView
->reload();
823 void DolphinMainWindow::stopLoading()
827 void DolphinMainWindow::togglePreview()
831 const KToggleAction
* showPreviewAction
=
832 static_cast<KToggleAction
*>(actionCollection()->action("show_preview"));
833 const bool show
= showPreviewAction
->isChecked();
834 m_activeView
->setShowPreview(show
);
837 void DolphinMainWindow::toggleShowHiddenFiles()
841 const KToggleAction
* showHiddenFilesAction
=
842 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
843 const bool show
= showHiddenFilesAction
->isChecked();
844 m_activeView
->setShowHiddenFiles(show
);
847 void DolphinMainWindow::showFilterBar()
849 const KToggleAction
* showFilterBarAction
=
850 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
851 const bool show
= showFilterBarAction
->isChecked();
852 m_activeView
->slotShowFilterBar(show
);
855 void DolphinMainWindow::zoomIn()
857 m_activeView
->zoomIn();
861 void DolphinMainWindow::zoomOut()
863 m_activeView
->zoomOut();
867 void DolphinMainWindow::toggleEditLocation()
871 KToggleAction
* action
= static_cast<KToggleAction
*>(actionCollection()->action("editable_location"));
873 bool editOrBrowse
= action
->isChecked();
874 // action->setChecked(action->setChecked);
875 m_activeView
->setUrlEditable(editOrBrowse
);
878 void DolphinMainWindow::editLocation()
880 KToggleAction
* action
= static_cast<KToggleAction
*>(actionCollection()->action("editable_location"));
881 action
->setChecked(true);
882 m_activeView
->setUrlEditable(true);
885 void DolphinMainWindow::adjustViewProperties()
888 ViewPropertiesDialog
dlg(m_activeView
);
892 void DolphinMainWindow::goBack()
895 m_activeView
->goBack();
898 void DolphinMainWindow::goForward()
901 m_activeView
->goForward();
904 void DolphinMainWindow::goUp()
907 m_activeView
->goUp();
910 void DolphinMainWindow::goHome()
913 m_activeView
->goHome();
916 void DolphinMainWindow::openTerminal()
918 QString
command("konsole --workdir \"");
919 command
.append(m_activeView
->url().path());
920 command
.append('\"');
922 KRun::runCommand(command
, "Konsole", "konsole");
925 void DolphinMainWindow::findFile()
927 KRun::run("kfind", m_activeView
->url());
930 void DolphinMainWindow::compareFiles()
932 // The method is only invoked if exactly 2 files have
933 // been selected. The selected files may be:
934 // - both in the primary view
935 // - both in the secondary view
936 // - one in the primary view and the other in the secondary
938 assert(m_view
[PrimaryIdx
] != 0);
942 KUrl::List urls
= m_view
[PrimaryIdx
]->selectedUrls();
944 switch (urls
.count()) {
946 assert(m_view
[SecondaryIdx
] != 0);
947 urls
= m_view
[SecondaryIdx
]->selectedUrls();
948 assert(urls
.count() == 2);
956 assert(m_view
[SecondaryIdx
] != 0);
957 urls
= m_view
[SecondaryIdx
]->selectedUrls();
958 assert(urls
.count() == 1);
970 // may not happen: compareFiles may only get invoked if 2
971 // files are selected
976 QString
command("kompare -c \"");
977 command
.append(urlA
.pathOrUrl());
978 command
.append("\" \"");
979 command
.append(urlB
.pathOrUrl());
980 command
.append('\"');
981 KRun::runCommand(command
, "Kompare", "kompare");
985 void DolphinMainWindow::editSettings()
987 // TODO: make a static method for opening the settings dialog
988 DolphinSettingsDialog
dlg(this);
992 void DolphinMainWindow::addUndoOperation(KJob
* job
)
994 if (job
->error() != 0) {
995 slotHandleJobError(job
);
998 const int id
= job
->progressId();
1000 // set iterator to the executed command with the current id...
1001 Q3ValueList
<UndoInfo
>::Iterator it
= m_pendingUndoJobs
.begin();
1002 const Q3ValueList
<UndoInfo
>::Iterator end
= m_pendingUndoJobs
.end();
1004 while (!found
&& (it
!= end
)) {
1005 if ((*it
).id
== id
) {
1014 DolphinCommand command
= (*it
).command
;
1015 if (command
.type() == DolphinCommand::Trash
) {
1016 // To be able to perform an undo for the 'Move to Trash' operation
1017 // all source Urls must be updated with the trash Url. E. g. when moving
1018 // a file "test.txt" and a second file "test.txt" to the trash,
1019 // then the filenames in the trash are "0-test.txt" and "1-test.txt".
1020 QMap
<QString
, QString
> metaData
;
1021 KIO::Job
*kiojob
= qobject_cast
<KIO::Job
*>( job
);
1024 metaData
= kiojob
->metaData();
1026 KUrl::List newSourceUrls
;
1028 KUrl::List sourceUrls
= command
.source();
1029 KUrl::List::Iterator sourceIt
= sourceUrls
.begin();
1030 const KUrl::List::Iterator sourceEnd
= sourceUrls
.end();
1032 while (sourceIt
!= sourceEnd
) {
1033 QMap
<QString
, QString
>::ConstIterator metaIt
= metaData
.find("trashUrl-" + (*sourceIt
).path());
1034 if (metaIt
!= metaData
.end()) {
1035 newSourceUrls
.append(KUrl(metaIt
.value()));
1039 command
.setSource(newSourceUrls
);
1042 UndoManager::instance().addCommand(command
);
1043 m_pendingUndoJobs
.erase(it
);
1045 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
1046 switch (command
.type()) {
1047 case DolphinCommand::Copy
:
1048 statusBar
->setMessage(i18n("Copy operation completed."),
1049 DolphinStatusBar::OperationCompleted
);
1051 case DolphinCommand::Move
:
1052 statusBar
->setMessage(i18n("Move operation completed."),
1053 DolphinStatusBar::OperationCompleted
);
1055 case DolphinCommand::Trash
:
1056 statusBar
->setMessage(i18n("Move to trash operation completed."),
1057 DolphinStatusBar::OperationCompleted
);
1066 void DolphinMainWindow::init()
1068 // Check whether Dolphin runs the first time. If yes then
1069 // a proper default window size is given at the end of DolphinMainWindow::init().
1070 GeneralSettings
* generalSettings
= DolphinSettings::instance().generalSettings();
1071 const bool firstRun
= generalSettings
->firstRun();
1073 setAcceptDrops(true);
1075 m_splitter
= new QSplitter(this);
1077 DolphinSettings
& settings
= DolphinSettings::instance();
1079 KBookmarkManager
* manager
= settings
.bookmarkManager();
1080 assert(manager
!= 0);
1081 KBookmarkGroup root
= manager
->root();
1082 if (root
.first().isNull()) {
1083 root
.addBookmark(manager
, i18n("Home"), settings
.generalSettings()->homeUrl(), "folder_home");
1084 root
.addBookmark(manager
, i18n("Storage Media"), KUrl("media:/"), "blockdevice");
1085 root
.addBookmark(manager
, i18n("Network"), KUrl("remote:/"), "network_local");
1086 root
.addBookmark(manager
, i18n("Root"), KUrl("/"), "folder_red");
1087 root
.addBookmark(manager
, i18n("Trash"), KUrl("trash:/"), "trashcan_full");
1092 const KUrl
& homeUrl
= root
.first().url();
1093 setCaption(homeUrl
.fileName());
1094 ViewProperties
props(homeUrl
);
1095 m_view
[PrimaryIdx
] = new DolphinView(this,
1099 props
.showHiddenFiles());
1100 connectViewSignals(PrimaryIdx
);
1101 m_view
[PrimaryIdx
]->show();
1103 m_activeView
= m_view
[PrimaryIdx
];
1105 setCentralWidget(m_splitter
);
1108 setupGUI(Keys
|Save
|Create
|ToolBar
);
1111 stateChanged("new_file");
1112 setAutoSaveSettings();
1114 QClipboard
* clipboard
= QApplication::clipboard();
1115 connect(clipboard
, SIGNAL(dataChanged()),
1116 this, SLOT(updatePasteAction()));
1117 updatePasteAction();
1120 setupCreateNewMenuActions();
1125 // assure a proper default size if Dolphin runs the first time
1130 void DolphinMainWindow::loadSettings()
1132 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
1134 KToggleAction
* splitAction
= static_cast<KToggleAction
*>(actionCollection()->action("split_view"));
1135 if (settings
->splitView()) {
1136 splitAction
->setChecked(true);
1140 updateViewActions();
1143 void DolphinMainWindow::setupActions()
1145 // setup 'File' menu
1146 KAction
*action
= new KAction(KIcon("window_new"), i18n( "New &Window" ), actionCollection(), "new_window" );
1147 connect(action
, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
1149 KAction
* createFolder
= new KAction(i18n("Folder..."), actionCollection(), "create_folder");
1150 createFolder
->setIcon(KIcon("folder"));
1151 createFolder
->setShortcut(Qt::Key_N
);
1152 connect(createFolder
, SIGNAL(triggered()), this, SLOT(createFolder()));
1154 KAction
* rename
= new KAction(i18n("Rename"), actionCollection(), "rename");
1155 rename
->setShortcut(Qt::Key_F2
);
1156 connect(rename
, SIGNAL(triggered()), this, SLOT(rename()));
1158 KAction
* moveToTrash
= new KAction(i18n("Move to Trash"), actionCollection(), "move_to_trash");
1159 moveToTrash
->setIcon(KIcon("edittrash"));
1160 moveToTrash
->setShortcut(QKeySequence::Delete
);
1161 connect(moveToTrash
, SIGNAL(triggered()), this, SLOT(moveToTrash()));
1163 KAction
* deleteAction
= new KAction(i18n("Delete"), actionCollection(), "delete");
1164 deleteAction
->setShortcut(Qt::ALT
| Qt::Key_Delete
);
1165 deleteAction
->setIcon(KIcon("editdelete"));
1166 connect(deleteAction
, SIGNAL(triggered()), this, SLOT(deleteItems()));
1168 KAction
* properties
= new KAction(i18n("Propert&ies"), actionCollection(), "properties");
1169 properties
->setShortcut(Qt::Key_Alt
| Qt::Key_Return
);
1170 connect(properties
, SIGNAL(triggered()), this, SLOT(properties()));
1172 KStandardAction::quit(this, SLOT(quit()), actionCollection());
1174 // setup 'Edit' menu
1175 UndoManager
& undoManager
= UndoManager::instance();
1176 KStandardAction::undo(this,
1178 actionCollection());
1179 connect(&undoManager
, SIGNAL(undoAvailable(bool)),
1180 this, SLOT(slotUndoAvailable(bool)));
1181 connect(&undoManager
, SIGNAL(undoTextChanged(const QString
&)),
1182 this, SLOT(slotUndoTextChanged(const QString
&)));
1184 KStandardAction::redo(this,
1186 actionCollection());
1187 connect(&undoManager
, SIGNAL(redoAvailable(bool)),
1188 this, SLOT(slotRedoAvailable(bool)));
1189 connect(&undoManager
, SIGNAL(redoTextChanged(const QString
&)),
1190 this, SLOT(slotRedoTextChanged(const QString
&)));
1192 KStandardAction::cut(this, SLOT(cut()), actionCollection());
1193 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1194 KStandardAction::paste(this, SLOT(paste()), actionCollection());
1196 KAction
* selectAll
= new KAction(i18n("Select All"), actionCollection(), "select_all");
1197 selectAll
->setShortcut(Qt::CTRL
+ Qt::Key_A
);
1198 connect(selectAll
, SIGNAL(triggered()), this, SLOT(selectAll()));
1200 KAction
* invertSelection
= new KAction(i18n("Invert Selection"), actionCollection(), "invert_selection");
1201 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1202 connect(invertSelection
, SIGNAL(triggered()), this, SLOT(invertSelection()));
1204 // setup 'View' menu
1205 KStandardAction::zoomIn(this,
1207 actionCollection());
1209 KStandardAction::zoomOut(this,
1211 actionCollection());
1213 KToggleAction
* iconsView
= new KToggleAction(i18n("Icons"), actionCollection(), "icons");
1214 iconsView
->setShortcut(Qt::CTRL
| Qt::Key_1
);
1215 iconsView
->setIcon(KIcon("view_icon"));
1216 connect(iconsView
, SIGNAL(triggered()), this, SLOT(setIconsView()));
1218 KToggleAction
* detailsView
= new KToggleAction(i18n("Details"), actionCollection(), "details");
1219 detailsView
->setShortcut(Qt::CTRL
| Qt::Key_2
);
1220 detailsView
->setIcon(KIcon("view_text"));
1221 connect(detailsView
, SIGNAL(triggered()), this, SLOT(setDetailsView()));
1223 QActionGroup
* viewModeGroup
= new QActionGroup(this);
1224 viewModeGroup
->addAction(iconsView
);
1225 viewModeGroup
->addAction(detailsView
);
1227 KToggleAction
* sortByName
= new KToggleAction(i18n("By Name"), actionCollection(), "by_name");
1228 connect(sortByName
, SIGNAL(triggered()), this, SLOT(sortByName()));
1230 KToggleAction
* sortBySize
= new KToggleAction(i18n("By Size"), actionCollection(), "by_size");
1231 connect(sortBySize
, SIGNAL(triggered()), this, SLOT(sortBySize()));
1233 KToggleAction
* sortByDate
= new KToggleAction(i18n("By Date"), actionCollection(), "by_date");
1234 connect(sortByDate
, SIGNAL(triggered()), this, SLOT(sortByDate()));
1236 QActionGroup
* sortGroup
= new QActionGroup(this);
1237 sortGroup
->addAction(sortByName
);
1238 sortGroup
->addAction(sortBySize
);
1239 sortGroup
->addAction(sortByDate
);
1241 KToggleAction
* sortDescending
= new KToggleAction(i18n("Descending"), actionCollection(), "descending");
1242 connect(sortDescending
, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
1244 KToggleAction
* showPreview
= new KToggleAction(i18n("Show Preview"), actionCollection(), "show_preview");
1245 connect(showPreview
, SIGNAL(triggered()), this, SLOT(togglePreview()));
1247 KToggleAction
* showHiddenFiles
= new KToggleAction(i18n("Show Hidden Files"), actionCollection(), "show_hidden_files");
1248 //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'?
1249 connect(showHiddenFiles
, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
1251 KToggleAction
* split
= new KToggleAction(i18n("Split View"), actionCollection(), "split_view");
1252 split
->setShortcut(Qt::Key_F10
);
1253 split
->setIcon(KIcon("view_left_right"));
1254 connect(split
, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1256 KAction
* reload
= new KAction(actionCollection(), "reload");
1257 reload
->setText(i18n("Reload"));
1258 reload
->setShortcut(Qt::Key_F5
);
1259 reload
->setIcon(KIcon("reload"));
1260 connect(reload
, SIGNAL(triggered()), this, SLOT(reloadView()));
1262 KAction
* stop
= new KAction(i18n("Stop"), actionCollection(), "stop");
1263 stop
->setIcon(KIcon("stop"));
1264 connect(stop
, SIGNAL(triggered()), this, SLOT(stopLoading()));
1266 KToggleAction
* showFullLocation
= new KToggleAction(i18n("Show Full Location"), actionCollection(), "editable_location");
1267 showFullLocation
->setShortcut(Qt::CTRL
| Qt::Key_L
);
1268 connect(showFullLocation
, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1270 KToggleAction
* editLocation
= new KToggleAction(i18n("Edit Location"), actionCollection(), "edit_location");
1271 editLocation
->setShortcut(Qt::Key_F6
);
1272 connect(editLocation
, SIGNAL(triggered()), this, SLOT(editLocation()));
1274 KAction
* adjustViewProps
= new KAction(i18n("Adjust View Properties..."), actionCollection(), "view_properties");
1275 connect(adjustViewProps
, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
1278 KStandardAction::back(this, SLOT(goBack()), actionCollection());
1279 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1280 KStandardAction::up(this, SLOT(goUp()), actionCollection());
1281 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1283 // setup 'Tools' menu
1284 KAction
* openTerminal
= new KAction(i18n("Open Terminal"), actionCollection(), "open_terminal");
1285 openTerminal
->setShortcut(Qt::Key_F4
);
1286 openTerminal
->setIcon(KIcon("konsole"));
1287 connect(openTerminal
, SIGNAL(triggered()), this, SLOT(openTerminal()));
1289 KAction
* findFile
= new KAction(i18n("Find File..."), actionCollection(), "find_file");
1290 findFile
->setShortcut(Qt::Key_F
);
1291 findFile
->setIcon(KIcon("filefind"));
1292 connect(findFile
, SIGNAL(triggered()), this, SLOT(findFile()));
1294 KToggleAction
* showFilterBar
= new KToggleAction(i18n("Show Filter Bar"), actionCollection(), "show_filter_bar");
1295 showFilterBar
->setShortcut(Qt::Key_Slash
);
1296 connect(showFilterBar
, SIGNAL(triggered()), this, SLOT(showFilterBar()));
1298 KAction
* compareFiles
= new KAction(i18n("Compare Files"), actionCollection(), "compare_files");
1299 compareFiles
->setIcon(KIcon("kompare"));
1300 compareFiles
->setEnabled(false);
1301 connect(compareFiles
, SIGNAL(triggered()), this, SLOT(compareFiles()));
1303 // setup 'Settings' menu
1304 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1307 void DolphinMainWindow::setupDockWidgets()
1309 QDockWidget
*shortcutsDock
= new QDockWidget(i18n("Shortcuts"));
1311 shortcutsDock
->setObjectName("shortcutsDock");
1312 shortcutsDock
->setWidget(new BookmarksSidebarPage(this));
1314 shortcutsDock
->toggleViewAction()->setObjectName("show_shortcuts_pane");
1315 shortcutsDock
->toggleViewAction()->setText(i18n("Show Shortcuts Panel"));
1316 actionCollection()->insert(shortcutsDock
->toggleViewAction());
1318 addDockWidget(Qt::LeftDockWidgetArea
, shortcutsDock
);
1320 QDockWidget
*infoDock
= new QDockWidget(i18n("Information"));
1322 infoDock
->setObjectName("infoDock");
1323 infoDock
->setWidget(new InfoSidebarPage(this));
1325 infoDock
->toggleViewAction()->setObjectName("show_info_pane");
1326 infoDock
->toggleViewAction()->setText(i18n("Show Information Panel"));
1327 actionCollection()->insert(infoDock
->toggleViewAction());
1329 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1332 void DolphinMainWindow::setupCreateNewMenuActions()
1334 // Parts of the following code have been taken
1335 // from the class KNewMenu located in
1336 // libqonq/knewmenu.h of Konqueror.
1337 // Copyright (C) 1998, 1999 David Faure <faure@kde.org>
1338 // 2003 Sven Leiber <s.leiber@web.de>
1340 QStringList files
= actionCollection()->instance()->dirs()->findAllResources("templates");
1341 for (QStringList::Iterator it
= files
.begin() ; it
!= files
.end(); ++it
) {
1342 if ((*it
)[0] != '.' ) {
1343 KSimpleConfig
config(*it
, true);
1344 config
.setDesktopGroup();
1346 // tricky solution to ensure that TextFile is at the beginning
1347 // because this filetype is the most used (according kde-core discussion)
1348 const QString
name(config
.readEntry("Name"));
1351 const QString
path(config
.readPathEntry("Url"));
1352 if (!path
.endsWith("emptydir")) {
1353 if (path
.endsWith("TextFile.txt")) {
1356 else if (!KDesktopFile::isDesktopFile(path
)) {
1359 else if (path
.endsWith("Url.desktop")){
1362 else if (path
.endsWith("Program.desktop")){
1369 const QString
icon(config
.readEntry("Icon"));
1370 const QString
comment(config
.readEntry("Comment"));
1371 const QString
type(config
.readEntry("Type"));
1373 const QString
filePath(*it
);
1376 if (type
== "Link") {
1377 CreateFileEntry entry
;
1380 entry
.comment
= comment
;
1381 entry
.templatePath
= filePath
;
1382 m_createFileTemplates
.insert(key
, entry
);
1387 m_createFileTemplates
.sort();
1389 unplugActionList("create_actions");
1390 KSortableList
<CreateFileEntry
, QString
>::ConstIterator it
= m_createFileTemplates
.begin();
1391 KSortableList
<CreateFileEntry
, QString
>::ConstIterator end
= m_createFileTemplates
.end();
1392 /* KDE4-TODO: don't port this code; use KNewMenu instead
1394 CreateFileEntry entry = (*it).value();
1395 KAction* action = new KAction(entry.name);
1396 action->setIcon(entry.icon);
1397 action->setName((*it).index());
1398 connect(action, SIGNAL(activated()),
1399 this, SLOT(createFile()));
1401 const QChar section = ((*it).index()[0]);
1405 m_fileGroupActions.append(action);
1411 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
1412 // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
1413 //m_linkGroupActions.append(action);
1418 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
1419 // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
1420 //m_linkToDeviceActions.append(action);
1429 plugActionList("create_file_group", m_fileGroupActions);
1430 //plugActionList("create_link_group", m_linkGroupActions);
1431 //plugActionList("link_to_device", m_linkToDeviceActions);*/
1434 void DolphinMainWindow::updateHistory()
1437 const Q3ValueList
<UrlNavigator::HistoryElem
> list
= m_activeView
->urlHistory(index
);
1439 QAction
* backAction
= actionCollection()->action("go_back");
1440 if (backAction
!= 0) {
1441 backAction
->setEnabled(index
< static_cast<int>(list
.count()) - 1);
1444 QAction
* forwardAction
= actionCollection()->action("go_forward");
1445 if (forwardAction
!= 0) {
1446 forwardAction
->setEnabled(index
> 0);
1450 void DolphinMainWindow::updateEditActions()
1452 const KFileItemList list
= m_activeView
->selectedItems();
1453 if (list
.isEmpty()) {
1454 stateChanged("has_no_selection");
1457 stateChanged("has_selection");
1459 QAction
* renameAction
= actionCollection()->action("rename");
1460 if (renameAction
!= 0) {
1461 renameAction
->setEnabled(list
.count() >= 1);
1464 bool enableMoveToTrash
= true;
1466 KFileItemList::const_iterator it
= list
.begin();
1467 const KFileItemList::const_iterator end
= list
.end();
1469 KFileItem
* item
= *it
;
1470 const KUrl
& url
= item
->url();
1471 // only enable the 'Move to Trash' action for local files
1472 if (!url
.isLocalFile()) {
1473 enableMoveToTrash
= false;
1478 QAction
* moveToTrashAction
= actionCollection()->action("move_to_trash");
1479 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1481 updatePasteAction();
1484 void DolphinMainWindow::updateViewActions()
1486 QAction
* zoomInAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn
));
1487 if (zoomInAction
!= 0) {
1488 zoomInAction
->setEnabled(m_activeView
->isZoomInPossible());
1491 QAction
* zoomOutAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut
));
1492 if (zoomOutAction
!= 0) {
1493 zoomOutAction
->setEnabled(m_activeView
->isZoomOutPossible());
1496 QAction
* action
= 0;
1497 switch (m_activeView
->mode()) {
1498 case DolphinView::IconsView
:
1499 action
= actionCollection()->action("icons");
1501 case DolphinView::DetailsView
:
1502 action
= actionCollection()->action("details");
1504 //case DolphinView::PreviewsView:
1505 // action = actionCollection()->action("previews");
1512 KToggleAction
* toggleAction
= static_cast<KToggleAction
*>(action
);
1513 toggleAction
->setChecked(true);
1516 slotSortingChanged(m_activeView
->sorting());
1517 slotSortOrderChanged(m_activeView
->sortOrder());
1519 KToggleAction
* showFilterBarAction
=
1520 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
1521 showFilterBarAction
->setChecked(m_activeView
->isFilterBarVisible());
1523 KToggleAction
* showHiddenFilesAction
=
1524 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
1525 showHiddenFilesAction
->setChecked(m_activeView
->showHiddenFiles());
1527 KToggleAction
* splitAction
= static_cast<KToggleAction
*>(actionCollection()->action("split_view"));
1528 splitAction
->setChecked(m_view
[SecondaryIdx
] != 0);
1531 void DolphinMainWindow::updateGoActions()
1533 QAction
* goUpAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Up
));
1534 const KUrl
& currentUrl
= m_activeView
->url();
1535 goUpAction
->setEnabled(currentUrl
.upUrl() != currentUrl
);
1538 void DolphinMainWindow::copyUrls(const KUrl::List
& source
, const KUrl
& dest
)
1540 KIO::Job
* job
= KIO::copy(source
, dest
);
1541 addPendingUndoJob(job
, DolphinCommand::Copy
, source
, dest
);
1544 void DolphinMainWindow::moveUrls(const KUrl::List
& source
, const KUrl
& dest
)
1546 KIO::Job
* job
= KIO::move(source
, dest
);
1547 addPendingUndoJob(job
, DolphinCommand::Move
, source
, dest
);
1550 void DolphinMainWindow::addPendingUndoJob(KIO::Job
* job
,
1551 DolphinCommand::Type commandType
,
1552 const KUrl::List
& source
,
1555 connect(job
, SIGNAL(result(KJob
*)),
1556 this, SLOT(addUndoOperation(KJob
*)));
1559 undoInfo
.id
= job
->progressId();
1560 undoInfo
.command
= DolphinCommand(commandType
, source
, dest
);
1561 m_pendingUndoJobs
.append(undoInfo
);
1564 void DolphinMainWindow::clearStatusBar()
1566 m_activeView
->statusBar()->clear();
1569 void DolphinMainWindow::connectViewSignals(int viewIndex
)
1571 DolphinView
* view
= m_view
[viewIndex
];
1572 connect(view
, SIGNAL(modeChanged()),
1573 this, SLOT(slotViewModeChanged()));
1574 connect(view
, SIGNAL(showHiddenFilesChanged()),
1575 this, SLOT(slotShowHiddenFilesChanged()));
1576 connect(view
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
1577 this, SLOT(slotSortingChanged(DolphinView::Sorting
)));
1578 connect(view
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
1579 this, SLOT(slotSortOrderChanged(Qt::SortOrder
)));
1580 connect(view
, SIGNAL(selectionChanged()),
1581 this, SLOT(slotSelectionChanged()));
1582 connect(view
, SIGNAL(showFilterBarChanged(bool)),
1583 this, SLOT(updateFilterBarAction(bool)));
1585 const UrlNavigator
* navigator
= view
->urlNavigator();
1586 connect(navigator
, SIGNAL(urlChanged(const KUrl
&)),
1587 this, SLOT(slotUrlChanged(const KUrl
&)));
1588 connect(navigator
, SIGNAL(historyChanged()),
1589 this, SLOT(slotHistoryChanged()));
1593 #include "dolphinmainwindow.moc"