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

« back to all changes in this revision

Viewing changes to systemsettings/core/ModuleView.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
/*****************************************************************************
 
2
 *   Copyright (C) 2009 Ben Cooksley <bcooksley@kde.org>                     *
 
3
 *   Copyright (C) 2009 by Mathias Soeken <msoeken@informatik.uni-bremen.de> *
 
4
 *                                                                           *
 
5
 *   This program is free software; you can redistribute it and/or modify    *
 
6
 *   it under the terms of the GNU General Public License as published by    *
 
7
 *   the Free Software Foundation; either version 2 of the License, or       *
 
8
 *   (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           *
 
13
 *   GNU 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; if not, write to the                           *
 
17
 *   Free Software Foundation, Inc.,                                         *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA            *
 
19
 *****************************************************************************/
 
20
 
 
21
#ifndef MODULE_VIEW_H
 
22
#define MODULE_VIEW_H
 
23
 
 
24
#include <QtGui/QWidget>
 
25
#include <QtCore/QModelIndex>
 
26
#include "systemsettingsview_export.h"
 
27
 
 
28
class MenuItem;
 
29
class KAboutData;
 
30
class KCModuleInfo;
 
31
class KCModuleProxy;
 
32
class KPageWidgetItem;
 
33
 
 
34
/**
 
35
 * @brief Provides a convienent way to display modules
 
36
 *
 
37
 * Provides a standardised interface for displaying multiple modules simultaneously
 
38
 * and provides facilities to access the current module, and to load its help, restore
 
39
 * default settings, save new settings and revert changes to settings
 
40
 *
 
41
 * It also provides checking for when a module has changed its configuration, and will prompt
 
42
 * if the user tries to change module or view if BaseMode is reimplemented correctly
 
43
 *
 
44
 * It also provides signals for active module changes, configuration changes and for when it has
 
45
 * been requested to close by button press
 
46
 *
 
47
 * @author Mathias Soeken <msoeken@informatik.uni-bremen.de>
 
48
 * @author Ben Cooksley <bcooksley@kde.org>
 
49
 */
 
50
class SYSTEMSETTINGSVIEW_EXPORT ModuleView : public QWidget
 
51
{
 
52
    Q_OBJECT
 
53
 
 
54
public:
 
55
    /**
 
56
     * Constructs a ModuleView, with the parent specified.
 
57
     */
 
58
    explicit ModuleView(QWidget * parent = 0);
 
59
 
 
60
    /**
 
61
     * Destroys the module view, along with all modules loaded, and any changes present in them.
 
62
     *
 
63
     * @warning The user will not be prompted to save changes if any exist.\n
 
64
     */
 
65
    ~ModuleView();
 
66
 
 
67
    /**
 
68
     * Provides the module information, which is used to set the caption of the window when either the
 
69
     * active module or configuration changes.
 
70
     */
 
71
    KCModuleInfo * activeModule() const;
 
72
 
 
73
    /**
 
74
     * Provides the about data of the active module, used for the about dialog.
 
75
     */
 
76
    const KAboutData * aboutData() const;
 
77
 
 
78
    /**
 
79
     * Resolves any changes in the currently active module by prompting the user if they exist.
 
80
     *
 
81
     * @returns true if the user saved or discarded changes, or there were no changes at all.
 
82
     * @returns false if the user canceled the module change.
 
83
     */
 
84
    bool resolveChanges();
 
85
 
 
86
    /**
 
87
     * Closes all active modules, after checking there are no active changes.
 
88
     *
 
89
     * @warning This forces all modules to be destroyed regardless of if changes exist or not
 
90
     * If possible, always check with resolveChanges() first.
 
91
     */
 
92
    void closeModules();
 
93
 
 
94
public Q_SLOTS:
 
95
    /**
 
96
     * Loads the module specified by menuItem.\n
 
97
     * If the module has children, they will all be loaded instead of the module.
 
98
     *
 
99
     * @param menuItem the QModelIndex that you want to load. Must be sourced from either MenuModel or MenuProxyModel
 
100
     */
 
101
    void loadModule( QModelIndex menuItem );
 
102
 
 
103
    /**
 
104
     * Will open KHelpCenter, and load the help for the active module.
 
105
     */
 
106
    void moduleHelp();
 
107
 
 
108
    /**
 
109
     * Causes the active module to reload its configuration, reverting all changes.
 
110
     */
 
111
    void moduleLoad();
 
112
 
 
113
    /**
 
114
     * Causes the active module to save its configuration, applying all changes.
 
115
     */
 
116
    bool moduleSave();
 
117
 
 
118
    /**
 
119
     * Causes the active module to revert all changes to the configuration, and return to defaults.
 
120
     */
 
121
    void moduleDefaults();
 
122
 
 
123
    /**
 
124
     * Reimplemented for internal reasons.\n
 
125
     */
 
126
    void keyPressEvent( QKeyEvent * event );
 
127
 
 
128
private:
 
129
    bool resolveChanges( KCModuleProxy *currentProxy );
 
130
    void addModule( KCModuleInfo *module );
 
131
    bool moduleSave( KCModuleProxy *module );
 
132
    void updatePageIconHeader( KPageWidgetItem * page, bool light = false );
 
133
 
 
134
private Q_SLOTS:
 
135
    void activeModuleChanged( KPageWidgetItem* current, KPageWidgetItem* previous);
 
136
    void updateButtons();
 
137
    void stateChanged();
 
138
 
 
139
Q_SIGNALS:
 
140
    /**
 
141
     * Emitted when the currently active module is changed. This occurs whenever the active module or
 
142
     * its configuration changes. This causes the window caption to update.
 
143
     */
 
144
    void moduleChanged( bool state );
 
145
 
 
146
    /**
 
147
     * Emitted when the ModuleView is asked to close.\n
 
148
     */
 
149
    void closeRequest();
 
150
 
 
151
private:
 
152
    class Private;
 
153
    Private *const d;
 
154
};
 
155
 
 
156
#endif