Add (and install) svg for the new krunner interface.
[kdebase/uwolfer.git] / workspace / klipper / popupproxy.h
blobb14f7a753bc5b566e70b2ce513dab05518d5568e
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>
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 _POPUPPROXY_H_
21 #define _POPUPPROXY_H_
23 #include <QObject>
25 #include <QRegExp>
27 #include <kmenu.h>
28 #include <history.h>
30 class HistoryItem;
31 class KlipperPopup;
33 /**
34 * Proxy helper for the "more" menu item
37 class PopupProxy : public QObject
39 Q_OBJECT
41 public:
42 /**
43 * Inserts up to itemsPerMenu into parent from parent->youngest(),
44 * and spills any remaining items into a more menu.
46 PopupProxy( KlipperPopup* parent, int menu_height, int menu_width );
48 KlipperPopup* parent();
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.
57 int buildParent( int index, const QRegExp& filter = QRegExp() );
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.
69 int insertFromSpill( int index = 0 );
71 /**
72 * Insert item into proxy_for_menu at index,
73 * subtracting the items height from remainingHeight
75 void tryInsertItem( HistoryItem const * const item, int& remainingHeight, const int index );
77 /**
78 * Delete all "More..." menus current created.
80 void deleteMoreMenus();
82 private:
83 KMenu* proxy_for_menu;
84 History::iterator spillPointer;
85 QRegExp m_filter;
86 int m_menu_height;
87 int m_menu_width;
88 int nextItemNumber;
92 #endif