Qt 4.8
Public Functions | Public Variables | List of all members
QResourcePrivate Class Reference

Public Functions

void clear ()
 
void ensureChildren () const
 
void ensureInitialized () const
 
bool load (const QString &file)
 
 QResourcePrivate (QResource *_q)
 
 ~QResourcePrivate ()
 

Public Variables

QString absoluteFilePath
 
QStringList children
 
uint compressed: 1
 
uint container: 1
 
const uchardata
 
QString fileName
 
QLocale locale
 
QResourceq_ptr
 
QList< QResourceRoot * > related
 
qint64 size
 

Detailed Description

Definition at line 229 of file qresource.cpp.

Constructors and Destructors

◆ QResourcePrivate()

QResourcePrivate::QResourcePrivate ( QResource _q)
inline

Definition at line 231 of file qresource.cpp.

231 : q_ptr(_q) { clear(); }
QResource * q_ptr
Definition: qresource.cpp:249

◆ ~QResourcePrivate()

QResourcePrivate::~QResourcePrivate ( )
inline

Definition at line 232 of file qresource.cpp.

232 { clear(); }

Functions

◆ clear()

void QResourcePrivate::clear ( )

Definition at line 254 of file qresource.cpp.

255 {
257  compressed = 0;
258  data = 0;
259  size = 0;
260  children.clear();
261  container = 0;
262  for(int i = 0; i < related.size(); ++i) {
263  QResourceRoot *root = related.at(i);
264  if(!root->ref.deref())
265  delete root;
266  }
267  related.clear();
268 }
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool deref()
Atomically decrements the value of this QAtomicInt.
void clear()
Removes all items from the list.
Definition: qlist.h:764
void clear()
Clears the contents of the string and makes it empty.
Definition: qstring.h:723
const uchar * data
Definition: qresource.cpp:246
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QString absoluteFilePath
Definition: qresource.cpp:241
QList< QResourceRoot * > related
Definition: qresource.cpp:242
QStringList children
Definition: qresource.cpp:247
QAtomicInt ref
Definition: qresource.cpp:121

◆ ensureChildren()

void QResourcePrivate::ensureChildren ( ) const

Definition at line 341 of file qresource.cpp.

342 {
344  if(!children.isEmpty() || !container || related.isEmpty())
345  return;
346 
347  QString path = absoluteFilePath, k;
348  if(path.startsWith(QLatin1Char(':')))
349  path = path.mid(1);
350  QSet<QString> kids;
351  QString cleaned = cleanPath(path);
352  for(int i = 0; i < related.size(); ++i) {
353  QResourceRoot *res = related.at(i);
354  if(res->mappingRootSubdir(path, &k) && !k.isEmpty()) {
355  if(!kids.contains(k)) {
356  children += k;
357  kids.insert(k);
358  }
359  } else {
360  const int node = res->findNode(cleaned);
361  if(node != -1) {
362  QStringList related_children = res->children(node);
363  for(int kid = 0; kid < related_children.size(); ++kid) {
364  k = related_children.at(kid);
365  if(!kids.contains(k)) {
366  children += k;
367  kids.insert(k);
368  }
369  }
370  }
371  }
372  }
373 }
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool contains(const T &value) const
Definition: qset.h:91
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
const_iterator insert(const T &value)
Definition: qset.h:179
static QString cleanPath(const QString &_path)
Definition: qresource.cpp:148
int findNode(const QString &path, const QLocale &locale=QLocale()) const
Definition: qresource.cpp:644
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool mappingRootSubdir(const QString &path, QString *match=0) const
Definition: qresource.cpp:827
void ensureInitialized() const
Definition: qresource.cpp:309
QStringList children(int node) const
Definition: qresource.cpp:806
QString absoluteFilePath
Definition: qresource.cpp:241
QList< QResourceRoot * > related
Definition: qresource.cpp:242
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QStringList children
Definition: qresource.cpp:247

◆ ensureInitialized()

void QResourcePrivate::ensureInitialized ( ) const

Definition at line 309 of file qresource.cpp.

