Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/styles/qgtkstyle_p.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5757#if !defined(QT_NO_STYLE_GTK)
    5858
     59#include <QtCore/qstring.h>
     60#include <QtCore/qstringbuilder.h>
     61#include <QtCore/qcoreapplication.h>
     62
    5963#include <QtGui/QFileDialog>
    6064
     
    7276
    7377#define QLS(x) QLatin1String(x)
     78
     79QT_BEGIN_NAMESPACE
     80
     81// ### Qt 4.7 - merge with QLatin1Literal
     82class QHashableLatin1Literal
     83{
     84public:
     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
     117private:
     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
     126bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2);
     127inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); }
     128uint qHash(const QHashableLatin1Literal &key);
     129
     130QT_END_NAMESPACE
    74131
    75132class GConf;
     
    253310        GnomeIconLookupResultFlags *result);
    254311
    255 
    256312class QGtkStylePrivate : public QCleanlooksStylePrivate
    257313{
     
    263319    QGtkStyleFilter filter;
    264320
    265     static GtkWidget* gtkWidget(const QString &path);
    266     static GtkStyle* gtkStyle(const QString &path = QLatin1String("GtkWindow"));
     321    static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
     322    static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
    267323
    268324    virtual void resolveGtk() const;
     
    419475    static Ptr_gnome_vfs_init gnome_vfs_init;
    420476
    421     virtual QPalette gtkWidgetPalette(const QString &gtkWidgetName) const;
     477    virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
    422478
    423479protected:
    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    }
    425488
    426489    static inline WidgetMap *gtkWidgetMap()
    427490    {
    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;
    432496    }
    433497
     
    439503    static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0);
    440504    static void addWidget(GtkWidget *widget);
     505    static void removeWidgetFromMap(const QHashableLatin1Literal &path);
    441506
    442507    virtual void init();
     
    444509private:
    445510    static QList<QGtkStylePrivate *> instances;
     511    static WidgetMap *widgetMap;
    446512    friend class QGtkStyleUpdateScheduler;
    447513};
Note: See TracChangeset for help on using the changeset viewer.