Changeset 846 for trunk/src/gui/styles/qgtkstyle_p.h
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/styles/qgtkstyle_p.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 57 57 #if !defined(QT_NO_STYLE_GTK) 58 58 59 #include <QtCore/qstring.h> 60 #include <QtCore/qstringbuilder.h> 61 #include <QtCore/qcoreapplication.h> 62 59 63 #include <QtGui/QFileDialog> 60 64 … … 72 76 73 77 #define QLS(x) QLatin1String(x) 78 79 QT_BEGIN_NAMESPACE 80 81 // ### Qt 4.7 - merge with QLatin1Literal 82 class QHashableLatin1Literal 83 { 84 public: 85 int size() const { return m_size; } 86 const char *data() const { return m_data; } 87 88 #ifdef __SUNPRO_CC 89 QHashableLatin1Literal(const char* str) 90 : m_size(strlen(str)), m_data(str) {} 91 #else 92 template <int N> 93 QHashableLatin1Literal(const char (&str)[N]) 94 : m_size(N - 1), m_data(str) {} 95 #endif 96 97 QHashableLatin1Literal(const QHashableLatin1Literal &other) 98 : m_size(other.m_size), m_data(other.m_data) 99 {} 100 101 QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other) 102 { 103 if (this == &other) 104 return *this; 105 *const_cast<int *>(&m_size) = other.m_size; 106 *const_cast<char **>(&m_data) = const_cast<char *>(other.m_data); 107 return *this; 108 } 109 110 QString toString() const { return QString::fromLatin1(m_data, m_size); } 111 112 static QHashableLatin1Literal fromData(const char *str) 113 { 114 return QHashableLatin1Literal(str, qstrlen(str)); 115 } 116 117 private: 118 QHashableLatin1Literal(const char *str, int length) 119 : m_size(length), m_data(str) 120 {} 121 122 const int m_size; 123 const char *m_data; 124 }; 125 126 bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2); 127 inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); } 128 uint qHash(const QHashableLatin1Literal &key); 129 130 QT_END_NAMESPACE 74 131 75 132 class GConf; … … 253 310 GnomeIconLookupResultFlags *result); 254 311 255 256 312 class QGtkStylePrivate : public QCleanlooksStylePrivate 257 313 { … … 263 319 QGtkStyleFilter filter; 264 320 265 static GtkWidget* gtkWidget(const Q String&path);266 static GtkStyle* gtkStyle(const Q String &path = QLatin1String("GtkWindow"));321 static GtkWidget* gtkWidget(const QHashableLatin1Literal &path); 322 static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow")); 267 323 268 324 virtual void resolveGtk() const; … … 419 475 static Ptr_gnome_vfs_init gnome_vfs_init; 420 476 421 virtual QPalette gtkWidgetPalette(const Q String>kWidgetName) const;477 virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal >kWidgetName) const; 422 478 423 479 protected: 424 typedef QHash<QString, GtkWidget*> WidgetMap; 480 typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap; 481 482 static inline void destroyWidgetMap() 483 { 484 cleanupGtkWidgets(); 485 delete widgetMap; 486 widgetMap = 0; 487 } 425 488 426 489 static inline WidgetMap *gtkWidgetMap() 427 490 { 428 static WidgetMap *map = 0; 429 if (!map) 430 map = new WidgetMap(); 431 return map; 491 if (!widgetMap) { 492 widgetMap = new WidgetMap(); 493 qAddPostRoutine(destroyWidgetMap); 494 } 495 return widgetMap; 432 496 } 433 497 … … 439 503 static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0); 440 504 static void addWidget(GtkWidget *widget); 505 static void removeWidgetFromMap(const QHashableLatin1Literal &path); 441 506 442 507 virtual void init(); … … 444 509 private: 445 510 static QList<QGtkStylePrivate *> instances; 511 static WidgetMap *widgetMap; 446 512 friend class QGtkStyleUpdateScheduler; 447 513 };
Note:
See TracChangeset
for help on using the changeset viewer.