From a54c49c6d7605c3142196c402fa4304a0ec6699e Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Thu, 21 Jun 2012 14:16:04 -0500 Subject: Fix inadvertent renaming. --- po/cs.po | 12 +-- po/du.po | 12 +-- po/fr.po | 12 +-- po/hu.pot | 10 +- po/kchmviewer.pot | 12 +-- po/ru.po | 12 +-- po/tr.po | 12 +-- po/zh_CN.po | 12 +-- src/Makefile.am | 4 +- src/kchmbookmarkwindow.cpp | 239 +++++++++++++++++++++++++++++++++++++++++++++ src/kchmbookmarkwindow.h | 64 ++++++++++++ src/kchmbookmartwindow.cpp | 239 --------------------------------------------- src/kchmbookmartwindow.h | 64 ------------ src/kchmmainwindow.cpp | 2 +- 14 files changed, 353 insertions(+), 353 deletions(-) create mode 100644 src/kchmbookmarkwindow.cpp create mode 100644 src/kchmbookmarkwindow.h delete mode 100644 src/kchmbookmartwindow.cpp delete mode 100644 src/kchmbookmartwindow.h diff --git a/po/cs.po b/po/cs.po index ba25b24..a5846d8 100644 --- a/po/cs.po +++ b/po/cs.po @@ -336,27 +336,27 @@ msgid "" "Your emails" msgstr "radonek@gmail.com" -#: kchmbookmartwindow.cpp:44 +#: kchmbookmarkwindow.cpp:44 msgid "&Add" msgstr "Přid&at" -#: kchmbookmartwindow.cpp:46 +#: kchmbookmarkwindow.cpp:46 msgid "&Del" msgstr "O&dstranit" -#: kchmbookmartwindow.cpp:88 +#: kchmbookmarkwindow.cpp:88 msgid "%1 - add a bookmark" msgstr "%1 - vložení záložky" -#: kchmbookmartwindow.cpp:89 kchmbookmartwindow.cpp:131 +#: kchmbookmarkwindow.cpp:89 kchmbookmarkwindow.cpp:131 msgid "Enter the name for this bookmark:" msgstr "Zadejte jméno záložky" -#: kchmbookmartwindow.cpp:130 +#: kchmbookmarkwindow.cpp:130 msgid "%1 - edit the bookmark name" msgstr "%1 - změna názvu záložky" -#: kchmbookmartwindow.cpp:201 +#: kchmbookmarkwindow.cpp:201 msgid "&Add bookmark" msgstr "Přid&at záložku" diff --git a/po/du.po b/po/du.po index 7d7eee5..a166a43 100644 --- a/po/du.po +++ b/po/du.po @@ -341,27 +341,27 @@ msgid "" "Your emails" msgstr "rinsedevries@kde.nl" -#: kchmbookmartwindow.cpp:44 +#: kchmbookmarkwindow.cpp:44 msgid "&Add" msgstr "&Toev." -#: kchmbookmartwindow.cpp:46 +#: kchmbookmarkwindow.cpp:46 msgid "&Del" msgstr "&Verw." -#: kchmbookmartwindow.cpp:88 +#: kchmbookmarkwindow.cpp:88 msgid "%1 - add a bookmark" msgstr "%1 - voeg een bladwijzer toe" -#: kchmbookmartwindow.cpp:89 kchmbookmartwindow.cpp:131 +#: kchmbookmarkwindow.cpp:89 kchmbookmarkwindow.cpp:131 msgid "Enter the name for this bookmark:" msgstr "Voer de naam in van deze bladwijzer:" -#: kchmbookmartwindow.cpp:130 +#: kchmbookmarkwindow.cpp:130 msgid "%1 - edit the bookmark name" msgstr "%1 - bewerk de bladwijzernaam" -#: kchmbookmartwindow.cpp:201 +#: kchmbookmarkwindow.cpp:201 msgid "&Add bookmark" msgstr "Bl&adwijzer toevoegen" diff --git a/po/fr.po b/po/fr.po index 758297f..96af72e 100644 --- a/po/fr.po +++ b/po/fr.po @@ -344,27 +344,27 @@ msgstr "" "_: EMAIL OF TRANSLATORS\n" "stephan@bellegy.org" -#: kchmbookmartwindow.cpp:44 +#: kchmbookmarkwindow.cpp:44 msgid "&Add" msgstr "&Ajouter" -#: kchmbookmartwindow.cpp:46 +#: kchmbookmarkwindow.cpp:46 msgid "&Del" msgstr "&Supprimer" -#: kchmbookmartwindow.cpp:88 +#: kchmbookmarkwindow.cpp:88 msgid "%1 - add a bookmark" msgstr "%1 - ajouter un marque-page" -#: kchmbookmartwindow.cpp:89 kchmbookmartwindow.cpp:131 +#: kchmbookmarkwindow.cpp:89 kchmbookmarkwindow.cpp:131 msgid "Enter the name for this bookmark:" msgstr "Entrer le nom du marque-page :" -#: kchmbookmartwindow.cpp:130 +#: kchmbookmarkwindow.cpp:130 msgid "%1 - edit the bookmark name" msgstr "%1 - modifier le nom du marque-page" -#: kchmbookmartwindow.cpp:201 +#: kchmbookmarkwindow.cpp:201 msgid "&Add bookmark" msgstr "&Ajouter un marque-page" diff --git a/po/hu.pot b/po/hu.pot index 69c9a64..82e4476 100644 --- a/po/hu.pot +++ b/po/hu.pot @@ -311,23 +311,23 @@ msgid "" "Your emails" msgstr "csaba.zakarias@gmail.com" -#: kchmbookmartwindow.cpp:39 +#: kchmbookmarkwindow.cpp:39 msgid "&Add" msgstr "&Hozzáadás" -#: kchmbookmartwindow.cpp:41 +#: kchmbookmarkwindow.cpp:41 msgid "&Del" msgstr "&Törlés" -#: kchmbookmartwindow.cpp:64 +#: kchmbookmarkwindow.cpp:64 msgid "%1 - add a bookmark" msgstr "%1 - hozzáadás a könyvjelzőhöz" -#: kchmbookmartwindow.cpp:65 kchmbookmartwindow.cpp:101 +#: kchmbookmarkwindow.cpp:65 kchmbookmarkwindow.cpp:101 msgid "Enter the name for this bookmark:" msgstr "Adja meg a könyvjelző nevét:" -#: kchmbookmartwindow.cpp:100 +#: kchmbookmarkwindow.cpp:100 msgid "%1 - edit the bookmark name" msgstr "%1 - könyvjelző név szerkesztése" diff --git a/po/kchmviewer.pot b/po/kchmviewer.pot index 079ced6..a20341e 100644 --- a/po/kchmviewer.pot +++ b/po/kchmviewer.pot @@ -333,27 +333,27 @@ msgid "" "Your emails" msgstr "" -#: kchmbookmartwindow.cpp:44 +#: kchmbookmarkwindow.cpp:44 msgid "&Add" msgstr "" -#: kchmbookmartwindow.cpp:46 +#: kchmbookmarkwindow.cpp:46 msgid "&Del" msgstr "" -#: kchmbookmartwindow.cpp:88 +#: kchmbookmarkwindow.cpp:88 msgid "%1 - add a bookmark" msgstr "" -#: kchmbookmartwindow.cpp:89 kchmbookmartwindow.cpp:131 +#: kchmbookmarkwindow.cpp:89 kchmbookmarkwindow.cpp:131 msgid "Enter the name for this bookmark:" msgstr "" -#: kchmbookmartwindow.cpp:130 +#: kchmbookmarkwindow.cpp:130 msgid "%1 - edit the bookmark name" msgstr "" -#: kchmbookmartwindow.cpp:201 +#: kchmbookmarkwindow.cpp:201 msgid "&Add bookmark" msgstr "" diff --git a/po/ru.po b/po/ru.po index c0793c8..3edf720 100644 --- a/po/ru.po +++ b/po/ru.po @@ -343,27 +343,27 @@ msgstr "" "_: EMAIL OF TRANSLATORS\n" "ibobrik@gmail.com" -#: kchmbookmartwindow.cpp:44 +#: kchmbookmarkwindow.cpp:44 msgid "&Add" msgstr "Добавить" -#: kchmbookmartwindow.cpp:46 +#: kchmbookmarkwindow.cpp:46 msgid "&Del" msgstr "Удалить" -#: kchmbookmartwindow.cpp:88 +#: kchmbookmarkwindow.cpp:88 msgid "%1 - add a bookmark" msgstr "%1 - добавить закладку" -#: kchmbookmartwindow.cpp:89 kchmbookmartwindow.cpp:131 +#: kchmbookmarkwindow.cpp:89 kchmbookmarkwindow.cpp:131 msgid "Enter the name for this bookmark:" msgstr "Введите имя для этой закладки" -#: kchmbookmartwindow.cpp:130 +#: kchmbookmarkwindow.cpp:130 msgid "%1 - edit the bookmark name" msgstr "%1 - редактировать имя закладки" -#: kchmbookmartwindow.cpp:201 +#: kchmbookmarkwindow.cpp:201 #, fuzzy msgid "&Add bookmark" msgstr "Добавить в избранное" diff --git a/po/tr.po b/po/tr.po index f6b3625..98217bf 100644 --- a/po/tr.po +++ b/po/tr.po @@ -337,27 +337,27 @@ msgid "" "Your emails" msgstr "coderlord@gmail.com" -#: kchmbookmartwindow.cpp:44 +#: kchmbookmarkwindow.cpp:44 msgid "&Add" msgstr "&Ekle" -#: kchmbookmartwindow.cpp:46 +#: kchmbookmarkwindow.cpp:46 msgid "&Del" msgstr "&Sil" -#: kchmbookmartwindow.cpp:88 +#: kchmbookmarkwindow.cpp:88 msgid "%1 - add a bookmark" msgstr "%1 - bir yer imi ekle" -#: kchmbookmartwindow.cpp:89 kchmbookmartwindow.cpp:131 +#: kchmbookmarkwindow.cpp:89 kchmbookmarkwindow.cpp:131 msgid "Enter the name for this bookmark:" msgstr "Bu yer imi için isim girin:" -#: kchmbookmartwindow.cpp:130 +#: kchmbookmarkwindow.cpp:130 msgid "%1 - edit the bookmark name" msgstr "%1 - yer imi adını düzenle" -#: kchmbookmartwindow.cpp:201 +#: kchmbookmarkwindow.cpp:201 #, fuzzy msgid "&Add bookmark" msgstr "Yer imlerine ekle" diff --git a/po/zh_CN.po b/po/zh_CN.po index d582f04..3640b53 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -336,27 +336,27 @@ msgid "" "Your emails" msgstr "demonlinjun@163.com" -#: kchmbookmartwindow.cpp:44 +#: kchmbookmarkwindow.cpp:44 msgid "&Add" msgstr "添加(&A)" -#: kchmbookmartwindow.cpp:46 +#: kchmbookmarkwindow.cpp:46 msgid "&Del" msgstr "删除(&D)" -#: kchmbookmartwindow.cpp:88 +#: kchmbookmarkwindow.cpp:88 msgid "%1 - add a bookmark" msgstr "%1 - 添加书签" -#: kchmbookmartwindow.cpp:89 kchmbookmartwindow.cpp:131 +#: kchmbookmarkwindow.cpp:89 kchmbookmarkwindow.cpp:131 msgid "Enter the name for this bookmark:" msgstr "输入书签的名称" -#: kchmbookmartwindow.cpp:130 +#: kchmbookmarkwindow.cpp:130 msgid "%1 - edit the bookmark name" msgstr "%1 - 编辑书签名称" -#: kchmbookmartwindow.cpp:201 +#: kchmbookmarkwindow.cpp:201 msgid "&Add bookmark" msgstr "添加书签(&A)" diff --git a/src/Makefile.am b/src/Makefile.am index 40a3131..c853ef9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ LIB_KDEEXTRA = kde/libkdeextra.a endif bin_PROGRAMS = kchmviewer -kchmviewer_SOURCES = iconstorage.cpp kchmbookmartwindow.cpp kchmconfig.cpp \ +kchmviewer_SOURCES = iconstorage.cpp kchmbookmarkwindow.cpp kchmconfig.cpp \ kchmindexwindow.cpp kchmmainwindow.cpp kchmsearchtoolbar.cpp kchmsearchwindow.cpp \ kchmsettings.cpp kchmsourcefactory.cpp kchmtreeviewitem.cpp kchmviewwindow.cpp main.cpp \ kchmdialogchooseurlfromlist.cpp kde-qt.cpp kchmviewwindow_qtextbrowser.cpp \ @@ -26,7 +26,7 @@ METASOURCES = AUTO KDE_OPTIONS = qtonly KDE_ICON = AUTO noinst_HEADERS = kchmsettings.h forwarddeclarations.h kchmsourcefactory.h \ - iconstorage.h kchmbookmartwindow.h kchmconfig.h kchmtreeviewitem.h \ + iconstorage.h kchmbookmarkwindow.h kchmconfig.h kchmtreeviewitem.h \ kchmdialogchooseurlfromlist.h kchmviewwindow.h kchmindexwindow.h \ kchmmainwindow.h kchmviewwindow_qtextbrowser.h kchmsearchtoolbar.h kde-qt.h \ kchmsearchwindow.h kqtempfile.h kqrunprocess.h kchmnavtoolbar.h kchmviewwindowmgr.h \ diff --git a/src/kchmbookmarkwindow.cpp b/src/kchmbookmarkwindow.cpp new file mode 100644 index 0000000..a95953c --- /dev/null +++ b/src/kchmbookmarkwindow.cpp @@ -0,0 +1,239 @@ +/*************************************************************************** + * Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com * + * Please do not use email address above for bug reports; see * + * the README file * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "kchmbookmarkwindow.h" +#include "kchmmainwindow.h" +#include "kchmviewwindow.h" +#include "kchmlistitemtooltip.h" +#include "kchmtreeviewitem.h" + +#include "kchmbookmarkwindow.moc" + +KCHMBookmarkWindow::KCHMBookmarkWindow(TQWidget *parent, const char *name) + : TQWidget(parent, name) +{ + TQVBoxLayout * layout = new TQVBoxLayout (this); + layout->setMargin (5); + + m_bookmarkList = new KQListView (this); + m_bookmarkList->addColumn( "bookmark" ); // no need to i18n - the column is hidden + m_bookmarkList->header()->hide(); + layout->addWidget (m_bookmarkList); + + new KCHMListItemTooltip( m_bookmarkList ); + + TQHBoxLayout * hlayout = new TQHBoxLayout (layout); + TQPushButton * add = new TQPushButton ( i18n( "&Add" ), this); + TQPushButton * edit = new TQPushButton ( i18n( "&Edit" ), this); + TQPushButton * del = new TQPushButton ( i18n( "&Del" ), this); + + hlayout->addWidget (add); + hlayout->addWidget (edit); + hlayout->addWidget (del); + + connect( m_bookmarkList, + TQT_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int) ), + this, + TQT_SLOT( onDoubleClicked ( TQListViewItem *, const TQPoint &, int) ) ); + + connect( add, + TQT_SIGNAL( clicked () ), + this, + TQT_SLOT( onAddBookmarkPressed( ) ) ); + + connect( del, + TQT_SIGNAL( clicked () ), + this, + TQT_SLOT( onDelBookmarkPressed( ) ) ); + + connect( edit, + TQT_SIGNAL( clicked () ), + this, + TQT_SLOT( onEditBookmarkPressed( ) ) ); + + connect( m_bookmarkList, + TQT_SIGNAL( contextMenuRequested( TQListViewItem *, const TQPoint& , int ) ), + this, + TQT_SLOT( slotContextMenuRequested ( TQListViewItem *, const TQPoint &, int ) ) ); + + m_menuBookmarks = 0; + m_contextMenu = 0; + m_listChanged = false; +} + +void KCHMBookmarkWindow::onAddBookmarkPressed( ) +{ + bool ok; + TQString url = ::mainWindow->currentBrowser()->getOpenedPage(); + TQString title = ::mainWindow->chmFile()->getTopicByUrl(url); + TQString name = TQInputDialog::getText( + i18n( "%1 - add a bookmark") . arg(APP_NAME), + i18n( "Enter the name for this bookmark:" ), + TQLineEdit::Normal, + title, + &ok, + this); + + if ( !ok || name.isEmpty() ) + return; + + KCHMBookmarkTreeViewItem * item = new KCHMBookmarkTreeViewItem ( + m_bookmarkList, + name, + url, + ::mainWindow->currentBrowser()->getScrollbarPosition() ); + + item->menuid = m_menuBookmarks->insertItem( name ); + m_listChanged = true; +} + + +void KCHMBookmarkWindow::onDelBookmarkPressed( ) +{ + KCHMBookmarkTreeViewItem * item = (KCHMBookmarkTreeViewItem *) m_bookmarkList->selectedItem(); + + if ( item ) + { + m_menuBookmarks->removeItem( item->menuid ); + delete item; + m_listChanged = true; + } +} + + +void KCHMBookmarkWindow::onEditBookmarkPressed( ) +{ + KCHMBookmarkTreeViewItem * item = (KCHMBookmarkTreeViewItem *) m_bookmarkList->selectedItem(); + + if ( item ) + { + bool ok; + TQString name = TQInputDialog::getText( + i18n( "%1 - edit the bookmark name") . arg(APP_NAME), + i18n( "Enter the name for this bookmark:" ), + TQLineEdit::Normal, + item->name, + &ok, + this); + + if ( !ok || name.isEmpty() ) + return; + + item->setText (0, name); + m_menuBookmarks->changeItem( item->menuid, name ); + m_listChanged = true; + } +} + + +void KCHMBookmarkWindow::onDoubleClicked( TQListViewItem * item, const TQPoint &, int ) +{ + if ( !item ) + return; + + KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) item; + + if ( ::mainWindow->currentBrowser()->getOpenedPage() != treeitem->url ) + ::mainWindow->openPage( treeitem->url, OPF_CONTENT_TREE | OPF_ADD2HISTORY ); + + ::mainWindow->currentBrowser()->setScrollbarPosition(treeitem->scroll_y); +} + + +void KCHMBookmarkWindow::restoreSettings( const KCHMSettings::bookmark_saved_settings_t & settings ) +{ + for ( unsigned int i = 0; i < settings.size(); i++ ) + { + KCHMBookmarkTreeViewItem * item = new KCHMBookmarkTreeViewItem (m_bookmarkList, settings[i].name, settings[i].url, settings[i].scroll_y); + + item->menuid = m_menuBookmarks->insertItem( settings[i].name ); + } +} + + +void KCHMBookmarkWindow::saveSettings( KCHMSettings::bookmark_saved_settings_t & settings ) +{ + TQListViewItemIterator it (m_bookmarkList); + + settings.clear(); + + for ( ; it.current(); it++ ) + { + KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) it.current(); + settings.push_back (KCHMSettings::SavedBookmark(treeitem->name, treeitem->url, treeitem->scroll_y)); + } +} + +void KCHMBookmarkWindow::invalidate( ) +{ + TQListViewItemIterator it( m_bookmarkList ); + + for ( ; it.current(); it++ ) + m_menuBookmarks->removeItem( ((KCHMBookmarkTreeViewItem *) it.current())->menuid ); + + m_bookmarkList->clear(); +} + +void KCHMBookmarkWindow::createMenu( KCHMMainWindow * parent ) +{ + // Create the main Bookmark menu + m_menuBookmarks = new KTQPopupMenu( parent ); + parent->menuBar()->insertItem( i18n( "&Bookmarks"), m_menuBookmarks ); + + m_menuBookmarks->insertItem( i18n( "&Add bookmark"), this, TQT_SLOT(onAddBookmarkPressed()), CTRL+Key_B ); + m_menuBookmarks->insertSeparator(); + + connect( m_menuBookmarks, TQT_SIGNAL( activated(int) ), this, TQT_SLOT ( onBookmarkSelected(int) )); +} + +void KCHMBookmarkWindow::onBookmarkSelected( int bookmark ) +{ + TQListViewItemIterator it( m_bookmarkList ); + + for ( ; it.current(); it++ ) + { + if ( ((KCHMBookmarkTreeViewItem *) it.current())->menuid == bookmark ) + { + KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) it.current(); + + if ( ::mainWindow->currentBrowser()->getOpenedPage() != treeitem->url ) + ::mainWindow->openPage( treeitem->url, OPF_CONTENT_TREE | OPF_ADD2HISTORY ); + + ::mainWindow->currentBrowser()->setScrollbarPosition(treeitem->scroll_y); + break; + } + } +} + +void KCHMBookmarkWindow::slotContextMenuRequested( TQListViewItem * item, const TQPoint & point, int ) +{ + if ( !m_contextMenu ) + m_contextMenu = ::mainWindow->currentBrowser()->createListItemContextMenu( this ); + + if( item ) + { + KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) item; + + ::mainWindow->currentBrowser()->setTabKeeper( treeitem->url ); + m_contextMenu->popup( point ); + } +} + diff --git a/src/kchmbookmarkwindow.h b/src/kchmbookmarkwindow.h new file mode 100644 index 0000000..ef57278 --- /dev/null +++ b/src/kchmbookmarkwindow.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com * + * Please do not use email address above for bug reports; see * + * the README file * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * 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; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef KCHMBOOKMARKWINDOW_H +#define KCHMBOOKMARKWINDOW_H + +#include "kde-qt.h" +#include "forwarddeclarations.h" +#include "kchmsettings.h" + +/** +@author Georgy Yunaev +*/ +class KCHMBookmarkWindow : public TQWidget +{ + Q_OBJECT + + public: + KCHMBookmarkWindow(TQWidget *parent = 0, const char *name = 0); + virtual ~KCHMBookmarkWindow() {}; + + void createMenu( KCHMMainWindow * parent ); + + void restoreSettings (const KCHMSettings::bookmark_saved_settings_t& settings); + void saveSettings (KCHMSettings::bookmark_saved_settings_t& settings); + void invalidate(); + + public slots: + void onAddBookmarkPressed (); + void slotContextMenuRequested ( TQListViewItem *item, const TQPoint &point, int column ); + + private slots: + void onBookmarkSelected( int ); + void onDelBookmarkPressed( ); + void onEditBookmarkPressed( ); + void onDoubleClicked ( TQListViewItem *, const TQPoint &, int ); + + private: + KTQPopupMenu * m_menuBookmarks; + KQListView * m_bookmarkList; + TQString m_bookmarkFileName; + bool m_listChanged; + KTQPopupMenu * m_contextMenu; +}; + +#endif diff --git a/src/kchmbookmartwindow.cpp b/src/kchmbookmartwindow.cpp deleted file mode 100644 index e5f6a19..0000000 --- a/src/kchmbookmartwindow.cpp +++ /dev/null @@ -1,239 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com * - * Please do not use email address above for bug reports; see * - * the README file * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * 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; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "kchmbookmartwindow.h" -#include "kchmmainwindow.h" -#include "kchmviewwindow.h" -#include "kchmlistitemtooltip.h" -#include "kchmtreeviewitem.h" - -#include "kchmbookmartwindow.moc" - -KCHMBookmarkWindow::KCHMBookmarkWindow(TQWidget *parent, const char *name) - : TQWidget(parent, name) -{ - TQVBoxLayout * layout = new TQVBoxLayout (this); - layout->setMargin (5); - - m_bookmarkList = new KQListView (this); - m_bookmarkList->addColumn( "bookmark" ); // no need to i18n - the column is hidden - m_bookmarkList->header()->hide(); - layout->addWidget (m_bookmarkList); - - new KCHMListItemTooltip( m_bookmarkList ); - - TQHBoxLayout * hlayout = new TQHBoxLayout (layout); - TQPushButton * add = new TQPushButton ( i18n( "&Add" ), this); - TQPushButton * edit = new TQPushButton ( i18n( "&Edit" ), this); - TQPushButton * del = new TQPushButton ( i18n( "&Del" ), this); - - hlayout->addWidget (add); - hlayout->addWidget (edit); - hlayout->addWidget (del); - - connect( m_bookmarkList, - TQT_SIGNAL( doubleClicked ( TQListViewItem *, const TQPoint &, int) ), - this, - TQT_SLOT( onDoubleClicked ( TQListViewItem *, const TQPoint &, int) ) ); - - connect( add, - TQT_SIGNAL( clicked () ), - this, - TQT_SLOT( onAddBookmarkPressed( ) ) ); - - connect( del, - TQT_SIGNAL( clicked () ), - this, - TQT_SLOT( onDelBookmarkPressed( ) ) ); - - connect( edit, - TQT_SIGNAL( clicked () ), - this, - TQT_SLOT( onEditBookmarkPressed( ) ) ); - - connect( m_bookmarkList, - TQT_SIGNAL( contextMenuRequested( TQListViewItem *, const TQPoint& , int ) ), - this, - TQT_SLOT( slotContextMenuRequested ( TQListViewItem *, const TQPoint &, int ) ) ); - - m_menuBookmarks = 0; - m_contextMenu = 0; - m_listChanged = false; -} - -void KCHMBookmarkWindow::onAddBookmarkPressed( ) -{ - bool ok; - TQString url = ::mainWindow->currentBrowser()->getOpenedPage(); - TQString title = ::mainWindow->chmFile()->getTopicByUrl(url); - TQString name = TQInputDialog::getText( - i18n( "%1 - add a bookmark") . arg(APP_NAME), - i18n( "Enter the name for this bookmark:" ), - TQLineEdit::Normal, - title, - &ok, - this); - - if ( !ok || name.isEmpty() ) - return; - - KCHMBookmarkTreeViewItem * item = new KCHMBookmarkTreeViewItem ( - m_bookmarkList, - name, - url, - ::mainWindow->currentBrowser()->getScrollbarPosition() ); - - item->menuid = m_menuBookmarks->insertItem( name ); - m_listChanged = true; -} - - -void KCHMBookmarkWindow::onDelBookmarkPressed( ) -{ - KCHMBookmarkTreeViewItem * item = (KCHMBookmarkTreeViewItem *) m_bookmarkList->selectedItem(); - - if ( item ) - { - m_menuBookmarks->removeItem( item->menuid ); - delete item; - m_listChanged = true; - } -} - - -void KCHMBookmarkWindow::onEditBookmarkPressed( ) -{ - KCHMBookmarkTreeViewItem * item = (KCHMBookmarkTreeViewItem *) m_bookmarkList->selectedItem(); - - if ( item ) - { - bool ok; - TQString name = TQInputDialog::getText( - i18n( "%1 - edit the bookmark name") . arg(APP_NAME), - i18n( "Enter the name for this bookmark:" ), - TQLineEdit::Normal, - item->name, - &ok, - this); - - if ( !ok || name.isEmpty() ) - return; - - item->setText (0, name); - m_menuBookmarks->changeItem( item->menuid, name ); - m_listChanged = true; - } -} - - -void KCHMBookmarkWindow::onDoubleClicked( TQListViewItem * item, const TQPoint &, int ) -{ - if ( !item ) - return; - - KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) item; - - if ( ::mainWindow->currentBrowser()->getOpenedPage() != treeitem->url ) - ::mainWindow->openPage( treeitem->url, OPF_CONTENT_TREE | OPF_ADD2HISTORY ); - - ::mainWindow->currentBrowser()->setScrollbarPosition(treeitem->scroll_y); -} - - -void KCHMBookmarkWindow::restoreSettings( const KCHMSettings::bookmark_saved_settings_t & settings ) -{ - for ( unsigned int i = 0; i < settings.size(); i++ ) - { - KCHMBookmarkTreeViewItem * item = new KCHMBookmarkTreeViewItem (m_bookmarkList, settings[i].name, settings[i].url, settings[i].scroll_y); - - item->menuid = m_menuBookmarks->insertItem( settings[i].name ); - } -} - - -void KCHMBookmarkWindow::saveSettings( KCHMSettings::bookmark_saved_settings_t & settings ) -{ - TQListViewItemIterator it (m_bookmarkList); - - settings.clear(); - - for ( ; it.current(); it++ ) - { - KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) it.current(); - settings.push_back (KCHMSettings::SavedBookmark(treeitem->name, treeitem->url, treeitem->scroll_y)); - } -} - -void KCHMBookmarkWindow::invalidate( ) -{ - TQListViewItemIterator it( m_bookmarkList ); - - for ( ; it.current(); it++ ) - m_menuBookmarks->removeItem( ((KCHMBookmarkTreeViewItem *) it.current())->menuid ); - - m_bookmarkList->clear(); -} - -void KCHMBookmarkWindow::createMenu( KCHMMainWindow * parent ) -{ - // Create the main Bookmark menu - m_menuBookmarks = new KTQPopupMenu( parent ); - parent->menuBar()->insertItem( i18n( "&Bookmarks"), m_menuBookmarks ); - - m_menuBookmarks->insertItem( i18n( "&Add bookmark"), this, TQT_SLOT(onAddBookmarkPressed()), CTRL+Key_B ); - m_menuBookmarks->insertSeparator(); - - connect( m_menuBookmarks, TQT_SIGNAL( activated(int) ), this, TQT_SLOT ( onBookmarkSelected(int) )); -} - -void KCHMBookmarkWindow::onBookmarkSelected( int bookmark ) -{ - TQListViewItemIterator it( m_bookmarkList ); - - for ( ; it.current(); it++ ) - { - if ( ((KCHMBookmarkTreeViewItem *) it.current())->menuid == bookmark ) - { - KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) it.current(); - - if ( ::mainWindow->currentBrowser()->getOpenedPage() != treeitem->url ) - ::mainWindow->openPage( treeitem->url, OPF_CONTENT_TREE | OPF_ADD2HISTORY ); - - ::mainWindow->currentBrowser()->setScrollbarPosition(treeitem->scroll_y); - break; - } - } -} - -void KCHMBookmarkWindow::slotContextMenuRequested( TQListViewItem * item, const TQPoint & point, int ) -{ - if ( !m_contextMenu ) - m_contextMenu = ::mainWindow->currentBrowser()->createListItemContextMenu( this ); - - if( item ) - { - KCHMBookmarkTreeViewItem * treeitem = (KCHMBookmarkTreeViewItem *) item; - - ::mainWindow->currentBrowser()->setTabKeeper( treeitem->url ); - m_contextMenu->popup( point ); - } -} - diff --git a/src/kchmbookmartwindow.h b/src/kchmbookmartwindow.h deleted file mode 100644 index ef57278..0000000 --- a/src/kchmbookmartwindow.h +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com * - * Please do not use email address above for bug reports; see * - * the README file * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * 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; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#ifndef KCHMBOOKMARKWINDOW_H -#define KCHMBOOKMARKWINDOW_H - -#include "kde-qt.h" -#include "forwarddeclarations.h" -#include "kchmsettings.h" - -/** -@author Georgy Yunaev -*/ -class KCHMBookmarkWindow : public TQWidget -{ - Q_OBJECT - - public: - KCHMBookmarkWindow(TQWidget *parent = 0, const char *name = 0); - virtual ~KCHMBookmarkWindow() {}; - - void createMenu( KCHMMainWindow * parent ); - - void restoreSettings (const KCHMSettings::bookmark_saved_settings_t& settings); - void saveSettings (KCHMSettings::bookmark_saved_settings_t& settings); - void invalidate(); - - public slots: - void onAddBookmarkPressed (); - void slotContextMenuRequested ( TQListViewItem *item, const TQPoint &point, int column ); - - private slots: - void onBookmarkSelected( int ); - void onDelBookmarkPressed( ); - void onEditBookmarkPressed( ); - void onDoubleClicked ( TQListViewItem *, const TQPoint &, int ); - - private: - KTQPopupMenu * m_menuBookmarks; - KQListView * m_bookmarkList; - TQString m_bookmarkFileName; - bool m_listChanged; - KTQPopupMenu * m_contextMenu; -}; - -#endif diff --git a/src/kchmmainwindow.cpp b/src/kchmmainwindow.cpp index 9c566cc..78a9226 100644 --- a/src/kchmmainwindow.cpp +++ b/src/kchmmainwindow.cpp @@ -39,7 +39,7 @@ #include "kchmconfig.h" #include "kchmindexwindow.h" #include "kchmsearchwindow.h" -#include "kchmbookmartwindow.h" +#include "kchmbookmarkwindow.h" #include "kchmtreeviewitem.h" #include "kchmsearchtoolbar.h" #include "kchmsettings.h" -- cgit v1.2.3