diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2010-02-09 11:46:41 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2010-02-09 11:46:41 (GMT) |
commit | f38f61df31b708e1f4e50c5fdcc30099f9a1fe8f (patch) | |
tree | 86001437916e0d497483aec61f4ed191e5b66f9d /tools/designer | |
parent | 16f89107f9c8019b05d5ccee1b6deccfdff6f98e (diff) | |
download | Qt-f38f61df31b708e1f4e50c5fdcc30099f9a1fe8f.zip Qt-f38f61df31b708e1f4e50c5fdcc30099f9a1fe8f.tar.gz Qt-f38f61df31b708e1f4e50c5fdcc30099f9a1fe8f.tar.bz2 |
Fix warnings ~QX11PixmapData(): QPixmap objects must be destroyed..
Reviewed-by: Trond Kjernåsen <trond@trolltech.com>
Task-number: QTBUG-8046
Diffstat (limited to 'tools/designer')
-rw-r--r-- | tools/designer/src/lib/shared/actionrepository.cpp | 21 | ||||
-rw-r--r-- | tools/designer/src/lib/shared/actionrepository_p.h | 9 | ||||
-rw-r--r-- | tools/designer/src/lib/shared/iconloader.cpp | 3 | ||||
-rw-r--r-- | tools/designer/src/lib/shared/qdesigner_menu.cpp | 11 | ||||
-rw-r--r-- | tools/designer/src/lib/shared/qdesigner_menu_p.h | 2 |
5 files changed, 25 insertions, 21 deletions
diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp index e3ff2c1..1076ff4 100644 --- a/tools/designer/src/lib/shared/actionrepository.cpp +++ b/tools/designer/src/lib/shared/actionrepository.cpp @@ -77,18 +77,12 @@ static inline QAction *actionOfItem(const QStandardItem* item) return qvariant_cast<QAction*>(item->data(qdesigner_internal::ActionModel::ActionRole)); } -static QIcon fixActionIcon(const QIcon &icon) -{ - if (icon.isNull()) - return qdesigner_internal::emptyIcon(); - return icon; -} - namespace qdesigner_internal { // ----------- ActionModel ActionModel::ActionModel(QWidget *parent ) : QStandardItemModel(parent), + m_emptyIcon(emptyIcon()), m_core(0) { QStringList headers; @@ -127,7 +121,7 @@ void ActionModel::update(int row) for (int i = 0; i < NumColumns; i++) list += item(row, i); - setItems(m_core, actionOfItem(list.front()), list); + setItems(m_core, actionOfItem(list.front()), m_emptyIcon, list); } void ActionModel::remove(int row) @@ -150,7 +144,7 @@ QModelIndex ActionModel::addAction(QAction *action) item->setFlags(flags); items.push_back(item); } - setItems(m_core, action, items); + setItems(m_core, action, m_emptyIcon, items); appendRow(items); return indexFromItem(items.front()); } @@ -185,7 +179,9 @@ PropertySheetKeySequenceValue ActionModel::actionShortCut(const QDesignerPropert return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index)); } -void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QStandardItemList &sl) +void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, + const QIcon &defaultIcon, + QStandardItemList &sl) { // Tooltip, mostly for icon view mode @@ -200,7 +196,10 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, QStandardItem *item = sl[NameColumn]; item->setText(action->objectName()); - item->setIcon(fixActionIcon(action->icon())); + QIcon icon = action->icon(); + if (icon.isNull()) + icon = defaultIcon; + item->setIcon(icon); item->setToolTip(firstTooltip); item->setWhatsThis(firstTooltip); // Used diff --git a/tools/designer/src/lib/shared/actionrepository_p.h b/tools/designer/src/lib/shared/actionrepository_p.h index 65adc5d..6e17e7b 100644 --- a/tools/designer/src/lib/shared/actionrepository_p.h +++ b/tools/designer/src/lib/shared/actionrepository_p.h @@ -59,6 +59,7 @@ #include <QtGui/QTreeView> #include <QtGui/QListView> #include <QtGui/QStackedWidget> +#include <QtGui/QIcon> QT_BEGIN_NAMESPACE @@ -110,10 +111,14 @@ signals: void resourceImageDropped(const QString &path, QAction *action); private: + typedef QList<QStandardItem *> QStandardItemList; + void initializeHeaders(); + static void setItems(QDesignerFormEditorInterface *core, QAction *a, + const QIcon &defaultIcon, + QStandardItemList &sl); - typedef QList<QStandardItem *> QStandardItemList; - static void setItems(QDesignerFormEditorInterface *core, QAction *a, QStandardItemList &sl); + const QIcon m_emptyIcon; QDesignerFormEditorInterface *m_core; }; diff --git a/tools/designer/src/lib/shared/iconloader.cpp b/tools/designer/src/lib/shared/iconloader.cpp index df0bb7e..ed312b8 100644 --- a/tools/designer/src/lib/shared/iconloader.cpp +++ b/tools/designer/src/lib/shared/iconloader.cpp @@ -70,8 +70,7 @@ QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) QDESIGNER_SHARED_EXPORT QIcon emptyIcon() { - static const QIcon empty_icon(QLatin1String(":/trolltech/formeditor/images/emptyicon.png")); - return empty_icon; + return QIcon(QLatin1String(":/trolltech/formeditor/images/emptyicon.png")); } } // namespace qdesigner_internal diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp index c83abad..ba512e4 100644 --- a/tools/designer/src/lib/shared/qdesigner_menu.cpp +++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp @@ -88,6 +88,7 @@ static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection d QDesignerMenu::QDesignerMenu(QWidget *parent) : QMenu(parent), + m_subMenuPixmap(QPixmap(QLatin1String(":/trolltech/formeditor/images/submenu.png"))), m_currentIndex(0), m_addItem(new SpecialMenuAction(this)), m_addSeparator(new SpecialMenuAction(this)), @@ -550,11 +551,10 @@ void QDesignerMenu::deleteAction(QAction *a) QRect QDesignerMenu::subMenuPixmapRect(QAction *action) const { - static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png")); const QRect g = actionGeometry(action); - const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - pm.width() - 2) : 2; - const int y = g.top() + (g.height() - pm.height())/2 + 1; - return QRect(x, y, pm.width(), pm.height()); + const int x = layoutDirection() == Qt::LeftToRight ? (g.right() - m_subMenuPixmap.width() - 2) : 2; + const int y = g.top() + (g.height() - m_subMenuPixmap.height())/2 + 1; + return QRect(x, y, m_subMenuPixmap.width(), m_subMenuPixmap.height()); } bool QDesignerMenu::hasSubMenuPixmap(QAction *action) const @@ -591,8 +591,7 @@ void QDesignerMenu::paintEvent(QPaintEvent *event) p.fillRect(g, lg); } else if (hasSubMenuPixmap(a)) { - static const QPixmap pm(QLatin1String(":/trolltech/formeditor/images/submenu.png")); - p.drawPixmap(subMenuPixmapRect(a).topLeft(), pm); + p.drawPixmap(subMenuPixmapRect(a).topLeft(), m_subMenuPixmap); } } diff --git a/tools/designer/src/lib/shared/qdesigner_menu_p.h b/tools/designer/src/lib/shared/qdesigner_menu_p.h index 9c9a311..ae1e0e7 100644 --- a/tools/designer/src/lib/shared/qdesigner_menu_p.h +++ b/tools/designer/src/lib/shared/qdesigner_menu_p.h @@ -57,6 +57,7 @@ #include <QtGui/QAction> #include <QtGui/QMenu> +#include <QtGui/QPixmap> #include <QtCore/QHash> QT_BEGIN_NAMESPACE @@ -183,6 +184,7 @@ protected: private: bool hideSubMenuOnCursorKey(); bool showSubMenuOnCursorKey(); + const QPixmap m_subMenuPixmap; QPoint m_startPosition; int m_currentIndex; |