~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to klipper/popupproxy.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

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
 
 
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 _POPUPPROXY_H_
 
21
#define _POPUPPROXY_H_
 
22
 
 
23
#include <QObject>
 
24
 
 
25
#include <QRegExp>
 
26
 
 
27
#include <kmenu.h>
 
28
#include <history.h>
 
29
 
 
30
class HistoryItem;
 
31
class KlipperPopup;
 
32
 
 
33
/**
 
34
 * Proxy helper for the "more" menu item
 
35
 *
 
36
 */
 
37
class PopupProxy : public QObject
 
38
{
 
39
    Q_OBJECT
 
40
 
 
41
public:
 
42
    /**
 
43
     * Inserts up to itemsPerMenu into parent from parent->youngest(),
 
44
     * and spills any remaining items into a more menu.
 
45
     */
 
46
    PopupProxy( KlipperPopup* parent, int menu_height, int menu_width );
 
47
 
 
48
    KlipperPopup* parent();
 
49
 
 
50
    /**
 
51
     * Called when rebuilding the menu
 
52
     * Deletes any More menus.. and start (re)inserting into the toplevel menu.
 
53
     * @param index Items are inserted at index.
 
54
     * @param filter If non-empty, only insert items that match filter as a regex
 
55
     * @return number of items inserted.
 
56
     */
 
57
    int buildParent( int index, const QRegExp& filter = QRegExp() );
 
58
 
 
59
public Q_SLOTS:
 
60
    void slotAboutToShow();
 
61
    void slotHistoryChanged();
 
62
private:
 
63
    /**
 
64
     * Insert up to m_itemsPerMenu items from spill and a new
 
65
     * more-menu if necessary.
 
66
     * @param index Items are inserted at index
 
67
     * @return number of items inserted.
 
68
     */
 
69
    int insertFromSpill( int index = 0 );
 
70
 
 
71
    /**
 
72
     * Insert item into proxy_for_menu at index,
 
73
     * subtracting the items height from remainingHeight
 
74
     */
 
75
    void tryInsertItem( HistoryItem const * const item, int& remainingHeight, const int index );
 
76
 
 
77
    /**
 
78
     * Delete all "More..." menus current created.
 
79
     */
 
80
    void deleteMoreMenus();
 
81
 
 
82
private:
 
83
    KMenu* m_proxy_for_menu;
 
84
    QByteArray m_spill_uuid;
 
85
    QRegExp m_filter;
 
86
    int m_menu_height;
 
87
    int m_menu_width;
 
88
};
 
89
 
 
90
#endif