emailuis/nmailuiengine/src/nmicons.cpp
changeset 18 578830873419
child 20 ecc8def7944a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emailuis/nmailuiengine/src/nmicons.cpp	Fri Apr 16 14:51:52 2010 +0300
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "nmuiengineheaders.h"
+
+static HbIcon *icons[NmIcons::NmLastItem];
+
+/*!
+    \struct IconRes
+    \brief Icon resource structure
+*/
+struct IconRes {
+    NmIcons::Icon id;
+    QString resName;
+};
+
+/*!
+    Icon array
+*/
+static IconRes icon_res[] = {
+    {NmIcons::NmIconDefaultMailbox, "qtg_large_email"},
+    {NmIcons::NmIconPlusSign, "qtg_small_expand"},
+    {NmIcons::NmIconMinusSign, "qtg_small_collapse"},
+    {NmIcons::NmIconAttachment, "qtg_small_attachment"},
+    {NmIcons::NmIconPriorityHigh, "qtg_small_priority_high"},
+    {NmIcons::NmIconPriorityLow, "qtg_small_priority_low"},
+    {NmIcons::NmIconAttach, "qtg_mono_attach"},
+    {NmIcons::NmIconSend, "qtg_mono_send"},
+    {NmIcons::NmIconContacts, "qtg_mono_contacts"},
+    {NmIcons::NmIconNewEmail, "qtg_mono_create_email"},
+    {NmIcons::NmIconDelete, "qtg_mono_delete"},
+    {NmIcons::NmIconForward, "qtg_mono_forward"},
+    {NmIcons::NmIconReply, "qtg_mono_reply"},
+    {NmIcons::NmIconReplyAll, "qtg_mono_reply_all"},
+    {NmIcons::NmIconSynching, "qtg_small_attachment"},
+    {NmIcons::NmIconOnline, "qtg_small_priority_low"},
+    {NmIcons::NmIconDisconnected, "qtg_small_priority_high"},
+    {NmIcons::NmIconOffline, "qtg_small_fail"},
+    {NmIcons::NmLastItem, ""} // Last item definion.
+};
+
+/*!
+    \class NmIcons
+    \brief handles icons loading and destruction
+*/
+
+
+/*!
+    Get icon function. Use this function with enumeration value to get
+    corresponding icon. Icon is created if it does not exist previously.
+*/
+HbIcon &NmIcons::getIcon(NmIcons::Icon icon)
+{
+    if (!icons[icon]) {
+        for (int i(0); icon_res[i].id != NmIcons::NmLastItem; i++) {
+            if (icon_res[i].id == icon) {
+                // Branding icon check here. If branded icon is not found
+                // default icon is to be loaded.
+                icons[icon] = new HbIcon(icon_res[i].resName);
+                break;
+            }
+        }
+    }
+    if (!icons[icon]) {
+        NMLOG(QString("nmailuiengine: Cannot open icon file: ###").arg(__FILE__));
+    }
+    return *icons[icon];
+}
+
+/*!
+    Icon array reset functionality. Called when application exists.
+*/
+void NmIcons::freeIcons()
+{
+    NMLOG("nmailuiengine: Enter freeIcons");
+    for (int i(0); icon_res[i].id != NmIcons::NmLastItem; i++) {
+        if (icons[i]) {
+            delete icons[i];
+            icons[i] = NULL;
+        }
+    }
+}
+