diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-08-28 22:44:34 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2025-08-31 23:30:34 +0900 |
commit | f9abd9d505434c9244c03eac708e29a0ca042f6b (patch) | |
tree | 30a197ab4c413849188bc131ff859212e636c821 /src/app/Dialogs/popularurls.h | |
parent | 14d42d284de233f9937becf3fc9ee0dabede3b21 (diff) | |
download | krusader-r14.1.x.tar.gz krusader-r14.1.x.zip |
Restructure source foldersr14.1.x
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 086012dcad8a976a0dabbb7cbc20c9cb612cdfa9)
Diffstat (limited to 'src/app/Dialogs/popularurls.h')
-rw-r--r-- | src/app/Dialogs/popularurls.h | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/app/Dialogs/popularurls.h b/src/app/Dialogs/popularurls.h new file mode 100644 index 0000000..775a356 --- /dev/null +++ b/src/app/Dialogs/popularurls.h @@ -0,0 +1,86 @@ +#ifndef POPULARURLS_H +#define POPULARURLS_H + +#include <tqobject.h> +#include <kurl.h> +#include <tqdict.h> +#include <kdialogbase.h> + +// the class holds a list of most popular links in a dual data structure +// * linked list, with head and tail: for fast append/prepend support +// * dictionary that maps urls to list nodes: to save the need to iterate +// over the list in order to find the correct node for each new url +// +// also, the class holds a maximum number of urls. two variables affect this: +// * maxUrls - the num. of urls the user can see +// * hardLimit - the actual number of urls kept. +// when the number of urls reaches hardLimit, a garbage collection is done and +// the bottom (hardLimit-maxUrls) entries are removed from the list +typedef struct _UrlNode* UrlNodeP; +typedef struct _UrlNode { + UrlNodeP prev; + KURL url; + int rank; + UrlNodeP next; +} UrlNode; + +class PopularUrlsDlg; + +class PopularUrls : public TQObject { + TQ_OBJECT + +public: + PopularUrls(TQObject *parent = 0, const char *name = 0); + ~PopularUrls(); + void save(); + void load(); + void addUrl(const KURL& url); + KURL::List getMostPopularUrls(int max); + +public slots: + void showDialog(); + +protected: + // NOTE: the following methods append/insert/remove a node to the list + // but NEVER free memory or allocate memory! + void appendNode(UrlNodeP node); + void insertNode(UrlNodeP node, UrlNodeP after); + void removeNode(UrlNodeP node); + void relocateIfNeeded(UrlNodeP node); + void clearList(); + void dumpList(); + void decreaseRanks(); + +private: + UrlNodeP head, tail; + TQDict<UrlNode> ranks; // actually holds UrlNode* + int count; + static const int maxUrls = 30; + PopularUrlsDlg *dlg; +}; + +class TDEListView; +class TDEListViewSearchLine; + +class PopularUrlsDlg: public KDialogBase { + TQ_OBJECT + +public: + PopularUrlsDlg(); + ~PopularUrlsDlg(); + void run(KURL::List list); // use this to open the dialog + inline int result() const { return selection; } // returns index 0 - topmost, or -1 + + +protected slots: + void slotSearchReturnPressed(const TQString&); + void slotItemSelected(TQListViewItem *it); + +private: + TDEListView *urls; + TDEListViewSearchLine *search; + int selection; +}; + + +#endif |