Qt 4.8
Classes | Public Types | Public Functions | Properties | List of all members
QWSPropertyManager Class Reference

#include <qwsproperty_qws.h>

Classes

class  Data
 

Public Types

enum  Atom { PropSelection = 0 }
 
enum  Mode { PropReplace = 0, PropPrepend, PropAppend }
 

Public Functions

bool addProperty (int winId, int property)
 
bool getProperty (int winId, int property, const char *&data, int &len)
 
bool hasProperty (int winId, int property)
 
 QWSPropertyManager ()
 
bool removeProperties (int winId)
 
bool removeProperty (int winId, int property)
 
bool setProperty (int winId, int property, int mode, const char *data, int len)
 
 ~QWSPropertyManager ()
 

Properties

Datad
 

Detailed Description

Definition at line 61 of file qwsproperty_qws.h.

Enumerations

◆ Atom

Enumerator
PropSelection 

Definition at line 71 of file qwsproperty_qws.h.

◆ Mode

Enumerator
PropReplace 
PropPrepend 
PropAppend 

Definition at line 64 of file qwsproperty_qws.h.

Constructors and Destructors

◆ QWSPropertyManager()

QWSPropertyManager::QWSPropertyManager ( )

Definition at line 72 of file qwsproperty_qws.cpp.

73 {
74  d = new Data;
75 }

◆ ~QWSPropertyManager()

QWSPropertyManager::~QWSPropertyManager ( )

Definition at line 77 of file qwsproperty_qws.cpp.

78 {
79  delete d;
80 }

Functions

◆ addProperty()

bool QWSPropertyManager::addProperty ( int  winId,
int  property 
)

Definition at line 116 of file qwsproperty_qws.cpp.

117 {
118  if( !d->properties[winId].contains(property) )
119  d->properties[winId][property] = QByteArray(); // only add if it doesn't exist
120  return true;
121 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
const char * property
Definition: qwizard.cpp:138

◆ getProperty()

bool QWSPropertyManager::getProperty ( int  winId,
int  property,
const char *&  data,
int &  len 
)

Definition at line 123 of file qwsproperty_qws.cpp.

124 {
125  QHash<int, QByteArray> props = d->properties.value(winId);
127  if (it == props.end()) {
128  data = 0;
129  len = -1;
130  return false;
131  }
132  data = it.value().constData();
133  len = it.value().length();
134 
135  return true;
136 }
#define it(className, varName)
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static const char * data(const QByteArray &arr)
int length() const
Same as size().
Definition: qbytearray.h:356
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
const char * property
Definition: qwizard.cpp:138
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ hasProperty()

bool QWSPropertyManager::hasProperty ( int  winId,
int  property 
)

Definition at line 103 of file qwsproperty_qws.cpp.

104 {
105  return d->properties.value(winId).contains(property);
106 }
bool contains(const Key &key) const
Returns true if the hash contains an item with the key; otherwise returns false.
Definition: qhash.h:872
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
const char * property
Definition: qwizard.cpp:138

◆ removeProperties()

bool QWSPropertyManager::removeProperties ( int  winId)

Definition at line 138 of file qwsproperty_qws.cpp.

139 {
140  return d->properties.remove(winId);
141 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784

◆ removeProperty()

bool QWSPropertyManager::removeProperty ( int  winId,
int  property 
)

Definition at line 108 of file qwsproperty_qws.cpp.

109 {
111  if (it == d->properties.end())
112  return false;
113  return d->properties[winId].remove( property );
114 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
#define it(className, varName)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
const char * property
Definition: qwizard.cpp:138
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

◆ setProperty()

bool QWSPropertyManager::setProperty ( int  winId,
int  property,
int  mode,
const char *  data,
int  len 
)

Definition at line 82 of file qwsproperty_qws.cpp.

83 {
84  QHash<int, QByteArray> props = d->properties.value(winId);
86  if (it == props.end())
87  return false;
88 
89  switch (mode) {
90  case PropReplace:
91  d->properties[winId][property] = QByteArray(data, len);
92  break;
93  case PropAppend:
94  d->properties[winId][property].append(data);
95  break;
96  case PropPrepend:
97  d->properties[winId][property].prepend(data);
98  break;
99  }
100  return true;
101 }
#define it(className, varName)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
static const char * data(const QByteArray &arr)
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:467
const char * property
Definition: qwizard.cpp:138
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
Definition: qhash.h:865

Properties

◆ d

Data* QWSPropertyManager::d
private

The documentation for this class was generated from the following files: