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-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-01-21 16:16:53 +00:00
|
|
|
|
2003-02-10 14:32:32 +00:00
|
|
|
#include <kkeydialog.h>
|
|
|
|
#include <kedittoolbar.h>
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <kbookmarkdrag.h>
|
|
|
|
#include <kbookmarkmanager.h>
|
2003-02-10 14:32:32 +00:00
|
|
|
#include <kmessagebox.h>
|
|
|
|
#include <kfiledialog.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"
|
|
|
|
#include "mymanager.h"
|
|
|
|
#include <qclipboard.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-01-21 16:16:53 +00:00
|
|
|
KEBTopLevel *KEBTopLevel::s_topLevel = 0;
|
2002-04-29 15:19:35 +00:00
|
|
|
|
2003-01-23 12:32:02 +00:00
|
|
|
KEBTopLevel::KEBTopLevel(const QString & bookmarksFile, bool readonly, QString address)
|
2003-01-21 16:16:53 +00:00
|
|
|
: KMainWindow(), m_commandHistory(actionCollection()), 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;
|
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-01-22 15:19:31 +00:00
|
|
|
ListView::createListView(this);
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->initListView();
|
|
|
|
setCentralWidget(ListView::self()->widget());
|
|
|
|
resize(ListView::self()->widget()->sizeHint().width(), 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-01-22 15:19:31 +00:00
|
|
|
connect(&m_commandHistory, SIGNAL( commandExecuted() ), SLOT( slotCommandExecuted() ));
|
|
|
|
connect(&m_commandHistory, SIGNAL( documentRestored() ), SLOT( slotDocumentRestored() ));
|
|
|
|
|
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-02-15 01:18:29 +00:00
|
|
|
KEBListViewItem *item = ListView::self()->getItemAtAddress(address);
|
2003-02-10 13:52:45 +00:00
|
|
|
if (!item) {
|
2003-02-15 01:18:29 +00:00
|
|
|
item = ListView::self()->getFirstChild();
|
2003-01-23 12:32:02 +00:00
|
|
|
}
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->setCurrent(item);
|
2003-02-10 13:52:45 +00:00
|
|
|
item->setSelected(true);
|
2002-04-27 10:47:22 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::construct() {
|
|
|
|
MyManager::self()->createManager(this, m_bookmarksFilename);
|
2002-04-27 10:47:22 +00:00
|
|
|
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->updateListViewSetup(m_readOnly);
|
|
|
|
ListView::self()->fillWithGroup(BkManagerAccessor::mgr()->root());
|
2002-10-16 17:29:51 +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-02-15 00:18:41 +00:00
|
|
|
this->docSaved(); // CmdHistory
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
KEBTopLevel::~KEBTopLevel() {
|
2002-10-16 17:50:42 +00:00
|
|
|
s_topLevel = 0;
|
2003-01-21 16:16:53 +00:00
|
|
|
delete m_dcopIface;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
// GUICORE
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
void KEBTopLevel::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(
|
|
|
|
i18n("&Auto-Save on Program Close"), 0,
|
|
|
|
this, SLOT( slotSaveOnClose() ), actionCollection(), "settings_saveonclose");
|
|
|
|
|
|
|
|
(void) new KToggleAction(
|
|
|
|
i18n("&Show Netscape Bookmarks in Konqueror Windows"), 0,
|
|
|
|
actn, SLOT( slotShowNS() ), actionCollection(), "settings_showNS");
|
|
|
|
(void) new KAction(i18n("&Delete"), "editdelete", Key_Delete,
|
|
|
|
actn, SLOT( slotDelete() ), actionCollection(), "delete");
|
|
|
|
(void) new KAction(i18n("Rename"), "text", Key_F2,
|
|
|
|
actn, SLOT( slotRename() ), actionCollection(), "rename");
|
|
|
|
(void) new KAction(i18n("C&hange URL"), "text", Key_F3,
|
|
|
|
actn, SLOT( slotChangeURL() ), actionCollection(), "changeurl");
|
|
|
|
(void) new KAction(i18n("Chan&ge Icon..."), 0,
|
|
|
|
actn, SLOT( slotChangeIcon() ), actionCollection(), "changeicon");
|
|
|
|
(void) new KAction(i18n("Update Favicon"), 0,
|
|
|
|
actn, SLOT( slotUpdateFavIcon() ), actionCollection(), "updatefavicon");
|
|
|
|
(void) new KAction(i18n("&Create New Folder..."), "folder_new", CTRL+Key_N,
|
|
|
|
actn, SLOT( slotNewFolder() ), actionCollection(), "newfolder");
|
|
|
|
(void) new KAction(i18n("Create &New Bookmark"), "www", 0,
|
|
|
|
actn, SLOT( slotNewBookmark() ), actionCollection(), "newbookmark");
|
|
|
|
(void) new KAction(i18n("&Insert Separator"), CTRL+Key_I,
|
|
|
|
actn, SLOT( slotInsertSeparator() ), actionCollection(), "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("&Find..."), 0,
|
|
|
|
actn, SLOT( slotSearch() ), actionCollection(), "search" ); // "find" ?
|
|
|
|
(void) new KAction(i18n("Check Status: &All"), 0,
|
|
|
|
actn, SLOT( slotTestAll() ), actionCollection(), "testall" );
|
|
|
|
(void) new KAction(i18n("Update All &Favicons"), 0,
|
|
|
|
actn, SLOT( slotUpdateAllFavIcons() ), actionCollection(), "updateallfavicons" );
|
|
|
|
(void) new KAction(i18n("Cancel &Checks"), 0,
|
|
|
|
actn, SLOT( slotCancelAllTests() ), actionCollection(), "canceltests" );
|
|
|
|
(void) new KAction(i18n("Cancel &Favicon Updates"), 0,
|
|
|
|
actn, SLOT( slotCancelFavIconUpdates() ), actionCollection(), "cancelfaviconupdates" );
|
|
|
|
(void) new KAction(i18n("Cancel &Search"), 0,
|
|
|
|
actn, SLOT( slotCancelSearch() ), actionCollection(), "cancelsearch" );
|
|
|
|
(void) new KAction(i18n("Import &Netscape Bookmarks..."), "netscape", 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importNS");
|
2003-01-22 17:58:59 +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-01-22 17:58:59 +00:00
|
|
|
(void) new KAction(i18n("Import &Galeon Bookmarks..."), 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importGaleon");
|
|
|
|
(void) new KAction(i18n("Import &KDE2 Bookmarks..."), 0,
|
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importKDE2");
|
2003-01-22 17:58:59 +00:00
|
|
|
(void) new KAction(i18n("&Import IE Bookmarks..."), 0,
|
2003-02-05 20:47:35 +00:00
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importIE");
|
|
|
|
(void) new KAction(i18n("Import &Mozilla Bookmarks..."), "mozilla", 0,
|
|
|
|
actn, SLOT( slotImport() ), actionCollection(), "importMoz");
|
2003-01-22 17:58:59 +00:00
|
|
|
(void) new KAction(i18n("&Export to Netscape Bookmarks"), "netscape", 0,
|
|
|
|
actn, SLOT( slotExportNS() ), actionCollection(), "exportNS");
|
|
|
|
(void) new KAction(i18n("Export to &Mozilla Bookmarks..."), "mozilla", 0,
|
|
|
|
actn, SLOT( slotExportMoz() ), actionCollection(), "exportMoz");
|
2003-01-21 16:16:53 +00:00
|
|
|
}
|
|
|
|
|
2003-02-11 09:57:10 +00:00
|
|
|
static void disableDynamicActions(QValueList<KAction *> actions) {
|
|
|
|
QValueList<KAction *>::Iterator it = actions.begin();
|
|
|
|
QValueList<KAction *>::Iterator end = actions.end();
|
|
|
|
for (; it != end; ++it) {
|
|
|
|
KAction *act = *it;
|
|
|
|
if ((strncmp(act->name(), "options_configure", strlen("options_configure")) != 0)
|
|
|
|
&& (strncmp(act->name(), "help_", strlen("help_")) != 0)) {
|
|
|
|
act->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::resetActions() {
|
2003-02-10 14:32:32 +00:00
|
|
|
// DESIGN - try to remove usage of this
|
2003-01-21 16:16:53 +00:00
|
|
|
disableDynamicActions(actionCollection()->actions());
|
|
|
|
|
|
|
|
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-01-21 16:16:53 +00:00
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("settings_saveonclose"))
|
|
|
|
->setChecked(m_saveOnClose);
|
2002-04-20 04:55:47 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
static_cast<KToggleAction*>(actionCollection()->action("settings_showNS"))
|
2003-01-22 15:19:31 +00:00
|
|
|
->setChecked(MyManager::self()->showNSBookmarks());
|
2002-03-26 23:28:26 +00:00
|
|
|
}
|
|
|
|
|
2003-02-06 13:16:40 +00:00
|
|
|
void KEBTopLevel::slotSaveOnClose() {
|
|
|
|
m_saveOnClose
|
|
|
|
= static_cast<KToggleAction*>(actionCollection()->action("settings_saveonclose"))->isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KEBTopLevel::nsShown() {
|
|
|
|
return static_cast<KToggleAction*>(actionCollection()->action("settings_showNS"))->isChecked();
|
|
|
|
}
|
2003-02-10 13:52:45 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::updateActions() {
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->updateLastAddress();
|
|
|
|
setActionsEnabled(ListView::self()->getSelectionAbilities());
|
2002-03-26 23:28:26 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::setActionsEnabled(SelcAbilities sa) {
|
2002-10-16 17:29:51 +00:00
|
|
|
KActionCollection * coll = actionCollection();
|
|
|
|
|
2003-01-22 15:19:31 +00:00
|
|
|
bool t2 = !m_readOnly && sa.itemSelected;
|
|
|
|
bool t4 = !m_readOnly && sa.singleSelect && !sa.root && !sa.separator;
|
|
|
|
bool t5 = !m_readOnly && !sa.multiSelect;
|
2002-10-16 17:29:51 +00:00
|
|
|
|
2003-02-15 00:34:29 +00:00
|
|
|
coll->action("edit_copy") ->setEnabled(sa.itemSelected);
|
|
|
|
coll->action("delete") ->setEnabled(t2 && !sa.root);
|
|
|
|
coll->action("edit_cut") ->setEnabled(t2 && !sa.root);
|
|
|
|
coll->action("edit_paste") ->setEnabled(t2 && m_canPaste);
|
|
|
|
|
|
|
|
coll->action("rename") ->setEnabled(t4);
|
|
|
|
coll->action("changeicon") ->setEnabled(t4);
|
|
|
|
coll->action("changeurl") ->setEnabled(t4 && !sa.group);
|
|
|
|
|
|
|
|
coll->action("newfolder") ->setEnabled(t5);
|
|
|
|
coll->action("newbookmark") ->setEnabled(t5);
|
|
|
|
coll->action("insertseparator") ->setEnabled(t5);
|
|
|
|
|
|
|
|
coll->action("expandall") ->setEnabled(true);
|
|
|
|
coll->action("collapseall") ->setEnabled(true);
|
|
|
|
coll->action("openlink") ->setEnabled(sa.itemSelected && !sa.urlIsEmpty
|
|
|
|
&& !sa.group && !sa.separator);
|
|
|
|
|
|
|
|
coll->action("search") ->setEnabled(!sa.multiSelect);
|
|
|
|
|
|
|
|
coll->action("testall") ->setEnabled(!m_readOnly && sa.notEmpty);
|
|
|
|
coll->action("testlink") ->setEnabled(t2 && !sa.separator);
|
|
|
|
|
|
|
|
coll->action("updateallfavicons")->setEnabled(!m_readOnly && sa.notEmpty);
|
|
|
|
coll->action("updatefavicon") ->setEnabled(t2 && !sa.separator);
|
|
|
|
|
|
|
|
coll->action("sort") ->setEnabled(t5 && sa.group);
|
|
|
|
coll->action("setastoolbar") ->setEnabled(t5 && sa.group);
|
2000-10-27 00:52:28 +00:00
|
|
|
}
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
// DESIGN clean up this sh*t
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::setCancelSearchEnabled(bool enabled) {
|
|
|
|
actionCollection()->action("cancelsearch")->setEnabled(enabled);
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::setCancelFavIconUpdatesEnabled(bool enabled) {
|
|
|
|
actionCollection()->action("cancelfaviconupdates")->setEnabled(enabled);
|
2002-03-26 23:28:26 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::setCancelTestsEnabled(bool enabled) {
|
|
|
|
actionCollection()->action("canceltests")->setEnabled(enabled);
|
2001-02-24 18:05:56 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::setModifiedFlag(bool modified) {
|
|
|
|
QString caption = i18n("Bookmark Editor");
|
2003-01-22 15:19:31 +00:00
|
|
|
m_modified = modified;
|
2003-01-21 16:16:53 +00:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (filename != default filename) {
|
|
|
|
caption += QString(" [%2]").arg(filename.name());
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
#endif
|
2000-10-26 03:52:56 +00:00
|
|
|
|
2003-01-22 15:19:31 +00:00
|
|
|
if (m_readOnly) {
|
|
|
|
m_modified = false;
|
2003-01-21 16:16:53 +00:00
|
|
|
caption += QString(" [%2]").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-01-21 16:16:53 +00:00
|
|
|
// AK - commented due to usability bug by zander
|
|
|
|
// 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-01-22 15:19:31 +00:00
|
|
|
MyManager::self()->setUpdate(!m_modified);
|
2002-04-28 22:01:11 +00:00
|
|
|
}
|
|
|
|
|
2003-01-22 15:19:31 +00:00
|
|
|
void KEBTopLevel::slotClipboardDataChanged() {
|
|
|
|
kdDebug() << "KEBTopLevel::slotClipboardDataChanged" << endl;
|
|
|
|
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-01-21 16:16:53 +00:00
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
// COMMAND HISTORY ACCESSORS
|
|
|
|
/* ------------------------------------------------------------- */
|
2002-04-28 22:01:11 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::didCommand(KCommand *cmd) {
|
|
|
|
if (cmd) {
|
|
|
|
m_commandHistory.addCommand(cmd, false);
|
|
|
|
emit slotCommandExecuted();
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2002-01-05 17:21:29 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::addCommand(KCommand *cmd) {
|
|
|
|
if (cmd) {
|
|
|
|
m_commandHistory.addCommand(cmd);
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2002-01-05 17:21:29 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::docSaved() {
|
|
|
|
m_commandHistory.documentSaved();
|
2001-04-18 22:54:26 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::clearHistory() {
|
|
|
|
m_commandHistory.clear();
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::emitSlotCommandExecuted() {
|
|
|
|
emit slotCommandExecuted();
|
2002-05-12 11:44:24 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
/* ------------------------------------------------------------- */
|
2002-06-25 20:46:24 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
// DESIGN - poinless drivel
|
2002-06-04 23:30:48 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::setAllOpen(bool open) {
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->setOpen(open);
|
2003-01-21 16:16:53 +00:00
|
|
|
setModifiedFlag(true);
|
2002-06-04 20:54:49 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
// GUI_CALLBACK
|
|
|
|
/* ------------------------------------------------------------- */
|
2000-11-22 16:31:09 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
// LATER - move
|
|
|
|
void KEBTopLevel::slotCommandExecuted() {
|
2003-01-22 15:19:31 +00:00
|
|
|
if (!m_readOnly) {
|
2003-01-21 16:16:53 +00:00
|
|
|
kdDebug() << "KEBTopLevel::slotCommandExecuted" << endl;
|
|
|
|
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-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotDocumentRestored() {
|
2003-01-22 15:19:31 +00:00
|
|
|
if (m_readOnly) {
|
2003-01-21 16:16:53 +00:00
|
|
|
return;
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
// called when undoing the very first action - or the first one after
|
|
|
|
// saving. the "document" is set to "non modified" in that case.
|
|
|
|
setModifiedFlag(false);
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotBookmarksChanged(const QString &, const QString &caller) {
|
|
|
|
// this is called when someone changes bookmarks in konqueror....
|
2003-02-10 13:52:45 +00:00
|
|
|
kdDebug() << "FIXME: " << caller << " == " << kapp->name() << "?" << endl;
|
2003-01-21 16:16:53 +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-01-23 10:24:52 +00:00
|
|
|
if ((caller != kapp->name()) && !m_modified) {
|
2003-01-21 16:16:53 +00:00
|
|
|
kdDebug() << "KEBTopLevel::slotBookmarksChanged" << endl;
|
|
|
|
// DESIGN - is this logic really unique?
|
|
|
|
clearHistory();
|
2003-02-15 01:18:29 +00:00
|
|
|
ListView::self()->fillWithGroup(BkManagerAccessor::mgr()->root());
|
2003-01-21 16:16:53 +00:00
|
|
|
updateActions();
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
// GUI - STANDARD
|
|
|
|
/* ------------------------------------------------------------- */
|
2002-04-20 04:55:47 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotConfigureKeyBindings() {
|
|
|
|
KKeyDialog::configure(actionCollection());
|
2001-09-09 15:36:30 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotConfigureToolbars() {
|
|
|
|
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-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotNewToolbarConfig() {
|
|
|
|
// called when OK or Apply is clicked
|
|
|
|
createGUI();
|
|
|
|
applyMainWindowSettings(KGlobal::config(), "MainWindow");
|
2002-04-19 23:09:16 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
// DOCUMENT
|
|
|
|
/* ------------------------------------------------------------- */
|
2002-04-26 22:21:50 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
bool KEBTopLevel::save() {
|
2003-01-22 15:19:31 +00:00
|
|
|
if (!MyManager::self()->managerSave()) {
|
2003-01-21 16:16:53 +00:00
|
|
|
return false;
|
2002-10-16 17:29:51 +00:00
|
|
|
}
|
2003-01-22 15:19:31 +00:00
|
|
|
MyManager::self()->notifyManagers();
|
2003-01-21 16:16:53 +00:00
|
|
|
setModifiedFlag(false);
|
2003-02-15 00:18:41 +00:00
|
|
|
this->docSaved(); // CmdHistory
|
2003-01-21 16:16:53 +00:00
|
|
|
return true;
|
2001-02-26 23:19:23 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
bool KEBTopLevel::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(
|
|
|
|
this, i18n("The bookmarks have been modified.\nSave changes?"))
|
|
|
|
) {
|
|
|
|
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-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotLoad() {
|
|
|
|
if (!queryClose()) {
|
2002-10-16 17:29:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-01-21 16:16:53 +00:00
|
|
|
// TODO - add a few default place to the file dialog somehow?,
|
|
|
|
// - e.g kfile bookmarks + normal bookmarks file dir
|
|
|
|
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-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotSave() {
|
|
|
|
(void)save();
|
2000-10-26 03:52:56 +00:00
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
void KEBTopLevel::slotSaveAs() {
|
|
|
|
QString saveFilename = KFileDialog::getSaveFileName(QString::null, "*.xml", this);
|
|
|
|
if(!saveFilename.isEmpty()) {
|
2003-01-22 15:19:31 +00:00
|
|
|
MyManager::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"
|