310 {
311  if(!related.isEmpty())
312  return;
313  QResourcePrivate *that = const_cast<QResourcePrivate *>(this);
314  if(fileName == QLatin1String(":"))
315  that->fileName += QLatin1Char('/');
316  that->absoluteFilePath = fileName;
317  if(!that->absoluteFilePath.startsWith(QLatin1Char(':')))
319 
320  QString path = fileName;
321  if(path.startsWith(QLatin1Char(':')))
322  path = path.mid(1);
323 
324  if(path.startsWith(QLatin1Char('/'))) {
325  that->load(path);
326  } else {
327  QMutexLocker lock(resourceMutex());
328  QStringList searchPaths = *resourceSearchPaths();
329  searchPaths << QLatin1String("");
330  for(int i = 0; i < searchPaths.size(); ++i) {
331  const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path);
332  if(that->load(searchPath)) {
333  that->absoluteFilePath = QLatin1Char(':') + searchPath;
334  break;
335  }
336  }
337  }
338 }
QString & prepend(QChar c)
Definition: qstring.h:261
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool load(const QString &file)
Definition: qresource.cpp:271
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static QReadWriteLock lock
Definition: proxyconf.cpp:399
QString absoluteFilePath
Definition: qresource.cpp:241
QList< QResourceRoot * > related
Definition: qresource.cpp:242
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ load()

bool QResourcePrivate::load ( const QString file)

Definition at line 271 of file qresource.cpp.

Referenced by ensureInitialized().

272 {
273  related.clear();
274  QMutexLocker lock(resourceMutex());
275  const ResourceList *list = resourceList();
276  QString cleaned = cleanPath(file);
277  for(int i = 0; i < list->size(); ++i) {
278  QResourceRoot *res = list->at(i);
279  const int node = res->findNode(cleaned, locale);
280  if(node != -1) {
281  if(related.isEmpty()) {
282  container = res->isContainer(node);
283  if(!container) {
284  data = res->data(node, &size);
285  compressed = res->isCompressed(node);
286  } else {
287  data = 0;
288  size = 0;
289  compressed = 0;
290  }
291  } else if(res->isContainer(node) != container) {
292  qWarning("QResourceInfo: Resource [%s] has both data and children!", file.toLatin1().constData());
293  }
294  res->ref.ref();
295  related.append(res);
296  } else if(res->mappingRootSubdir(file)) {
297  container = true;
298  data = 0;
299  size = 0;
300  compressed = 0;
301  res->ref.ref();
302  related.append(res);
303  }
304  }
305  return !related.isEmpty();
306 }
const uchar * data(int node, qint64 *size) const
Definition: qresource.cpp:781
bool isCompressed(int node) const
Definition: qresource.cpp:128
bool ref()
Atomically increments the value of this QAtomicInt.
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
void clear()
Removes all items from the list.
Definition: qlist.h:764
static QString cleanPath(const QString &_path)
Definition: qresource.cpp:148
int findNode(const QString &path, const QLocale &locale=QLocale()) const
Definition: qresource.cpp:644
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
const uchar * data
Definition: qresource.cpp:246
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool mappingRootSubdir(const QString &path, QString *match=0) const
Definition: qresource.cpp:827
static QReadWriteLock lock
Definition: proxyconf.cpp:399
bool isContainer(int node) const
Definition: qresource.cpp:127
QList< QResourceRoot * > related
Definition: qresource.cpp:242
QAtomicInt ref
Definition: qresource.cpp:121

Properties

◆ absoluteFilePath

QString QResourcePrivate::absoluteFilePath

Definition at line 241 of file qresource.cpp.

Referenced by ensureInitialized().

◆ children

QStringList QResourcePrivate::children
mutable

Definition at line 247 of file qresource.cpp.

◆ compressed

uint QResourcePrivate::compressed
mutable

Definition at line 244 of file qresource.cpp.

◆ container

uint QResourcePrivate::container

Definition at line 243 of file qresource.cpp.

◆ data

const uchar* QResourcePrivate::data
mutable

Definition at line 246 of file qresource.cpp.

◆ fileName

QString QResourcePrivate::fileName

Definition at line 241 of file qresource.cpp.

Referenced by ensureInitialized().

◆ locale

QLocale QResourcePrivate::locale

Definition at line 240 of file qresource.cpp.

◆ q_ptr

QResource* QResourcePrivate::q_ptr

Definition at line 249 of file qresource.cpp.

◆ related

QList<QResourceRoot*> QResourcePrivate::related

Definition at line 242 of file qresource.cpp.

◆ size

qint64 QResourcePrivate::size
mutable

Definition at line 245 of file qresource.cpp.


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