2005-05-12 12:15:44 +00:00
|
|
|
// -*- indent-tabs-mode:nil -*-
|
2003-10-06 18:29:56 +00:00
|
|
|
// vim: set ts=4 sts=4 sw=4 et:
|
2003-01-21 16:16:53 +00:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
Copyright (C) 2000 David Faure <faure@kde.org>
|
|
|
|
Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License version 2 as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2003-10-06 18:29:56 +00:00
|
|
|
General Public License for more details.
|
2003-01-21 16:16:53 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
2005-07-04 19:02:09 +00:00
|
|
|
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
2003-01-21 16:16:53 +00:00
|
|
|
*/
|
|
|
|
|
2003-09-14 18:07:31 +00:00
|
|
|
#include "actionsimpl.h"
|
|
|
|
|
|
|
|
#include "toplevel.h"
|
|
|
|
#include "commands.h"
|
|
|
|
#include "importers.h"
|
|
|
|
#include "favicons.h"
|
|
|
|
#include "testlink.h"
|
|
|
|
#include "exporters.h"
|
2005-06-15 14:41:18 +00:00
|
|
|
#include "bookmarkinfo.h"
|
2003-09-14 18:07:31 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <qclipboard.h>
|
|
|
|
#include <qpainter.h>
|
|
|
|
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <dcopclient.h>
|
2003-08-28 18:27:21 +00:00
|
|
|
#include <dcopref.h>
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kapplication.h>
|
|
|
|
|
|
|
|
#include <kaction.h>
|
|
|
|
#include <kstdaction.h>
|
|
|
|
#include <kedittoolbar.h>
|
|
|
|
#include <kfiledialog.h>
|
|
|
|
#include <kkeydialog.h>
|
|
|
|
#include <kmessagebox.h>
|
2003-06-08 14:44:34 +00:00
|
|
|
#include <kinputdialog.h>
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <krun.h>
|
|
|
|
|
2003-08-28 19:09:57 +00:00
|
|
|
#include <kdatastream.h>
|
|
|
|
#include <ktempfile.h>
|
2004-11-10 19:55:57 +00:00
|
|
|
#include <kstandarddirs.h>
|
2003-08-28 19:09:57 +00:00
|
|
|
|
|
|
|
#include <kparts/part.h>
|
|
|
|
#include <kparts/componentfactory.h>
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <kicondialog.h>
|
|
|
|
#include <kiconloader.h>
|
|
|
|
|
|
|
|
#include <kbookmarkdrag.h>
|
|
|
|
#include <kbookmarkmanager.h>
|
|
|
|
#include <kbookmarkimporter.h>
|
|
|
|
|
2003-09-14 18:07:31 +00:00
|
|
|
#include <kbookmarkimporter_ie.h>
|
|
|
|
#include <kbookmarkimporter_opera.h>
|
|
|
|
#include <kbookmarkexporter.h>
|
2003-01-22 17:58:59 +00:00
|
|
|
|
|
|
|
ActionsImpl* ActionsImpl::s_self = 0;
|
|
|
|
|
2004-03-31 08:49:19 +00:00
|
|
|
// decoupled from resetActions in toplevel.cpp
|
|
|
|
// as resetActions simply uses the action groups
|
2003-09-14 17:28:52 +00:00
|
|
|
// specified in the ui.rc file
|
|
|
|
void KEBApp::createActions() {
|
|
|
|
|
2003-10-06 18:29:56 +00:00
|
|
|
ActionsImpl *actn = ActionsImpl::self();
|
|
|
|
|
|
|
|
// save and quit should probably not be in the toplevel???
|
|
|
|
(void) KStdAction::quit(
|
|
|
|
this, SLOT( close() ), actionCollection());
|
2005-06-15 14:41:18 +00:00
|
|
|
KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), actionCollection());
|
2003-10-06 18:29:56 +00:00
|
|
|
(void) KStdAction::configureToolbars(
|
|
|
|
this, SLOT( slotConfigureToolbars() ), actionCollection());
|
|
|
|
|
|
|
|
if (m_browser) {
|
|
|
|
(void) KStdAction::open(
|
|
|
|
actn, SLOT( slotLoad() ), actionCollection());
|
|
|
|
(void) KStdAction::saveAs(
|
|
|
|
actn, SLOT( slotSaveAs() ), actionCollection());
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) KStdAction::cut(actn, SLOT( slotCut() ), actionCollection());
|
|
|
|
(void) KStdAction::copy(actn, SLOT( slotCopy() ), actionCollection());
|
|
|
|
(void) KStdAction::paste(actn, SLOT( slotPaste() ), actionCollection());
|
|
|
|
(void) KStdAction::print(actn, SLOT( slotPrint() ), actionCollection());
|
|
|
|
|
|
|
|
// settings menu
|
|
|
|
(void) new KToggleAction(
|
2004-03-31 08:49:19 +00:00
|
|
|
i18n("&Show Netscape Bookmarks in Konqueror"), 0,
|
|
|
|
actn, SLOT( slotShowNS() ), actionCollection(),
|
2003-10-06 18:29:56 +00:00
|
|
|
"settings_showNS");
|
|
|
|
|
|
|
|
// actions
|
|
|
|
(void) new KAction(
|
2005-07-28 14:59:42 +00:00
|
|
|
i18n("&Delete"), "editdelete", Qt::Key_Delete,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotDelete() ), actionCollection(), "delete");
|
|
|
|
(void) new KAction(
|
2005-07-28 14:59:42 +00:00
|
|
|
i18n("Rename"), "text", Qt::Key_F2,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotRename() ), actionCollection(), "rename");
|
|
|
|
(void) new KAction(
|
2005-07-28 14:59:42 +00:00
|
|
|
i18n("C&hange URL"), "text", Qt::Key_F3,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotChangeURL() ), actionCollection(), "changeurl");
|
|
|
|
(void) new KAction(
|
2005-07-28 14:59:42 +00:00
|
|
|
i18n("C&hange Comment"), "text", Qt::Key_F4,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotChangeComment() ), actionCollection(), "changecomment");
|
|
|
|
(void) new KAction(
|
2005-02-19 23:19:52 +00:00
|
|
|
i18n("Chan&ge Icon..."), "icons", 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotChangeIcon() ), actionCollection(), "changeicon");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Update Favicon"), 0,
|
|
|
|
actn, SLOT( slotUpdateFavIcon() ), actionCollection(), "updatefavicon");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Recursive Sort"), 0,
|
|
|
|
actn, SLOT( slotRecursiveSort() ), actionCollection(), "recursivesort");
|
|
|
|
(void) new KAction(
|
2005-08-06 19:41:55 +00:00
|
|
|
i18n("&New Folder..."), "folder_new", Qt::CTRL+Qt::Key_N,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotNewFolder() ), actionCollection(), "newfolder");
|
|
|
|
(void) new KAction(
|
2005-01-19 03:50:47 +00:00
|
|
|
i18n("&New Bookmark"), "www", 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotNewBookmark() ), actionCollection(), "newbookmark");
|
|
|
|
(void) new KAction(
|
2005-08-06 19:41:55 +00:00
|
|
|
i18n("&Insert Separator"), Qt::CTRL+Qt::Key_I,
|
2004-03-31 08:49:19 +00:00
|
|
|
actn, SLOT( slotInsertSeparator() ), actionCollection(),
|
2003-10-06 18:29:56 +00:00
|
|
|
"insertseparator");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("&Sort Alphabetically"), 0,
|
|
|
|
actn, SLOT( slotSort() ), actionCollection(), "sort");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Set as T&oolbar Folder"), "bookmark_toolbar", 0,
|
|
|
|
actn, SLOT( slotSetAsToolbar() ), actionCollection(), "setastoolbar");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("&Expand All Folders"), 0,
|
|
|
|
actn, SLOT( slotExpandAll() ), actionCollection(), "expandall");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Collapse &All Folders"), 0,
|
|
|
|
actn, SLOT( slotCollapseAll() ), actionCollection(), "collapseall" );
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("&Open in Konqueror"), "fileopen", 0,
|
|
|
|
actn, SLOT( slotOpenLink() ), actionCollection(), "openlink" );
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Check &Status"), "bookmark", 0,
|
|
|
|
actn, SLOT( slotTestSelection() ), actionCollection(), "testlink" );
|
|
|
|
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Check Status: &All"), 0,
|
|
|
|
actn, SLOT( slotTestAll() ), actionCollection(), "testall" );
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Update All &Favicons"), 0,
|
2004-03-31 08:49:19 +00:00
|
|
|
actn, SLOT( slotUpdateAllFavIcons() ), actionCollection(),
|
2003-10-06 18:29:56 +00:00
|
|
|
"updateallfavicons" );
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Cancel &Checks"), 0,
|
|
|
|
actn, SLOT( slotCancelAllTests() ), actionCollection(), "canceltests" );
|
|
|
|
(void) new KAction(
|
2003-10-06 18:34:44 +00:00
|
|
|
i18n("Cancel &Favicon Updates"), 0,
|
2004-03-31 08:49:19 +00:00
|
|
|
actn, SLOT( slotCancelFavIconUpdates() ), actionCollection(),
|
2003-10-06 18:29:56 +00:00
|
|
|
"cancelfaviconupdates" );
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Import &Netscape Bookmarks..."), "netscape", 0,
|
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importNS");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Import &Opera Bookmarks..."), "opera", 0,
|
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importOpera");
|
|
|
|
(void) new KAction(
|
2005-05-12 19:31:23 +00:00
|
|
|
i18n("Import All &Crash Sessions as Bookmarks..."), 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importCrashes");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Import &Galeon Bookmarks..."), 0,
|
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importGaleon");
|
|
|
|
(void) new KAction(
|
2005-06-27 15:43:40 +00:00
|
|
|
i18n("Import &KDE2/KDE3 Bookmarks..."), 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importKDE2");
|
|
|
|
(void) new KAction(
|
2005-05-12 19:31:23 +00:00
|
|
|
i18n("Import &IE Bookmarks..."), 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importIE");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Import &Mozilla Bookmarks..."), "mozilla", 0,
|
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importMoz");
|
|
|
|
(void) new KAction(
|
2005-05-12 19:31:23 +00:00
|
|
|
i18n("Export to &Netscape Bookmarks"), "netscape", 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotExportNS() ), actionCollection(), "exportNS");
|
|
|
|
(void) new KAction(
|
2005-05-12 19:31:23 +00:00
|
|
|
i18n("Export to &Opera Bookmarks..."), "opera", 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotExportOpera() ), actionCollection(), "exportOpera");
|
|
|
|
(void) new KAction(
|
2005-05-12 19:31:23 +00:00
|
|
|
i18n("Export to &HTML Bookmarks..."), "html", 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotExportHTML() ), actionCollection(), "exportHTML");
|
|
|
|
(void) new KAction(
|
2005-05-12 19:31:23 +00:00
|
|
|
i18n("Export to &IE Bookmarks..."), 0,
|
2003-10-06 18:29:56 +00:00
|
|
|
actn, SLOT( slotExportIE() ), actionCollection(), "exportIE");
|
|
|
|
(void) new KAction(
|
|
|
|
i18n("Export to &Mozilla Bookmarks..."), "mozilla", 0,
|
|
|
|
actn, SLOT( slotExportMoz() ), actionCollection(), "exportMoz");
|
2003-09-14 17:28:52 +00:00
|
|
|
}
|
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotLoad()
|
|
|
|
{
|
2004-03-31 08:49:19 +00:00
|
|
|
QString bookmarksFile
|
2003-10-06 18:29:56 +00:00
|
|
|
= KFileDialog::getOpenFileName(QString::null, "*.xml", KEBApp::self());
|
|
|
|
if (bookmarksFile.isNull())
|
|
|
|
return;
|
2005-08-13 20:13:21 +00:00
|
|
|
KEBApp::self()->reset(QString::null, bookmarksFile);
|
2003-09-14 17:28:52 +00:00
|
|
|
}
|
|
|
|
|
2003-09-14 20:17:45 +00:00
|
|
|
void ActionsImpl::slotSaveAs() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2004-03-31 08:49:19 +00:00
|
|
|
QString saveFilename
|
2003-10-06 18:29:56 +00:00
|
|
|
= KFileDialog::getSaveFileName(QString::null, "*.xml", KEBApp::self());
|
|
|
|
if (!saveFilename.isEmpty())
|
|
|
|
CurrentMgr::self()->saveAs(saveFilename);
|
2003-09-14 17:28:52 +00:00
|
|
|
}
|
|
|
|
|
2003-09-25 17:25:53 +00:00
|
|
|
void CurrentMgr::doExport(ExportType type, const QString & _path) {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
QString path(_path);
|
|
|
|
// TODO - add a factory and make all this use the base class
|
|
|
|
if (type == OperaExport) {
|
|
|
|
if (path.isNull())
|
|
|
|
path = KOperaBookmarkImporterImpl().findDefaultLocation(true);
|
|
|
|
KOperaBookmarkExporterImpl exporter(mgr(), path);
|
|
|
|
exporter.write(mgr()->root());
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (type == HTMLExport) {
|
|
|
|
if (path.isNull())
|
2004-03-31 08:49:19 +00:00
|
|
|
path = KFileDialog::getSaveFileName(
|
2005-09-25 14:49:01 +00:00
|
|
|
QDir::homePath(),
|
2003-10-06 18:29:56 +00:00
|
|
|
i18n("*.html|HTML Bookmark Listing") );
|
|
|
|
HTMLExporter exporter;
|
|
|
|
exporter.write(mgr()->root(), path);
|
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (type == IEExport) {
|
|
|
|
if (path.isNull())
|
|
|
|
path = KIEBookmarkImporterImpl().findDefaultLocation(true);
|
|
|
|
KIEBookmarkExporterImpl exporter(mgr(), path);
|
|
|
|
exporter.write(mgr()->root());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool moz = (type == MozillaExport);
|
|
|
|
|
|
|
|
if (path.isNull())
|
|
|
|
path = (moz) ? KNSBookmarkImporter::mozillaBookmarksFile(true)
|
|
|
|
: KNSBookmarkImporter::netscapeBookmarksFile(true);
|
|
|
|
|
|
|
|
if (!path.isEmpty()) {
|
|
|
|
KNSBookmarkExporter exporter(mgr(), path);
|
|
|
|
exporter.write(moz);
|
|
|
|
}
|
2003-09-14 17:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KEBApp::setActionsEnabled(SelcAbilities sa) {
|
2003-10-06 18:29:56 +00:00
|
|
|
KActionCollection * coll = actionCollection();
|
|
|
|
|
|
|
|
QStringList toEnable;
|
2004-03-31 08:49:19 +00:00
|
|
|
|
2005-07-05 22:31:08 +00:00
|
|
|
if (sa.multiSelect || (sa.singleSelect && !sa.root))
|
2003-10-06 18:29:56 +00:00
|
|
|
toEnable << "edit_copy";
|
2005-07-05 22:31:08 +00:00
|
|
|
|
|
|
|
if (sa.multiSelect || (sa.singleSelect && !sa.root && !sa.urlIsEmpty && !sa.group && !sa.separator))
|
2003-10-06 18:29:56 +00:00
|
|
|
toEnable << "openlink";
|
|
|
|
|
|
|
|
if (!m_readOnly) {
|
|
|
|
if (sa.notEmpty)
|
|
|
|
toEnable << "testall" << "updateallfavicons";
|
|
|
|
|
2005-07-05 22:31:08 +00:00
|
|
|
if ( sa.multiSelect || (sa.singleSelect && !sa.root) )
|
2003-10-06 18:29:56 +00:00
|
|
|
toEnable << "delete" << "edit_cut";
|
2005-07-05 22:31:08 +00:00
|
|
|
|
|
|
|
if( sa.singleSelect)
|
2003-10-06 18:29:56 +00:00
|
|
|
if (m_canPaste)
|
|
|
|
toEnable << "edit_paste";
|
2005-07-05 22:31:08 +00:00
|
|
|
|
|
|
|
if( sa.multiSelect || (sa.singleSelect && !sa.root && !sa.urlIsEmpty && !sa.group && !sa.separator))
|
|
|
|
toEnable << "testlink" << "updatefavicon";
|
|
|
|
|
2003-10-06 18:29:56 +00:00
|
|
|
if (sa.singleSelect && !sa.root && !sa.separator) {
|
|
|
|
toEnable << "rename" << "changeicon" << "changecomment";
|
|
|
|
if (!sa.group)
|
|
|
|
toEnable << "changeurl";
|
|
|
|
}
|
|
|
|
|
2005-07-05 22:31:08 +00:00
|
|
|
if (sa.singleSelect) {
|
2003-10-19 10:38:10 +00:00
|
|
|
toEnable << "newfolder" << "newbookmark" << "insertseparator";
|
2003-10-06 18:29:56 +00:00
|
|
|
if (sa.group)
|
|
|
|
toEnable << "sort" << "recursivesort" << "setastoolbar";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-31 08:49:19 +00:00
|
|
|
for ( QStringList::Iterator it = toEnable.begin();
|
2003-10-06 18:29:56 +00:00
|
|
|
it != toEnable.end(); ++it )
|
2003-10-19 10:38:10 +00:00
|
|
|
{
|
2005-08-13 20:13:21 +00:00
|
|
|
//kdDebug() <<" enabling action "<<(*it) << endl;
|
2003-10-06 18:29:56 +00:00
|
|
|
coll->action((*it).ascii())->setEnabled(true);
|
2003-10-19 10:38:10 +00:00
|
|
|
}
|
2003-09-14 17:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KEBApp::setCancelFavIconUpdatesEnabled(bool enabled) {
|
2003-10-06 18:29:56 +00:00
|
|
|
actionCollection()->action("cancelfaviconupdates")->setEnabled(enabled);
|
2003-09-14 17:28:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KEBApp::setCancelTestsEnabled(bool enabled) {
|
2003-10-06 18:29:56 +00:00
|
|
|
actionCollection()->action("canceltests")->setEnabled(enabled);
|
2003-09-14 17:28:52 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotCut() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
slotCopy();
|
2005-08-13 20:13:21 +00:00
|
|
|
DeleteManyCommand *mcmd = new DeleteManyCommand( i18n("Cut Items"), KEBApp::self()->selectedBookmarks() );
|
2005-07-14 01:29:14 +00:00
|
|
|
CmdHistory::self()->addCommand(mcmd);
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotCopy()
|
|
|
|
{
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
// this is not a command, because it can't be undone
|
2005-09-28 16:16:52 +00:00
|
|
|
QList<KBookmark> bookmarks = KEBApp::self()->selectedBookmarksExpanded();
|
2005-10-04 20:42:32 +00:00
|
|
|
//FIXME rewrite
|
|
|
|
//KBookmarkDrag* data = KBookmarkDrag::newDrag(bookmarks, 0 /* not this ! */);
|
|
|
|
//kapp->clipboard()->setData(data, QClipboard::Selection);
|
|
|
|
//kapp->clipboard()->setData(data, QClipboard::Clipboard);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotPaste() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
|
|
|
KEBMacroCommand *mcmd =
|
2005-06-18 02:03:05 +00:00
|
|
|
CmdGen::insertMimeSource(
|
2004-03-31 08:49:19 +00:00
|
|
|
i18n("Paste"),
|
|
|
|
kapp->clipboard()->data(QClipboard::Clipboard),
|
2005-08-13 20:13:21 +00:00
|
|
|
KEBApp::self()->firstSelected().address());
|
2003-10-06 18:29:56 +00:00
|
|
|
CmdHistory::self()->didCommand(mcmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------------------- */
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotNewFolder()
|
|
|
|
{
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
bool ok;
|
|
|
|
QString str = KInputDialog::getText( i18n( "Create New Bookmark Folder" ),
|
|
|
|
i18n( "New folder:" ), QString::null, &ok );
|
|
|
|
if (!ok)
|
|
|
|
return;
|
2003-06-08 14:44:34 +00:00
|
|
|
|
2003-10-06 18:29:56 +00:00
|
|
|
CreateCommand *cmd = new CreateCommand(
|
2005-08-13 20:13:21 +00:00
|
|
|
KEBApp::self()->insertAddress(),
|
2003-10-06 18:29:56 +00:00
|
|
|
str, "bookmark_folder", /*open*/ true);
|
|
|
|
CmdHistory::self()->addCommand(cmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotNewBookmark()
|
|
|
|
{
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
// TODO - make a setCurrentItem(Command *) which uses finaladdress interface
|
|
|
|
CreateCommand * cmd = new CreateCommand(
|
2005-08-13 20:13:21 +00:00
|
|
|
KEBApp::self()->insertAddress(),
|
2003-10-06 18:29:56 +00:00
|
|
|
QString::null, "www", KURL("http://"));
|
|
|
|
CmdHistory::self()->addCommand(cmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotInsertSeparator()
|
|
|
|
{
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
CreateCommand * cmd = new CreateCommand(KEBApp::self()->insertAddress());
|
2003-10-06 18:29:56 +00:00
|
|
|
CmdHistory::self()->addCommand(cmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2004-03-31 08:49:19 +00:00
|
|
|
void ActionsImpl::slotImport() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2004-03-31 08:49:19 +00:00
|
|
|
// kdDebug() << "ActionsImpl::slotImport() where sender()->name() == "
|
2003-11-03 10:33:23 +00:00
|
|
|
// << sender()->name() << endl;
|
2004-03-31 08:49:19 +00:00
|
|
|
ImportCommand* import
|
2003-10-06 18:29:56 +00:00
|
|
|
= ImportCommand::performImport(sender()->name()+6, KEBApp::self());
|
|
|
|
if (!import)
|
|
|
|
return;
|
|
|
|
CmdHistory::self()->addCommand(import);
|
2005-08-13 20:13:21 +00:00
|
|
|
//FIXME select import->groupAddress
|
2003-02-05 20:47:35 +00:00
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-06-06 19:10:43 +00:00
|
|
|
// TODO - this is getting ugly and repetitive. cleanup!
|
2003-06-01 18:36:58 +00:00
|
|
|
|
2003-06-06 19:10:43 +00:00
|
|
|
void ActionsImpl::slotExportOpera() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
CurrentMgr::self()->doExport(CurrentMgr::OperaExport); }
|
2003-06-06 19:50:36 +00:00
|
|
|
void ActionsImpl::slotExportHTML() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
CurrentMgr::self()->doExport(CurrentMgr::HTMLExport); }
|
2003-06-06 19:10:43 +00:00
|
|
|
void ActionsImpl::slotExportIE() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
CurrentMgr::self()->doExport(CurrentMgr::IEExport); }
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotExportNS() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
CurrentMgr::self()->doExport(CurrentMgr::NetscapeExport); }
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotExportMoz() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
CurrentMgr::self()->doExport(CurrentMgr::MozillaExport); }
|
2004-03-31 08:49:19 +00:00
|
|
|
|
2003-08-28 18:27:21 +00:00
|
|
|
/* -------------------------------------- */
|
|
|
|
|
2005-09-28 16:21:42 +00:00
|
|
|
static DCOPCString s_appId, s_objId;
|
2003-08-28 19:09:57 +00:00
|
|
|
static KParts::ReadOnlyPart *s_part;
|
2003-08-28 18:27:21 +00:00
|
|
|
|
|
|
|
void ActionsImpl::slotPrint() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
s_part = KParts::ComponentFactory
|
|
|
|
::createPartInstanceFromQuery<KParts::ReadOnlyPart>(
|
|
|
|
"text/html", QString::null);
|
|
|
|
s_part->setProperty("pluginsEnabled", QVariant(false, 1));
|
|
|
|
s_part->setProperty("javaScriptEnabled", QVariant(false, 1));
|
|
|
|
s_part->setProperty("javaEnabled", QVariant(false, 1));
|
2003-08-28 18:27:21 +00:00
|
|
|
|
2003-10-11 13:38:01 +00:00
|
|
|
// doc->openStream( "text/html", KURL() );
|
|
|
|
// doc->writeStream( QCString( "<HTML><BODY>FOO</BODY></HTML>" ) );
|
|
|
|
// doc->closeStream();
|
|
|
|
|
2003-10-06 18:29:56 +00:00
|
|
|
HTMLExporter exporter;
|
|
|
|
KTempFile tmpf(locateLocal("tmp", "print_bookmarks"), ".html");
|
|
|
|
QTextStream *tstream = tmpf.textStream();
|
2003-10-18 17:30:35 +00:00
|
|
|
tstream->setEncoding(QTextStream::Unicode);
|
2005-08-13 20:13:21 +00:00
|
|
|
(*tstream) << exporter.toString(CurrentMgr::self()->root(), true);
|
2003-10-06 18:29:56 +00:00
|
|
|
tmpf.close();
|
2003-08-28 18:27:21 +00:00
|
|
|
|
2003-10-06 18:29:56 +00:00
|
|
|
s_appId = kapp->dcopClient()->appId();
|
|
|
|
s_objId = s_part->property("dcopObjectId").toString().latin1();
|
|
|
|
connect(s_part, SIGNAL(completed()), this, SLOT(slotDelayedPrint()));
|
2003-08-28 19:09:57 +00:00
|
|
|
|
2004-03-13 13:19:02 +00:00
|
|
|
s_part->openURL(KURL( tmpf.name() ));
|
2003-08-28 19:09:57 +00:00
|
|
|
}
|
2003-08-28 18:27:21 +00:00
|
|
|
|
2003-08-28 19:09:57 +00:00
|
|
|
void ActionsImpl::slotDelayedPrint() {
|
2003-10-06 18:29:56 +00:00
|
|
|
Q_ASSERT(s_part);
|
2004-03-31 08:49:19 +00:00
|
|
|
DCOPRef(s_appId, s_objId).send("print", false);
|
2005-06-13 15:16:12 +00:00
|
|
|
delete s_part;
|
2003-10-06 18:29:56 +00:00
|
|
|
s_part = 0;
|
2003-08-28 18:27:21 +00:00
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------------------- */
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotShowNS() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2003-10-06 18:29:56 +00:00
|
|
|
bool shown = KEBApp::self()->nsShown();
|
|
|
|
CurrentMgr::self()->mgr()->setShowNSBookmarks(shown);
|
2003-11-03 10:33:23 +00:00
|
|
|
// TODO - need to force a save here
|
|
|
|
CurrentMgr::self()->reloadConfig();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotCancelFavIconUpdates() {
|
2003-10-06 18:29:56 +00:00
|
|
|
FavIconsItrHolder::self()->cancelAllItrs();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotCancelAllTests() {
|
2003-10-06 18:29:56 +00:00
|
|
|
TestLinkItrHolder::self()->cancelAllItrs();
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotTestAll() {
|
2003-10-06 18:29:56 +00:00
|
|
|
TestLinkItrHolder::self()->insertItr(
|
2005-08-13 20:13:21 +00:00
|
|
|
new TestLinkItr(KEBApp::self()->allBookmarks()));
|
2003-01-22 15:19:31 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotUpdateAllFavIcons() {
|
2003-10-06 18:29:56 +00:00
|
|
|
FavIconsItrHolder::self()->insertItr(
|
2005-08-13 20:13:21 +00:00
|
|
|
new FavIconsItr(KEBApp::self()->allBookmarks()));
|
2003-01-22 15:19:31 +00:00
|
|
|
}
|
|
|
|
|
2003-10-19 17:59:04 +00:00
|
|
|
ActionsImpl::~ActionsImpl() {
|
|
|
|
delete FavIconsItrHolder::self();
|
|
|
|
delete TestLinkItrHolder::self();
|
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------------------- */
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotTestSelection() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
TestLinkItrHolder::self()->insertItr(new TestLinkItr(KEBApp::self()->selectedBookmarksExpanded()));
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotUpdateFavIcon() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
FavIconsItrHolder::self()->insertItr(new FavIconsItr(KEBApp::self()->selectedBookmarksExpanded()));
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------------------- */
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-05-20 20:39:06 +00:00
|
|
|
class KBookmarkGroupList : private KBookmarkGroupTraverser {
|
|
|
|
public:
|
2003-10-06 18:29:56 +00:00
|
|
|
KBookmarkGroupList(KBookmarkManager *);
|
2005-07-28 14:59:42 +00:00
|
|
|
Q3ValueList<KBookmark> getList(const KBookmarkGroup &);
|
2003-05-20 20:39:06 +00:00
|
|
|
private:
|
2003-10-06 18:29:56 +00:00
|
|
|
virtual void visit(const KBookmark &) { ; }
|
|
|
|
virtual void visitEnter(const KBookmarkGroup &);
|
|
|
|
virtual void visitLeave(const KBookmarkGroup &) { ; }
|
2003-05-20 20:39:06 +00:00
|
|
|
private:
|
2003-10-06 18:29:56 +00:00
|
|
|
KBookmarkManager *m_manager;
|
2005-07-28 14:59:42 +00:00
|
|
|
Q3ValueList<KBookmark> m_list;
|
2003-05-20 20:39:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
KBookmarkGroupList::KBookmarkGroupList( KBookmarkManager *manager ) {
|
2003-10-06 18:29:56 +00:00
|
|
|
m_manager = manager;
|
2003-05-20 20:39:06 +00:00
|
|
|
}
|
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
Q3ValueList<KBookmark> KBookmarkGroupList::getList( const KBookmarkGroup &grp ) {
|
2003-10-06 18:29:56 +00:00
|
|
|
traverse(grp);
|
|
|
|
return m_list;
|
2003-05-20 20:39:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KBookmarkGroupList::visitEnter(const KBookmarkGroup &grp) {
|
2003-10-06 18:29:56 +00:00
|
|
|
m_list << grp;
|
2003-05-20 20:39:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionsImpl::slotRecursiveSort() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
KBookmark bk = KEBApp::self()->firstSelected();
|
2003-10-06 18:29:56 +00:00
|
|
|
Q_ASSERT(bk.isGroup());
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBMacroCommand *mcmd = new KEBMacroCommand(i18n("Recursive Sort"));
|
2003-10-06 18:29:56 +00:00
|
|
|
KBookmarkGroupList lister(CurrentMgr::self()->mgr());
|
2005-07-28 14:59:42 +00:00
|
|
|
Q3ValueList<KBookmark> bookmarks = lister.getList(bk.toGroup());
|
2003-10-06 18:29:56 +00:00
|
|
|
bookmarks << bk.toGroup();
|
2005-07-28 14:59:42 +00:00
|
|
|
for (Q3ValueListConstIterator<KBookmark> it = bookmarks.begin(); it != bookmarks.end(); ++it) {
|
2003-10-06 18:29:56 +00:00
|
|
|
SortCommand *cmd = new SortCommand("", (*it).address());
|
|
|
|
cmd->execute();
|
|
|
|
mcmd->addCommand(cmd);
|
|
|
|
}
|
|
|
|
CmdHistory::self()->didCommand(mcmd);
|
2003-05-20 20:39:06 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotSort() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
KBookmark bk = KEBApp::self()->firstSelected();
|
2003-10-06 18:29:56 +00:00
|
|
|
Q_ASSERT(bk.isGroup());
|
|
|
|
SortCommand *cmd = new SortCommand(i18n("Sort Alphabetically"), bk.address());
|
|
|
|
CmdHistory::self()->addCommand(cmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------------------- */
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotDelete() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
DeleteManyCommand *mcmd = new DeleteManyCommand(i18n("Delete Items"), KEBApp::self()->selectedBookmarks());
|
2005-07-14 01:29:14 +00:00
|
|
|
CmdHistory::self()->addCommand(mcmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotOpenLink()
|
|
|
|
{
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-09-28 16:16:52 +00:00
|
|
|
QList<KBookmark> bookmarks = KEBApp::self()->selectedBookmarksExpanded();
|
|
|
|
QList<KBookmark>::const_iterator it, end;
|
2005-08-13 20:13:21 +00:00
|
|
|
end = bookmarks.constEnd();
|
|
|
|
for (it = bookmarks.constBegin(); it != end; ++it) {
|
2003-10-06 18:29:56 +00:00
|
|
|
if ((*it).isGroup() || (*it).isSeparator())
|
|
|
|
continue;
|
2005-10-04 20:42:32 +00:00
|
|
|
(void)new KRun((*it).url(), KEBApp::self());
|
2003-10-06 18:29:56 +00:00
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------------------- */
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotRename() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
KEBApp::self()->startEdit( KEBApp::NameColumn );
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotChangeURL() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
KEBApp::self()->startEdit( KEBApp::UrlColumn );
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-02-21 20:44:23 +00:00
|
|
|
void ActionsImpl::slotChangeComment() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
KEBApp::self()->startEdit( KEBApp::CommentColumn );
|
2003-02-21 20:44:23 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotSetAsToolbar() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
KBookmark bk = KEBApp::self()->firstSelected();
|
2003-10-06 18:29:56 +00:00
|
|
|
Q_ASSERT(bk.isGroup());
|
2005-06-18 02:03:05 +00:00
|
|
|
KEBMacroCommand *mcmd = CmdGen::setAsToolbar(bk);
|
2003-10-06 18:29:56 +00:00
|
|
|
CmdHistory::self()->addCommand(mcmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
void ActionsImpl::slotChangeIcon() {
|
2005-06-15 14:41:18 +00:00
|
|
|
KEBApp::self()->bkInfo()->commitChanges();
|
2005-08-13 20:13:21 +00:00
|
|
|
KBookmark bk = KEBApp::self()->firstSelected();
|
2003-10-06 18:29:56 +00:00
|
|
|
KIconDialog dlg(KEBApp::self());
|
|
|
|
QString newIcon = dlg.selectIcon(KIcon::Small, KIcon::FileSystem);
|
|
|
|
if (newIcon.isEmpty())
|
|
|
|
return;
|
2005-08-13 20:13:21 +00:00
|
|
|
EditCommand *cmd = new EditCommand(bk.address(), -1, newIcon);
|
|
|
|
|
2003-10-06 18:29:56 +00:00
|
|
|
CmdHistory::self()->addCommand(cmd);
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
2003-01-22 17:58:59 +00:00
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotExpandAll()
|
|
|
|
{
|
|
|
|
KEBApp::self()->expandAll();
|
2003-03-22 00:43:39 +00:00
|
|
|
}
|
|
|
|
|
2005-08-13 20:13:21 +00:00
|
|
|
void ActionsImpl::slotCollapseAll()
|
|
|
|
{
|
|
|
|
KEBApp::self()->collapseAll();
|
2003-03-22 00:43:39 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 17:58:59 +00:00
|
|
|
#include "actionsimpl.moc"
|