aboutsummaryrefslogtreecommitdiff
path: root/src/views/mdialogview_p.h
blob: 9c6d5c1b52cdc36019f3dbdc1ccf9d1b892c0d03 (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#ifndef MDIALOGVIEW_P_H
#define MDIALOGVIEW_P_H

#include "mdialogview.h"
#include <mnamespace.h>
#include <QPointer>

class MDialog;
class MDialogPrivate;
class MButton;
class MLabel;
class MPannableViewport;
class MProgressIndicator;
class MLayout;
class MButtonGroupLayoutPolicy;

/*
Widget hierarchy:
==================

MDialog (MSceneWindow), rootLayout
 |
 |- top spacer
 |
 |- horizontal widget
 |      |
 |      |- left spacer
 |      |
 |      |- dialogBox (the actual graphical dialog)
 |      |      |
 |      |      |- title bar
 |      |      |     |
 |      |      |     |- spinner
 |      |      |     |
 |      |      |     |- title label
 |      |      |     |
 |      |      |     |- close button
 |      |      |
 |      |      |- contents viewport (a pannable viewport)
 |      |            |
 |      |            |- contents (inside a pannable viewport)
 |      |                  |
 |      |                  |- central widget
 |      |                  |
 |      |                  |- button box
 |      |
 |      | - right spacer
 |
 |- bottom spacer (only when dialog-vertical-alignment = center)
*/

class MDialogViewPrivate
{
    Q_DECLARE_PUBLIC(MDialogView)

protected:
    MDialogView *q_ptr;

public:
    MDialogViewPrivate();
    virtual ~MDialogViewPrivate();

    void updateWidgetVisibility(QGraphicsWidget *widget, bool visible, int index,
                                QGraphicsLinearLayout *layout);
    void setupDialogVerticalAlignment();

    void createWidgetHierarchy();
    void createHorizontalLayout();
    void createTitleBar();
    void createButtonBox();
    void createDialogBox();
    static QGraphicsWidget *createSpacer();
    static QGraphicsLinearLayout *createLayout(Qt::Orientation orientation);
    void repopulateButtonBox();
    static int stdButtonOrder(M::StandardButton buttonType);
    void removeButtonsNotInDialogModel();
    void addButtonsFromDialogModel();
    bool isButtonInButtonBox(MButtonModel *buttonModel);
    void setCentralWidget(QGraphicsWidget *newCentralWidget);
    void addButton(MButtonModel *buttonModel);
    void updateButtonBox();
    void setSpinnerVisibility(bool visibility);

    MDialog *controller;

    // Layout applied to the controller itself.
    QGraphicsLinearLayout *rootLayout;

    QGraphicsWidget *topSpacer;
    QGraphicsWidget *bottomSpacer;
    QGraphicsWidget *leftSpacer;
    QGraphicsWidget *rightSpacer;

    QGraphicsWidget *horizontalWidget;
    QGraphicsLinearLayout *horizontalLayout;

    // The dialog box itself.
    // Contains a title bar and a pannable viewport for the dialog's contents
    QGraphicsWidget *dialogBox;
    QGraphicsLinearLayout *dialogBoxLayout;

    // Widget that contains the contents of the dialog box.
    // It has the central widget and the button box.
    // Classes inheriting from MDialog may add new items to it.
    // We expect that specialized classes don't remove our items from
    // it by themselves.
    QGraphicsWidget *contents;
    QGraphicsLinearLayout *contentsLayout;

    MPannableViewport *contentsViewport;

    QPointer<QGraphicsWidget> centralWidget;

    MWidget *titleBar;
    MLabel *titleLabel;
    MProgressIndicator *spinner;
    MButton *closeButton;

    QGraphicsWidget *buttonBox;
    MLayout *buttonBoxLayout;
    MButtonGroupLayoutPolicy *buttonBoxLayoutPolicy;
};

#endif