konq_historymgr.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 #include <libkonq_export.h>
00039
00040 class KCompletion;
00041
00042
00043 typedef QPtrList<KonqHistoryEntry> KonqBaseHistoryList;
00044 typedef QPtrListIterator<KonqHistoryEntry> KonqHistoryIterator;
00045
00046 class LIBKONQ_EXPORT KonqHistoryList : public KonqBaseHistoryList
00047 {
00048 public:
00054 KonqHistoryEntry * findEntry( const KURL& url );
00055
00056 protected:
00060 virtual int compareItems( QPtrCollection::Item, QPtrCollection::Item );
00061 };
00062
00063
00065
00066
00074 class LIBKONQ_EXPORT KonqHistoryManager : public KParts::HistoryProvider,
00075 public KonqHistoryComm
00076 {
00077 Q_OBJECT
00078
00079 public:
00080 static KonqHistoryManager *kself() {
00081 return static_cast<KonqHistoryManager*>( KParts::HistoryProvider::self() );
00082 }
00083
00084 KonqHistoryManager( QObject *parent, const char *name );
00085 ~KonqHistoryManager();
00086
00094 void emitSetMaxCount( Q_UINT32 count );
00095
00105 void emitSetMaxAge( Q_UINT32 days );
00106
00113 void emitRemoveFromHistory( const KURL& url );
00114
00121 void emitRemoveFromHistory( const KURL::List& urls );
00122
00126 Q_UINT32 maxCount() const { return m_maxCount; }
00127
00131 Q_UINT32 maxAge() const { return m_maxAgeDays; }
00132
00150 void addPending( const KURL& url, const QString& typedURL = QString::null,
00151 const QString& title = QString::null );
00152
00156 void confirmPending( const KURL& url,
00157 const QString& typedURL = QString::null,
00158 const QString& title = QString::null );
00159
00164 void removePending( const KURL& url );
00165
00169 KCompletion * completionObject() const { return m_pCompletion; }
00170
00175 const KonqHistoryList& entries() const { return m_history; }
00176
00177
00184 virtual void insert( const QString& );
00185 virtual void remove( const QString& ) {}
00186 virtual void clear() {}
00187
00188
00189 public slots:
00193 bool loadHistory();
00194
00198 bool saveHistory();
00199
00205 void emitClear();
00206
00207
00208 signals:
00212 void loadingFinished();
00213
00217 void entryAdded( const KonqHistoryEntry *entry );
00218
00224 void entryRemoved( const KonqHistoryEntry *entry );
00225
00226 protected:
00231 void adjustSize();
00232
00237 inline bool isExpired( KonqHistoryEntry *entry ) {
00238 return (entry && m_maxAgeDays > 0 && entry->lastVisited <
00239 QDate::currentDate().addDays( -m_maxAgeDays ));
00240 }
00241
00245 void emitAddToHistory( const KonqHistoryEntry& entry );
00246
00255 virtual void notifyHistoryEntry( KonqHistoryEntry e, QCString saveId );
00256
00261 virtual void notifyMaxCount( Q_UINT32 count, QCString saveId );
00262
00267 virtual void notifyMaxAge( Q_UINT32 days, QCString saveId );
00268
00272 virtual void notifyClear( QCString saveId );
00273
00278 virtual void notifyRemove( KURL url, QCString saveId );
00279
00284 virtual void notifyRemove( KURL::List urls, QCString saveId );
00285
00289 virtual QStringList allURLs() const;
00290
00302 void addToHistory( bool pending, const KURL& url,
00303 const QString& typedURL = QString::null,
00304 const QString& title = QString::null );
00305
00306
00312 virtual bool filterOut( const KURL& url );
00313
00314 void addToUpdateList( const QString& url ) {
00315 m_updateURLs.append( url );
00316 m_updateTimer->start( 500, true );
00317 }
00318
00324 QStringList m_updateURLs;
00325
00326 private slots:
00331 void slotEmitUpdated();
00332
00333 private:
00337 bool isSenderOfBroadcast();
00338
00339 void clearPending();
00346 KonqHistoryEntry * findEntry( const KURL& url );
00347
00352 bool loadFallback();
00353 KonqHistoryEntry * createFallbackEntry( const QString& ) const;
00354
00355 void addToCompletion( const QString& url, const QString& typedURL, int numberOfTimesVisited = 1 );
00356 void removeFromCompletion( const QString& url, const QString& typedURL );
00357
00358 QString m_filename;
00359 KonqHistoryList m_history;
00360
00367 QMap<QString,KonqHistoryEntry*> m_pending;
00368
00369 Q_UINT32 m_maxCount;
00370 Q_UINT32 m_maxAgeDays;
00371
00372 KCompletion *m_pCompletion;
00373
00378 QTimer *m_updateTimer;
00379
00380 static const Q_UINT32 s_historyVersion;
00381 };
00382
00383
00384 #endif // KONQ_HISTORY_H
This file is part of the documentation for libkonq Library Version 3.4.2.