aboutsummaryrefslogtreecommitdiff
path: root/src/corelib/style/mstylesheetselector.h
blob: e9cfda21239005122370c799fa47cc38c23ba9f0 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/***************************************************************************
**
** 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 MSTYLESHEETSELECTOR_H
#define MSTYLESHEETSELECTOR_H

#include "mexport.h"
#include "mstylesheetattribute.h"
#include "muniquestringcache.h"

#include <QByteArray>
#include <QVariant>

class MStyleSheetSelectorPrivate;

//! \internal
/*!
 * Style sheet selector class.
 *
 * This class represents a set of properties for a single selector statement in CSS file.
 * Later, when the style for the target object is requested, all known selectors are compared to
 * target object and the matching settings are stored to target object's style object.
 */
class M_CORE_EXPORT MStyleSheetSelector
{
    //friend class MStyleSheetParser;

public:

    enum Flags {
        Child           = 0x1,
        ExactClassMatch = 0x2
    };

    enum Orientation {
	LandscapeOrientation = M::Landscape,
	PortraitOrientation = M::Portrait,
	UndefinedOrientation = 3
    };
    /*!
     * MStyleSheetSelector constructor
     * \param objectName target object name of this selector, can be empty
     * \param className target class name for this selector, can be empty
     * \param classType class type
     * \param orientation target orientation for this selector, can be empty
     * \param mode target mode for this selector, can be empty
     * \param filename Name of the css file where this selector was parsed, can be empty.
              Parameter is used for providing detailed css parsing errors.
     * \param parentName Name of parent
     * \param child A flag indicating whether this selector represents a descendant or
              direct child of the parent.
     * \param subclasses A flag indicating whether the su
     * \deprecated Please use the new constructor
     */
    explicit MStyleSheetSelector(MUniqueStringCache::Index objectName = MUniqueStringCache::UndefinedIndex,
                                   MUniqueStringCache::Index className = MUniqueStringCache::UndefinedIndex,
                                   MUniqueStringCache::Index classType = MUniqueStringCache::UndefinedIndex,
                                   const Orientation orientation = UndefinedOrientation,
                                   MUniqueStringCache::Index mode = MUniqueStringCache::UndefinedIndex,
                                   MUniqueStringCache::Index parentName = MUniqueStringCache::UndefinedIndex,
                                   Flags flags = (Flags) 0);


    /*!
     * MStyleSheetSelector constructor
     * \param objectName target object name of this selector, can be empty
     * \param className target class name for this selector, can be empty
     * \param classType class type
     * \param orientation target orientation for this selector, can be empty
     * \param mode target mode for this selector, can be empty
     * \param filename Name of the css file where this selector was parsed, can be empty.
              Parameter is used for providing detailed css parsing errors.
     * \param parentName Name of parent
     * \param parentObjectName Parent object (style) name
     * \param child A flag indicating whether this selector represents a descendant or
              direct child of the parent.
     * \param subclasses A flag indicating whether the su
     */

    explicit MStyleSheetSelector(MUniqueStringCache::Index objectName,
                                   MUniqueStringCache::Index className,
                                   MUniqueStringCache::Index classType,
                                   const Orientation orientation,
                                   MUniqueStringCache::Index mode,
                                   MUniqueStringCache::Index parentName,
                                   MUniqueStringCache::Index parentObjectName,
                                   Flags flags = (Flags) 0);
    MUniqueStringCache::Index objectNameID() const;
    MUniqueStringCache::Index classNameID() const;
    MUniqueStringCache::Index classTypeID() const;
    MUniqueStringCache::Index modeID() const;
    MUniqueStringCache::Index parentNameID() const;
    MUniqueStringCache::Index parentObjectNameID() const;

    /*!
     * Copy constructor
     * \param selector style sheet selector to clone
     */
    MStyleSheetSelector(const MStyleSheetSelector &selector);

    //! Destructor for MStyleSheetSelector class
    virtual ~MStyleSheetSelector();

    /*!
     * \brief Provides access for the attributes of this selector.
     */
    MAttributeList *attributes();

    /*!
     * \brief Returns the parent class name for this selector.
     */
    QByteArray parentName() const;

    /*!
     * \brief Returns the parent class object name for this selector.
     */
    QByteArray parentObjectName() const;

    /*!
     * \brief Returns the object name for this selector.
     */
    QByteArray objectName() const;

    /*!
     * \brief Returns the class name for this selector.
     */
    QByteArray className() const;

    /*!
     * \brief Returns the type for this selector.
     */
    QByteArray classType() const;

    /*!
     * \brief Returns the screen orientation for this selector.
     */
    Orientation orientation() const;

    /*!
     * \brief Returns the object mode for this selector.
     */
    QByteArray mode() const;

    /*!
     * \brief Returns flags of this selector.
     */
    Flags flags() const;

private:
    Q_DECLARE_PRIVATE(MStyleSheetSelector)
    MStyleSheetSelectorPrivate *const d_ptr;
};
//! \internal_end

#endif