File: menuactions.h

package info (click to toggle)
portabase 2.0%2Bgit20110117-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 6,692 kB
  • sloc: cpp: 32,047; sh: 2,675; ansic: 2,320; makefile: 343; xml: 20; python: 16; asm: 10
file content (101 lines) | stat: -rw-r--r-- 2,560 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * menuactions.h
 *
 * (c) 2003,2009-2010 by Jeremy Bowman <jmbowman@alum.mit.edu>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

/** @file menuactions.h
 * Header file for MenuActions
 */

#ifndef MENUACTIONS_H
#define MENUACTIONS_H

#include <QIcon>
#include <QKeySequence>
#include <QMap>
#include <QObject>
#include <QString>
#include "dbeditor.h"

class QAction;

/**
 * Text, accelerator, and shortcut definitions for menu actions.  Based
 * around the idea of mapping an enumeration key to the corresponding bits
 * of data needed to build a menu action.  For example, the key
 * MenuActions::Print maps to tr("&Print") and CTRL+Key_P.  Grouped
 * together here partially so the relevant text strings are always included
 * in generated translation files, regardless of which platform the code is
 * being built on (some menu actions may not be present on all platforms).
 */
class MenuActions : public QObject
{
    Q_OBJECT
public:
    /** Enumeration of menus and menu items */
    enum Item {
        Row,
        View,
        Sort,
        Filter,
        ChangePassword,
        Import,
        ImportCSV,
        Export,
        Slideshow,
        Properties,
        Preferences,
        QuickFilter,
        AddRow,
        AddView,
        AddSorting,
        AddFilter,
        EditRow,
        EditView,
        EditSorting,
        EditFilter,
        DeleteRow,
        DeleteView,
        DeleteSorting,
        DeleteFilter,
        AllColumns,
        AllRows,
        CopyRow,
        CopyText,
        Show,
        DeleteRowsInFilter,
        EditColumns,
        EditEnums,
        PrintPreview,
        Print,
        Views,
        Sortings,
        Filters,
        Fullscreen
    };
    typedef QMap< Item, QString > PhraseMap;
    typedef QMap< Item, QKeySequence > ShortcutMap;

    MenuActions(QObject *parent=0);

    QString menuText(Item item);
    QAction *action(Item item, bool toggle=false);
    QAction *action(Item item, const QIcon &icon);

private:
    int shortcut(Item item);
    void prepareAction(Item item, QAction *action);

private:
    PhraseMap textMap; /**< Mapping of items to translations (including accelerators) */
    PhraseMap toolTipMap; /**< Mapping of items to translated tooltips */
    ShortcutMap shortcutMap; /**< Mapping of items to shortcut key combinations */
};

#endif