libkonq Library API Documentation

konq_historymgr.h

00001 /* This file is part of the KDE project 00002 Copyright (C) 2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 00003 00004 This program is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; see the file COPYING. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef KONQ_HISTORY_H 00021 #define KONQ_HISTORY_H 00022 00023 #include <qdatastream.h> 00024 #include <qfile.h> 00025 #include <qptrlist.h> 00026 #include <qobject.h> 00027 #include <qmap.h> 00028 #include <qtimer.h> 00029 00030 #include <dcopobject.h> 00031 00032 #include <kcompletion.h> 00033 #include <kurl.h> 00034 #include <kparts/historyprovider.h> 00035 00036 #include "konq_historycomm.h" 00037 00038 class KCompletion; 00039 00040 00041 typedef QPtrList<KonqHistoryEntry> KonqBaseHistoryList; 00042 typedef QPtrListIterator<KonqHistoryEntry> KonqHistoryIterator; 00043 00044 class KonqHistoryList : public KonqBaseHistoryList 00045 { 00046 public: 00052 KonqHistoryEntry * findEntry( const KURL& url ); 00053 00054 protected: 00058 virtual int compareItems( QPtrCollection::Item, QPtrCollection::Item ); 00059 }; 00060 00061 00063 00064 00072 class KonqHistoryManager : public KParts::HistoryProvider, 00073 public KonqHistoryComm 00074 { 00075 Q_OBJECT 00076 00077 public: 00078 static KonqHistoryManager *kself() { 00079 return static_cast<KonqHistoryManager*>( KParts::HistoryProvider::self() ); 00080 } 00081 00082 KonqHistoryManager( QObject *parent, const char *name ); 00083 ~KonqHistoryManager(); 00084 00092 void emitSetMaxCount( Q_UINT32 count ); 00093 00103 void emitSetMaxAge( Q_UINT32 days ); 00104 00111 void emitRemoveFromHistory( const KURL& url ); 00112 00119 void emitRemoveFromHistory( const KURL::List& urls ); 00120 00124 Q_UINT32 maxCount() const { return m_maxCount; } 00125 00129 Q_UINT32 maxAge() const { return m_maxAgeDays; } 00130 00148 void addPending( const KURL& url, const QString& typedURL = QString::null, 00149 const QString& title = QString::null ); 00150 00154 void confirmPending( const KURL& url, 00155 const QString& typedURL = QString::null, 00156 const QString& title = QString::null ); 00157 00162 void removePending( const KURL& url ); 00163 00167 KCompletion * completionObject() const { return m_pCompletion; } 00168 00173 const KonqHistoryList& entries() const { return m_history; } 00174 00175 // HistoryProvider interfae, let konq handle this 00182 virtual void insert( const QString& ); 00183 virtual void remove( const QString& ) {} 00184 virtual void clear() {} 00185 00186 00187 public slots: 00191 bool loadHistory(); 00192 00196 bool saveHistory(); 00197 00203 void emitClear(); 00204 00205 00206 signals: 00210 void loadingFinished(); 00211 00215 void entryAdded( const KonqHistoryEntry *entry ); 00216 00222 void entryRemoved( const KonqHistoryEntry *entry ); 00223 00224 protected: 00229 void adjustSize(); 00230 00235 inline bool isExpired( KonqHistoryEntry *entry ) { 00236 return (entry && m_maxAgeDays > 0 && entry->lastVisited < 00237 QDate::currentDate().addDays( -m_maxAgeDays )); 00238 } 00239 00243 void emitAddToHistory( const KonqHistoryEntry& entry ); 00244 00253 virtual void notifyHistoryEntry( KonqHistoryEntry e, QCString saveId ); 00254 00259 virtual void notifyMaxCount( Q_UINT32 count, QCString saveId ); 00260 00265 virtual void notifyMaxAge( Q_UINT32 days, QCString saveId ); 00266 00270 virtual void notifyClear( QCString saveId ); 00271 00276 virtual void notifyRemove( KURL url, QCString saveId ); 00277 00282 virtual void notifyRemove( KURL::List urls, QCString saveId ); 00283 00287 virtual QStringList allURLs() const; 00288 00300 void addToHistory( bool pending, const KURL& url, 00301 const QString& typedURL = QString::null, 00302 const QString& title = QString::null ); 00303 00304 00310 virtual bool filterOut( const KURL& url ); 00311 00312 void addToUpdateList( const QString& url ) { 00313 m_updateURLs.append( url ); 00314 m_updateTimer->start( 500, true ); 00315 } 00316 00322 QStringList m_updateURLs; 00323 00324 private slots: 00329 void slotEmitUpdated(); 00330 00331 private: 00335 bool isSenderOfBroadcast(); 00336 00337 void clearPending(); 00344 KonqHistoryEntry * findEntry( const KURL& url ); 00345 00350 bool loadFallback(); 00351 KonqHistoryEntry * createFallbackEntry( const QString& ) const; 00352 00353 void addToCompletion( const QString& url, const QString& typedURL, int numberOfTimesVisited = 1 ); 00354 void removeFromCompletion( const QString& url, const QString& typedURL ); 00355 00356 QString m_filename; 00357 KonqHistoryList m_history; 00358 00365 QMap<QString,KonqHistoryEntry*> m_pending; 00366 00367 Q_UINT32 m_maxCount; // maximum of history entries 00368 Q_UINT32 m_maxAgeDays; // maximum age of a history entry 00369 00370 KCompletion *m_pCompletion; // the completion object we sync with 00371 00376 QTimer *m_updateTimer; 00377 00378 static const Q_UINT32 s_historyVersion; 00379 }; 00380 00381 00382 #endif // KONQ_HISTORY_H
KDE Logo
This file is part of the documentation for libkonq Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 16 15:59:26 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003