X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/197f9a4280d601a7dc145e9eb1dd2ffca6fb8980..328de208710faebaa275e2ef8ddb28a78ea5a2f0:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index fdda8d9e6..61b7bb221 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -16,7 +16,7 @@ * 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" @@ -218,6 +218,7 @@ void DolphinMainWindow::refreshViews() url, props.viewMode(), props.isShowHiddenFilesEnabled()); + connectViewSignals(i); m_view[i]->show(); } } @@ -229,24 +230,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(); @@ -259,13 +242,6 @@ void DolphinMainWindow::slotShowHiddenFilesChanged() showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled()); } -void DolphinMainWindow::slotShowFilterBarChanged() -{ - KToggleAction* showFilterBarAction = - static_cast(actionCollection()->action("show_filter_bar")); - showFilterBarAction->setChecked(m_activeView->isFilterBarVisible()); -} - void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting) { QAction* action = 0; @@ -314,17 +290,36 @@ void DolphinMainWindow::slotSelectionChanged() emit selectionChanged(); } -void DolphinMainWindow::slotRedo() +void DolphinMainWindow::slotHistoryChanged() +{ + updateHistory(); +} + +void DolphinMainWindow::slotUrlChanged(const KUrl& url) +{ + updateEditActions(); + updateGoActions(); + setCaption(url.fileName()); +} + +void DolphinMainWindow::updateFilterBarAction(bool show) +{ + KToggleAction* showFilterBarAction = + static_cast(actionCollection()->action("show_filter_bar")); + showFilterBarAction->setChecked(show); +} + +void DolphinMainWindow::redo() { UndoManager::instance().redo(this); } -void DolphinMainWindow::slotUndo() +void DolphinMainWindow::undo() { UndoManager::instance().undo(this); } -void DolphinMainWindow::slotNewMainWindow() +void DolphinMainWindow::openNewMainWindow() { DolphinApplication::app()->createMainWindow()->show(); } @@ -361,14 +356,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(); @@ -463,7 +458,7 @@ void DolphinMainWindow::createFile() bool found = false; CreateFileEntry entry; while (!found && (it != end)) { - if ((*it).index() == senderName) { + if ((*it).key() == senderName) { entry = (*it).value(); found = true; } @@ -480,7 +475,7 @@ 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"); @@ -490,7 +485,7 @@ void DolphinMainWindow::createFile() 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"). @@ -725,7 +720,7 @@ void DolphinMainWindow::updatePasteAction() QString text(i18n("Paste")); QClipboard* clipboard = QApplication::clipboard(); - QMimeSource* data = clipboard->data(); + const QMimeData* data = clipboard->mimeData(); /* KDE4-TODO: if (KUrlDrag::canDecode(data)) { pasteAction->setEnabled(true); @@ -819,12 +814,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()); + connectViewSignals(SecondaryIdx); + m_splitter->addWidget(m_view[SecondaryIdx]); + m_splitter->setSizes(QList() << newWidth << newWidth); m_view[SecondaryIdx]->show(); } else { @@ -841,7 +840,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]); @@ -1057,7 +1056,7 @@ void DolphinMainWindow::addUndoOperation(KJob* job) while (sourceIt != sourceEnd) { QMap::ConstIterator metaIt = metaData.find("trashUrl-" + (*sourceIt).path()); if (metaIt != metaData.end()) { - newSourceUrls.append(KUrl(metaIt.data())); + newSourceUrls.append(KUrl(metaIt.value())); } ++sourceIt; } @@ -1122,6 +1121,8 @@ void DolphinMainWindow::init() homeUrl, props.viewMode(), props.isShowHiddenFilesEnabled()); + connectViewSignals(PrimaryIdx); + m_view[PrimaryIdx]->show(); m_activeView = m_view[PrimaryIdx]; @@ -1167,7 +1168,7 @@ 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())); + connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow())); KAction* createFolder = new KAction(i18n("Folder..."), actionCollection(), "create_folder"); createFolder->setIcon(KIcon("folder")); @@ -1197,7 +1198,7 @@ void DolphinMainWindow::setupActions() // setup 'Edit' menu UndoManager& undoManager = UndoManager::instance(); KStdAction::undo(this, - SLOT(slotUndo()), + SLOT(undo()), actionCollection()); connect(&undoManager, SIGNAL(undoAvailable(bool)), this, SLOT(slotUndoAvailable(bool))); @@ -1205,7 +1206,7 @@ void DolphinMainWindow::setupActions() this, SLOT(slotUndoTextChanged(const QString&))); KStdAction::redo(this, - SLOT(slotRedo()), + SLOT(redo()), actionCollection()); connect(&undoManager, SIGNAL(redoAvailable(bool)), this, SLOT(slotRedoAvailable(bool))); @@ -1329,6 +1330,31 @@ void DolphinMainWindow::setupActions() KStdAction::preferences(this, SLOT(editSettings()), actionCollection()); } +void DolphinMainWindow::setupDockWidgets() +{ + QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts")); + + shortcutsDock->setObjectName("shortcutsDock"); + shortcutsDock->setWidget(new BookmarksSidebarPage(this)); + + shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_pane"); + shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel")); + actionCollection()->insert(shortcutsDock->toggleViewAction()); + + addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock); + + QDockWidget *infoDock = new QDockWidget(i18n("Information")); + + infoDock->setObjectName("infoDock"); + infoDock->setWidget(new InfoSidebarPage(this)); + + infoDock->toggleViewAction()->setObjectName("show_info_pane"); + infoDock->toggleViewAction()->setText(i18n("Show Information Panel")); + actionCollection()->insert(infoDock->toggleViewAction()); + + addDockWidget(Qt::RightDockWidgetArea, infoDock); +} + void DolphinMainWindow::setupCreateNewMenuActions() { // Parts of the following code have been taken @@ -1590,29 +1616,28 @@ void DolphinMainWindow::clearStatusBar() m_activeView->statusBar()->clear(); } -void DolphinMainWindow::setupDockWidgets() -{ - QDockWidget *shortcutsDock = new QDockWidget(i18n("Shortcuts")); - - shortcutsDock->setObjectName("shortcutsDock"); - shortcutsDock->setWidget(new BookmarksSidebarPage(this)); - - shortcutsDock->toggleViewAction()->setObjectName("show_shortcuts_pane"); - shortcutsDock->toggleViewAction()->setText(i18n("Show Shortcuts Panel")); - actionCollection()->insert(shortcutsDock->toggleViewAction()); - - 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->setWidget(new InfoSidebarPage(this)); - - infoDock->toggleViewAction()->setObjectName("show_info_pane"); - infoDock->toggleViewAction()->setText(i18n("Show Information Panel")); - actionCollection()->insert(infoDock->toggleViewAction()); - - addDockWidget(Qt::RightDockWidgetArea, infoDock); } #include "dolphinmainwindow.moc"