~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to klipper/klipperpopup.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
9
 
 
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.
 
14
 
 
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.
 
19
*/
 
20
#ifndef _KLIPPERPOPUP_H_
 
21
#define _KLIPPERPOPUP_H_
 
22
 
 
23
#include <kmenu.h>
 
24
#include <Qt3Support/Q3PtrList>
 
25
 
 
26
//Added by qt3to4:
 
27
#include <QKeyEvent>
 
28
 
 
29
class History;
 
30
class KHelpMenu;
 
31
class QAction;
 
32
class PopupProxy;
 
33
class KLineEdit;
 
34
 
 
35
/**
 
36
 * Default view of clipboard history.
 
37
 *
 
38
 */
 
39
class KlipperPopup : public KMenu
 
40
{
 
41
    Q_OBJECT
 
42
 
 
43
public:
 
44
    explicit KlipperPopup( History* history, QWidget* parent=0 );
 
45
    ~KlipperPopup();
 
46
    void plugAction( QAction* action );
 
47
 
 
48
    /**
 
49
     * Normally, the popupmenu is only rebuilt just before showing.
 
50
     * If you need the pixel-size or similar of the this menu, call
 
51
     * this beforehand.
 
52
     */
 
53
    void ensureClean();
 
54
 
 
55
    History* history() { return m_history; }
 
56
    const History* history() const { return m_history; }
 
57
 
 
58
public Q_SLOTS:
 
59
    void slotHistoryChanged() { m_dirty = true; }
 
60
    void slotAboutToShow();
 
61
 
 
62
private:
 
63
    void rebuild( const QString& filter = QString() );
 
64
    void buildFromScratch();
 
65
 
 
66
    void insertSearchFilter();
 
67
    void removeSearchFilter();
 
68
 
 
69
protected:
 
70
     virtual void keyPressEvent( QKeyEvent* e );
 
71
 
 
72
private:
 
73
    bool m_dirty : 1; // true if menu contents needs to be rebuild.
 
74
 
 
75
    /**
 
76
     * Contains the string shown if the menu is empty.
 
77
     */
 
78
    QString QSempty;
 
79
 
 
80
    /**
 
81
     * Contains the string shown if the search string has no
 
82
     * matches and the menu is not empty.
 
83
     */
 
84
    QString QSnomatch;
 
85
 
 
86
    /**
 
87
     * The "document" (clipboard history)
 
88
     */
 
89
    History* m_history;
 
90
 
 
91
    /**
 
92
     * The help menu
 
93
     */
 
94
    KHelpMenu* helpmenu;
 
95
 
 
96
    /**
 
97
     * (unowned) actions to plug into the primary popup menu
 
98
     */
 
99
    Q3PtrList<QAction> m_actions;
 
100
 
 
101
    /**
 
102
     * Proxy helper object used to track history items
 
103
     */
 
104
    PopupProxy* m_popupProxy;
 
105
 
 
106
    /**
 
107
     * search filter widget
 
108
     */
 
109
    KLineEdit* m_filterWidget;
 
110
 
 
111
    /**
 
112
     * id of search widget, for convenience
 
113
     */
 
114
    int m_filterWidgetId;
 
115
 
 
116
    /**
 
117
     * The current number of history items in the clipboard
 
118
     */
 
119
    int n_history_items;
 
120
 
 
121
Q_SIGNALS:
 
122
    void clearHistory();
 
123
    void configure();
 
124
    void quit();
 
125
 
 
126
};
 
127
 
 
128
#endif