konq_historymgr.h00001
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
00256 virtual void notifyHistoryEntry( KonqHistoryEntry e, QCString saveId );
00257
00262 virtual void notifyMaxCount( Q_UINT32 count, QCString saveId );
00263
00268 virtual void notifyMaxAge( Q_UINT32 days, QCString saveId );
00269
00273 virtual void notifyClear( QCString saveId );
00274
00279 virtual void notifyRemove( KURL url, QCString saveId );
00280
00285 virtual void notifyRemove( KURL::List urls, QCString saveId );
00286
00290 virtual QStringList allURLs() const;
00291
00303 void addToHistory( bool pending, const KURL& url,
00304 const QString& typedURL = QString::null,
00305 const QString& title = QString::null );
00306
00307
00313 virtual bool filterOut( const KURL& url );
00314
00315 void addToUpdateList( const QString& url ) {
00316 m_updateURLs.append( url );
00317 m_updateTimer->start( 500, true );
00318 }
00319
00325 QStringList m_updateURLs;
00326
00327 private slots:
00332 void slotEmitUpdated();
00333
00334 private:
00338 bool isSenderOfBroadcast();
00339
00340 void clearPending();
00347 KonqHistoryEntry * findEntry( const KURL& url );
00348
00353 bool loadFallback();
00354 KonqHistoryEntry * createFallbackEntry( const QString& ) const;
00355
00356 void addToCompletion( const QString& url, const QString& typedURL, int numberOfTimesVisited = 1 );
00357 void removeFromCompletion( const QString& url, const QString& typedURL );
00358
00359 QString m_filename;
00360 KonqHistoryList m_history;
00361
00368 QMap<QString,KonqHistoryEntry*> m_pending;
00369
00370 Q_UINT32 m_maxCount;
00371 Q_UINT32 m_maxAgeDays;
00372
00373 KCompletion *m_pCompletion;
00374
00379 QTimer *m_updateTimer;
00380
00381 static const Q_UINT32 s_historyVersion;
00382 };
00383
00384
00385 #endif // KONQ_HISTORY_H
|