not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / klipper / klipperpopup.h
blob07a4162ed4ad6981424e52fe38eae512070ef00a
1 // -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*-
2 /* This file is part of the KDE project
3 Copyright (C) 2004 Esben Mose Hansen <kde@mosehansen.dk>
4 Copytight (C) by Andrew Stanley-Jones
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
20 #ifndef KLIPPERPOPUP_H
21 #define KLIPPERPOPUP_H
23 #include <QList>
24 #include <QWidgetAction>
26 #include <kmenu.h>
28 class History;
29 class KHelpMenu;
30 class QAction;
31 class PopupProxy;
32 class KLineEdit;
34 /**
35 * Default view of clipboard history.
38 class KlipperPopup : public KMenu
40 Q_OBJECT
42 public:
43 explicit KlipperPopup( History* history );
44 ~KlipperPopup();
45 void plugAction( QAction* action );
47 /**
48 * Normally, the popupmenu is only rebuilt just before showing.
49 * If you need the pixel-size or similar of the this menu, call
50 * this beforehand.
52 void ensureClean();
54 History* history() { return m_history; }
55 const History* history() const { return m_history; }
57 public Q_SLOTS:
58 void slotHistoryChanged() { m_dirty = true; }
59 void slotAboutToShow();
61 private:
62 void rebuild( const QString& filter = QString() );
63 void buildFromScratch();
65 void insertSearchFilter();
66 void removeSearchFilter();
68 protected:
69 virtual void keyPressEvent( QKeyEvent* e );
71 private:
72 bool m_dirty : 1; // true if menu contents needs to be rebuild.
74 /**
75 * Contains the string shown if the menu is empty.
77 QString m_qsEmpty;
79 /**
80 * Contains the string shown if the search string has no
81 * matches and the menu is not empty.
83 QString m_qsNoMatch;
85 /**
86 * The "document" (clipboard history)
88 History* m_history;
90 /**
91 * The help menu
93 KHelpMenu* m_helpmenu;
95 /**
96 * (unowned) actions to plug into the primary popup menu
98 QList<QAction*> m_actions;
101 * Proxy helper object used to track history items
103 PopupProxy* m_popupProxy;
106 * search filter widget
108 KLineEdit* m_filterWidget;
111 * Action of search widget
113 QWidgetAction *m_filterWidgetAction;
116 * The current number of history items in the clipboard
118 int m_nHistoryItems;
120 Q_SIGNALS:
121 void clearHistory();
122 void configure();
123 void quit();
127 #endif