]>
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 "dolphinapplication.h"
27 #include "dolphinsettings.h"
28 #include "dolphinsettingsdialog.h"
29 #include "dolphinstatusbar.h"
30 #include "dolphinapplication.h"
31 #include "urlnavigator.h"
32 #include "dolphinsettings.h"
33 #include "bookmarkssidebarpage.h"
34 #include "infosidebarpage.h"
35 #include "generalsettings.h"
36 #include "viewpropertiesdialog.h"
37 #include "viewproperties.h"
40 #include <kactioncollection.h>
41 #include <kbookmarkmanager.h>
43 #include <kdesktopfile.h>
44 #include <kdeversion.h>
45 #include <kfiledialog.h>
48 #include <kiconloader.h>
49 #include <kio/netaccess.h>
50 #include <kio/renamedialog.h>
51 #include <kinputdialog.h>
54 #include <kmessagebox.h>
55 #include <konqmimedata.h>
56 #include <konq_undo.h>
57 #include <kpropertiesdialog.h>
58 #include <kprotocolinfo.h>
59 #include <ktoggleaction.h>
62 #include <kstandarddirs.h>
63 #include <kstatusbar.h>
64 #include <kstandardaction.h>
67 #include <Q3ValueList> // TODO
68 #include <QCloseEvent>
71 #include <QDockWidget>
73 DolphinMainWindow::DolphinMainWindow() :
78 setObjectName("Dolphin");
79 m_view
[PrimaryIdx
] = 0;
80 m_view
[SecondaryIdx
] = 0;
82 KonqUndoManager::incRef();
84 connect(KonqUndoManager::self(), SIGNAL(undoAvailable(bool)),
85 this, SLOT(slotUndoAvailable(bool)));
86 connect(KonqUndoManager::self(), SIGNAL(undoTextChanged(const QString
&)),
87 this, SLOT(slotUndoTextChanged(const QString
&)));
90 DolphinMainWindow::~DolphinMainWindow()
92 KonqUndoManager::decRef();
94 qDeleteAll(m_fileGroupActions
);
95 m_fileGroupActions
.clear();
97 DolphinApplication::app()->removeMainWindow(this);
100 void DolphinMainWindow::setActiveView(DolphinView
* view
)
102 assert((view
== m_view
[PrimaryIdx
]) || (view
== m_view
[SecondaryIdx
]));
103 if (m_activeView
== view
) {
114 setCaption(m_activeView
->url().fileName());
116 emit
activeViewChanged();
119 void DolphinMainWindow::dropUrls(const KUrl::List
& urls
,
120 const KUrl
& destination
)
122 m_dropDestination
= destination
;
123 m_droppedUrls
= urls
;
126 const ButtonState keyboardState = KApplication::keyboardMouseState();
127 const bool shiftPressed = (keyboardState & ShiftButton) > 0;
128 const bool controlPressed = (keyboardState & ControlButton) > 0;
132 if (shiftPressed && controlPressed) {
133 // shortcut for 'Linke Here' is used
136 else if (controlPressed) {
137 // shortcut for 'Copy Here' is used
140 else if (shiftPressed) {
141 // shortcut for 'Move Here' is used
145 // no shortcut is used, hence open a popup menu
148 QAction
* moveAction
= popup
.addAction(SmallIcon("goto"), i18n("&Move Here"));
149 connect(moveAction
, SIGNAL(triggered()), this, SLOT(moveDroppedItems()));
151 QAction
* copyAction
= popup
.addAction(SmallIcon("editcopy"), i18n( "&Copy Here" ));
152 connect(copyAction
, SIGNAL(triggered()), this, SLOT(copyDroppedItems()));
154 QAction
* linkAction
= popup
.addAction(i18n("&Link Here"));
155 connect(linkAction
, SIGNAL(triggered()), this, SLOT(linkDroppedItems()));
157 QAction
* cancelAction
= popup
.addAction(SmallIcon("stop"), i18n("Cancel"));
158 popup
.insertSeparator(cancelAction
);
160 popup
.exec(QCursor::pos());
163 m_droppedUrls
.clear();
166 void DolphinMainWindow::refreshViews()
168 const bool split
= DolphinSettings::instance().generalSettings()->splitView();
169 const bool isPrimaryViewActive
= (m_activeView
== m_view
[PrimaryIdx
]);
171 for (int i
= PrimaryIdx
; i
<= SecondaryIdx
; ++i
) {
172 if (m_view
[i
] != 0) {
173 url
= m_view
[i
]->url();
175 // delete view instance...
177 m_view
[i
]->deleteLater();
181 if (split
|| (i
== PrimaryIdx
)) {
182 // ... and recreate it
183 ViewProperties
props(url
);
184 m_view
[i
] = new DolphinView(this,
188 props
.showHiddenFiles());
189 connectViewSignals(i
);
194 m_activeView
= isPrimaryViewActive
? m_view
[PrimaryIdx
] : m_view
[SecondaryIdx
];
195 assert(m_activeView
!= 0);
198 emit
activeViewChanged();
201 void DolphinMainWindow::slotViewModeChanged()
206 void DolphinMainWindow::slotShowHiddenFilesChanged()
208 KToggleAction
* showHiddenFilesAction
=
209 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
210 showHiddenFilesAction
->setChecked(m_activeView
->showHiddenFiles());
213 void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting
)
217 case DolphinView::SortByName
:
218 action
= actionCollection()->action("by_name");
220 case DolphinView::SortBySize
:
221 action
= actionCollection()->action("by_size");
223 case DolphinView::SortByDate
:
224 action
= actionCollection()->action("by_date");
231 KToggleAction
* toggleAction
= static_cast<KToggleAction
*>(action
);
232 toggleAction
->setChecked(true);
236 void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order
)
238 KToggleAction
* descending
= static_cast<KToggleAction
*>(actionCollection()->action("descending"));
239 const bool sortDescending
= (order
== Qt::Descending
);
240 descending
->setChecked(sortDescending
);
243 void DolphinMainWindow::slotSelectionChanged()
247 assert(m_view
[PrimaryIdx
] != 0);
248 int selectedUrlsCount
= m_view
[PrimaryIdx
]->selectedUrls().count();
249 if (m_view
[SecondaryIdx
] != 0) {
250 selectedUrlsCount
+= m_view
[SecondaryIdx
]->selectedUrls().count();
253 QAction
* compareFilesAction
= actionCollection()->action("compare_files");
254 compareFilesAction
->setEnabled(selectedUrlsCount
== 2);
256 m_activeView
->updateStatusBar();
258 emit
selectionChanged();
261 void DolphinMainWindow::slotHistoryChanged()
266 void DolphinMainWindow::slotUrlChanged(const KUrl
& url
)
270 setCaption(url
.fileName());
273 void DolphinMainWindow::updateFilterBarAction(bool show
)
275 KToggleAction
* showFilterBarAction
=
276 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
277 showFilterBarAction
->setChecked(show
);
280 void DolphinMainWindow::openNewMainWindow()
282 DolphinApplication::app()->createMainWindow()->show();
285 void DolphinMainWindow::moveDroppedItems()
287 moveUrls(m_droppedUrls
, m_dropDestination
);
290 void DolphinMainWindow::copyDroppedItems()
292 copyUrls(m_droppedUrls
, m_dropDestination
);
295 void DolphinMainWindow::linkDroppedItems()
297 KonqOperations::copy(this, KonqOperations::LINK
, m_droppedUrls
, m_dropDestination
);
298 m_undoOperations
.append(KonqOperations::LINK
);
301 void DolphinMainWindow::closeEvent(QCloseEvent
* event
)
303 DolphinSettings
& settings
= DolphinSettings::instance();
304 GeneralSettings
* generalSettings
= settings
.generalSettings();
305 generalSettings
->setFirstRun(false);
309 // TODO: I assume there will be a generic way in KDE 4 to store the docks
310 // of the main window. In the meantime they are stored manually:
311 QString filename
= KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName());
312 filename
.append("/panels_layout");
313 QFile
file(filename
);
314 if (file
.open(QIODevice::WriteOnly
)) {
315 QByteArray data
= saveState();
320 KMainWindow::closeEvent(event
);
323 void DolphinMainWindow::saveProperties(KConfig
* config
)
325 config
->setGroup("Primary view");
326 config
->writeEntry("Url", m_view
[PrimaryIdx
]->url().url());
327 config
->writeEntry("Editable Url", m_view
[PrimaryIdx
]->isUrlEditable());
328 if (m_view
[SecondaryIdx
] != 0) {
329 config
->setGroup("Secondary view");
330 config
->writeEntry("Url", m_view
[SecondaryIdx
]->url().url());
331 config
->writeEntry("Editable Url", m_view
[SecondaryIdx
]->isUrlEditable());
335 void DolphinMainWindow::readProperties(KConfig
* config
)
337 config
->setGroup("Primary view");
338 m_view
[PrimaryIdx
]->setUrl(config
->readEntry("Url"));
339 m_view
[PrimaryIdx
]->setUrlEditable(config
->readEntry("Editable Url", false));
340 if (config
->hasGroup("Secondary view")) {
341 config
->setGroup("Secondary view");
342 if (m_view
[SecondaryIdx
] == 0) {
345 m_view
[SecondaryIdx
]->setUrl(config
->readEntry("Url"));
346 m_view
[SecondaryIdx
]->setUrlEditable(config
->readEntry("Editable Url", false));
348 else if (m_view
[SecondaryIdx
] != 0) {
353 void DolphinMainWindow::createFolder()
355 // Parts of the following code have been taken
356 // from the class KonqPopupMenu located in
357 // libqonq/konq_popupmenu.h of Konqueror.
358 // (Copyright (C) 2000 David Faure <faure@kde.org>,
359 // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
363 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
364 const KUrl
baseUrl(m_activeView
->url());
366 QString
name(i18n("New Folder"));
367 baseUrl
.path(KUrl::AddTrailingSlash
);
370 if (baseUrl
.isLocalFile() && QFileInfo(baseUrl
.path(KUrl::AddTrailingSlash
) + name
).exists()) {
371 name
= KIO::RenameDialog::suggestName(baseUrl
, i18n("New Folder"));
375 name
= KInputDialog::getText(i18n("New Folder"),
376 i18n("Enter folder name:" ),
382 // the user has pressed 'Cancel'
386 assert(!name
.isEmpty());
389 if ((name
[0] == '/') || (name
[0] == '~')) {
390 url
.setPath(KShell::tildeExpand(name
));
393 name
= KIO::encodeFileName(name
);
398 KonqOperations::mkdir(this, url
);
400 // TODO: is there a possability to check whether the mkdir operation
401 // has been successful?
403 statusBar
->setMessage(i18n("Created folder %1.",url
.path()),
404 DolphinStatusBar::OperationCompleted
);
407 // // Creating of the folder has been failed. Check whether the creating
408 // // has been failed because a folder with the same name exists...
409 // if (KIO::NetAccess::exists(url, true, this)) {
410 // statusBar->setMessage(i18n("A folder named %1 already exists.",url.path()),
411 // DolphinStatusBar::Error);
414 // statusBar->setMessage(i18n("Creating of folder %1 failed.",url.path()),
415 // DolphinStatusBar::Error);
419 void DolphinMainWindow::createFile()
421 // Parts of the following code have been taken
422 // from the class KonqPopupMenu located in
423 // libqonq/konq_popupmenu.h of Konqueror.
424 // (Copyright (C) 2000 David Faure <faure@kde.org>,
425 // Copyright (C) 2001 Holger Freyther <freyther@yahoo.com>)
429 // TODO: const Entry& entry = m_createFileTemplates[QString(sender->name())];
430 // should be enough. Anyway: the implementation of [] does a linear search internally too.
431 KSortableList
<CreateFileEntry
, QString
>::ConstIterator it
= m_createFileTemplates
.begin();
432 KSortableList
<CreateFileEntry
, QString
>::ConstIterator end
= m_createFileTemplates
.end();
434 const QString
senderName(sender()->objectName());
436 CreateFileEntry entry
;
437 while (!found
&& (it
!= end
)) {
438 if ((*it
).key() == senderName
) {
439 entry
= (*it
).value();
447 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
448 if (!found
|| !QFile::exists(entry
.templatePath
)) {
449 statusBar
->setMessage(i18n("Could not create file."), DolphinStatusBar::Error
);
453 // Get the source path of the template which should be copied.
454 // The source path is part of the Url entry of the desktop file.
455 const int pos
= entry
.templatePath
.lastIndexOf('/');
456 QString
sourcePath(entry
.templatePath
.left(pos
+ 1));
457 sourcePath
+= KDesktopFile(entry
.templatePath
, true).readPathEntry("Url");
459 QString
name(i18n(entry
.name
.toAscii()));
460 // Most entry names end with "..." (e. g. "HTML File..."), which is ok for
461 // menus but no good choice for a new file name -> remove the dots...
462 name
.replace("...", QString::null
);
464 // add the file extension to the name
465 name
.append(sourcePath
.right(sourcePath
.length() - sourcePath
.lastIndexOf('.')));
467 // Check whether a file with the current name already exists. If yes suggest automatically
468 // a unique file name (e. g. "HTML File" will be replaced by "HTML File_1").
469 const KUrl
viewUrl(m_activeView
->url());
470 const bool fileExists
= viewUrl
.isLocalFile() &&
471 QFileInfo(viewUrl
.path(KUrl::AddTrailingSlash
) + KIO::encodeFileName(name
)).exists();
473 name
= KIO::RenameDialog::suggestName(viewUrl
, name
);
476 // let the user change the suggested file name
478 name
= KInputDialog::getText(entry
.name
,
484 // the user has pressed 'Cancel'
488 // before copying the template to the destination path check whether a file
489 // with the given name already exists
490 const QString
destPath(viewUrl
.pathOrUrl() + "/" + KIO::encodeFileName(name
));
491 const KUrl
destUrl(destPath
);
492 if (KIO::NetAccess::exists(destUrl
, false, this)) {
493 statusBar
->setMessage(i18n("A file named %1 already exists.",name
),
494 DolphinStatusBar::Error
);
498 // copy the template to the destination path
499 const KUrl
sourceUrl(sourcePath
);
500 KIO::CopyJob
* job
= KIO::copyAs(sourceUrl
, destUrl
);
501 job
->setDefaultPermissions(true);
502 if (KIO::NetAccess::synchronousRun(job
, this)) {
503 statusBar
->setMessage(i18n("Created file %1.",name
),
504 DolphinStatusBar::OperationCompleted
);
507 list
.append(sourceUrl
);
509 // TODO: use the KonqUndoManager/KonqOperations instead.
510 //DolphinCommand command(DolphinCommand::CreateFile, list, destUrl);
511 //UndoManager::instance().addCommand(command);
515 statusBar
->setMessage(i18n("Creating of file %1 failed.",name
),
516 DolphinStatusBar::Error
);
520 void DolphinMainWindow::rename()
523 m_activeView
->renameSelectedItems();
526 void DolphinMainWindow::moveToTrash()
529 const KUrl::List selectedUrls
= m_activeView
->selectedUrls();
530 // TODO: per default a message box is opened which asks whether the item
531 // should really be moved to the trash. This does not make sense, as the
532 // action can be undone anyway by the user.
533 KonqOperations::del(this, KonqOperations::TRASH
, selectedUrls
);
534 m_undoOperations
.append(KonqOperations::TRASH
);
537 void DolphinMainWindow::deleteItems()
541 KUrl::List list
= m_activeView
->selectedUrls();
542 const uint itemCount
= list
.count();
543 assert(itemCount
>= 1);
547 text
= i18n("Do you really want to delete the %1 selected items?",itemCount
);
550 const KUrl
& url
= list
.first();
551 text
= i18n("Do you really want to delete '%1'?",url
.fileName());
554 const bool del
= KMessageBox::warningContinueCancel(this,
557 KGuiItem(i18n("Delete"), KIcon("editdelete"))
558 ) == KMessageBox::Continue
;
560 KIO::Job
* job
= KIO::del(list
);
561 connect(job
, SIGNAL(result(KJob
*)),
562 this, SLOT(slotHandleJobError(KJob
*)));
563 connect(job
, SIGNAL(result(KJob
*)),
564 this, SLOT(slotDeleteFileFinished(KJob
*)));
568 void DolphinMainWindow::properties()
570 const KFileItemList list
= m_activeView
->selectedItems();
571 new KPropertiesDialog(list
, this);
574 void DolphinMainWindow::quit()
579 void DolphinMainWindow::slotHandleJobError(KJob
* job
)
581 if (job
->error() != 0) {
582 m_activeView
->statusBar()->setMessage(job
->errorString(),
583 DolphinStatusBar::Error
);
587 void DolphinMainWindow::slotDeleteFileFinished(KJob
* job
)
589 if (job
->error() == 0) {
590 m_activeView
->statusBar()->setMessage(i18n("Delete operation completed."),
591 DolphinStatusBar::OperationCompleted
);
593 // TODO: In opposite to the 'Move to Trash' operation in the class KFileIconView
594 // no rearranging of the item position is done when a file has been deleted.
595 // This is bypassed by reloading the view, but it might be worth to investigate
596 // deeper for the root of this issue.
597 m_activeView
->reload();
601 void DolphinMainWindow::slotUndoAvailable(bool available
)
603 QAction
* undoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo
));
604 if (undoAction
!= 0) {
605 undoAction
->setEnabled(available
);
608 if (available
&& (m_undoOperations
.count() > 0)) {
609 const KonqOperations::Operation op
= m_undoOperations
.takeFirst();
610 DolphinStatusBar
* statusBar
= m_activeView
->statusBar();
612 case KonqOperations::COPY
:
613 statusBar
->setMessage(i18n("Copy operation completed."),
614 DolphinStatusBar::OperationCompleted
);
616 case KonqOperations::MOVE
:
617 statusBar
->setMessage(i18n("Move operation completed."),
618 DolphinStatusBar::OperationCompleted
);
620 case KonqOperations::LINK
:
621 statusBar
->setMessage(i18n("Link operation completed."),
622 DolphinStatusBar::OperationCompleted
);
624 case KonqOperations::TRASH
:
625 statusBar
->setMessage(i18n("Move to trash operation completed."),
626 DolphinStatusBar::OperationCompleted
);
635 void DolphinMainWindow::slotUndoTextChanged(const QString
& text
)
637 QAction
* undoAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo
));
638 if (undoAction
!= 0) {
639 undoAction
->setText(text
);
643 void DolphinMainWindow::cut()
645 QMimeData
* mimeData
= new QMimeData();
646 const KUrl::List kdeUrls
= m_activeView
->selectedUrls();
647 const KUrl::List mostLocalUrls
;
648 KonqMimeData::populateMimeData(mimeData
, kdeUrls
, mostLocalUrls
, true);
649 QApplication::clipboard()->setMimeData(mimeData
);
652 void DolphinMainWindow::copy()
654 QMimeData
* mimeData
= new QMimeData();
655 const KUrl::List kdeUrls
= m_activeView
->selectedUrls();
656 const KUrl::List mostLocalUrls
;
657 KonqMimeData::populateMimeData(mimeData
, kdeUrls
, mostLocalUrls
, false);
659 QApplication::clipboard()->setMimeData(mimeData
);
662 void DolphinMainWindow::paste()
664 QClipboard
* clipboard
= QApplication::clipboard();
665 const QMimeData
* mimeData
= clipboard
->mimeData();
669 const KUrl::List sourceUrls
= KUrl::List::fromMimeData(mimeData
);
671 // per default the pasting is done into the current Url of the view
672 KUrl
destUrl(m_activeView
->url());
674 // check whether the pasting should be done into a selected directory
675 KUrl::List selectedUrls
= m_activeView
->selectedUrls();
676 if (selectedUrls
.count() == 1) {
677 const KFileItem
fileItem(S_IFDIR
,
679 selectedUrls
.first(),
681 if (fileItem
.isDir()) {
682 // only one item is selected which is a directory, hence paste
683 // into this directory
684 destUrl
= selectedUrls
.first();
688 if (KonqMimeData::decodeIsCutSelection(mimeData
)) {
689 moveUrls(sourceUrls
, destUrl
);
693 copyUrls(sourceUrls
, destUrl
);
697 void DolphinMainWindow::updatePasteAction()
699 QAction
* pasteAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste
));
700 if (pasteAction
== 0) {
704 QString
text(i18n("Paste"));
705 QClipboard
* clipboard
= QApplication::clipboard();
706 const QMimeData
* mimeData
= clipboard
->mimeData();
708 KUrl::List urls
= KUrl::List::fromMimeData(mimeData
);
709 if (!urls
.isEmpty()) {
710 pasteAction
->setEnabled(true);
712 const int count
= urls
.count();
714 pasteAction
->setText(i18n("Paste 1 File"));
717 pasteAction
->setText(i18n("Paste %1 Files").arg(count
));
721 pasteAction
->setEnabled(false);
722 pasteAction
->setText(i18n("Paste"));
725 if (pasteAction
->isEnabled()) {
726 KUrl::List urls
= m_activeView
->selectedUrls();
727 const uint count
= urls
.count();
729 // pasting should not be allowed when more than one file
731 pasteAction
->setEnabled(false);
733 else if (count
== 1) {
734 // Only one file is selected. Pasting is only allowed if this
735 // file is a directory.
736 // TODO: this doesn't work with remote protocols; instead we need a
737 // m_activeView->selectedFileItems() to get the real KFileItems
738 const KFileItem
fileItem(S_IFDIR
,
742 pasteAction
->setEnabled(fileItem
.isDir());
747 void DolphinMainWindow::selectAll()
750 m_activeView
->selectAll();
753 void DolphinMainWindow::invertSelection()
756 m_activeView
->invertSelection();
758 void DolphinMainWindow::setIconsView()
760 m_activeView
->setMode(DolphinView::IconsView
);
763 void DolphinMainWindow::setDetailsView()
765 m_activeView
->setMode(DolphinView::DetailsView
);
768 void DolphinMainWindow::sortByName()
770 m_activeView
->setSorting(DolphinView::SortByName
);
773 void DolphinMainWindow::sortBySize()
775 m_activeView
->setSorting(DolphinView::SortBySize
);
778 void DolphinMainWindow::sortByDate()
780 m_activeView
->setSorting(DolphinView::SortByDate
);
783 void DolphinMainWindow::toggleSortOrder()
785 const Qt::SortOrder order
= (m_activeView
->sortOrder() == Qt::Ascending
) ?
788 m_activeView
->setSortOrder(order
);
791 void DolphinMainWindow::toggleSplitView()
793 if (m_view
[SecondaryIdx
] == 0) {
794 const int newWidth
= (m_view
[PrimaryIdx
]->width() - m_splitter
->handleWidth()) / 2;
795 // create a secondary view
796 m_view
[SecondaryIdx
] = new DolphinView(this,
798 m_view
[PrimaryIdx
]->url(),
799 m_view
[PrimaryIdx
]->mode(),
800 m_view
[PrimaryIdx
]->showHiddenFiles());
801 connectViewSignals(SecondaryIdx
);
802 m_splitter
->addWidget(m_view
[SecondaryIdx
]);
803 m_splitter
->setSizes(QList
<int>() << newWidth
<< newWidth
);
804 m_view
[SecondaryIdx
]->show();
807 // remove secondary view
808 if (m_activeView
== m_view
[PrimaryIdx
]) {
809 m_view
[SecondaryIdx
]->close();
810 m_view
[SecondaryIdx
]->deleteLater();
811 m_view
[SecondaryIdx
] = 0;
812 setActiveView(m_view
[PrimaryIdx
]);
815 // The secondary view is active, hence from the users point of view
816 // the content of the secondary view should be moved to the primary view.
817 // From an implementation point of view it is more efficient to close
818 // the primary view and exchange the internal pointers afterwards.
819 m_view
[PrimaryIdx
]->close();
820 delete m_view
[PrimaryIdx
];
821 m_view
[PrimaryIdx
] = m_view
[SecondaryIdx
];
822 m_view
[SecondaryIdx
] = 0;
823 setActiveView(m_view
[PrimaryIdx
]);
828 void DolphinMainWindow::reloadView()
831 m_activeView
->reload();
834 void DolphinMainWindow::stopLoading()
838 void DolphinMainWindow::togglePreview()
842 const KToggleAction
* showPreviewAction
=
843 static_cast<KToggleAction
*>(actionCollection()->action("show_preview"));
844 const bool show
= showPreviewAction
->isChecked();
845 m_activeView
->setShowPreview(show
);
848 void DolphinMainWindow::toggleShowHiddenFiles()
852 const KToggleAction
* showHiddenFilesAction
=
853 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
854 const bool show
= showHiddenFilesAction
->isChecked();
855 m_activeView
->setShowHiddenFiles(show
);
858 void DolphinMainWindow::showFilterBar()
860 const KToggleAction
* showFilterBarAction
=
861 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
862 const bool show
= showFilterBarAction
->isChecked();
863 m_activeView
->slotShowFilterBar(show
);
866 void DolphinMainWindow::zoomIn()
868 m_activeView
->zoomIn();
872 void DolphinMainWindow::zoomOut()
874 m_activeView
->zoomOut();
878 void DolphinMainWindow::toggleEditLocation()
882 KToggleAction
* action
= static_cast<KToggleAction
*>(actionCollection()->action("editable_location"));
884 bool editOrBrowse
= action
->isChecked();
885 // action->setChecked(action->setChecked);
886 m_activeView
->setUrlEditable(editOrBrowse
);
889 void DolphinMainWindow::editLocation()
891 KToggleAction
* action
= static_cast<KToggleAction
*>(actionCollection()->action("editable_location"));
892 action
->setChecked(true);
893 m_activeView
->setUrlEditable(true);
896 void DolphinMainWindow::adjustViewProperties()
899 ViewPropertiesDialog
dlg(m_activeView
);
903 void DolphinMainWindow::goBack()
906 m_activeView
->goBack();
909 void DolphinMainWindow::goForward()
912 m_activeView
->goForward();
915 void DolphinMainWindow::goUp()
918 m_activeView
->goUp();
921 void DolphinMainWindow::goHome()
924 m_activeView
->goHome();
927 void DolphinMainWindow::openTerminal()
929 QString
command("konsole --workdir \"");
930 command
.append(m_activeView
->url().path());
931 command
.append('\"');
933 KRun::runCommand(command
, "Konsole", "konsole");
936 void DolphinMainWindow::findFile()
938 KRun::run("kfind", m_activeView
->url());
941 void DolphinMainWindow::compareFiles()
943 // The method is only invoked if exactly 2 files have
944 // been selected. The selected files may be:
945 // - both in the primary view
946 // - both in the secondary view
947 // - one in the primary view and the other in the secondary
949 assert(m_view
[PrimaryIdx
] != 0);
953 KUrl::List urls
= m_view
[PrimaryIdx
]->selectedUrls();
955 switch (urls
.count()) {
957 assert(m_view
[SecondaryIdx
] != 0);
958 urls
= m_view
[SecondaryIdx
]->selectedUrls();
959 assert(urls
.count() == 2);
967 assert(m_view
[SecondaryIdx
] != 0);
968 urls
= m_view
[SecondaryIdx
]->selectedUrls();
969 assert(urls
.count() == 1);
981 // may not happen: compareFiles may only get invoked if 2
982 // files are selected
987 QString
command("kompare -c \"");
988 command
.append(urlA
.pathOrUrl());
989 command
.append("\" \"");
990 command
.append(urlB
.pathOrUrl());
991 command
.append('\"');
992 KRun::runCommand(command
, "Kompare", "kompare");
996 void DolphinMainWindow::editSettings()
998 // TODO: make a static method for opening the settings dialog
999 DolphinSettingsDialog
dlg(this);
1003 void DolphinMainWindow::init()
1005 // Check whether Dolphin runs the first time. If yes then
1006 // a proper default window size is given at the end of DolphinMainWindow::init().
1007 GeneralSettings
* generalSettings
= DolphinSettings::instance().generalSettings();
1008 const bool firstRun
= generalSettings
->firstRun();
1010 setAcceptDrops(true);
1012 m_splitter
= new QSplitter(this);
1014 DolphinSettings
& settings
= DolphinSettings::instance();
1016 KBookmarkManager
* manager
= settings
.bookmarkManager();
1017 assert(manager
!= 0);
1018 KBookmarkGroup root
= manager
->root();
1019 if (root
.first().isNull()) {
1020 root
.addBookmark(manager
, i18n("Home"), settings
.generalSettings()->homeUrl(), "folder_home");
1021 root
.addBookmark(manager
, i18n("Storage Media"), KUrl("media:/"), "blockdevice");
1022 root
.addBookmark(manager
, i18n("Network"), KUrl("remote:/"), "network_local");
1023 root
.addBookmark(manager
, i18n("Root"), KUrl("/"), "folder_red");
1024 root
.addBookmark(manager
, i18n("Trash"), KUrl("trash:/"), "trashcan_full");
1029 const KUrl
& homeUrl
= root
.first().url();
1030 setCaption(homeUrl
.fileName());
1031 ViewProperties
props(homeUrl
);
1032 m_view
[PrimaryIdx
] = new DolphinView(this,
1036 props
.showHiddenFiles());
1037 connectViewSignals(PrimaryIdx
);
1038 m_view
[PrimaryIdx
]->show();
1040 m_activeView
= m_view
[PrimaryIdx
];
1042 setCentralWidget(m_splitter
);
1045 setupGUI(Keys
|Save
|Create
|ToolBar
);
1048 stateChanged("new_file");
1049 setAutoSaveSettings();
1051 QClipboard
* clipboard
= QApplication::clipboard();
1052 connect(clipboard
, SIGNAL(dataChanged()),
1053 this, SLOT(updatePasteAction()));
1054 updatePasteAction();
1057 setupCreateNewMenuActions();
1062 // assure a proper default size if Dolphin runs the first time
1067 void DolphinMainWindow::loadSettings()
1069 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
1071 KToggleAction
* splitAction
= static_cast<KToggleAction
*>(actionCollection()->action("split_view"));
1072 if (settings
->splitView()) {
1073 splitAction
->setChecked(true);
1077 updateViewActions();
1079 // TODO: I assume there will be a generic way in KDE 4 to restore the docks
1080 // of the main window. In the meantime they are restored manually (see also
1081 // DolphinMainWindow::closeEvent() for more details):
1082 QString filename
= KStandardDirs::locateLocal("data", KGlobal::instance()->instanceName());
1083 filename
.append("/panels_layout");
1084 QFile
file(filename
);
1085 if (file
.open(QIODevice::ReadOnly
)) {
1086 QByteArray data
= file
.readAll();
1092 void DolphinMainWindow::setupActions()
1094 // setup 'File' menu
1095 QAction
*action
= actionCollection()->addAction("new_window");
1096 action
->setIcon(KIcon("window_new"));
1097 action
->setText(i18n("New &Window"));
1098 connect(action
, SIGNAL(triggered()), this, SLOT(openNewMainWindow()));
1100 QAction
* createFolder
= actionCollection()->addAction("create_folder");
1101 createFolder
->setText(i18n("Folder..."));
1102 createFolder
->setIcon(KIcon("folder"));
1103 createFolder
->setShortcut(Qt::Key_N
);
1104 connect(createFolder
, SIGNAL(triggered()), this, SLOT(createFolder()));
1106 QAction
* rename
= actionCollection()->addAction("rename");
1107 rename
->setText(i18n("Rename"));
1108 rename
->setShortcut(Qt::Key_F2
);
1109 connect(rename
, SIGNAL(triggered()), this, SLOT(rename()));
1111 QAction
* moveToTrash
= actionCollection()->addAction("move_to_trash");
1112 moveToTrash
->setText(i18n("Move to Trash"));
1113 moveToTrash
->setIcon(KIcon("edittrash"));
1114 moveToTrash
->setShortcut(QKeySequence::Delete
);
1115 connect(moveToTrash
, SIGNAL(triggered()), this, SLOT(moveToTrash()));
1117 QAction
* deleteAction
= actionCollection()->addAction("delete");
1118 deleteAction
->setText(i18n("Delete"));
1119 deleteAction
->setShortcut(Qt::ALT
| Qt::Key_Delete
);
1120 deleteAction
->setIcon(KIcon("editdelete"));
1121 connect(deleteAction
, SIGNAL(triggered()), this, SLOT(deleteItems()));
1123 QAction
* properties
= actionCollection()->addAction("properties");
1124 properties
->setText(i18n("Propert&ies"));
1125 properties
->setShortcut(Qt::Key_Alt
| Qt::Key_Return
);
1126 connect(properties
, SIGNAL(triggered()), this, SLOT(properties()));
1128 KStandardAction::quit(this, SLOT(quit()), actionCollection());
1130 // setup 'Edit' menu
1131 KStandardAction::undo(KonqUndoManager::self(),
1133 actionCollection());
1135 KStandardAction::cut(this, SLOT(cut()), actionCollection());
1136 KStandardAction::copy(this, SLOT(copy()), actionCollection());
1137 KStandardAction::paste(this, SLOT(paste()), actionCollection());
1139 QAction
* selectAll
= actionCollection()->addAction("select_all");
1140 selectAll
->setText(i18n("Select All"));
1141 selectAll
->setShortcut(Qt::CTRL
+ Qt::Key_A
);
1142 connect(selectAll
, SIGNAL(triggered()), this, SLOT(selectAll()));
1144 QAction
* invertSelection
= actionCollection()->addAction("invert_selection");
1145 invertSelection
->setText(i18n("Invert Selection"));
1146 invertSelection
->setShortcut(Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
1147 connect(invertSelection
, SIGNAL(triggered()), this, SLOT(invertSelection()));
1149 // setup 'View' menu
1150 KStandardAction::zoomIn(this,
1152 actionCollection());
1154 KStandardAction::zoomOut(this,
1156 actionCollection());
1158 KToggleAction
* iconsView
= actionCollection()->add
<KToggleAction
>("icons");
1159 iconsView
->setText(i18n("Icons"));
1160 iconsView
->setShortcut(Qt::CTRL
| Qt::Key_1
);
1161 iconsView
->setIcon(KIcon("view_icon"));
1162 connect(iconsView
, SIGNAL(triggered()), this, SLOT(setIconsView()));
1164 KToggleAction
* detailsView
= actionCollection()->add
<KToggleAction
>("details");
1165 detailsView
->setText(i18n("Details"));
1166 detailsView
->setShortcut(Qt::CTRL
| Qt::Key_2
);
1167 detailsView
->setIcon(KIcon("view_text"));
1168 connect(detailsView
, SIGNAL(triggered()), this, SLOT(setDetailsView()));
1170 QActionGroup
* viewModeGroup
= new QActionGroup(this);
1171 viewModeGroup
->addAction(iconsView
);
1172 viewModeGroup
->addAction(detailsView
);
1174 KToggleAction
* sortByName
= actionCollection()->add
<KToggleAction
>("by_name");
1175 sortByName
->setText(i18n("By Name"));
1176 connect(sortByName
, SIGNAL(triggered()), this, SLOT(sortByName()));
1178 KToggleAction
* sortBySize
= actionCollection()->add
<KToggleAction
>("by_size");
1179 sortBySize
->setText(i18n("By Size"));
1180 connect(sortBySize
, SIGNAL(triggered()), this, SLOT(sortBySize()));
1182 KToggleAction
* sortByDate
= actionCollection()->add
<KToggleAction
>("by_date");
1183 sortByDate
->setText(i18n("By Date"));
1184 connect(sortByDate
, SIGNAL(triggered()), this, SLOT(sortByDate()));
1186 QActionGroup
* sortGroup
= new QActionGroup(this);
1187 sortGroup
->addAction(sortByName
);
1188 sortGroup
->addAction(sortBySize
);
1189 sortGroup
->addAction(sortByDate
);
1191 KToggleAction
* sortDescending
= actionCollection()->add
<KToggleAction
>("descending");
1192 sortDescending
->setText(i18n("Descending"));
1193 connect(sortDescending
, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
1195 KToggleAction
* showPreview
= actionCollection()->add
<KToggleAction
>("show_preview");
1196 showPreview
->setText(i18n("Show Preview"));
1197 connect(showPreview
, SIGNAL(triggered()), this, SLOT(togglePreview()));
1199 KToggleAction
* showHiddenFiles
= actionCollection()->add
<KToggleAction
>("show_hidden_files");
1200 showHiddenFiles
->setText(i18n("Show Hidden Files"));
1201 //showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'?
1202 connect(showHiddenFiles
, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
1204 KToggleAction
* split
= actionCollection()->add
<KToggleAction
>("split_view");
1205 split
->setText(i18n("Split View"));
1206 split
->setShortcut(Qt::Key_F10
);
1207 split
->setIcon(KIcon("view_left_right"));
1208 connect(split
, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
1210 QAction
* reload
= actionCollection()->addAction("reload");
1211 reload
->setText(i18n("Reload"));
1212 reload
->setShortcut(Qt::Key_F5
);
1213 reload
->setIcon(KIcon("reload"));
1214 connect(reload
, SIGNAL(triggered()), this, SLOT(reloadView()));
1216 QAction
* stop
= actionCollection()->addAction("stop");
1217 stop
->setText(i18n("Stop"));
1218 stop
->setIcon(KIcon("stop"));
1219 connect(stop
, SIGNAL(triggered()), this, SLOT(stopLoading()));
1221 KToggleAction
* showFullLocation
= actionCollection()->add
<KToggleAction
>("editable_location");
1222 showFullLocation
->setText(i18n("Show Full Location"));
1223 showFullLocation
->setShortcut(Qt::CTRL
| Qt::Key_L
);
1224 connect(showFullLocation
, SIGNAL(triggered()), this, SLOT(toggleEditLocation()));
1226 KToggleAction
* editLocation
= actionCollection()->add
<KToggleAction
>("edit_location");
1227 editLocation
->setText(i18n("Edit Location"));
1228 editLocation
->setShortcut(Qt::Key_F6
);
1229 connect(editLocation
, SIGNAL(triggered()), this, SLOT(editLocation()));
1231 QAction
* adjustViewProps
= actionCollection()->addAction("view_properties");
1232 adjustViewProps
->setText(i18n("Adjust View Properties..."));
1233 connect(adjustViewProps
, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
1236 KStandardAction::back(this, SLOT(goBack()), actionCollection());
1237 KStandardAction::forward(this, SLOT(goForward()), actionCollection());
1238 KStandardAction::up(this, SLOT(goUp()), actionCollection());
1239 KStandardAction::home(this, SLOT(goHome()), actionCollection());
1241 // setup 'Tools' menu
1242 QAction
* openTerminal
= actionCollection()->addAction("open_terminal");
1243 openTerminal
->setText(i18n("Open Terminal"));
1244 openTerminal
->setShortcut(Qt::Key_F4
);
1245 openTerminal
->setIcon(KIcon("konsole"));
1246 connect(openTerminal
, SIGNAL(triggered()), this, SLOT(openTerminal()));
1248 QAction
* findFile
= actionCollection()->addAction("find_file");
1249 findFile
->setText(i18n("Find File..."));
1250 findFile
->setShortcut(Qt::Key_F
);
1251 findFile
->setIcon(KIcon("filefind"));
1252 connect(findFile
, SIGNAL(triggered()), this, SLOT(findFile()));
1254 KToggleAction
* showFilterBar
= actionCollection()->add
<KToggleAction
>("show_filter_bar");
1255 showFilterBar
->setText(i18n("Show Filter Bar"));
1256 showFilterBar
->setShortcut(Qt::Key_Slash
);
1257 connect(showFilterBar
, SIGNAL(triggered()), this, SLOT(showFilterBar()));
1259 QAction
* compareFiles
= actionCollection()->addAction("compare_files");
1260 compareFiles
->setText(i18n("Compare Files"));
1261 compareFiles
->setIcon(KIcon("kompare"));
1262 compareFiles
->setEnabled(false);
1263 connect(compareFiles
, SIGNAL(triggered()), this, SLOT(compareFiles()));
1265 // setup 'Settings' menu
1266 KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
1269 void DolphinMainWindow::setupDockWidgets()
1271 QDockWidget
* shortcutsDock
= new QDockWidget(i18n("Bookmarks"));
1272 shortcutsDock
->setObjectName("bookmarksDock");
1273 shortcutsDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1274 shortcutsDock
->setWidget(new BookmarksSidebarPage(this));
1276 shortcutsDock
->toggleViewAction()->setText(i18n("Show Bookmarks Panel"));
1277 actionCollection()->addAction("show_bookmarks_panel", shortcutsDock
->toggleViewAction());
1279 addDockWidget(Qt::LeftDockWidgetArea
, shortcutsDock
);
1281 QDockWidget
* infoDock
= new QDockWidget(i18n("Information"));
1282 infoDock
->setObjectName("infoDock");
1283 infoDock
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
1284 infoDock
->setWidget(new InfoSidebarPage(this));
1286 infoDock
->toggleViewAction()->setText(i18n("Show Information Panel"));
1287 actionCollection()->addAction("show_info_panel", infoDock
->toggleViewAction());
1289 addDockWidget(Qt::RightDockWidgetArea
, infoDock
);
1292 void DolphinMainWindow::setupCreateNewMenuActions()
1294 // Parts of the following code have been taken
1295 // from the class KNewMenu located in
1296 // libqonq/knewmenu.h of Konqueror.
1297 // Copyright (C) 1998, 1999 David Faure <faure@kde.org>
1298 // 2003 Sven Leiber <s.leiber@web.de>
1300 QStringList files
= actionCollection()->instance()->dirs()->findAllResources("templates");
1301 for (QStringList::Iterator it
= files
.begin() ; it
!= files
.end(); ++it
) {
1302 if ((*it
)[0] != '.' ) {
1303 KSimpleConfig
config(*it
, true);
1304 config
.setDesktopGroup();
1306 // tricky solution to ensure that TextFile is at the beginning
1307 // because this filetype is the most used (according kde-core discussion)
1308 const QString
name(config
.readEntry("Name"));
1311 const QString
path(config
.readPathEntry("Url"));
1312 if (!path
.endsWith("emptydir")) {
1313 if (path
.endsWith("TextFile.txt")) {
1316 else if (!KDesktopFile::isDesktopFile(path
)) {
1319 else if (path
.endsWith("Url.desktop")){
1322 else if (path
.endsWith("Program.desktop")){
1329 const QString
icon(config
.readEntry("Icon"));
1330 const QString
comment(config
.readEntry("Comment"));
1331 const QString
type(config
.readEntry("Type"));
1333 const QString
filePath(*it
);
1336 if (type
== "Link") {
1337 CreateFileEntry entry
;
1340 entry
.comment
= comment
;
1341 entry
.templatePath
= filePath
;
1342 m_createFileTemplates
.insert(key
, entry
);
1347 m_createFileTemplates
.sort();
1349 unplugActionList("create_actions");
1350 KSortableList
<CreateFileEntry
, QString
>::ConstIterator it
= m_createFileTemplates
.begin();
1351 KSortableList
<CreateFileEntry
, QString
>::ConstIterator end
= m_createFileTemplates
.end();
1352 /* KDE4-TODO: don't port this code; use KNewMenu instead
1354 CreateFileEntry entry = (*it).value();
1355 KAction* action = new KAction(entry.name);
1356 action->setIcon(entry.icon);
1357 action->setName((*it).index());
1358 connect(action, SIGNAL(activated()),
1359 this, SLOT(createFile()));
1361 const QChar section = ((*it).index()[0]);
1365 m_fileGroupActions.append(action);
1371 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
1372 // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
1373 //m_linkGroupActions.append(action);
1378 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
1379 // and DolphinMainWindow::linkToDeviceActions() in the header file for details.
1380 //m_linkToDeviceActions.append(action);
1389 plugActionList("create_file_group", m_fileGroupActions);
1390 //plugActionList("create_link_group", m_linkGroupActions);
1391 //plugActionList("link_to_device", m_linkToDeviceActions);*/
1394 void DolphinMainWindow::updateHistory()
1397 const Q3ValueList
<UrlNavigator::HistoryElem
> list
= m_activeView
->urlHistory(index
);
1399 QAction
* backAction
= actionCollection()->action("go_back");
1400 if (backAction
!= 0) {
1401 backAction
->setEnabled(index
< static_cast<int>(list
.count()) - 1);
1404 QAction
* forwardAction
= actionCollection()->action("go_forward");
1405 if (forwardAction
!= 0) {
1406 forwardAction
->setEnabled(index
> 0);
1410 void DolphinMainWindow::updateEditActions()
1412 const KFileItemList list
= m_activeView
->selectedItems();
1413 if (list
.isEmpty()) {
1414 stateChanged("has_no_selection");
1417 stateChanged("has_selection");
1419 QAction
* renameAction
= actionCollection()->action("rename");
1420 if (renameAction
!= 0) {
1421 renameAction
->setEnabled(list
.count() >= 1);
1424 bool enableMoveToTrash
= true;
1426 KFileItemList::const_iterator it
= list
.begin();
1427 const KFileItemList::const_iterator end
= list
.end();
1429 KFileItem
* item
= *it
;
1430 const KUrl
& url
= item
->url();
1431 // only enable the 'Move to Trash' action for local files
1432 if (!url
.isLocalFile()) {
1433 enableMoveToTrash
= false;
1438 QAction
* moveToTrashAction
= actionCollection()->action("move_to_trash");
1439 moveToTrashAction
->setEnabled(enableMoveToTrash
);
1441 updatePasteAction();
1444 void DolphinMainWindow::updateViewActions()
1446 QAction
* zoomInAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn
));
1447 if (zoomInAction
!= 0) {
1448 zoomInAction
->setEnabled(m_activeView
->isZoomInPossible());
1451 QAction
* zoomOutAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut
));
1452 if (zoomOutAction
!= 0) {
1453 zoomOutAction
->setEnabled(m_activeView
->isZoomOutPossible());
1456 QAction
* action
= 0;
1457 switch (m_activeView
->mode()) {
1458 case DolphinView::IconsView
:
1459 action
= actionCollection()->action("icons");
1461 case DolphinView::DetailsView
:
1462 action
= actionCollection()->action("details");
1464 //case DolphinView::PreviewsView:
1465 // action = actionCollection()->action("previews");
1472 KToggleAction
* toggleAction
= static_cast<KToggleAction
*>(action
);
1473 toggleAction
->setChecked(true);
1476 slotSortingChanged(m_activeView
->sorting());
1477 slotSortOrderChanged(m_activeView
->sortOrder());
1479 KToggleAction
* showFilterBarAction
=
1480 static_cast<KToggleAction
*>(actionCollection()->action("show_filter_bar"));
1481 showFilterBarAction
->setChecked(m_activeView
->isFilterBarVisible());
1483 KToggleAction
* showHiddenFilesAction
=
1484 static_cast<KToggleAction
*>(actionCollection()->action("show_hidden_files"));
1485 showHiddenFilesAction
->setChecked(m_activeView
->showHiddenFiles());
1487 KToggleAction
* splitAction
= static_cast<KToggleAction
*>(actionCollection()->action("split_view"));
1488 splitAction
->setChecked(m_view
[SecondaryIdx
] != 0);
1491 void DolphinMainWindow::updateGoActions()
1493 QAction
* goUpAction
= actionCollection()->action(KStandardAction::stdName(KStandardAction::Up
));
1494 const KUrl
& currentUrl
= m_activeView
->url();
1495 goUpAction
->setEnabled(currentUrl
.upUrl() != currentUrl
);
1498 void DolphinMainWindow::copyUrls(const KUrl::List
& source
, const KUrl
& dest
)
1500 KonqOperations::copy(this, KonqOperations::COPY
, source
, dest
);
1501 m_undoOperations
.append(KonqOperations::COPY
);
1504 void DolphinMainWindow::moveUrls(const KUrl::List
& source
, const KUrl
& dest
)
1506 KonqOperations::copy(this, KonqOperations::MOVE
, source
, dest
);
1507 m_undoOperations
.append(KonqOperations::MOVE
);
1510 void DolphinMainWindow::clearStatusBar()
1512 m_activeView
->statusBar()->clear();
1515 void DolphinMainWindow::connectViewSignals(int viewIndex
)
1517 DolphinView
* view
= m_view
[viewIndex
];
1518 connect(view
, SIGNAL(modeChanged()),
1519 this, SLOT(slotViewModeChanged()));
1520 connect(view
, SIGNAL(showHiddenFilesChanged()),
1521 this, SLOT(slotShowHiddenFilesChanged()));
1522 connect(view
, SIGNAL(sortingChanged(DolphinView::Sorting
)),
1523 this, SLOT(slotSortingChanged(DolphinView::Sorting
)));
1524 connect(view
, SIGNAL(sortOrderChanged(Qt::SortOrder
)),
1525 this, SLOT(slotSortOrderChanged(Qt::SortOrder
)));
1526 connect(view
, SIGNAL(selectionChanged()),
1527 this, SLOT(slotSelectionChanged()));
1528 connect(view
, SIGNAL(showFilterBarChanged(bool)),
1529 this, SLOT(updateFilterBarAction(bool)));
1531 const UrlNavigator
* navigator
= view
->urlNavigator();
1532 connect(navigator
, SIGNAL(urlChanged(const KUrl
&)),
1533 this, SLOT(slotUrlChanged(const KUrl
&)));
1534 connect(navigator
, SIGNAL(historyChanged()),
1535 this, SLOT(slotHistoryChanged()));
1539 #include "dolphinmainwindow.moc"