2000-10-26 03:52:56 +00:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
Copyright (C) 2000 David Faure <faure@kde.org>
|
2003-01-21 16:16:53 +00:00
|
|
|
Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
|
2000-10-26 03:52:56 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <stdlib.h>
|
2002-09-17 17:16:23 +00:00
|
|
|
|
2003-03-01 11:04:06 +00:00
|
|
|
#include <qclipboard.h>
|
|
|
|
#include <qsplitter.h>
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <klocale.h>
|
2000-10-26 03:52:56 +00:00
|
|
|
#include <kdebug.h>
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-02-10 14:32:32 +00:00
|
|
|
#include <kapplication.h>
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <kstdaction.h>
|
2003-02-10 14:32:32 +00:00
|
|
|
#include <kaction.h>
|
2003-02-19 00:11:04 +00:00
|
|
|
#include <dcopclient.h>
|
2003-03-25 22:00:49 +00:00
|
|
|
#include <dcopref.h>
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-02-10 14:32:32 +00:00
|
|
|
#include <kkeydialog.h>
|
|
|
|
#include <kedittoolbar.h>
|
2003-03-25 22:00:49 +00:00
|
|
|
#include <kmessagebox.h>
|
|
|
|
#include <klineedit.h>
|
|
|
|
#include <kfiledialog.h>
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <kbookmarkdrag.h>
|
|
|
|
#include <kbookmarkmanager.h>
|
2003-03-22 19:50:23 +00:00
|
|
|
#include <kbookmarkimporter.h>
|
|
|
|
#include <kbookmarkexporter.h>
|
2002-04-29 15:19:35 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include "listview.h"
|
2003-01-22 17:58:59 +00:00
|
|
|
#include "actionsimpl.h"
|
2003-02-10 14:32:32 +00:00
|
|
|
#include "dcop.h"
|
2003-03-25 22:41:31 +00:00
|
|
|
#include "search.h"
|
2002-04-29 15:19:35 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include "toplevel.h"
|
2002-04-29 15:19:35 +00:00
|
|
|
|
2003-03-22 16:52:02 +00:00
|
|
|
CmdHistory* CmdHistory::s_self = 0;
|
|
|
|
|
|
|
|
CmdHistory::CmdHistory(KActionCollection *collection) : m_commandHistory(collection) {
|
|
|
|
connect(&m_commandHistory, SIGNAL( commandExecuted() ),
|
|
|
|
SLOT( slotCommandExecuted() ));
|
|
|
|
connect(&m_commandHistory, SIGNAL( documentRestored() ),
|
|
|
|
SLOT( slotDocumentRestored() ));
|
|
|
|
|
|
|
|
assert(!s_self);
|
|
|
|
s_self = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
CmdHistory* CmdHistory::self() {
|
|
|
|
assert(s_self);
|
|
|
|
return s_self;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdHistory::slotCommandExecuted() {
|
2003-03-22 20:27:55 +00:00
|
|
|
KEBApp::self()->notifyCommandExecuted();
|
2003-03-22 16:52:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CmdHistory::slotDocumentRestored() {
|
|
|
|
// called when undoing the very first action - or the first one after
|
|
|
|
// saving. the "document" is set to "non modified" in that case.
|
|
|
|
if (!KEBApp::self()->readonly()) {
|
|
|
|
KEBApp::self()->setModifiedFlag(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdHistory::notifyDocSaved() {
|
|
|
|
m_commandHistory.documentSaved();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdHistory::didCommand(KCommand *cmd) {
|
|
|
|
if (cmd) {
|
|
|
|
m_commandHistory.addCommand(cmd, false);
|
2003-03-22 20:27:55 +00:00
|
|
|
KEBApp::self()->notifyCommandExecuted();
|
2003-03-22 16:52:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdHistory::addCommand(KCommand *cmd) {
|
|
|
|
if (cmd) {
|
|
|
|
m_commandHistory.addCommand(cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CmdHistory::clearHistory() {
|
|
|
|
m_commandHistory.clear();
|
|
|
|
}
|
|
|
|
|
2003-03-22 19:50:23 +00:00
|
|
|
CurrentMgr *CurrentMgr::s_mgr = 0;
|
|
|
|
|
|
|
|
KBookmark CurrentMgr::bookmarkAt(const QString & a) {
|
|
|
|
return self()->mgr()->findByAddress(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CurrentMgr::managerSave() { return mgr()->save(); }
|
|
|
|
void CurrentMgr::saveAs(const QString &fileName) { mgr()->saveAs(fileName); }
|
|
|
|
void CurrentMgr::setUpdate(bool update) { mgr()->setUpdate(update); }
|
|
|
|
QString CurrentMgr::path() { return mgr()->path(); }
|
|
|
|
bool CurrentMgr::showNSBookmarks() { return mgr()->showNSBookmarks(); }
|
|
|
|
|
2003-03-23 04:11:19 +00:00
|
|
|
void CurrentMgr::createManager(const QString &filename) {
|
2003-03-22 19:50:23 +00:00
|
|
|
if (m_mgr) {
|
2003-03-22 20:27:55 +00:00
|
|
|
disconnect(m_mgr, 0, 0, 0);
|
|
|
|
// still todo - delete old m_mgr
|
2003-03-22 19:50:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_mgr = KBookmarkManager::managerForFile(filename, false);
|
|
|
|
|
2003-03-22 20:27:55 +00:00
|
|
|
connect(m_mgr, SIGNAL( changed(const QString &, const QString &) ),
|
|
|
|
SLOT( slotBookmarksChanged(const QString &, const QString &) ));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CurrentMgr::slotBookmarksChanged(const QString &, const QString &caller) {
|
2003-03-23 04:11:19 +00:00
|
|
|
// kdDebug() << "CurrentMgr::slotBookmarksChanged" << endl;
|
2003-03-22 20:27:55 +00:00
|
|
|
if ((caller.latin1() != kapp->dcopClient()->appId()) && !KEBApp::self()->modified()) {
|
2003-03-23 04:11:19 +00:00
|
|
|
// TODO
|
|
|
|
// umm.. what happens if a readonly gets a update for a non-readonly???
|
|
|
|
// the non-readonly maybe has a pretty much random kapp->name() ??? umm...
|
2003-03-22 20:27:55 +00:00
|
|
|
CmdHistory::self()->clearHistory();
|
2003-03-23 10:46:14 +00:00
|
|
|
ListView::self()->updateListView();
|
2003-03-22 20:27:55 +00:00
|
|
|
KEBApp::self()->updateActions();
|
|
|
|
}
|
2003-03-22 19:50:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CurrentMgr::notifyManagers() {
|
|
|
|
QCString objId("KBookmarkManager-");
|
|
|
|
objId += mgr()->path().utf8();
|
|
|
|
DCOPRef("*", objId).send("notifyCompleteChange", QString::fromLatin1(kapp->dcopClient()->appId()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CurrentMgr::doExport(bool moz) {
|
|
|
|
QString path =
|
|
|
|
(moz)
|
|
|
|
? KNSBookmarkImporter::mozillaBookmarksFile(true)
|
|
|
|
: KNSBookmarkImporter::netscapeBookmarksFile(true);
|
|
|
|
if (!path.isEmpty()) {
|
|
|
|
KNSBookmarkExporter exporter(mgr(), path);
|
|
|
|
exporter.write(moz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CurrentMgr::correctAddress(const QString &address) {
|
|
|
|
return mgr()->findByAddress(address, true).address();
|
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
KEBApp *KEBApp::s_topLevel = 0;
|
2002-04-29 15:19:35 +00:00
|
|
|
|
2003-02-27 23:31:16 +00:00
|
|
|
KEBApp::KEBApp(const QString & bookmarksFile, bool readonly, const QString &address)
|
2003-03-22 16:52:02 +00:00
|
|
|
: KMainWindow(), m_dcopIface(0) {
|
2002-10-16 17:29:51 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
m_bookmarksFilename = bookmarksFile;
|
2003-01-22 15:19:31 +00:00
|
|
|
m_readOnly = readonly;
|
2003-01-21 16:16:53 +00:00
|
|
|
m_saveOnClose = true;
|
2003-03-22 16:52:02 +00:00
|
|
|
m_cmdHistory = new CmdHistory(actionCollection());
|
2002-10-16 17:29:51 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
s_topLevel = this;
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-03-25 22:00:49 +00:00
|
|
|
QSplitter *vsplitter = new QSplitter(this);
|
|
|
|
m_iSearchLineEdit = new KLineEdit(vsplitter);
|
|
|
|
vsplitter->setOrientation(QSplitter::Vertical);
|
|
|
|
vsplitter->setSizes(QValueList<int>() << 20 << 380);
|
2003-03-01 10:40:23 +00:00
|
|
|
|
2003-03-25 22:00:49 +00:00
|
|
|
QSplitter *splitter = new QSplitter(vsplitter);
|
2003-03-01 11:04:06 +00:00
|
|
|
ListView::createListViews(splitter);
|
|
|
|
ListView::self()->initListViews();
|
2003-03-23 11:08:37 +00:00
|
|
|
ListView::self()->setInitialAddress(address);
|
2003-03-01 10:40:23 +00:00
|
|
|
|
2003-03-25 22:00:49 +00:00
|
|
|
setCentralWidget(vsplitter);
|
2003-03-01 10:40:23 +00:00
|
|
|
resize(ListView::self()->widget()->sizeHint().width()
|
2003-03-21 23:22:20 +00:00
|
|
|
+ 0 /* TODO - other split view */, 400);
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
createActions();
|
|
|
|
createGUI();
|
2002-06-03 18:58:18 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
m_dcopIface = new KBookmarkEditorIface();
|
2002-04-26 22:21:50 +00:00
|
|
|
|
2003-01-22 15:19:31 +00:00
|
|
|
connect(kapp->clipboard(), SIGNAL( dataChanged() ), SLOT( slotClipboardDataChanged() ));
|
2003-02-15 00:18:41 +00:00
|
|
|
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->connectSignals();
|
2002-04-26 22:21:50 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
KGlobal::locale()->insertCatalogue("libkonq");
|
2002-04-27 10:47:22 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
construct();
|
2003-01-23 12:32:02 +00:00
|
|
|
|
2003-03-01 11:36:20 +00:00
|
|
|
updateActions();
|
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::construct() {
|
2003-03-23 04:11:19 +00:00
|
|
|
CurrentMgr::self()->createManager(m_bookmarksFilename);
|
2002-04-27 10:47:22 +00:00
|
|
|
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->updateListViewSetup(m_readOnly);
|
2003-03-23 10:46:14 +00:00
|
|
|
ListView::self()->updateListView();
|
2002-10-16 17:29:51 +00:00
|
|
|
|
2003-03-25 22:00:49 +00:00
|
|
|
connect(m_iSearchLineEdit, SIGNAL( textChanged(const QString &) ),
|
2003-03-25 22:41:31 +00:00
|
|
|
Searcher::self(), SLOT( slotSearchTextChanged(const QString &) ));
|
2003-03-25 22:00:49 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
slotClipboardDataChanged();
|
2002-10-16 17:29:51 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
resetActions();
|
2003-02-10 13:52:45 +00:00
|
|
|
updateActions();
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
setAutoSaveSettings();
|
|
|
|
setModifiedFlag(false);
|
2003-03-22 16:52:02 +00:00
|
|
|
m_cmdHistory->notifyDocSaved();
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
KEBApp::~KEBApp() {
|
2002-10-16 17:50:42 +00:00
|
|
|
s_topLevel = 0;
|
2003-01-21 16:16:53 +00:00
|
|
|
delete m_dcopIface;
|
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------- */
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::createActions() {
|
2003-02-15 00:18:41 +00:00
|
|
|
|
|
|
|
ActionsImpl *actn = ActionsImpl::self();
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
(void) KStdAction::open(this, SLOT( slotLoad() ), actionCollection());
|
|
|
|
(void) KStdAction::save(this, SLOT( slotSave() ), actionCollection());
|
|
|
|
(void) KStdAction::saveAs(this, SLOT( slotSaveAs() ), actionCollection());
|
|
|
|
(void) KStdAction::quit(this, SLOT( close() ), actionCollection());
|
|
|
|
(void) KStdAction::keyBindings(this, SLOT( slotConfigureKeyBindings() ), actionCollection());
|
|
|
|
(void) KStdAction::configureToolbars(this, SLOT( slotConfigureToolbars() ), actionCollection());
|
2003-01-22 17:58:59 +00:00
|
|
|
(void) KStdAction::cut(actn, SLOT( slotCut() ), actionCollection());
|
|
|
|
(void) KStdAction::copy(actn, SLOT( slotCopy() ), actionCollection());
|
|
|
|
(void) KStdAction::paste(actn, SLOT( slotPaste() ), actionCollection());
|
|
|
|
|
|
|
|
(void) new KToggleAction(
|
2003-03-18 12:55:27 +00:00
|
|
|
i18n("&Auto-Save on Program Close"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
this, SLOT( slotSaveOnClose() ), actionCollection(), "settings_saveonclose");
|
|
|
|
|
|
|
|
(void) new KToggleAction(
|
2003-03-18 12:55:27 +00:00
|
|
|
i18n("&Show Netscape Bookmarks in Konqueror Windows"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotShowNS() ), actionCollection(), "settings_showNS");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Delete"), "editdelete", Key_Delete,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotDelete() ), actionCollection(), "delete");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Rename"), "text", Key_F2,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotRename() ), actionCollection(), "rename");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("C&hange URL"), "text", Key_F3,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotChangeURL() ), actionCollection(), "changeurl");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("C&hange Comment"), "text", Key_F4,
|
2003-02-21 20:44:23 +00:00
|
|
|
actn, SLOT( slotChangeComment() ), actionCollection(), "changecomment");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Chan&ge Icon..."), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotChangeIcon() ), actionCollection(), "changeicon");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Update Favicon"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotUpdateFavIcon() ), actionCollection(), "updatefavicon");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Create New Folder..."), "folder_new", CTRL+Key_N,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotNewFolder() ), actionCollection(), "newfolder");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Create &New Bookmark"), "www", 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotNewBookmark() ), actionCollection(), "newbookmark");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Insert Separator"), CTRL+Key_I,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotInsertSeparator() ), actionCollection(), "insertseparator");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Sort Alphabetically"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotSort() ), actionCollection(), "sort");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Set as T&oolbar Folder"), "bookmark_toolbar", 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotSetAsToolbar() ), actionCollection(), "setastoolbar");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Expand All Folders"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotExpandAll() ), actionCollection(), "expandall");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Collapse &All Folders"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotCollapseAll() ), actionCollection(), "collapseall" );
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Open in Konqueror"), "fileopen", 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotOpenLink() ), actionCollection(), "openlink" );
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Check &Status"), "bookmark", 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotTestSelection() ), actionCollection(), "testlink" );
|
2003-03-18 12:55:27 +00:00
|
|
|
|
|
|
|
(void) new KAction(i18n("Check Status: &All"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotTestAll() ), actionCollection(), "testall" );
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Update All &Favicons"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotUpdateAllFavIcons() ), actionCollection(), "updateallfavicons" );
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Cancel &Checks"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotCancelAllTests() ), actionCollection(), "canceltests" );
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Cancel &Favicon Updates"), 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotCancelFavIconUpdates() ), actionCollection(), "cancelfaviconupdates" );
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Import &Netscape Bookmarks..."), "netscape", 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importNS");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Import &Opera Bookmarks..."), "opera", 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importOpera");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Import &Galeon Bookmarks..."), 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importGaleon");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Import &KDE2 Bookmarks..."), 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importKDE2");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Import IE Bookmarks..."), 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importIE");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Import &Mozilla Bookmarks..."), "mozilla", 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importMoz");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("&Export to Netscape Bookmarks"), "netscape", 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotExportNS() ), actionCollection(), "exportNS");
|
2003-03-18 12:55:27 +00:00
|
|
|
(void) new KAction(i18n("Export to &Mozilla Bookmarks..."), "mozilla", 0,
|
2003-01-22 17:58:59 +00:00
|
|
|
actn, SLOT( slotExportMoz() ), actionCollection(), "exportMoz");
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 21:30:16 +00:00
|
|
|
KToggleAction* KEBApp::getToggleAction(const char *action) {
|
|
|
|
return static_cast<KToggleAction*>(actionCollection()->action(action));
|
2003-02-11 09:57:10 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::resetActions() {
|
2003-03-21 21:30:16 +00:00
|
|
|
stateChanged("disablestuff");
|
2003-01-21 16:16:53 +00:00
|
|
|
stateChanged("normal");
|
2002-10-16 16:39:37 +00:00
|
|
|
|
2003-01-22 15:19:31 +00:00
|
|
|
if (!m_readOnly) {
|
2003-01-21 16:16:53 +00:00
|
|
|
stateChanged("notreadonly");
|
2002-03-26 23:28:26 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 21:30:16 +00:00
|
|
|
getToggleAction("settings_saveonclose")->setChecked(m_saveOnClose);
|
|
|
|
getToggleAction("settings_showNS")
|
2003-02-16 00:29:18 +00:00
|
|
|
->setChecked(CurrentMgr::self()->showNSBookmarks());
|
2002-03-26 23:28:26 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotSaveOnClose() {
|
2003-03-21 21:30:16 +00:00
|
|
|
m_saveOnClose = getToggleAction("settings_saveonclose")->isChecked();
|
2003-02-06 13:16:40 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
bool KEBApp::nsShown() {
|
2003-03-21 21:30:16 +00:00
|
|
|
return getToggleAction("settings_showNS")->isChecked();
|
2003-02-06 13:16:40 +00:00
|
|
|
}
|
2003-02-10 13:52:45 +00:00
|
|
|
|
2003-03-23 10:46:14 +00:00
|
|
|
// this should be pushed from listview, not pulled
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::updateActions() {
|
2003-02-15 01:18:29 +00:00
|
|
|
setActionsEnabled(ListView::self()->getSelectionAbilities());
|
2002-03-26 23:28:26 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::setActionsEnabled(SelcAbilities sa) {
|
2002-10-16 17:29:51 +00:00
|
|
|
KActionCollection * coll = actionCollection();
|
|
|
|
|
2003-03-23 04:11:19 +00:00
|
|
|
#define ENABLE(a) coll->action(a)->setEnabled(true);
|
2003-03-21 23:22:20 +00:00
|
|
|
|
2003-03-23 04:11:19 +00:00
|
|
|
if (sa.itemSelected) {
|
|
|
|
ENABLE("edit_copy");
|
|
|
|
if (!sa.urlIsEmpty && !sa.group && !sa.separator) {
|
|
|
|
ENABLE("openlink");
|
|
|
|
}
|
|
|
|
}
|
2003-03-18 12:55:27 +00:00
|
|
|
|
2003-03-23 04:11:19 +00:00
|
|
|
if (!m_readOnly) {
|
|
|
|
if (sa.notEmpty) {
|
|
|
|
ENABLE("testall");
|
|
|
|
ENABLE("updateallfavicons");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sa.itemSelected) {
|
|
|
|
if (!sa.root) {
|
|
|
|
ENABLE("delete");
|
|
|
|
ENABLE("edit_cut");
|
|
|
|
}
|
|
|
|
if (m_canPaste) {
|
|
|
|
ENABLE("edit_paste");
|
|
|
|
}
|
|
|
|
if (!sa.separator) {
|
|
|
|
ENABLE("testlink");
|
|
|
|
ENABLE("updatefavicon");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sa.singleSelect && !sa.root && !sa.separator) {
|
|
|
|
ENABLE("rename");
|
|
|
|
ENABLE("changeicon");
|
|
|
|
ENABLE("changecomment");
|
|
|
|
if (!sa.group) {
|
|
|
|
ENABLE("changeurl");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!sa.multiSelect) {
|
|
|
|
ENABLE("newfolder");
|
|
|
|
ENABLE("newbookmark");
|
|
|
|
ENABLE("insertseparator");
|
|
|
|
if (sa.group) {
|
|
|
|
ENABLE("sort");
|
|
|
|
ENABLE("setastoolbar");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-10-27 00:52:28 +00:00
|
|
|
}
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::setCancelFavIconUpdatesEnabled(bool enabled) {
|
2003-01-21 16:16:53 +00:00
|
|
|
actionCollection()->action("cancelfaviconupdates")->setEnabled(enabled);
|
2002-03-26 23:28:26 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::setCancelTestsEnabled(bool enabled) {
|
2003-01-21 16:16:53 +00:00
|
|
|
actionCollection()->action("canceltests")->setEnabled(enabled);
|
2001-02-24 18:05:56 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::setModifiedFlag(bool modified) {
|
2003-01-22 15:19:31 +00:00
|
|
|
m_modified = modified;
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-03-21 23:22:20 +00:00
|
|
|
QString caption = i18n("Bookmark Editor");
|
|
|
|
|
|
|
|
if (m_bookmarksFilename != KBookmarkManager::userBookmarksManager()->path()) {
|
|
|
|
caption += QString(" %1").arg(m_bookmarksFilename);
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-22 15:19:31 +00:00
|
|
|
if (m_readOnly) {
|
|
|
|
m_modified = false;
|
2003-02-24 12:18:27 +00:00
|
|
|
caption += QString(" [%1]").arg(i18n("Read Only"));
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-22 15:19:31 +00:00
|
|
|
setCaption(caption, m_modified);
|
2002-01-05 17:21:29 +00:00
|
|
|
|
2003-03-18 12:55:27 +00:00
|
|
|
// AK - commented due to usability bug by zander
|
2003-01-21 16:16:53 +00:00
|
|
|
// AK - on second thoughts. this is just wrong. and against
|
|
|
|
// the style guide. maybe zander just saw a bug. doubt it though...
|
2003-01-22 15:19:31 +00:00
|
|
|
// actionCollection()->action("file_save")->setEnabled(m_modified);
|
2002-04-28 22:01:11 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
// only update when non-modified
|
|
|
|
// - this means that when we have modifications
|
|
|
|
// changes are sent via dcop rather than via
|
|
|
|
// a reload - which would loose user changes
|
2003-03-18 12:55:27 +00:00
|
|
|
CurrentMgr::self()->setUpdate(!m_modified);
|
2002-04-28 22:01:11 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotClipboardDataChanged() {
|
2003-03-23 04:11:19 +00:00
|
|
|
// kdDebug() << "KEBApp::slotClipboardDataChanged" << endl;
|
2003-01-22 15:19:31 +00:00
|
|
|
if (!m_readOnly) {
|
2003-02-11 09:57:10 +00:00
|
|
|
m_canPaste = KBookmarkDrag::canDecode(kapp->clipboard()->data(QClipboard::Clipboard));
|
2003-01-22 15:19:31 +00:00
|
|
|
ListView::self()->emitSlotSelectionChanged();
|
|
|
|
}
|
2002-04-28 22:01:11 +00:00
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------- */
|
2002-04-28 22:01:11 +00:00
|
|
|
|
2003-03-22 20:27:55 +00:00
|
|
|
void KEBApp::notifyCommandExecuted() {
|
2003-03-23 04:11:19 +00:00
|
|
|
// kdDebug() << "KEBApp::notifyCommandExecuted()" << endl;
|
2003-01-22 15:19:31 +00:00
|
|
|
if (!m_readOnly) {
|
2003-01-21 16:16:53 +00:00
|
|
|
setModifiedFlag(true);
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->updateListView();
|
|
|
|
ListView::self()->emitSlotSelectionChanged();
|
2003-01-21 16:16:53 +00:00
|
|
|
updateActions();
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2000-11-22 01:46:49 +00:00
|
|
|
}
|
|
|
|
|
2003-03-22 16:52:02 +00:00
|
|
|
/* -------------------------- */
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotConfigureKeyBindings() {
|
2003-01-21 16:16:53 +00:00
|
|
|
KKeyDialog::configure(actionCollection());
|
2001-09-09 15:36:30 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotConfigureToolbars() {
|
2003-01-21 16:16:53 +00:00
|
|
|
saveMainWindowSettings(KGlobal::config(), "MainWindow");
|
|
|
|
KEditToolbar dlg(actionCollection());
|
|
|
|
connect(&dlg, SIGNAL( newToolbarConfig() ), this, SLOT( slotNewToolbarConfig() ));
|
|
|
|
dlg.exec();
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotNewToolbarConfig() {
|
2003-01-21 16:16:53 +00:00
|
|
|
// called when OK or Apply is clicked
|
|
|
|
createGUI();
|
|
|
|
applyMainWindowSettings(KGlobal::config(), "MainWindow");
|
2002-04-19 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
2003-02-16 00:05:39 +00:00
|
|
|
/* -------------------------- */
|
2002-04-26 22:21:50 +00:00
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
bool KEBApp::save() {
|
2003-02-16 00:29:18 +00:00
|
|
|
if (!CurrentMgr::self()->managerSave()) {
|
2003-01-21 16:16:53 +00:00
|
|
|
return false;
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2003-02-16 00:29:18 +00:00
|
|
|
CurrentMgr::self()->notifyManagers();
|
2003-01-21 16:16:53 +00:00
|
|
|
setModifiedFlag(false);
|
2003-03-22 16:52:02 +00:00
|
|
|
m_cmdHistory->notifyDocSaved();
|
2003-01-21 16:16:53 +00:00
|
|
|
return true;
|
2001-02-26 23:19:23 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
bool KEBApp::queryClose() {
|
2003-01-22 15:19:31 +00:00
|
|
|
if (!m_modified) {
|
2003-01-21 16:16:53 +00:00
|
|
|
return true;
|
2002-11-06 17:16:16 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
if (m_saveOnClose) {
|
|
|
|
return save();
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2002-04-28 14:03:35 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
switch (
|
|
|
|
KMessageBox::warningYesNoCancel(
|
2003-03-18 12:55:27 +00:00
|
|
|
this, i18n("The bookmarks have been modified.\nSave changes?"))
|
2003-01-21 16:16:53 +00:00
|
|
|
) {
|
|
|
|
case KMessageBox::Yes:
|
|
|
|
return save();
|
|
|
|
case KMessageBox::No:
|
|
|
|
return true;
|
|
|
|
default: // case KMessageBox::Cancel:
|
|
|
|
return false;
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2000-11-18 01:04:45 +00:00
|
|
|
}
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotLoad() {
|
2003-01-21 16:16:53 +00:00
|
|
|
if (!queryClose()) {
|
2002-10-16 17:29:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
QString bookmarksFile = KFileDialog::getOpenFileName(QString::null, "*.xml", this);
|
2003-01-25 08:39:50 +00:00
|
|
|
if (!bookmarksFile.isNull()) {
|
2003-01-21 16:16:53 +00:00
|
|
|
m_bookmarksFilename = bookmarksFile;
|
|
|
|
construct();
|
2002-10-16 16:39:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotSave() {
|
2003-01-21 16:16:53 +00:00
|
|
|
(void)save();
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-02-15 19:00:14 +00:00
|
|
|
void KEBApp::slotSaveAs() {
|
2003-01-21 16:16:53 +00:00
|
|
|
QString saveFilename = KFileDialog::getSaveFileName(QString::null, "*.xml", this);
|
|
|
|
if(!saveFilename.isEmpty()) {
|
2003-02-16 00:29:18 +00:00
|
|
|
CurrentMgr::self()->saveAs(saveFilename);
|
2002-10-16 16:39:37 +00:00
|
|
|
}
|
2000-11-06 00:34:03 +00:00
|
|
|
}
|
2000-11-05 20:12:58 +00:00
|
|
|
|
2000-10-26 03:52:56 +00:00
|
|
|
#include "toplevel.moc"
|