diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /konqueror/sidebar/trees/history_module | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konqueror/sidebar/trees/history_module')
-rw-r--r-- | konqueror/sidebar/trees/history_module/Makefile.am | 16 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/history_dlg.ui | 239 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/history_item.cpp | 246 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/history_item.h | 111 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/history_module.cpp | 369 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/history_module.h | 108 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/history_settings.cpp | 111 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/history_settings.h | 66 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/kcmhistory.cpp | 272 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/kcmhistory.desktop | 233 | ||||
-rw-r--r-- | konqueror/sidebar/trees/history_module/kcmhistory.h | 64 |
11 files changed, 1835 insertions, 0 deletions
diff --git a/konqueror/sidebar/trees/history_module/Makefile.am b/konqueror/sidebar/trees/history_module/Makefile.am new file mode 100644 index 000000000..5f033d662 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = -I$(top_srcdir)/libkonq -I$(srcdir)/.. -I$(srcdir)/../.. $(all_includes) + +kde_module_LTLIBRARIES = konq_sidebartree_history.la kcm_history.la + +METASOURCES = AUTO + +konq_sidebartree_history_la_SOURCES = history_module.cpp history_item.cpp \ + history_settings.cpp history_settings.skel +konq_sidebartree_history_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +konq_sidebartree_history_la_LIBADD = ../../libkonqsidebarplugin.la ../libkonq_sidebar_tree.la + +kcm_history_la_SOURCES = kcmhistory.cpp history_dlg.ui history_settings.cpp history_settings.skel +kcm_history_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +kcm_history_la_LIBADD = -lkdeui $(top_builddir)/libkonq/libkonq.la + +xdg_apps_DATA = kcmhistory.desktop diff --git a/konqueror/sidebar/trees/history_module/history_dlg.ui b/konqueror/sidebar/trees/history_module/history_dlg.ui new file mode 100644 index 000000000..32fd31296 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_dlg.ui @@ -0,0 +1,239 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>KonqSidebarHistoryDlg</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KonqHistoryDlg</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>450</width> + <height>290</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gbLimits</cstring> + </property> + <property name="title"> + <string>Limits</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="1" column="2"> + <property name="name"> + <cstring>Spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>240</width> + <height>16</height> + </size> + </property> + </spacer> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>cbExpire</cstring> + </property> + <property name="text"> + <string>URLs e&xpire after</string> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="1"> + <property name="name"> + <cstring>spinExpire</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lEntries</cstring> + </property> + <property name="text"> + <string>Maximum &number of URLs:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>spinEntries</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>spinEntries</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gbFonts</cstring> + </property> + <property name="title"> + <string>Custom Fonts For</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntNumInput" row="0" column="1"> + <property name="name"> + <cstring>spinNewer</cstring> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="1"> + <property name="name"> + <cstring>spinOlder</cstring> + </property> + </widget> + <widget class="QComboBox" row="1" column="2"> + <property name="name"> + <cstring>comboOlder</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lbNewer</cstring> + </property> + <property name="text"> + <string>URLs newer than</string> + </property> + </widget> + <widget class="QComboBox" row="0" column="2"> + <property name="name"> + <cstring>comboNewer</cstring> + </property> + </widget> + <widget class="QPushButton" row="1" column="3"> + <property name="name"> + <cstring>btnFontOlder</cstring> + </property> + <property name="text"> + <string>Choose Font...</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>lbOlder</cstring> + </property> + <property name="text"> + <string>URLs older than</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="3"> + <property name="name"> + <cstring>btnFontNewer</cstring> + </property> + <property name="text"> + <string>Choose Font...</string> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gbDetails</cstring> + </property> + <property name="title"> + <string>Details</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>cbDetailedTips</cstring> + </property> + <property name="text"> + <string>Detailed tooltips</string> + </property> + <property name="toolTip" stdset="0"> + <string>Shows the number of times visited and the dates of the first and last visits, in addition to the URL</string> + </property> + </widget> + </hbox> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>btnClearHistory</cstring> + </property> + <property name="text"> + <string>Clear History</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>418</width> + <height>0</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>16</width> + <height>30</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<layoutdefaults spacing="6" margin="0"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/konqueror/sidebar/trees/history_module/history_item.cpp b/konqueror/sidebar/trees/history_module/history_item.cpp new file mode 100644 index 000000000..bfda3152c --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_item.cpp @@ -0,0 +1,246 @@ +/* This file is part of the KDE project + Copyright (C) 2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <kbookmarkdrag.h> +#include <kprotocolinfo.h> +#include <konq_faviconmgr.h> +#include <qpainter.h> + +#include <assert.h> + +#include "history_item.h" +#include "history_module.h" +#include "history_settings.h" +#include <kiconloader.h> + +#define MYMODULE static_cast<KonqSidebarHistoryModule*>(module()) +#define MYGROUP static_cast<KonqSidebarHistoryGroupItem*>(parent()) + +KonqSidebarHistorySettings * KonqSidebarHistoryItem::s_settings = 0L; + +KonqSidebarHistoryItem::KonqSidebarHistoryItem( const KonqHistoryEntry *entry, + KonqSidebarTreeItem * parentItem, + KonqSidebarTreeTopLevelItem *topLevelItem ) + : KonqSidebarTreeItem( parentItem, topLevelItem ) +{ + setExpandable( false ); + update( entry ); +} + +KonqSidebarHistoryItem::~KonqSidebarHistoryItem() +{ +} + +void KonqSidebarHistoryItem::update( const KonqHistoryEntry *entry ) +{ + m_entry = entry; + + if (!entry) + return; + + QString title( entry->title ); + if ( !title.stripWhiteSpace().isEmpty() && + title != entry->url.url() ) + setText( 0, title ); + else { + QString path( entry->url.path() ); + if ( path.isEmpty() ) + path += '/'; + setText( 0, path ); + } + + KonqSidebarHistoryGroupItem *group = MYGROUP; + assert(group); + QString path = entry->url.path(); + if ( group->hasFavIcon() && (path.isNull() || path == "/") ) + { + const QPixmap *pm = group->pixmap(0); + if (pm) + setPixmap( 0, *pm ); + } + else + { + setPixmap( 0, SmallIcon(KProtocolInfo::icon( entry->url.protocol() ))); + } + + group->itemUpdated( this ); // update for sorting +} + +void KonqSidebarHistoryItem::itemSelected() +{ + tree()->enableActions( true, true, false, false, false, false ); +} + +void KonqSidebarHistoryItem::rightButtonPressed() +{ + MYMODULE->showPopupMenu(); +} + +QDragObject * KonqSidebarHistoryItem::dragObject( QWidget * parent, bool /*move*/ ) +{ + QString icon = KonqFavIconMgr::iconForURL( m_entry->url.url() ); + KBookmark bookmark = KBookmark::standaloneBookmark( m_entry->title, + m_entry->url, icon ); + KBookmarkDrag *drag = KBookmarkDrag::newDrag( bookmark, parent ); + return drag; +} + +// new items go on top +QString KonqSidebarHistoryItem::key( int column, bool ascending ) const +{ + if ( MYMODULE->sortsByName() ) + return KonqSidebarTreeItem::key( column, ascending ); + + QString tmp; + tmp.sprintf( "%08x", m_entry->lastVisited.secsTo(MYMODULE->currentTime())); + return tmp; +} + +QString KonqSidebarHistoryItem::toolTipText() const +{ + if ( s_settings->m_detailedTips ) { + // this weird ordering of %4, %1, %2, %3 is due to the reason, that some + // urls seem to contain %N, which would get substituted in the next + // .arg() calls. So to fix this, we first substitute the last items + // and then put in the url. + QString tip = i18n("<qt><center><b>%4</b></center><hr>Last visited: %1<br>First visited: %2<br>Number of times visited: %3</qt>"); + return tip.arg( KGlobal::locale()->formatDateTime( m_entry->lastVisited ) ).arg( KGlobal::locale()->formatDateTime( m_entry->firstVisited ) ).arg( m_entry->numberOfTimesVisited ).arg( m_entry->url.url() ); + } + + return m_entry->url.url(); +} + +void KonqSidebarHistoryItem::paintCell( QPainter *p, const QColorGroup & cg, + int column, int width, int alignment ) +{ + QDateTime dt; + QDateTime current = QDateTime::currentDateTime(); + + if ( s_settings->m_metricYoungerThan == KonqSidebarHistorySettings::DAYS ) + dt = current.addDays( - s_settings->m_valueYoungerThan ); + else + dt = current.addSecs( - (s_settings->m_valueYoungerThan * 60) ); + + if ( m_entry->lastVisited > dt ) + p->setFont( s_settings->m_fontYoungerThan ); + + else { + if ( s_settings->m_metricOlderThan == KonqSidebarHistorySettings::DAYS ) + dt = current.addDays( - s_settings->m_valueOlderThan ); + else + dt = current.addSecs( - (s_settings->m_valueOlderThan * 60) ); + + if ( m_entry->lastVisited < dt ) + p->setFont( s_settings->m_fontOlderThan ); + } + + KonqSidebarTreeItem::paintCell( p, cg, column, width, alignment ); +} + +/////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////// + + +KonqSidebarHistoryGroupItem::KonqSidebarHistoryGroupItem( const KURL& url, + KonqSidebarTreeTopLevelItem *topLevelItem) + : KonqSidebarTreeItem( topLevelItem, topLevelItem ), + m_hasFavIcon( false ), + m_url( url ) +{ +} + +void KonqSidebarHistoryGroupItem::setFavIcon( const QPixmap& pix ) +{ + setPixmap( 0, pix ); + m_hasFavIcon = true; +} + +// the group item itself will be removed automatically, +// when the last child is removed +void KonqSidebarHistoryGroupItem::remove() +{ + KURL::List list; + KonqSidebarHistoryItem *child = static_cast<KonqSidebarHistoryItem*>( firstChild() ); + while( child ) { + list.append( child->externalURL() ); + child = static_cast<KonqSidebarHistoryItem*>( child->nextSibling() ); + } + + if ( !list.isEmpty() ) + KonqHistoryManager::kself()->emitRemoveFromHistory( list ); +} + +KonqSidebarHistoryItem * KonqSidebarHistoryGroupItem::findChild(const KonqHistoryEntry *entry) const +{ + QListViewItem *child = firstChild(); + KonqSidebarHistoryItem *item = 0L; + + while ( child ) { + item = static_cast<KonqSidebarHistoryItem *>( child ); + if ( item->entry() == entry ) + return item; + + child = child->nextSibling(); + } + + return 0L; +} + +void KonqSidebarHistoryGroupItem::itemSelected() +{ + tree()->enableActions( false, false, false, + false, false, false ); +} + +void KonqSidebarHistoryGroupItem::rightButtonPressed() +{ + MYMODULE->showPopupMenu(); +} + +// let the module change our pixmap (opened/closed) +void KonqSidebarHistoryGroupItem::setOpen( bool open ) +{ + MYMODULE->groupOpened( this, open ); + KonqSidebarTreeItem::setOpen( open ); +} + +// new items go on top +QString KonqSidebarHistoryGroupItem::key( int column, bool ascending ) const +{ + if ( !m_lastVisited.isValid() || MYMODULE->sortsByName() ) + return KonqSidebarTreeItem::key( column, ascending ); + + QString tmp; + tmp.sprintf( "%08x", m_lastVisited.secsTo( MYMODULE->currentTime() )); + return tmp; +} + +void KonqSidebarHistoryGroupItem::itemUpdated( KonqSidebarHistoryItem *item ) +{ + if ( !m_lastVisited.isValid() || m_lastVisited < item->lastVisited() ) + m_lastVisited = item->lastVisited(); +} + +QDragObject * KonqSidebarHistoryGroupItem::dragObject( QWidget *parent, bool /*move*/) +{ + QString icon = KonqFavIconMgr::iconForURL( m_url.url() ); + KBookmark bookmark = KBookmark::standaloneBookmark( QString::null, m_url, + icon ); + KBookmarkDrag *drag = KBookmarkDrag::newDrag( bookmark, parent ); + return drag; +} diff --git a/konqueror/sidebar/trees/history_module/history_item.h b/konqueror/sidebar/trees/history_module/history_item.h new file mode 100644 index 000000000..a7c77a677 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_item.h @@ -0,0 +1,111 @@ +/* This file is part of the KDE project + Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef HISTORY_ITEM_H +#define HISTORY_ITEM_H + +#include <kurl.h> +#include <konq_historymgr.h> + +#include "konq_sidebartreeitem.h" + +class QDropEvent; +class QPainter; +class KonqSidebarHistorySettings; + +class KonqSidebarHistoryItem : public KonqSidebarTreeItem +{ +public: + KonqSidebarHistoryItem( const KonqHistoryEntry *entry, + KonqSidebarTreeItem *parentItem, + KonqSidebarTreeTopLevelItem *topLevelItem ); + ~KonqSidebarHistoryItem(); + + virtual void rightButtonPressed(); + + virtual void itemSelected(); + + // The URL to open when this link is clicked + virtual KURL externalURL() const { return m_entry->url; } + const KURL& url() const { return m_entry->url; } // a faster one + virtual QString toolTipText() const; + + QString host() const { return m_entry->url.host(); } + QString path() const { return m_entry->url.path(); } + + const QDateTime& lastVisited() const { return m_entry->lastVisited; } + + void update( const KonqHistoryEntry *entry ); + const KonqHistoryEntry *entry() const { return m_entry; } + + virtual QDragObject * dragObject( QWidget * parent, bool move = false ); + + virtual QString key( int column, bool ascending ) const; + + static void setSettings( KonqSidebarHistorySettings *s ) { s_settings = s; } + + virtual void paintCell( QPainter *, const QColorGroup & cg, int column, + int width, int alignment ); + +private: + const KonqHistoryEntry *m_entry; + static KonqSidebarHistorySettings *s_settings; + +}; + +class KonqSidebarHistoryGroupItem : public KonqSidebarTreeItem +{ +public: + + KonqSidebarHistoryGroupItem( const KURL& url, KonqSidebarTreeTopLevelItem * ); + + /** + * removes itself and all its children from the history (not just the view) + */ + void remove(); + + KonqSidebarHistoryItem * findChild( const KonqHistoryEntry *entry ) const; + + virtual void rightButtonPressed(); + + virtual void setOpen( bool open ); + + virtual QString key( int column, bool ascending ) const; + + void itemUpdated( KonqSidebarHistoryItem *item ); + + bool hasFavIcon() const { return m_hasFavIcon; } + void setFavIcon( const QPixmap& pix ); + + virtual QDragObject * dragObject( QWidget *, bool ); + virtual void itemSelected(); + + // we don't support the following of KonqSidebarTreeItem + bool acceptsDrops( const QStrList& ) { return false; } + virtual void drop( QDropEvent * ) {} + virtual KURL externalURL() const { return KURL(); } + +private: + bool m_hasFavIcon; + const KURL m_url; + QDateTime m_lastVisited; + +}; + + +#endif // HISTORY_ITEM_H diff --git a/konqueror/sidebar/trees/history_module/history_module.cpp b/konqueror/sidebar/trees/history_module/history_module.cpp new file mode 100644 index 000000000..832abd74e --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_module.cpp @@ -0,0 +1,369 @@ +/* This file is part of the KDE project + Copyright (C) 2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> + 2000 David Faure <faure@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qapplication.h> +#include <qpopupmenu.h> + +#include <kapplication.h> +#include <kaction.h> +#include <kcursor.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kiconloader.h> +#include <kmessagebox.h> +#include <krun.h> +#include <kstaticdeleter.h> + +#include <konq_faviconmgr.h> + +#include "history_module.h" +#include "history_settings.h" + +static KStaticDeleter<KonqSidebarHistorySettings> sd; +KonqSidebarHistorySettings * KonqSidebarHistoryModule::s_settings = 0L; + +KonqSidebarHistoryModule::KonqSidebarHistoryModule( KonqSidebarTree * parentTree, const char *name ) + : QObject( 0L, name ), KonqSidebarTreeModule( parentTree ), + m_dict( 349 ), + m_topLevelItem( 0L ), + m_dlg( 0L ), + m_initialized( false ) +{ + if ( !s_settings ) { + sd.setObject( s_settings, + new KonqSidebarHistorySettings( 0, "history settings" )); + s_settings->readSettings( true ); + } + + connect( s_settings, SIGNAL( settingsChanged() ), SLOT( slotSettingsChanged() )); + + m_dict.setAutoDelete( true ); + m_currentTime = QDateTime::currentDateTime(); + + KConfig *kc = KGlobal::config(); + KConfigGroupSaver cs( kc, "HistorySettings" ); + m_sortsByName = kc->readEntry( "SortHistory", "byDate" ) == "byName"; + + + KonqHistoryManager *manager = KonqHistoryManager::kself(); + + connect( manager, SIGNAL( loadingFinished() ), SLOT( slotCreateItems() )); + connect( manager, SIGNAL( cleared() ), SLOT( clear() )); + + connect( manager, SIGNAL( entryAdded( const KonqHistoryEntry * ) ), + SLOT( slotEntryAdded( const KonqHistoryEntry * ) )); + connect( manager, SIGNAL( entryRemoved( const KonqHistoryEntry *) ), + SLOT( slotEntryRemoved( const KonqHistoryEntry *) )); + + connect( parentTree, SIGNAL( expanded( QListViewItem * )), + SLOT( slotItemExpanded( QListViewItem * ))); + + m_collection = new KActionCollection( this, "history actions" ); + (void) new KAction( i18n("New &Window"), "window_new", 0, this, + SLOT( slotNewWindow() ), m_collection, "open_new"); + (void) new KAction( i18n("&Remove Entry"), "editdelete", 0, this, + SLOT( slotRemoveEntry() ), m_collection, "remove"); + (void) new KAction( i18n("C&lear History"), "history_clear", 0, this, + SLOT( slotClearHistory() ), m_collection, "clear"); + (void) new KAction( i18n("&Preferences..."), "configure", 0, this, + SLOT( slotPreferences()), m_collection, "preferences"); + + KRadioAction *sort; + sort = new KRadioAction( i18n("By &Name"), 0, this, + SLOT( slotSortByName() ), m_collection, "byName"); + sort->setExclusiveGroup("SortGroup"); + sort->setChecked( m_sortsByName ); + + sort = new KRadioAction( i18n("By &Date"), 0, this, + SLOT( slotSortByDate() ), m_collection, "byDate"); + sort->setExclusiveGroup("SortGroup"); + sort->setChecked( !m_sortsByName ); + + m_folderClosed = SmallIcon( "folder" ); + m_folderOpen = SmallIcon( "folder_open" ); + + slotSettingsChanged(); // read the settings +} + +KonqSidebarHistoryModule::~KonqSidebarHistoryModule() +{ + HistoryItemIterator it( m_dict ); + QStringList openGroups; + while ( it.current() ) { + if ( it.current()->isOpen() ) + openGroups.append( it.currentKey() ); + ++it; + } + + KConfig *kc = KGlobal::config(); + KConfigGroupSaver cs( kc, "HistorySettings" ); + kc->writeEntry("OpenGroups", openGroups); + kc->sync(); +} + +void KonqSidebarHistoryModule::slotSettingsChanged() +{ + KonqSidebarHistoryItem::setSettings( s_settings ); + tree()->triggerUpdate(); +} + +void KonqSidebarHistoryModule::slotCreateItems() +{ + QApplication::setOverrideCursor( KCursor::waitCursor() ); + clear(); + + KonqSidebarHistoryItem *item; + KonqHistoryEntry *entry; + KonqHistoryList entries( KonqHistoryManager::kself()->entries() ); + KonqHistoryIterator it( entries ); + m_currentTime = QDateTime::currentDateTime(); + + // the group item and the item of the serverroot '/' get a fav-icon + // if available. All others get the protocol icon. + while ( (entry = it.current()) ) { + KonqSidebarHistoryGroupItem *group = getGroupItem( entry->url ); + item = new KonqSidebarHistoryItem( entry, group, m_topLevelItem ); + + ++it; + } + + KConfig *kc = KGlobal::config(); + KConfigGroupSaver cs( kc, "HistorySettings" ); + QStringList openGroups = kc->readListEntry("OpenGroups"); + QStringList::Iterator it2 = openGroups.begin(); + KonqSidebarHistoryGroupItem *group; + while ( it2 != openGroups.end() ) { + group = m_dict.find( *it2 ); + if ( group ) + group->setOpen( true ); + + ++it2; + } + + QApplication::restoreOverrideCursor(); + m_initialized = true; +} + +// deletes the listview items but does not affect the history backend +void KonqSidebarHistoryModule::clear() +{ + m_dict.clear(); +} + +void KonqSidebarHistoryModule::slotEntryAdded( const KonqHistoryEntry *entry ) +{ + if ( !m_initialized ) + return; + + m_currentTime = QDateTime::currentDateTime(); + KonqSidebarHistoryGroupItem *group = getGroupItem( entry->url ); + KonqSidebarHistoryItem *item = group->findChild( entry ); + if ( !item ) + item = new KonqSidebarHistoryItem( entry, group, m_topLevelItem ); + else + item->update( entry ); + + // QListView scrolls when calling sort(), so we have to hack around that + // (we don't want no scrolling every time an entry is added) + KonqSidebarTree *t = tree(); + t->lockScrolling( true ); + group->sort(); + m_topLevelItem->sort(); + qApp->processOneEvent(); + t->lockScrolling( false ); +} + +void KonqSidebarHistoryModule::slotEntryRemoved( const KonqHistoryEntry *entry ) +{ + if ( !m_initialized ) + return; + + QString groupKey = groupForURL( entry->url ); + KonqSidebarHistoryGroupItem *group = m_dict.find( groupKey ); + if ( !group ) + return; + + delete group->findChild( entry ); + + if ( group->childCount() == 0 ) + m_dict.remove( groupKey ); +} + +void KonqSidebarHistoryModule::addTopLevelItem( KonqSidebarTreeTopLevelItem * item ) +{ + m_topLevelItem = item; +} + +bool KonqSidebarHistoryModule::handleTopLevelContextMenu( KonqSidebarTreeTopLevelItem *, + const QPoint& pos ) +{ + showPopupMenu( ModuleContextMenu, pos ); + return true; +} + +void KonqSidebarHistoryModule::showPopupMenu() +{ + showPopupMenu( EntryContextMenu | ModuleContextMenu, QCursor::pos() ); +} + +void KonqSidebarHistoryModule::showPopupMenu( int which, const QPoint& pos ) +{ + QPopupMenu *sortMenu = new QPopupMenu; + m_collection->action("byName")->plug( sortMenu ); + m_collection->action("byDate")->plug( sortMenu ); + + QPopupMenu *menu = new QPopupMenu; + + if ( which & EntryContextMenu ) + { + m_collection->action("open_new")->plug( menu ); + menu->insertSeparator(); + m_collection->action("remove")->plug( menu ); + } + + m_collection->action("clear")->plug( menu ); + menu->insertSeparator(); + menu->insertItem( i18n("Sort"), sortMenu ); + menu->insertSeparator(); + m_collection->action("preferences")->plug( menu ); + + menu->exec( pos ); + delete menu; + delete sortMenu; +} + +void KonqSidebarHistoryModule::slotNewWindow() +{ + kdDebug(1201)<<"void KonqSidebarHistoryModule::slotNewWindow()"<<endl; + + QListViewItem *item = tree()->selectedItem(); + KonqSidebarHistoryItem *hi = dynamic_cast<KonqSidebarHistoryItem*>( item ); + if ( hi ) + { + kdDebug(1201)<<"void KonqSidebarHistoryModule::slotNewWindow(): emitting createNewWindow"<<endl; + emit tree()->createNewWindow( hi->url() ); + } +} + +void KonqSidebarHistoryModule::slotRemoveEntry() +{ + QListViewItem *item = tree()->selectedItem(); + KonqSidebarHistoryItem *hi = dynamic_cast<KonqSidebarHistoryItem*>( item ); + if ( hi ) // remove a single entry + KonqHistoryManager::kself()->emitRemoveFromHistory( hi->externalURL()); + + else { // remove a group of entries + KonqSidebarHistoryGroupItem *gi = dynamic_cast<KonqSidebarHistoryGroupItem*>( item ); + if ( gi ) + gi->remove(); + } +} + +void KonqSidebarHistoryModule::slotPreferences() +{ + // Run the history sidebar settings. + KRun::run( "kcmshell kcmhistory", KURL::List() ); +} + +void KonqSidebarHistoryModule::slotSortByName() +{ + m_sortsByName = true; + sortingChanged(); +} + +void KonqSidebarHistoryModule::slotSortByDate() +{ + m_sortsByName = false; + sortingChanged(); +} + +void KonqSidebarHistoryModule::sortingChanged() +{ + m_topLevelItem->sort(); + + KConfig *kc = KGlobal::config(); + KConfigGroupSaver cs( kc, "HistorySettings" ); + kc->writeEntry( "SortHistory", m_sortsByName ? "byName" : "byDate" ); + kc->sync(); +} + +void KonqSidebarHistoryModule::slotItemExpanded( QListViewItem *item ) +{ + if ( item == m_topLevelItem && !m_initialized ) + slotCreateItems(); +} + +void KonqSidebarHistoryModule::groupOpened( KonqSidebarHistoryGroupItem *item, bool open ) +{ + if ( item->hasFavIcon() ) + return; + + if ( open ) + item->setPixmap( 0, m_folderOpen ); + else + item->setPixmap( 0, m_folderClosed ); +} + + +KonqSidebarHistoryGroupItem * KonqSidebarHistoryModule::getGroupItem( const KURL& url ) +{ + const QString& groupKey = groupForURL( url ); + KonqSidebarHistoryGroupItem *group = m_dict.find( groupKey ); + if ( !group ) { + group = new KonqSidebarHistoryGroupItem( url, m_topLevelItem ); + + QString icon = KonqFavIconMgr::iconForURL( url.url() ); + if ( icon.isEmpty() ) + group->setPixmap( 0, m_folderClosed ); + else + group->setFavIcon( SmallIcon( icon ) ); + + group->setText( 0, groupKey ); + + m_dict.insert( groupKey, group ); + } + + return group; +} + +void KonqSidebarHistoryModule::slotClearHistory() +{ + KGuiItem guiitem = KStdGuiItem::clear(); + guiitem.setIconSet( SmallIconSet("history_clear")); + + if ( KMessageBox::warningContinueCancel( tree(), + i18n("Do you really want to clear " + "the entire history?"), + i18n("Clear History?"), guiitem ) + == KMessageBox::Continue ) + KonqHistoryManager::kself()->emitClear(); +} + + +extern "C" +{ + KDE_EXPORT KonqSidebarTreeModule* create_konq_sidebartree_history(KonqSidebarTree* par, const bool) + { + return new KonqSidebarHistoryModule(par); + } +} + + + +#include "history_module.moc" diff --git a/konqueror/sidebar/trees/history_module/history_module.h b/konqueror/sidebar/trees/history_module/history_module.h new file mode 100644 index 000000000..30295fc3f --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_module.h @@ -0,0 +1,108 @@ +/* This file is part of the KDE project + Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef HISTORY_MODULE_H +#define HISTORY_MODULE_H + +#include <qdatetime.h> +#include <qobject.h> +#include <qdict.h> +#include <qpixmap.h> + +#include <kglobal.h> +#include <klocale.h> +#include <konq_sidebartreemodule.h> + +#include "history_item.h" + +class KActionCollection; +class KDialogBase; +class KonqSidebarHistorySettings; +class KonqSidebarTree; +class KonqSidebarTreeItem; + +class KonqSidebarHistoryModule : public QObject, public KonqSidebarTreeModule +{ + Q_OBJECT + +public: + enum { + ModuleContextMenu = 1, + EntryContextMenu = 2 + }; + + KonqSidebarHistoryModule( KonqSidebarTree * parentTree, const char * name = 0 ); + virtual ~KonqSidebarHistoryModule(); + + virtual void addTopLevelItem( KonqSidebarTreeTopLevelItem * item ); + virtual bool handleTopLevelContextMenu( KonqSidebarTreeTopLevelItem *item, const QPoint& pos ); + + void showPopupMenu( int which, const QPoint& pos ); + + // called by the items + void showPopupMenu(); + void groupOpened( KonqSidebarHistoryGroupItem *item, bool open ); + const QDateTime& currentTime() const { return m_currentTime; } + bool sortsByName() const { return m_sortsByName; } + + static QString groupForURL( const KURL& url ) { + static const QString& misc = KGlobal::staticQString(i18n("Miscellaneous")); + return url.host().isEmpty() ? misc : url.host(); + } + +public slots: + void clear(); + +private slots: + void slotCreateItems(); + void slotEntryAdded( const KonqHistoryEntry * ); + void slotEntryRemoved( const KonqHistoryEntry * ); + + void slotNewWindow(); + void slotRemoveEntry(); + void slotPreferences(); + void slotSettingsChanged(); + + void slotItemExpanded( QListViewItem * ); + + void slotSortByName(); + void slotSortByDate(); + + void slotClearHistory(); + +private: + KonqSidebarHistoryGroupItem *getGroupItem( const KURL& url ); + + void sortingChanged(); + typedef QDictIterator<KonqSidebarHistoryGroupItem> HistoryItemIterator; + QDict<KonqSidebarHistoryGroupItem> m_dict; + + KonqSidebarTreeTopLevelItem * m_topLevelItem; + + KActionCollection *m_collection; + + KDialogBase *m_dlg; + QPixmap m_folderClosed; + QPixmap m_folderOpen; + bool m_initialized; + bool m_sortsByName; + QDateTime m_currentTime; // used for sorting the items by date + static KonqSidebarHistorySettings *s_settings; +}; + +#endif // HISTORY_MODULE_H diff --git a/konqueror/sidebar/trees/history_module/history_settings.cpp b/konqueror/sidebar/trees/history_module/history_settings.cpp new file mode 100644 index 000000000..ed8bc7756 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_settings.cpp @@ -0,0 +1,111 @@ + +#include <kapplication.h> +#include <kconfig.h> +#include <kglobal.h> +#include <dcopclient.h> + +#include "history_settings.h" + +KonqSidebarHistorySettings::KonqSidebarHistorySettings( QObject *parent, const char *name ) + : QObject( parent, name ), + DCOPObject( "KonqSidebarHistorySettings" ) +{ + m_fontOlderThan.setItalic( true ); // default +} + +KonqSidebarHistorySettings::KonqSidebarHistorySettings() + : QObject(), + DCOPObject( "KonqSidebarHistorySettings" ) +{ + m_fontOlderThan.setItalic( true ); // default +} + +KonqSidebarHistorySettings::KonqSidebarHistorySettings( const KonqSidebarHistorySettings& s ) + : QObject(), + DCOPObject( "KonqSidebarHistorySettings" ) +{ + m_valueYoungerThan = s.m_valueYoungerThan; + m_valueOlderThan = s.m_valueOlderThan; + + m_metricYoungerThan = s.m_metricYoungerThan; + m_metricOlderThan = s.m_metricOlderThan; + + m_detailedTips = s.m_detailedTips; + + m_fontYoungerThan = s.m_fontYoungerThan; + m_fontOlderThan = s.m_fontOlderThan; +} + +KonqSidebarHistorySettings::~KonqSidebarHistorySettings() +{ +} + +void KonqSidebarHistorySettings::readSettings(bool global) +{ + KConfig *config; + QString oldgroup; + + if (global) { + config = KGlobal::config(); + oldgroup= config->group(); + } + else + config = new KConfig("konquerorrc"); + + config->setGroup("HistorySettings"); + m_valueYoungerThan = config->readNumEntry("Value youngerThan", 1 ); + m_valueOlderThan = config->readNumEntry("Value olderThan", 2 ); + + QString minutes = QString::fromLatin1("minutes"); + QString days = QString::fromLatin1("days"); + QString metric = config->readEntry("Metric youngerThan", days ); + m_metricYoungerThan = (metric == days) ? DAYS : MINUTES; + metric = config->readEntry("Metric olderThan", days ); + m_metricOlderThan = (metric == days) ? DAYS : MINUTES; + + m_detailedTips = config->readBoolEntry("Detailed Tooltips", true); + + m_fontYoungerThan = config->readFontEntry( "Font youngerThan", + &m_fontYoungerThan ); + m_fontOlderThan = config->readFontEntry( "Font olderThan", + &m_fontOlderThan ); + if (global) + config->setGroup( oldgroup ); + else + delete config; +} + +void KonqSidebarHistorySettings::applySettings() +{ + KConfig *config = new KConfig("konquerorrc"); + config->setGroup("HistorySettings"); + + config->writeEntry("Value youngerThan", m_valueYoungerThan ); + config->writeEntry("Value olderThan", m_valueOlderThan ); + + QString minutes = QString::fromLatin1("minutes"); + QString days = QString::fromLatin1("days"); + config->writeEntry("Metric youngerThan", m_metricYoungerThan == DAYS ? + days : minutes ); + config->writeEntry("Metric olderThan", m_metricOlderThan == DAYS ? + days : minutes ); + + config->writeEntry("Detailed Tooltips", m_detailedTips); + + config->writeEntry("Font youngerThan", m_fontYoungerThan ); + config->writeEntry("Font olderThan", m_fontOlderThan ); + + delete config; + + // notify konqueror instances about the new configuration + kapp->dcopClient()->send( "konqueror*", "KonqSidebarHistorySettings", + "notifySettingsChanged()", QByteArray() ); +} + +void KonqSidebarHistorySettings::notifySettingsChanged() +{ + readSettings(false); + emit settingsChanged(); +} + +#include "history_settings.moc" diff --git a/konqueror/sidebar/trees/history_module/history_settings.h b/konqueror/sidebar/trees/history_module/history_settings.h new file mode 100644 index 000000000..21bcd01db --- /dev/null +++ b/konqueror/sidebar/trees/history_module/history_settings.h @@ -0,0 +1,66 @@ +/* This file is part of the KDE project + Copyright (C) 2000 Carsten Pfeiffer <pfeiffer@kde.org> + + 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; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef HISTORY_SETTINGS_H +#define HISTORY_SETTINGS_H + +#include <qfont.h> +#include <qobject.h> + +#include <dcopobject.h> + +class KonqSidebarHistorySettings : public QObject, public DCOPObject +{ + K_DCOP + Q_OBJECT + +public: + enum { MINUTES, DAYS }; + + KonqSidebarHistorySettings( QObject *parent, const char *name ); + virtual ~KonqSidebarHistorySettings(); + + void readSettings(bool global); + void applySettings(); + + uint m_valueYoungerThan; + uint m_valueOlderThan; + + int m_metricYoungerThan; + int m_metricOlderThan; + + bool m_detailedTips; + + QFont m_fontYoungerThan; + QFont m_fontOlderThan; + +signals: + void settingsChanged(); + +protected: + KonqSidebarHistorySettings(); + KonqSidebarHistorySettings( const KonqSidebarHistorySettings& ); + +k_dcop: + void notifySettingsChanged(); + +private: // to make dcopidl happy :-/ +}; + +#endif // HISTORY_SETTINGS_H diff --git a/konqueror/sidebar/trees/history_module/kcmhistory.cpp b/konqueror/sidebar/trees/history_module/kcmhistory.cpp new file mode 100644 index 000000000..e4b31b232 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/kcmhistory.cpp @@ -0,0 +1,272 @@ +/* + * kcmhistory.cpp + * Copyright (c) 2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> + * Copyright (c) 2002 Stephan Binner <binner@kde.org> + * + * based on kcmtaskbar.cpp + * Copyright (c) 2000 Kurt Granroth <granroth@kde.org> + * + * 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 + */ + +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qradiobutton.h> + +#include <dcopclient.h> +#include <dcopref.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kdialog.h> +#include <kfontdialog.h> +#include <kgenericfactory.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <knuminput.h> +#include "history_dlg.h" + +#include "konq_historymgr.h" + +#include "kcmhistory.h" +#include "history_settings.h" + +typedef KGenericFactory<HistorySidebarConfig, QWidget > KCMHistoryFactory; +K_EXPORT_COMPONENT_FACTORY (kcm_history, KCMHistoryFactory("kcmhistory") ) + +HistorySidebarConfig::HistorySidebarConfig( QWidget *parent, const char* name, const QStringList & ) + : KCModule (KCMHistoryFactory::instance(), parent, name) +{ + KGlobal::locale()->insertCatalogue("konqueror"); + + m_settings = new KonqSidebarHistorySettings( 0, "history settings" ); + m_settings->readSettings( false ); + + QVBoxLayout *topLayout = new QVBoxLayout(this, 0, KDialog::spacingHint()); + dialog = new KonqSidebarHistoryDlg(this); + + dialog->spinEntries->setRange( 0, INT_MAX, 1, false ); + dialog->spinExpire->setRange( 0, INT_MAX, 1, false ); + + dialog->spinNewer->setRange( 0, INT_MAX, 1, false ); + dialog->spinOlder->setRange( 0, INT_MAX, 1, false ); + + dialog->comboNewer->insertItem( i18n("Minutes"), + KonqSidebarHistorySettings::MINUTES ); + dialog->comboNewer->insertItem( i18n("Days"), + KonqSidebarHistorySettings::DAYS ); + + dialog->comboOlder->insertItem( i18n("Minutes"), + KonqSidebarHistorySettings::MINUTES ); + dialog->comboOlder->insertItem( i18n("Days"), + KonqSidebarHistorySettings::DAYS ); + + connect( dialog->cbExpire, SIGNAL( toggled( bool )), + dialog->spinExpire, SLOT( setEnabled( bool ))); + connect( dialog->spinExpire, SIGNAL( valueChanged( int )), + this, SLOT( slotExpireChanged( int ))); + + connect( dialog->spinNewer, SIGNAL( valueChanged( int )), + SLOT( slotNewerChanged( int ))); + connect( dialog->spinOlder, SIGNAL( valueChanged( int )), + SLOT( slotOlderChanged( int ))); + + connect( dialog->btnFontNewer, SIGNAL( clicked() ), + SLOT( slotGetFontNewer() )); + connect( dialog->btnFontOlder, SIGNAL( clicked() ), + SLOT( slotGetFontOlder() )); + connect( dialog->btnClearHistory, SIGNAL( clicked() ), + SLOT( slotClearHistory() )); + + connect( dialog->cbDetailedTips, SIGNAL( toggled( bool )), + SLOT( configChanged() )); + connect( dialog->cbExpire, SIGNAL( toggled( bool )), + SLOT( configChanged() )); + connect( dialog->spinEntries, SIGNAL( valueChanged( int )), + SLOT( configChanged() )); + connect( dialog->comboNewer, SIGNAL( activated( int )), + SLOT( configChanged() )); + connect( dialog->comboOlder, SIGNAL( activated( int )), + SLOT( configChanged() )); + + dialog->show(); + topLayout->add(dialog); + load(); +} + +void HistorySidebarConfig::configChanged() +{ + emit changed(true); +} + +void HistorySidebarConfig::load() +{ + KConfig config("konquerorrc"); + config.setGroup("HistorySettings"); + dialog->spinExpire->setValue( config.readNumEntry( "Maximum age of History entries", 90) ); + dialog->spinEntries->setValue( config.readNumEntry( "Maximum of History entries", 500 ) ); + dialog->cbExpire->setChecked( dialog->spinExpire->value() > 0 ); + + dialog->spinNewer->setValue( m_settings->m_valueYoungerThan ); + dialog->spinOlder->setValue( m_settings->m_valueOlderThan ); + + dialog->comboNewer->setCurrentItem( m_settings->m_metricYoungerThan ); + dialog->comboOlder->setCurrentItem( m_settings->m_metricOlderThan ); + + dialog->cbDetailedTips->setChecked( m_settings->m_detailedTips ); + + m_fontNewer = m_settings->m_fontYoungerThan; + m_fontOlder = m_settings->m_fontOlderThan; + + // enable/disable widgets + dialog->spinExpire->setEnabled( dialog->cbExpire->isChecked() ); + + slotExpireChanged( dialog->spinExpire->value() ); + slotNewerChanged( dialog->spinNewer->value() ); + slotOlderChanged( dialog->spinOlder->value() ); + + emit changed(false); +} + +void HistorySidebarConfig::save() +{ + Q_UINT32 age = dialog->cbExpire->isChecked() ? dialog->spinExpire->value() : 0; + Q_UINT32 count = dialog->spinEntries->value(); + + KConfig config("konquerorrc"); + config.setGroup("HistorySettings"); + config.writeEntry( "Maximum of History entries", count ); + config.writeEntry( "Maximum age of History entries", age ); + + QByteArray dataAge; + QDataStream streamAge( dataAge, IO_WriteOnly ); + streamAge << age << "foo"; + kapp->dcopClient()->send( "konqueror*", "KonqHistoryManager", + "notifyMaxAge(Q_UINT32, QCString)", dataAge ); + + QByteArray dataCount; + QDataStream streamCount( dataCount, IO_WriteOnly ); + streamCount << count << "foo"; + kapp->dcopClient()->send( "konqueror*", "KonqHistoryManager", + "notifyMaxCount(Q_UINT32, QCString)", dataCount ); + + m_settings->m_valueYoungerThan = dialog->spinNewer->value(); + m_settings->m_valueOlderThan = dialog->spinOlder->value(); + + m_settings->m_metricYoungerThan = dialog->comboNewer->currentItem(); + m_settings->m_metricOlderThan = dialog->comboOlder->currentItem(); + + m_settings->m_detailedTips = dialog->cbDetailedTips->isChecked(); + + m_settings->m_fontYoungerThan = m_fontNewer; + m_settings->m_fontOlderThan = m_fontOlder; + + m_settings->applySettings(); + + emit changed(false); +} + +void HistorySidebarConfig::defaults() +{ + dialog->spinEntries->setValue( 500 ); + dialog->cbExpire->setChecked( true ); + dialog->spinExpire->setValue( 90 ); + + dialog->spinNewer->setValue( 1 ); + dialog->spinOlder->setValue( 2 ); + + dialog->comboNewer->setCurrentItem( KonqSidebarHistorySettings::DAYS ); + dialog->comboOlder->setCurrentItem( KonqSidebarHistorySettings::DAYS ); + + dialog->cbDetailedTips->setChecked( true ); + + m_fontNewer = QFont(); + m_fontNewer.setItalic( true ); + m_fontOlder = QFont(); + + emit changed(true); +} + +QString HistorySidebarConfig::quickHelp() const +{ + return i18n("<h1>History Sidebar</h1>" + " You can configure the history sidebar here."); +} + +void HistorySidebarConfig::slotExpireChanged( int value ) +{ + dialog->spinExpire->setSuffix( i18n(" day", " days", value) ); + configChanged(); +} + +// change hour to days, minute to minutes and the other way round, +// depending on the value of the spinbox, and synchronize the two spinBoxes +// to enfore newer <= older. +void HistorySidebarConfig::slotNewerChanged( int value ) +{ + dialog->comboNewer->changeItem( i18n ( "Day", "Days", value), + KonqSidebarHistorySettings::DAYS); + dialog->comboNewer->changeItem( i18n ( "Minute", "Minutes", value), + KonqSidebarHistorySettings::MINUTES); + + if ( dialog->spinNewer->value() > dialog->spinOlder->value() ) + dialog->spinOlder->setValue( dialog->spinNewer->value() ); + configChanged(); +} + +void HistorySidebarConfig::slotOlderChanged( int value ) +{ + dialog->comboOlder->changeItem( i18n ( "Day", "Days", value), + KonqSidebarHistorySettings::DAYS); + dialog->comboOlder->changeItem( i18n ( "Minute", "Minutes", value), + KonqSidebarHistorySettings::MINUTES); + + if ( dialog->spinNewer->value() > dialog->spinOlder->value() ) + dialog->spinNewer->setValue( dialog->spinOlder->value() ); + + configChanged(); +} + +void HistorySidebarConfig::slotGetFontNewer() +{ + int result = KFontDialog::getFont( m_fontNewer, false, this ); + if ( result == KFontDialog::Accepted ) + configChanged(); +} + +void HistorySidebarConfig::slotGetFontOlder() +{ + int result = KFontDialog::getFont( m_fontOlder, false, this ); + if ( result == KFontDialog::Accepted ) + configChanged(); +} + +void HistorySidebarConfig::slotClearHistory() +{ + KGuiItem guiitem = KStdGuiItem::clear(); + guiitem.setIconSet( SmallIconSet("history_clear")); + if ( KMessageBox::warningContinueCancel( this, + i18n("Do you really want to clear " + "the entire history?"), + i18n("Clear History?"), guiitem ) + == KMessageBox::Continue ) { + DCOPRef dcopHistManager( "konqueror*", "KonqHistoryManager" ); + dcopHistManager.send( "notifyClear", "KonqHistoryManager" ); + } +} + +#include "kcmhistory.moc" diff --git a/konqueror/sidebar/trees/history_module/kcmhistory.desktop b/konqueror/sidebar/trees/history_module/kcmhistory.desktop new file mode 100644 index 000000000..396b27b84 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/kcmhistory.desktop @@ -0,0 +1,233 @@ +[Desktop Entry] +Icon=history +Type=Application +Exec=kcmshell kcmhistory + +X-KDE-ModuleType=Library +X-KDE-Library=history +X-KDE-FactoryName=history + +Name=History Sidebar +Name[af]=Geskiedenis Kantbalk +Name[ar]=الشريط الجانبي للخط الزمني +Name[az]=Keçmiş Yan Çubuğu +Name[be]=Бакавая панэль гісторыі +Name[bg]=История +Name[bn]=ইতিহাস সাইডবার +Name[bs]=Historija sidebar +Name[ca]=Barra de l'historial +Name[cs]=Panel historie +Name[csb]=Bòcznô lëstew historëji +Name[cy]=Cwpwrdd Cornel Hanes +Name[da]=Historik-sidebjælke +Name[de]=Verlaufsbereich +Name[el]=Πλευρική μπάρα ιστορικού +Name[eo]=Historia flankzono +Name[es]=Barra de historial +Name[et]=Ajaloo külgriba +Name[eu]=Historiaren alboko barra +Name[fa]=میله جانبی تاریخچه +Name[fi]=Historiasivupalkki +Name[fr]=Barre latérale d'historique +Name[fy]=Histoarje +Name[ga]=Barra Taoibh Staire +Name[gl]=Barra Lateral co Historial +Name[he]=סרגל היסטוריה +Name[hi]=इतिहास बाज़ूपट्टी +Name[hr]=Traka povijesti +Name[hu]=Napló-oldalsáv +Name[is]=Sögu hliðarslá +Name[it]=Barra laterale cronologia +Name[ja]=履歴サイドバー +Name[ka]=ისტორიის გვერდითი პანელი +Name[kk]=Бүйірдегі журнал панелі +Name[km]=របារប្រវត្តិ +Name[ko]=과거 기록 사이드바 +Name[lo]=ປະວັດການໃໍຊ້ງານ +Name[lt]=Istorijos šoninė juosta +Name[lv]=Vēstures sānjosla +Name[mk]=Лента за историја +Name[mn]=Түүхийн хуудас +Name[ms]=Bar Sisi Sejarah +Name[mt]=Kronoloġija +Name[nb]=Historie-sidestolpe +Name[nds]=Vörgeschicht-Sietpaneel +Name[ne]=इतिहास छेउपट्टी +Name[nl]=Geschiedenis +Name[nn]=Historie-sidestolpe +Name[nso]=Bar ya lehlakori ya Histori +Name[pa]=ਅਤੀਤ ਪਾਸੇ ਪੱਟੀ +Name[pl]=Pasek boczny z historią +Name[pt]=Barra Lateral do Histórico +Name[pt_BR]=Barra Lateral de Histórico +Name[ro]=Bară laterală de istoric +Name[ru]=Журнал +Name[rw]=Umurongokuruhande w'Amateka +Name[se]=Historihkkaholga +Name[sk]=Bočný panel histórie +Name[sl]=Stranska vrstica zgodovine +Name[sr]=Бочни панел историјата +Name[sr@Latn]=Bočni panel istorijata +Name[sv]=Historiksidopanel +Name[ta]=வரலாற்றுப் பக்கப்பட்டி +Name[tg]=Паҳлӯи сафҳаи торихча +Name[th]=แถบประวัติการใช้ด้านข้าง +Name[tr]=Geçmiş Yan Çubuğu +Name[tt]=Taríx Yantiräse +Name[uk]=Бічна панель історії +Name[uz]=Tarix paneli +Name[uz@cyrillic]=Тарих панели +Name[ven]=Bara ya lurumbu ya Divhazwakale +Name[vi]=Bảng Lịch sử +Name[wa]=Bår di costé di l' istwere +Name[xh]=Ibar esecaleni Yembali +Name[zh_CN]=历史侧边栏 +Name[zh_TW]=歷史紀錄邊列 +Name[zu]=Umlando webha yaseceleni +Comment=Configure the history sidebar +Comment[af]=Stel die geskiedenis kantbalk op +Comment[ar]=إعداد الشريط الجانبي للخط الزمني +Comment[az]=Keçmiş yan çubuğunu quraşdır +Comment[be]=Настаўленне бакавой панэлі гісторыі +Comment[bg]=Настройване на историята +Comment[bn]=ইতিহাস সাইডবার কনফিগার করুন +Comment[bs]=Ovdje možete podesiti history sidebar +Comment[ca]=Configura la barra de l'historial +Comment[cs]=Nastavení panelu historie +Comment[csb]=Kònfigùracëjô bòczny lëstwë historëji +Comment[cy]=Ffurfweddu'r cwpwrdd cornel hanes +Comment[da]=Indstil historik-sidebjælken +Comment[de]=Verlaufsanzeige im Navigationsbereich einrichten +Comment[el]=Ρυθμίστε την πλευρική μπάρα ιστορικού +Comment[eo]=Agordo de la historia flankzono +Comment[es]=Configuración de la barra del historial +Comment[et]=Ajaloo külgriba seadistamine +Comment[eu]=Konfiguratu historiaren alboko barra +Comment[fa]=پیکربندی میله جانبی تاریخچه +Comment[fi]=Historiasivupalkin asetukset +Comment[fr]=Configuration de l'historique de la barre latérale +Comment[fy]=Hjir kinne jo de histoarje ynstelle +Comment[ga]=Cumraigh an barra taoibh staire +Comment[gl]=Configurar o historial da barra lateral +Comment[he]=שינוי הגדרות הסרגל הצדדי של ההיסטוריה +Comment[hi]=इतिहास बाज़ूपट्टी कॉन्फ़िगर करें +Comment[hr]=Konfiguriranje trake povijesti +Comment[hu]=A napló-oldalsáv beállításai +Comment[is]=Stilla hliðardálk með flakksögu +Comment[it]=Configura la barra laterale della cronologia +Comment[ja]=履歴サイドバーの設定 +Comment[ka]=ისტორიის გვერდითი პანელის კონფიგურირება +Comment[kk]=Бүйірдегі журнал панелін баптау +Comment[km]=កំណត់រចនាសម្ព័ន្ធរបារប្រវត្តិ +Comment[ko]=과거 기록 사이드바를 설정합니다 +Comment[lo]=ທ່ານສາມາດປັບແຕ່ງຖາດພາເນລແຖບຫນ້າຕ່າງງານ ໄດ້ທີ່ນີ້ +Comment[lt]=Konfigūruoti istorijos šoninę juostą +Comment[lv]=Šeit jūs varat konfigurēt vēstures sānjoslu +Comment[mk]=Конфигурација на лентата за историја +Comment[mn]=Түүхийн хуудас тохируулах +Comment[ms]=Konfigur bar sisi sejarah +Comment[mt]=Ikkonfigura l-wirja tal-kronoloġija +Comment[nb]=Tilpass historiesidestolpen +Comment[nds]=Dat Vörgeschicht-Sietpaneel instellen +Comment[ne]=इतिहास छेउपट्टी कन्फिगर गर्नुहोस् +Comment[nl]=Hier kunt u de geschiedenis instellen +Comment[nn]=Set opp historie-sidestolpen +Comment[nso]=Beakanya bar ya lehlakori ya histori +Comment[pa]=ਅਤੀਤ ਬਾਹੀ ਸੰਰਚਨਾ +Comment[pl]=Konfiguracja paska bocznego z historią +Comment[pt]=Configuração da barra lateral do histórico +Comment[pt_BR]=Configura a barra lateral de Histórico +Comment[ro]=Configurează bara laterală de URL-uri vizitate +Comment[ru]=Настройка боковой панели журнала +Comment[rw]=Kuboneza umurongokuruhande w'amateka +Comment[se]=Heivet historihkkaholgga +Comment[sk]=Nastavenie bočného panelu histórie +Comment[sl]=Nastavitve stranske vrstice zgodovine +Comment[sr]=Подешавање бочног панела историјата +Comment[sr@Latn]=Podešavanje bočnog panela istorijata +Comment[sv]=Anpassa historiksidopanelen +Comment[ta]=வரலாறு பக்கப்பட்டியலை வடிவமை +Comment[tg]=Танзимоти паҳлӯи сафҳаи торихча +Comment[th]=ปรับแต่งแถบประวัติการใช้ด้านข้าง +Comment[tr]=Geçmiş yan çubuğunu yapılandır +Comment[tt]="Uzğanı" yantiräseneñ caylawı +Comment[uk]=Налаштування бічної панелі історії +Comment[uz]=Tarix panelini moslash +Comment[uz@cyrillic]=Тарих панелини мослаш +Comment[ven]=Dzudzanyani bara ya lurumbu lwa divhazwakale +Comment[vi]=Cấu hình bảng nằm bên cạnh chứa lịch sử duyệt mạng +Comment[wa]=Apontyî l' dujhance del bår di costé d' istwere +Comment[xh]=Qwalasela imbali ye bar yasecaleni +Comment[zh_CN]=配置任务侧边栏 +Comment[zh_TW]=設定歷史紀錄邊列 +Comment[zu]=Hlanganisela ibha yaseceleni yomlando +Keywords=history,expire +Keywords[ar]=الخط الزمني, إنتهاء الأجل +Keywords[az]=history,expire,keçmiş +Keywords[be]=Гісторыя,Састарэлая,history,expire +Keywords[bg]=история, сърфиране, срок, изтичане, history, expire +Keywords[ca]=historial,expira +Keywords[cs]=historie,vypršení +Keywords[csb]=historëjô,wëgasëwanié +Keywords[cy]=hanes,daw i ben +Keywords[da]=historik,udløbe +Keywords[de]=History,Verlauf +Keywords[el]=ιστορικό,λήξη +Keywords[eo]=historio,malvalidiĝi +Keywords[es]=historial,expirar +Keywords[et]=ajalugu,aegumine +Keywords[eu]=historia,iraungi +Keywords[fa]=تاریخچه، انقضا +Keywords[fi]=historia,umpeenmeno +Keywords[fr]=historique,expiration +Keywords[fy]=histoarje,ferrinne +Keywords[ga]=stair,caite,as feidhm +Keywords[gl]=historial,caducar +Keywords[he]=היסטוריה,תפוגה,history,expire +Keywords[hi]=इतिहास,बीत गया +Keywords[hr]=history,expire,povijest,istek +Keywords[hu]=napló,lejárás +Keywords[is]=Saga,útrunnið,history +Keywords[it]=cronologia,scadenza +Keywords[ja]=履歴,失効 +Keywords[km]=ប្រវត្តិ ផុតកំណត់ +Keywords[lo]=ໃຊ້ຮ່ວມກັນ +Keywords[lt]=history,expire, istorija,pasibaigti +Keywords[lv]=vēsture,beigties +Keywords[mk]=history,expire,историја,истекува +Keywords[mn]=Түүх,Дуусах +Keywords[ms]=sejarah, luput +Keywords[mt]=history,expire,kronoloġija,skadi +Keywords[nb]=historie,utløper +Keywords[nds]=Vörgeschicht,aflopen +Keywords[ne]=इतिहास, म्याद समाप्त +Keywords[nl]=geschiedenis,verloop +Keywords[nn]=historie,utgår +Keywords[nso]=histori,felelwa ke nako +Keywords[pa]=expire,ਅਤੀਤ +Keywords[pl]=historia,wygasanie +Keywords[pt]=histórico,expirar +Keywords[pt_BR]=histórico,expirar +Keywords[ro]=istoric,expirare +Keywords[ru]=history,expire,журнал +Keywords[rw]=amateka,kurangiza igihe +Keywords[se]=historihkka,boarásnuvvat +Keywords[sk]=história,vypršanie +Keywords[sl]=zgodovina,potek,poteče +Keywords[sr]=history,expire,историјат,истицање +Keywords[sr@Latn]=history,expire,istorijat,isticanje +Keywords[sv]=historik,utgå +Keywords[ta]=வரலாறு,முடிந்தது +Keywords[th]=ประวัติการใช้,หมดอายุ +Keywords[tr]=geçmiş +Keywords[uk]=історія,закінчення терміну,втрата чинності +Keywords[uz]=tarix,muddati oʻtish +Keywords[uz@cyrillic]=тарих,муддати ўтиш +Keywords[ven]=divhazwakale,fhelelwa nga tshifhinga +Keywords[vi]=lịch sử,hết hạn +Keywords[wa]=istwere,espirer,espiraedje +Keywords[xh]=imbali,ephelelwa lixesha +Keywords[zh_CN]=history,expire,历史,过期 +Keywords[zh_TW]=history,expire,歷史紀錄,過期 +Keywords[zu]=umlando,ukuphelelwa isikhathi +Categories=Qt;KDE;X-KDE-settings-webbrowsing; diff --git a/konqueror/sidebar/trees/history_module/kcmhistory.h b/konqueror/sidebar/trees/history_module/kcmhistory.h new file mode 100644 index 000000000..5eaaf3a64 --- /dev/null +++ b/konqueror/sidebar/trees/history_module/kcmhistory.h @@ -0,0 +1,64 @@ +/* + * kcmhistory.h + * Copyright (c) 2002 Stephan Binner <binner@kde.org> + * + * based on kcmtaskbar.h + * Copyright (c) 2000 Kurt Granroth <granroth@kde.org> + * + * 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 + */ +#ifndef __kcmhistory_h__ +#define __kcmhistory_h__ + +#include <kcmodule.h> + +class KonqHistoryManager; +class KonqSidebarHistorySettings; +class KonqSidebarHistoryDlg; + +class HistorySidebarConfig : public KCModule +{ + Q_OBJECT + +public: + HistorySidebarConfig( QWidget *parent=0, const char* name=0, const QStringList &list=QStringList() ); + + void load(); + void save(); + void defaults(); + + QString quickHelp() const; + +private slots: + void configChanged(); + + void slotGetFontNewer(); + void slotGetFontOlder(); + + void slotExpireChanged( int ); + void slotNewerChanged( int ); + void slotOlderChanged( int ); + + void slotClearHistory(); + +private: + QFont m_fontNewer; + QFont m_fontOlder; + + KonqSidebarHistoryDlg* dialog; + KonqSidebarHistorySettings *m_settings; + KonqHistoryManager *mgr; +}; + +#endif |