iaupdate/IAD/bgcindicatorplugin/src/bgcindicator.cpp
changeset 72 a0dc14075813
parent 53 ae54820ef82c
child 77 d1838696558c
equal deleted inserted replaced
67:3a625661d1ce 72:a0dc14075813
    18 #include <w32std.h>
    18 #include <w32std.h>
    19 #include <apgtask.h>
    19 #include <apgtask.h>
    20 #include <apacmdln.h>
    20 #include <apacmdln.h>
    21 #include <xqservicerequest.h>
    21 #include <xqservicerequest.h>
    22 
    22 
    23 #include <hb/hbcore/hbtranslator.h>
       
    24 
       
    25 #include <hbicon.h>
    23 #include <hbicon.h>
    26 
    24 
    27 #include "bgcindicator.h" 
    25 #include "bgcindicator.h" 
       
    26 
       
    27 const char KTranslatorFileName[] = "swupdate";
       
    28 const char KIconName[] = "qtg_large_swupdate";
    28 
    29 
    29 //----------------------------------------------------------------------
    30 //----------------------------------------------------------------------
    30 
    31 
    31 
    32 
    32 // ----------------------------------------------------------------------------
    33 // ----------------------------------------------------------------------------
    35 // ----------------------------------------------------------------------------
    36 // ----------------------------------------------------------------------------
    36 BgcIndicator::BgcIndicator(const QString &indicatorType) :
    37 BgcIndicator::BgcIndicator(const QString &indicatorType) :
    37 HbIndicatorInterface(indicatorType,
    38 HbIndicatorInterface(indicatorType,
    38         HbIndicatorInterface::NotificationCategory,
    39         HbIndicatorInterface::NotificationCategory,
    39         InteractionActivated), 
    40         InteractionActivated), 
    40         mNrOfUpdates(0)
    41         mNrOfUpdates(0),
    41     {
    42         mTranslator(0)
       
    43     {
       
    44   
       
    45     HbTranslator* mTranslator = new HbTranslator(KTranslatorFileName);
       
    46     
    42     }
    47     }
    43 
    48 
    44 // ----------------------------------------------------------------------------
    49 // ----------------------------------------------------------------------------
    45 // BgcIndicator::~BgcIndicator
    50 // BgcIndicator::~BgcIndicator
    46 // @see bgcindicator.h
    51 // @see bgcindicator.h
    47 // ----------------------------------------------------------------------------
    52 // ----------------------------------------------------------------------------
    48 BgcIndicator::~BgcIndicator()
    53 BgcIndicator::~BgcIndicator()
    49     {
    54     {
       
    55     if (mTranslator) 
       
    56         {
       
    57         delete mTranslator;
       
    58         mTranslator = 0;
       
    59         }
    50     }
    60     }
    51 
    61 
    52 // ----------------------------------------------------------------------------
    62 // ----------------------------------------------------------------------------
    53 // BgcIndicator::handleInteraction
    63 // BgcIndicator::handleInteraction
    54 // @see bgcindicator.h
    64 // @see bgcindicator.h
    75 // BgcIndicator::indicatorData
    85 // BgcIndicator::indicatorData
    76 // @see bgcindicator.h
    86 // @see bgcindicator.h
    77 // ----------------------------------------------------------------------------
    87 // ----------------------------------------------------------------------------
    78 QVariant BgcIndicator::indicatorData(int role) const
    88 QVariant BgcIndicator::indicatorData(int role) const
    79 {
    89 {
    80     // use iaupdate's translate file
       
    81     // loc: HbTranslator trans("z:\\resource\\iaupdate\\","Text_Map_Swupdate_");
       
    82         
    90         
    83 switch(role)
    91     switch(role)
    84     {
    92     {
    85     case PrimaryTextRole: 
    93     case PrimaryTextRole: 
    86         {
    94         {
    87         QString text("");
    95         QString text("");
    88         if ( mNrOfUpdates == 0 )
    96         if ( mNrOfUpdates == 0 )
    89             {
    97             {
    90             // First time case
    98             // First time case
    91             // loc: text.append(hbTrId("txt_software_dblist_update_checking"));
    99             text.append(hbTrId("txt_software_dblist_update_checking"));
    92             text.append(QString("Update checking"));
       
    93             }
   100             }
    94         else if ( mNrOfUpdates == 1 )
   101         else if ( mNrOfUpdates == 1 )
    95             {
   102             {
    96             // one update available
   103             // one update available
    97             // loc: text.append(hbTrId("txt_software_dblist_update_available"));
   104             text.append(hbTrId("txt_software_dblist_update_available"));
    98             text.append(QString("Update available"));
       
    99             }
   105             }
   100         else
   106         else
   101             {
   107             {
   102             // several updates available
   108             // several updates available
   103             // loc: text.append(hbTrId("txt_software_dblist_updates_available"));
   109             text.append(hbTrId("txt_software_dblist_updates_available"));
   104             text.append(QString("Updates available"));
       
   105             }
   110             }
   106         return text;        
   111         return text;        
   107         }
   112         }
   108     case SecondaryTextRole:
   113     case SecondaryTextRole:
   109         {
   114         {
   110         QString text("");
   115         QString text("");
   111         if ( mNrOfUpdates == 0 )
   116         if ( mNrOfUpdates == 0 )
   112             {
   117             {
   113             // First time case
   118             // First time case
   114             // loc: QString text(hbTrId("txt_software_dblist_val_not_activated"));
   119             text.append(hbTrId("txt_software_dblist_val_not_activated"));
   115             text.append(QString("Not activated"));
   120             }
   116             }
   121         else 
   117         else if ( mNrOfUpdates == 1 )
   122             {
   118             {
   123             // update(s) available
   119             // one update available
   124             text.append(hbTrId("txt_software_dblist_val_ln_update", mNrOfUpdates));
   120             // loc: QString text(hbTrId("txt_software_dblist_1_val_ln_update"));
   125             }
   121             text.append(QString("%Ln updates").arg(mNrOfUpdates));
   126 
   122             }
       
   123         else
       
   124             {
       
   125             // several updates available
       
   126             // loc: QString text(hbTrId("txt_software_dblist_1_val_ln_update"));
       
   127             text.append(QString("%%Ln updates").arg(mNrOfUpdates));
       
   128             }
       
   129         return text; 
   127         return text; 
   130         }
   128         }
   131     case DecorationNameRole:
   129     case DecorationNameRole:
   132     case MonoDecorationNameRole:
   130     case MonoDecorationNameRole:
   133         {
   131         {
   134         QString iconName("");
   132         return QString(KIconName);
   135         return iconName;
       
   136         }
   133         }
   137     default: 
   134     default: 
   138         return QVariant();      
   135         return QVariant();      
   139     }
   136     }
   140 }
   137 }