#include <kfiledialog.h>
#include <kconfig.h>
#include <kurl.h>
-#include <kstdaccel.h>
#include <kaction.h>
-#include <kstdaction.h>
+#include <kstandardaction.h>
#include <kmenu.h>
-#include <kio/renamedlg.h>
+#include <kio/renamedialog.h>
#include <kinputdialog.h>
#include <kshell.h>
#include <kdesktopfile.h>
#include <kstandarddirs.h>
#include <krun.h>
#include <klocale.h>
+#include <konqmimedata.h>
#include <qclipboard.h>
#include <q3dragobject.h>
DolphinMainWindow::DolphinMainWindow() :
KMainWindow(0),
m_splitter(0),
- m_activeView(0),
- m_clipboardContainsCutData(false)
+ m_activeView(0)
{
setObjectName("Dolphin");
m_view[PrimaryIdx] = 0;
m_view[SecondaryIdx] = 0;
-
- m_fileGroupActions.setAutoDelete(true);
-
- // TODO: the following members are not used yet. See documentation
- // of DolphinMainWindow::linkGroupActions() and DolphinMainWindow::linkToDeviceActions()
- // in the header file for details.
- //m_linkGroupActions.setAutoDelete(true);
- //m_linkToDeviceActions.setAutoDelete(true);
}
DolphinMainWindow::~DolphinMainWindow()
{
- /*
- * bye, bye managed window
- */
- DolphinApplication::app()->removeMainWindow( this );
+ qDeleteAll(m_fileGroupActions);
+ m_fileGroupActions.clear();
+
+ DolphinApplication::app()->removeMainWindow(this);
}
void DolphinMainWindow::setActiveView(DolphinView* view)
m_splitter,
url,
props.viewMode(),
- props.isShowHiddenFilesEnabled());
+ props.showHiddenFiles());
connectViewSignals(i);
m_view[i]->show();
}
{
KToggleAction* showHiddenFilesAction =
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
- showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled());
+ showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
}
void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
{
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();
if (baseUrl.isLocalFile() && QFileInfo(baseUrl.path(KUrl::AddTrailingSlash) + name).exists()) {
- name = KIO::RenameDlg::suggestName(baseUrl, i18n("New Folder"));
+ name = KIO::RenameDialog::suggestName(baseUrl, i18n("New Folder"));
}
bool ok = false;
bool found = false;
CreateFileEntry entry;
while (!found && (it != end)) {
- if ((*it).index() == senderName) {
+ if ((*it).key() == senderName) {
entry = (*it).value();
found = true;
}
// 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");
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").
const bool fileExists = viewUrl.isLocalFile() &&
QFileInfo(viewUrl.path(KUrl::AddTrailingSlash) + KIO::encodeFileName(name)).exists();
if (fileExists) {
- name = KIO::RenameDlg::suggestName(viewUrl, name);
+ name = KIO::RenameDialog::suggestName(viewUrl, name);
}
// let the user change the suggested file name
const bool del = KMessageBox::warningContinueCancel(this,
text,
QString::null,
- KGuiItem(i18n("Delete"), SmallIcon("editdelete"))
+ KGuiItem(i18n("Delete"), KIcon("editdelete"))
) == KMessageBox::Continue;
if (del) {
KIO::Job* job = KIO::del(list);
void DolphinMainWindow::slotUndoAvailable(bool available)
{
- QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
if (undoAction != 0) {
undoAction->setEnabled(available);
}
void DolphinMainWindow::slotUndoTextChanged(const QString& text)
{
- QAction* undoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Undo));
+ QAction* undoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Undo));
if (undoAction != 0) {
undoAction->setText(text);
}
void DolphinMainWindow::slotRedoAvailable(bool available)
{
- QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
+ QAction* redoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Redo));
if (redoAction != 0) {
redoAction->setEnabled(available);
}
void DolphinMainWindow::slotRedoTextChanged(const QString& text)
{
- QAction* redoAction = actionCollection()->action(KStdAction::stdName(KStdAction::Redo));
+ QAction* redoAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Redo));
if (redoAction != 0) {
redoAction->setText(text);
}
void DolphinMainWindow::cut()
{
- // TODO: this boolean doesn't work between instances of dolphin or with konqueror or with other
- // apps. The "application/x-kde-cutselection" mimetype should be used instead, see KonqMimeData
- // in libkonq
- m_clipboardContainsCutData = true;
- /* KDE4-TODO: Q3DragObject* data = new KUrlDrag(m_activeView->selectedUrls(),
- widget());
- QApplication::clipboard()->setData(data);*/
+ QMimeData* mimeData = new QMimeData();
+ const KUrl::List kdeUrls = m_activeView->selectedUrls();
+ const KUrl::List mostLocalUrls;
+ KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true);
+ QApplication::clipboard()->setMimeData(mimeData);
}
void DolphinMainWindow::copy()
{
- m_clipboardContainsCutData = false;
- /* KDE4-TODO:
- Q3DragObject* data = new KUrlDrag(m_activeView->selectedUrls(),
- widget());
- QApplication::clipboard()->setData(data);*/
+ QMimeData* mimeData = new QMimeData();
+ const KUrl::List kdeUrls = m_activeView->selectedUrls();
+ const KUrl::List mostLocalUrls;
+ KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false);
+
+ QApplication::clipboard()->setMimeData(mimeData);
}
void DolphinMainWindow::paste()
{
- /* KDE4-TODO: - see KonqOperations::doPaste
QClipboard* clipboard = QApplication::clipboard();
- QMimeSource* data = clipboard->data();
- if (!KUrlDrag::canDecode(data)) {
- return;
- }
+ const QMimeData* mimeData = clipboard->mimeData();
clearStatusBar();
- KUrl::List sourceUrls;
- KUrlDrag::decode(data, sourceUrls);
+ const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
// per default the pasting is done into the current Url of the view
KUrl destUrl(m_activeView->url());
}
}
-
- updateViewProperties(sourceUrls);
- if (m_clipboardContainsCutData) {
+ if (KonqMimeData::decodeIsCutSelection(mimeData)) {
moveUrls(sourceUrls, destUrl);
- m_clipboardContainsCutData = false;
clipboard->clear();
}
else {
copyUrls(sourceUrls, destUrl);
- }*/
+ }
}
void DolphinMainWindow::updatePasteAction()
{
- QAction* pasteAction = actionCollection()->action(KStdAction::stdName(KStdAction::Paste));
+ QAction* pasteAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Paste));
if (pasteAction == 0) {
return;
}
QString text(i18n("Paste"));
QClipboard* clipboard = QApplication::clipboard();
- QMimeSource* data = clipboard->data();
- /* KDE4-TODO:
- if (KUrlDrag::canDecode(data)) {
+ const QMimeData* mimeData = clipboard->mimeData();
+
+ KUrl::List urls = KUrl::List::fromMimeData(mimeData);
+ if (!urls.isEmpty()) {
pasteAction->setEnabled(true);
- KUrl::List urls;
- KUrlDrag::decode(data, urls);
const int count = urls.count();
if (count == 1) {
pasteAction->setText(i18n("Paste 1 File"));
pasteAction->setText(i18n("Paste %1 Files").arg(count));
}
}
- else {*/
+ else {
pasteAction->setEnabled(false);
pasteAction->setText(i18n("Paste"));
- //}
+ }
if (pasteAction->isEnabled()) {
KUrl::List urls = m_activeView->selectedUrls();
m_activeView->setMode(DolphinView::DetailsView);
}
-void DolphinMainWindow::setPreviewsView()
-{
- m_activeView->setMode(DolphinView::PreviewsView);
-}
-
void DolphinMainWindow::sortByName()
{
m_activeView->setSorting(DolphinView::SortByName);
0,
m_view[PrimaryIdx]->url(),
m_view[PrimaryIdx]->mode(),
- m_view[PrimaryIdx]->isShowHiddenFilesEnabled());
+ m_view[PrimaryIdx]->showHiddenFiles());
connectViewSignals(SecondaryIdx);
m_splitter->addWidget(m_view[SecondaryIdx]);
m_splitter->setSizes(QList<int>() << newWidth << newWidth);
{
}
-void DolphinMainWindow::showHiddenFiles()
+void DolphinMainWindow::togglePreview()
+{
+ clearStatusBar();
+
+ const KToggleAction* showPreviewAction =
+ static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
+ const bool show = showPreviewAction->isChecked();
+ m_activeView->setShowPreview(show);
+}
+
+void DolphinMainWindow::toggleShowHiddenFiles()
{
clearStatusBar();
const KToggleAction* showHiddenFilesAction =
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
const bool show = showHiddenFilesAction->isChecked();
- m_activeView->setShowHiddenFilesEnabled(show);
+ m_activeView->setShowHiddenFiles(show);
}
void DolphinMainWindow::showFilterBar()
while (sourceIt != sourceEnd) {
QMap<QString, QString>::ConstIterator metaIt = metaData.find("trashUrl-" + (*sourceIt).path());
if (metaIt != metaData.end()) {
- newSourceUrls.append(KUrl(metaIt.data()));
+ newSourceUrls.append(KUrl(metaIt.value()));
}
++sourceIt;
}
m_splitter,
homeUrl,
props.viewMode(),
- props.isShowHiddenFilesEnabled());
+ props.showHiddenFiles());
connectViewSignals(PrimaryIdx);
m_view[PrimaryIdx]->show();
properties->setShortcut(Qt::Key_Alt | Qt::Key_Return);
connect(properties, SIGNAL(triggered()), this, SLOT(properties()));
- KStdAction::quit(this, SLOT(quit()), actionCollection());
+ KStandardAction::quit(this, SLOT(quit()), actionCollection());
// setup 'Edit' menu
UndoManager& undoManager = UndoManager::instance();
- KStdAction::undo(this,
+ KStandardAction::undo(this,
SLOT(undo()),
actionCollection());
connect(&undoManager, SIGNAL(undoAvailable(bool)),
connect(&undoManager, SIGNAL(undoTextChanged(const QString&)),
this, SLOT(slotUndoTextChanged(const QString&)));
- KStdAction::redo(this,
+ KStandardAction::redo(this,
SLOT(redo()),
actionCollection());
connect(&undoManager, SIGNAL(redoAvailable(bool)),
connect(&undoManager, SIGNAL(redoTextChanged(const QString&)),
this, SLOT(slotRedoTextChanged(const QString&)));
- KStdAction::cut(this, SLOT(cut()), actionCollection());
- KStdAction::copy(this, SLOT(copy()), actionCollection());
- KStdAction::paste(this, SLOT(paste()), actionCollection());
+ KStandardAction::cut(this, SLOT(cut()), actionCollection());
+ KStandardAction::copy(this, SLOT(copy()), actionCollection());
+ KStandardAction::paste(this, SLOT(paste()), actionCollection());
KAction* selectAll = new KAction(i18n("Select All"), actionCollection(), "select_all");
selectAll->setShortcut(Qt::CTRL + Qt::Key_A);
connect(invertSelection, SIGNAL(triggered()), this, SLOT(invertSelection()));
// setup 'View' menu
- KStdAction::zoomIn(this,
+ KStandardAction::zoomIn(this,
SLOT(zoomIn()),
actionCollection());
- KStdAction::zoomOut(this,
+ KStandardAction::zoomOut(this,
SLOT(zoomOut()),
actionCollection());
detailsView->setIcon(KIcon("view_text"));
connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView()));
- KToggleAction* previewsView = new KToggleAction(i18n("Previews"), actionCollection(), "previews");
- previewsView->setShortcut(Qt::CTRL | Qt::Key_3);
- previewsView->setIcon(KIcon("gvdirpart"));
- connect(previewsView, SIGNAL(triggered()), this, SLOT(setPreviewsView()));
-
QActionGroup* viewModeGroup = new QActionGroup(this);
viewModeGroup->addAction(iconsView);
viewModeGroup->addAction(detailsView);
- viewModeGroup->addAction(previewsView);
KToggleAction* sortByName = new KToggleAction(i18n("By Name"), actionCollection(), "by_name");
connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
KToggleAction* sortDescending = new KToggleAction(i18n("Descending"), actionCollection(), "descending");
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
+ KToggleAction* showPreview = new KToggleAction(i18n("Show Preview"), actionCollection(), "show_preview");
+ connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
+
KToggleAction* showHiddenFiles = new KToggleAction(i18n("Show Hidden Files"), actionCollection(), "show_hidden_files");
//showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_ KDE4-TODO: what Qt-Key represents '.'?
- connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(showHiddenFiles()));
+ connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
KToggleAction* split = new KToggleAction(i18n("Split View"), actionCollection(), "split_view");
split->setShortcut(Qt::Key_F10);
split->setIcon(KIcon("view_left_right"));
connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
- KAction* reload = new KAction(i18n("Reload"), "F5", actionCollection(), "reload");
+ KAction* reload = new KAction(actionCollection(), "reload");
+ reload->setText(i18n("Reload"));
reload->setShortcut(Qt::Key_F5);
reload->setIcon(KIcon("reload"));
connect(reload, SIGNAL(triggered()), this, SLOT(reloadView()));
connect(adjustViewProps, SIGNAL(triggered()), this, SLOT(adjustViewProperties()));
// setup 'Go' menu
- KStdAction::back(this, SLOT(goBack()), actionCollection());
- KStdAction::forward(this, SLOT(goForward()), actionCollection());
- KStdAction::up(this, SLOT(goUp()), actionCollection());
- KStdAction::home(this, SLOT(goHome()), actionCollection());
+ KStandardAction::back(this, SLOT(goBack()), actionCollection());
+ KStandardAction::forward(this, SLOT(goForward()), actionCollection());
+ KStandardAction::up(this, SLOT(goUp()), actionCollection());
+ KStandardAction::home(this, SLOT(goHome()), actionCollection());
// setup 'Tools' menu
KAction* openTerminal = new KAction(i18n("Open Terminal"), actionCollection(), "open_terminal");
connect(compareFiles, SIGNAL(triggered()), this, SLOT(compareFiles()));
// setup 'Settings' menu
- KStdAction::preferences(this, SLOT(editSettings()), actionCollection());
+ KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
}
void DolphinMainWindow::setupDockWidgets()
void DolphinMainWindow::updateViewActions()
{
- QAction* zoomInAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomIn));
+ QAction* zoomInAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomIn));
if (zoomInAction != 0) {
zoomInAction->setEnabled(m_activeView->isZoomInPossible());
}
- QAction* zoomOutAction = actionCollection()->action(KStdAction::stdName(KStdAction::ZoomOut));
+ QAction* zoomOutAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::ZoomOut));
if (zoomOutAction != 0) {
zoomOutAction->setEnabled(m_activeView->isZoomOutPossible());
}
case DolphinView::DetailsView:
action = actionCollection()->action("details");
break;
- case DolphinView::PreviewsView:
- action = actionCollection()->action("previews");
- break;
+ //case DolphinView::PreviewsView:
+ // action = actionCollection()->action("previews");
+ // break;
default:
break;
}
KToggleAction* showHiddenFilesAction =
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
- showHiddenFilesAction->setChecked(m_activeView->isShowHiddenFilesEnabled());
+ showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles());
KToggleAction* splitAction = static_cast<KToggleAction*>(actionCollection()->action("split_view"));
splitAction->setChecked(m_view[SecondaryIdx] != 0);
void DolphinMainWindow::updateGoActions()
{
- QAction* goUpAction = actionCollection()->action(KStdAction::stdName(KStdAction::Up));
+ QAction* goUpAction = actionCollection()->action(KStandardAction::stdName(KStandardAction::Up));
const KUrl& currentUrl = m_activeView->url();
goUpAction->setEnabled(currentUrl.upUrl() != currentUrl);
}
}
void DolphinMainWindow::addPendingUndoJob(KIO::Job* job,
- DolphinCommand::Type commandType,
- const KUrl::List& source,
- const KUrl& dest)
+ DolphinCommand::Type commandType,
+ const KUrl::List& source,
+ const KUrl& dest)
{
connect(job, SIGNAL(result(KJob*)),
this, SLOT(addUndoOperation(KJob*)));