#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();
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 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::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()
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()
+{
+}
+
+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();
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()));
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::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*)));