appinstaller/AppinstUi/sifuidevicedialogplugin/src/sifuidialogcontentwidget.cpp
changeset 60 245df5276b97
parent 52 92f864ef0288
equal deleted inserted replaced
53:ae54820ef82c 60:245df5276b97
    22 #include <hbpushbutton.h>
    22 #include <hbpushbutton.h>
    23 #include <hbcombobox.h>
    23 #include <hbcombobox.h>
    24 #include <hbprogressbar.h>
    24 #include <hbprogressbar.h>
    25 #include <QPixmap>
    25 #include <QPixmap>
    26 #include <qsysteminfo.h>                    // QSystemStorageInfo
    26 #include <qsysteminfo.h>                    // QSystemStorageInfo
    27 QTM_USE_NAMESPACE
    27 #include <qvaluespacepublisher.h>           // QValueSpacePublisher
       
    28 #include <qvaluespacesubscriber.h>          // QValueSpaceSubscriber
    28 #if defined(Q_OS_SYMBIAN)
    29 #if defined(Q_OS_SYMBIAN)
    29 #include <driveinfo.h>                      // DriveInfo
    30 #include <driveinfo.h>                      // DriveInfo
    30 #include <fbs.h>                            // CFbsBitmap
    31 #include <fbs.h>                            // CFbsBitmap
    31 #endif  // Q_OS_SYMBIAN
    32 #endif  // Q_OS_SYMBIAN
    32 
    33 
       
    34 QTM_USE_NAMESPACE
       
    35 
    33 const char KSifUiDefaultApplicationIcon[] = "qtg_large_application";
    36 const char KSifUiDefaultApplicationIcon[] = "qtg_large_application";
    34 const char KSifUiErrorIcon[] = "qtg_large_warning";
    37 const char KSifUiErrorIcon[] = "qtg_large_warning";
    35 
    38 
    36 const int KSifUiKilo = 1024;
    39 const int KSifUiKilo = 1024;
    37 const int KSifUiMega = 1024*1024;
    40 const int KSifUiMega = 1024*1024;
    38 
    41 
    39 const int KAppNameIndex = 0;
    42 const int KAppNameIndex = 0;
    40 const int KAppSizeIndex = 1;
    43 const int KAppSizeIndex = 1;
    41 
    44 
    42 enum TSifUiDriveName {
    45 enum TSifUiDriveName {
    43     EUnknown,
       
    44     EPhoneMemory,
    46     EPhoneMemory,
    45     EMassStorage,
    47     EMassStorage,
    46     EMemoryCard
    48     EMemoryCard,
       
    49     EOtherDrive
    47 };
    50 };
       
    51 
       
    52 const char KInitialDefaultDrive = 'C';
       
    53 
       
    54 // Path and value name for QValueSpacePublisher/QValueSpaceSubscriber.
       
    55 const QString KSifUiCenRepPath = "/KCRUIDSifUiDefaults";
       
    56 const QString KSifUiCenRepDefaultDrive = "KCRUIDSifUiDefaultDrive";
       
    57 
       
    58 // TODO: replace with proper logging
       
    59 #ifdef _DEBUG
       
    60 #define FLOG1(x)        qDebug() << (x)
       
    61 #define FLOG2(x,y)      qDebug() << (x) << (y)
       
    62 #define FLOG3(x,y,z)    qDebug() << (x) << (y) << (z)
       
    63 #else
       
    64 #define FLOG1(x)
       
    65 #define FLOG2(x,y)
       
    66 #define FLOG3(x,y,z)
       
    67 #endif
    48 
    68 
    49 
    69 
    50 // ======== LOCAL FUNCTIONS ========
    70 // ======== LOCAL FUNCTIONS ========
    51 
    71 
    52 // ----------------------------------------------------------------------------
    72 // ----------------------------------------------------------------------------
    88     err = DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRemovableMassStorage, drive);
   108     err = DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRemovableMassStorage, drive);
    89     if (!err && volume.toAscii() == drive) {
   109     if (!err && volume.toAscii() == drive) {
    90         return EMemoryCard;
   110         return EMemoryCard;
    91     }
   111     }
    92 #endif  // Q_OS_SYMBIAN
   112 #endif  // Q_OS_SYMBIAN
    93     return EUnknown;
   113     return EOtherDrive;
    94 }
   114 }
    95 
   115 
    96 
   116 
    97 // ======== MEMBER FUNCTIONS ========
   117 // ======== MEMBER FUNCTIONS ========
    98 
   118 
   103 SifUiDialogContentWidget::SifUiDialogContentWidget(QGraphicsItem *parent,
   123 SifUiDialogContentWidget::SifUiDialogContentWidget(QGraphicsItem *parent,
   104         Qt::WindowFlags flags) : HbWidget(parent, flags),
   124         Qt::WindowFlags flags) : HbWidget(parent, flags),
   105         mAppIcon(0), mAppName(0), mAppSize(0),
   125         mAppIcon(0), mAppName(0), mAppSize(0),
   106         mMainLayout(0), mAppDetailsLayout(0), mStackedWidget(0),
   126         mMainLayout(0), mAppDetailsLayout(0), mStackedWidget(0),
   107         mMemorySelection(0), mProgressBar(0), mErrorText(0),
   127         mMemorySelection(0), mProgressBar(0), mErrorText(0),
   108         mBitmap(0), mMask(0)
   128         mBitmap(0), mMask(0), mPublisher(0), mSubscriber(0)
   109 {
   129 {
   110 }
   130 }
   111 
   131 
   112 // ----------------------------------------------------------------------------
   132 // ----------------------------------------------------------------------------
   113 // SifUiDialogContentWidget::~SifUiDialogContentWidget()
   133 // SifUiDialogContentWidget::~SifUiDialogContentWidget()
   123 // SifUiDialogContentWidget::constructFromParameters()
   143 // SifUiDialogContentWidget::constructFromParameters()
   124 // ----------------------------------------------------------------------------
   144 // ----------------------------------------------------------------------------
   125 //
   145 //
   126 void SifUiDialogContentWidget::constructFromParameters(const QVariantMap &parameters)
   146 void SifUiDialogContentWidget::constructFromParameters(const QVariantMap &parameters)
   127 {
   147 {
       
   148     FLOG1("SifUiDialogContentWidget::constructFromParameters");
       
   149 
   128     Q_ASSERT(mMainLayout == 0);
   150     Q_ASSERT(mMainLayout == 0);
   129     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
   151     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
   130 
   152 
   131     // Application icon
   153     // Application icon
   132     QGraphicsLinearLayout *iconAndAppLayout = new QGraphicsLinearLayout(Qt::Horizontal);
   154     QGraphicsLinearLayout *iconAndAppLayout = new QGraphicsLinearLayout(Qt::Horizontal);
   156     Q_ASSERT(mStackedWidget == 0);
   178     Q_ASSERT(mStackedWidget == 0);
   157     mStackedWidget = new HbStackedWidget;
   179     mStackedWidget = new HbStackedWidget;
   158 
   180 
   159     Q_ASSERT(mMemorySelection == 0);
   181     Q_ASSERT(mMemorySelection == 0);
   160     mMemorySelection = new HbComboBox;
   182     mMemorySelection = new HbComboBox;
   161     connect(mMemorySelection, SIGNAL(currentIndexChanged(int)),
       
   162             this, SLOT(handleMemorySelectionChange(int)));
       
   163     mStackedWidget->addWidget(mMemorySelection);
   183     mStackedWidget->addWidget(mMemorySelection);
   164 
   184 
   165     Q_ASSERT(mProgressBar == 0);
   185     Q_ASSERT(mProgressBar == 0);
   166     mProgressBar = new HbProgressBar;
   186     mProgressBar = new HbProgressBar;
   167     mProgressBar->setRange(0,0);    // busy indicator by default
   187     mProgressBar->setRange(0,0);    // busy indicator by default
   185 // SifUiDialogContentWidget::updateFromParameters()
   205 // SifUiDialogContentWidget::updateFromParameters()
   186 // ----------------------------------------------------------------------------
   206 // ----------------------------------------------------------------------------
   187 //
   207 //
   188 void SifUiDialogContentWidget::updateFromParameters(const QVariantMap &parameters)
   208 void SifUiDialogContentWidget::updateFromParameters(const QVariantMap &parameters)
   189 {
   209 {
       
   210     FLOG1("SifUiDialogContentWidget::updateFromParameters");
       
   211 
   190     // Application icon
   212     // Application icon
   191     updateAppIcon(parameters);
   213     updateAppIcon(parameters);
   192 
   214 
   193     // Application name and version
   215     // Application name and version
   194     if (parameters.contains(KSifUiApplicationName)) {
   216     if (parameters.contains(KSifUiApplicationName)) {
   230 // SifUiDialogContentWidget::changeType()
   252 // SifUiDialogContentWidget::changeType()
   231 // ----------------------------------------------------------------------------
   253 // ----------------------------------------------------------------------------
   232 //
   254 //
   233 void SifUiDialogContentWidget::changeType(SifUiDeviceDialogType type)
   255 void SifUiDialogContentWidget::changeType(SifUiDeviceDialogType type)
   234 {
   256 {
       
   257     FLOG2("SifUiDialogContentWidget::changeType", type);
       
   258 
   235     switch (type) {
   259     switch (type) {
   236         case SifUiConfirmationQuery:
   260         case SifUiConfirmationQuery:
   237             mStackedWidget->setCurrentWidget(mMemorySelection);
   261             mStackedWidget->setCurrentWidget(mMemorySelection);
   238             break;
   262             break;
   239         case SifUiProgressNote:
   263         case SifUiProgressNote:
   240             mStackedWidget->setCurrentWidget(mProgressBar);
   264             mStackedWidget->setCurrentWidget(mProgressBar);
   241             break;
   265             break;
   242         case SifUiCompleteNote:
   266         case SifUiCompleteNote:
   243             // TODO: remove mStackedWidget?
       
   244             break;
   267             break;
   245         case SifUiErrorNote:
   268         case SifUiErrorNote:
   246             mStackedWidget->setCurrentWidget(mErrorText);
   269             mStackedWidget->setCurrentWidget(mErrorText);
   247             break;
   270             break;
   248         default:
   271         default:
   249             break;
   272             break;
   250     }
   273     }
   251 }
   274 }
   252 
   275 
   253 // ----------------------------------------------------------------------------
   276 // ----------------------------------------------------------------------------
       
   277 // SifUiDialogContentWidget::applicationName()
       
   278 // ----------------------------------------------------------------------------
       
   279 //
       
   280 QString SifUiDialogContentWidget::applicationName() const
       
   281 {
       
   282     if (mAppName) {
       
   283         return mAppName->plainText();
       
   284     }
       
   285     return QString();
       
   286 }
       
   287 
       
   288 // ----------------------------------------------------------------------------
   254 // SifUiDialogContentWidget::handleMemorySelectionChange()
   289 // SifUiDialogContentWidget::handleMemorySelectionChange()
   255 // ----------------------------------------------------------------------------
   290 // ----------------------------------------------------------------------------
   256 //
   291 //
   257 void SifUiDialogContentWidget::handleMemorySelectionChange(int selectedIndex)
   292 void SifUiDialogContentWidget::handleMemorySelectionChange(int selectedIndex)
   258 {
   293 {
       
   294     FLOG2("SifUiDialogContentWidget::handleMemorySelectionChange", selectedIndex);
       
   295 
   259     QChar selectedDrive = mDriveLetterList[selectedIndex][0];
   296     QChar selectedDrive = mDriveLetterList[selectedIndex][0];
   260 
   297     saveSelectedDriveAsDefault( selectedDrive );
   261     // TODO: save selected drive to cenrep
       
   262 
       
   263     emit memorySelectionChanged( selectedDrive );
   298     emit memorySelectionChanged( selectedDrive );
   264 }
   299 }
   265 
   300 
   266 // ----------------------------------------------------------------------------
   301 // ----------------------------------------------------------------------------
   267 // SifUiDialogContentWidget::applicationName()
   302 // SifUiDialogContentWidget::applicationName()
   276             QString versionParam = parameters.value(KSifUiApplicationVersion).toString();
   311             QString versionParam = parameters.value(KSifUiApplicationVersion).toString();
   277             //: Custom layout ID parent. Template for application name and version in SW install
   312             //: Custom layout ID parent. Template for application name and version in SW install
   278             //: confirmation query. %1 is the application name and %2 is the version number.
   313             //: confirmation query. %1 is the application name and %2 is the version number.
   279             //: Version number consist of major, minor, and build numbers.
   314             //: Version number consist of major, minor, and build numbers.
   280             //: For example: "Chess (v 1.01(123))".
   315             //: For example: "Chess (v 1.01(123))".
   281             appName = hbTrId("txt_installer_list_appname_version").arg(nameParam, versionParam);
   316             // TODO: use hbTrId when arg() starts to work with limited length arguments like "%[99]1"
       
   317             //appName = hbTrId("txt_installer_list_appname_version").arg(nameParam, versionParam);
       
   318             appName = QString("%1 (v %2)").arg(nameParam, versionParam);
   282         } else {
   319         } else {
   283             appName = nameParam;
   320             appName = nameParam;
   284         }
   321         }
   285     }
   322     }
   286     return appName;
   323     return appName;
   292 //
   329 //
   293 QString SifUiDialogContentWidget::applicationSize(const QVariantMap &parameters)
   330 QString SifUiDialogContentWidget::applicationSize(const QVariantMap &parameters)
   294 {
   331 {
   295     QString appSize = "";
   332     QString appSize = "";
   296     if (parameters.contains(KSifUiApplicationSize)) {
   333     if (parameters.contains(KSifUiApplicationSize)) {
   297         uint size = parameters.value(KSifUiApplicationSize).toUInt();
   334         bool ok = false;
   298         if (size > 0) {
   335         uint size = parameters.value(KSifUiApplicationSize).toUInt(&ok);
       
   336         if (ok) {
   299             if (size > KSifUiMega) {
   337             if (size > KSifUiMega) {
   300                 //: Application size in SW install confirmation query, %1 is in megabytes
   338                 //: Application size in SW install confirmation query, %1 is in megabytes
   301                 appSize = hbTrId("txt_installer_list_appsize_mb").arg(size/KSifUiMega);
   339                 appSize = hbTrId("txt_installer_list_appsize_mb").arg(size/KSifUiMega);
   302             } else if(size > KSifUiKilo) {
   340             } else if(size > KSifUiKilo) {
   303                 //: Application size in SW install confirmation query, %1 is in kilobytes
   341                 //: Application size in SW install confirmation query, %1 is in kilobytes
   373 //
   411 //
   374 void SifUiDialogContentWidget::updateAppIcon(const QVariantMap &parameters)
   412 void SifUiDialogContentWidget::updateAppIcon(const QVariantMap &parameters)
   375 {
   413 {
   376     Q_ASSERT(mAppIcon != 0);
   414     Q_ASSERT(mAppIcon != 0);
   377 
   415 
       
   416     // TODO: proper icon handling
   378     if (parameters.contains(KSifUiDialogType) &&
   417     if (parameters.contains(KSifUiDialogType) &&
   379         (parameters.value(KSifUiDialogType).toInt() == SifUiErrorNote)) {
   418         (parameters.value(KSifUiDialogType).toInt() == SifUiErrorNote)) {
   380         mAppIcon->setIcon(HbIcon(KSifUiErrorIcon));
   419         mAppIcon->setIcon(HbIcon(KSifUiErrorIcon));
   381     } else if (parameters.contains(KSifUiApplicationIconHandle) &&
   420     } else if (parameters.contains(KSifUiApplicationIconHandle) &&
   382         parameters.contains(KSifUiApplicationIconMaskHandle)) {
   421         parameters.contains(KSifUiApplicationIconMaskHandle)) {
   431 {
   470 {
   432     if (parameters.contains(KSifUiMemorySelection)) {
   471     if (parameters.contains(KSifUiMemorySelection)) {
   433         QString drives = parameters.value(KSifUiMemorySelection).toString();
   472         QString drives = parameters.value(KSifUiMemorySelection).toString();
   434         mDriveLetterList = drives.split(",");
   473         mDriveLetterList = drives.split(",");
   435 
   474 
       
   475         QChar defaultDrive = readDefaultSelectedDrive();
       
   476         int defaultDriveIndex = 0;
       
   477 
   436         QStringList driveList;
   478         QStringList driveList;
   437         QSystemStorageInfo info;
   479         QSystemStorageInfo info;
   438         QStringList volumeList = info.logicalDrives();
   480         QStringList volumeList = info.logicalDrives();
   439         foreach (QString volume, volumeList) {
   481         foreach (QString volume, volumeList) {
   440             if (mDriveLetterList.contains(volume)) {
   482             if (mDriveLetterList.contains(volume)) {
   441                 qlonglong size = info.availableDiskSpace(volume);
   483                 qlonglong size = info.availableDiskSpace(volume);
   442                 switch (driveName(volume[0])) {
   484 
       
   485                 QChar driveLetter(volume[0]);
       
   486                 switch (driveName(driveLetter)) {
   443                 case EPhoneMemory:
   487                 case EPhoneMemory:
   444                     if (size > KSifUiMega) {
   488                     if (size > KSifUiMega) {
   445                         //: Drive name for internal phone memory with megabytes of free space.
   489                         //: Drive name for internal phone memory with megabytes of free space.
   446                         //: %1 is replaced with drive letter (usually 'C')
   490                         //: %1 is replaced with drive letter (usually 'C')
   447                         //: %2 is replaced with available free space (in megabytes, MB)
   491                         //: %2 is replaced with available free space (in megabytes, MB)
   448                         //TODO: enable when available
   492                         //TODO: enable when available
   449                         //driveList.append(hbTrId("txt_installer_device_memory_mb")
   493                         //driveList.append(hbTrId("txt_installer_device_memory_mb")
   450                         //    .arg(volume).arg(size/KSifUiMega));
   494                         //    .arg(volume).arg(size/KSifUiMega));
   451                         driveList.append(tr("%1: Device (%L2 MB free)"
   495                         driveList.append(tr("%1: Phone mem. (%L2 MB)"
   452                             ).arg(volume).arg(size/KSifUiMega));
   496                             ).arg(volume).arg(size/KSifUiMega));
   453                     } else {
   497                     } else {
   454                         //: Drive name for internal phone memory with kilobytes of free space.
   498                         //: Drive name for internal phone memory with kilobytes of free space.
   455                         //: %1 is replaced with drive letter (usually 'C')
   499                         //: %1 is replaced with drive letter (usually 'C')
   456                         //: %2 is replaced with available free space (in kilobytes, kB)
   500                         //: %2 is replaced with available free space (in kilobytes, kB)
   457                         //TODO: enable when available
   501                         //TODO: enable when available
   458                         //driveList.append(hbTrId("txt_installer_device_memory_kb")
   502                         //driveList.append(hbTrId("txt_installer_device_memory_kb")
   459                         //    .arg(volume).arg(size/KSifUiKilo));
   503                         //    .arg(volume).arg(size/KSifUiKilo));
   460                         driveList.append(tr("%1: Device (%L2 kB free)"
   504                         driveList.append(tr("%1: Phone mem. (%L2 kB)"
   461                             ).arg(volume).arg(size/KSifUiKilo));
   505                             ).arg(volume).arg(size/KSifUiKilo));
   462                     }
   506                     }
   463                     break;
   507                     break;
       
   508 
   464                 case EMassStorage:
   509                 case EMassStorage:
   465                     if (size > KSifUiMega) {
   510                     if (size > KSifUiMega) {
   466                         //: Drive name for mass storage with megabytes of free space.
   511                         //: Drive name for mass storage with megabytes of free space.
   467                         //: %1 is replaced with drive letter (usually 'E')
   512                         //: %1 is replaced with drive letter (usually 'E')
   468                         //: %2 is replaced with available free space (in megabytes, MB)
   513                         //: %2 is replaced with available free space (in megabytes, MB)
   469                         // TODO: enable when available
   514                         // TODO: enable when available
   470                         //driveList.append(hbTrId("txt_installer_mass_storage_mb")
   515                         //driveList.append(hbTrId("txt_installer_mass_storage_mb")
   471                         //    .arg(volume).arg(size/KSifUiMega));
   516                         //    .arg(volume).arg(size/KSifUiMega));
   472                         driveList.append(tr("%1: Mass.mem (%L2 MB free)"
   517                         driveList.append(tr("%1: Mass.mem (%L2 MB)"
   473                             ).arg(volume).arg(size/KSifUiMega));
   518                             ).arg(volume).arg(size/KSifUiMega));
   474                     } else {
   519                     } else {
   475                         //: Drive name for mass storage with kilobytes of free space.
   520                         //: Drive name for mass storage with kilobytes of free space.
   476                         //: %1 is replaced with drive letter (usually 'E')
   521                         //: %1 is replaced with drive letter (usually 'E')
   477                         //: %2 is replaced with available free space (in kilobytes, kB)
   522                         //: %2 is replaced with available free space (in kilobytes, kB)
   478                         // TODO: enable when available
   523                         // TODO: enable when available
   479                         //driveList.append(hbTrId("txt_installer_mass_storage_kb")
   524                         //driveList.append(hbTrId("txt_installer_mass_storage_kb")
   480                         //    .arg(volume).arg(size/KSifUiKilo));
   525                         //    .arg(volume).arg(size/KSifUiKilo));
   481                         driveList.append(tr("%1: Mass.mem (%L2 kB free)"
   526                         driveList.append(tr("%1: Mass.mem (%L2 kB)"
   482                             ).arg(volume).arg(size/KSifUiKilo));
   527                             ).arg(volume).arg(size/KSifUiKilo));
   483                     }
   528                     }
   484                     break;
   529                     break;
       
   530 
   485                 case EMemoryCard:
   531                 case EMemoryCard:
   486                     if (size > KSifUiMega) {
   532                     if (size > KSifUiMega) {
   487                         //: Drive name for memory card with megabytes of free space.
   533                         //: Drive name for memory card with megabytes of free space.
   488                         //: %1 is replaced with drive letter (usually 'F')
   534                         //: %1 is replaced with drive letter (usually 'F')
   489                         //: %2 is replaced with available free space (in megabytes, MB)
   535                         //: %2 is replaced with available free space (in megabytes, MB)
   490                         // TODO: enable when available
   536                         // TODO: enable when available
   491                         //driveList.append(hbTrId("txt_installer_memory_card_mb")
   537                         //driveList.append(hbTrId("txt_installer_memory_card_mb")
   492                         //    .arg(volume).arg(size/KSifUiMega));
   538                         //    .arg(volume).arg(size/KSifUiMega));
   493                         driveList.append(tr("%1: Mem.card (%L2 MB free)"
   539                         driveList.append(tr("%1: Mem.card (%L2 MB)"
   494                             ).arg(volume).arg(size/KSifUiMega));
   540                             ).arg(volume).arg(size/KSifUiMega));
   495                     } else {
   541                     } else {
   496                         //: Drive name for memory card with kilobytes of free space.
   542                         //: Drive name for memory card with kilobytes of free space.
   497                         //: %1 is replaced with drive letter (usually 'F')
   543                         //: %1 is replaced with drive letter (usually 'F')
   498                         //: %2 is replaced with available free space (in kilobytes, kB)
   544                         //: %2 is replaced with available free space (in kilobytes, kB)
   499                         // TODO: enable when available
   545                         // TODO: enable when available
   500                         //driveList.append(hbTrId("txt_installer_memory_card_kb")
   546                         //driveList.append(hbTrId("txt_installer_memory_card_kb")
   501                         //    .arg(volume).arg(size/KSifUiKilo));
   547                         //    .arg(volume).arg(size/KSifUiKilo));
   502                         driveList.append(tr("%1: Mem.card (%L2 kB free)"
   548                         driveList.append(tr("%1: Mem.card (%L2 kB)"
   503                             ).arg(volume).arg(size/KSifUiKilo));
   549                             ).arg(volume).arg(size/KSifUiKilo));
   504                     }
   550                     }
   505                     break;
   551                     break;
       
   552 
       
   553                 case EOtherDrive:
   506                 default:
   554                 default:
       
   555                     if (size > KSifUiMega) {
       
   556                         //: Generic drive name for other removable drives, like
       
   557                         //: USB memories attached via USB OTG adapter.
       
   558                         // TODO: proper localisation needed
       
   559                         driveList.append(tr("%1: Drive (%L2 MB)"
       
   560                             ).arg(volume).arg(size/KSifUiMega));
       
   561                     } else {
       
   562                         //: Generic drive name for other removable drives, like
       
   563                         //: USB memories attached via USB OTG adapter.
       
   564                         // TODO: proper localisation needed
       
   565                         driveList.append(tr("%1: Drive (%L2 kB)"
       
   566                             ).arg(volume).arg(size/KSifUiKilo));
       
   567                     }
   507                     break;
   568                     break;
   508                 }
   569                 }
       
   570 
       
   571                 if (driveLetter == defaultDrive) {
       
   572                     defaultDriveIndex = driveList.count() - 1;
       
   573                 }
   509             }
   574             }
   510         }
   575         }
   511 
   576 
       
   577         disconnect(mMemorySelection, SIGNAL(currentIndexChanged(int)),
       
   578             this, SLOT(handleMemorySelectionChange(int)));
   512         mMemorySelection->setItems(driveList);
   579         mMemorySelection->setItems(driveList);
       
   580         if (defaultDriveIndex) {
       
   581             FLOG2("SifUiDialogContentWidget::updateMemorySelection, setCurrentIndex",
       
   582                 defaultDriveIndex);
       
   583             mMemorySelection->setCurrentIndex(defaultDriveIndex);
       
   584         }
       
   585         connect(mMemorySelection, SIGNAL(currentIndexChanged(int)),
       
   586             this, SLOT(handleMemorySelectionChange(int)));
   513         mStackedWidget->setCurrentWidget(mMemorySelection);
   587         mStackedWidget->setCurrentWidget(mMemorySelection);
   514 
       
   515         // TODO: set selected item, read the default from cenrep
       
   516 
   588 
   517         return true;
   589         return true;
   518     }
   590     }
   519     return false;
   591     return false;
   520 }
   592 }
   530         mProgressBar->setMaximum(parameters.value(KSifUiProgressNoteFinalValue).toInt());
   602         mProgressBar->setMaximum(parameters.value(KSifUiProgressNoteFinalValue).toInt());
   531         progressBarChanged = true;
   603         progressBarChanged = true;
   532     }
   604     }
   533     if (parameters.contains(KSifUiProgressNoteValue)) {
   605     if (parameters.contains(KSifUiProgressNoteValue)) {
   534         int newValue = mProgressBar->progressValue();
   606         int newValue = mProgressBar->progressValue();
   535         newValue += parameters.value(KSifUiProgressNoteValue).toInt();
   607         bool ok = false;
   536         mProgressBar->setProgressValue(newValue);
   608         newValue += parameters.value(KSifUiProgressNoteValue).toInt(&ok);
   537         progressBarChanged = true;
   609         if (ok) {
       
   610             mProgressBar->setProgressValue(newValue);
       
   611             progressBarChanged = true;
       
   612         }
   538     }
   613     }
   539     if (progressBarChanged) {
   614     if (progressBarChanged) {
   540         mStackedWidget->setCurrentWidget(mProgressBar);
   615         mStackedWidget->setCurrentWidget(mProgressBar);
   541     }
   616     }
   542     return progressBarChanged;
   617     return progressBarChanged;
   546 // SifUiDialogContentWidget::updateErrorText()
   621 // SifUiDialogContentWidget::updateErrorText()
   547 // ----------------------------------------------------------------------------
   622 // ----------------------------------------------------------------------------
   548 //
   623 //
   549 bool SifUiDialogContentWidget::updateErrorText(const QVariantMap &parameters)
   624 bool SifUiDialogContentWidget::updateErrorText(const QVariantMap &parameters)
   550 {
   625 {
   551     if (parameters.contains(KSifUiErrorCode)) {
   626     // TODO: move default error messages (category based) here
   552         // TODO: proper error texts
   627     if (parameters.contains(KSifUiErrorMessage)) {
   553         bool ok = false;
   628         QString errorText = parameters.value(KSifUiErrorMessage).toString();
   554         int errorCode = parameters.value(KSifUiErrorCode).toInt(&ok);
       
   555         QString errorText;
       
   556         if (ok) {
       
   557             errorText = tr("Error %1").arg(errorCode);
       
   558         } else {
       
   559             errorText = tr("No error code.");
       
   560         }
       
   561         mErrorText->setPlainText(errorText);
   629         mErrorText->setPlainText(errorText);
   562         mStackedWidget->setCurrentWidget(mErrorText);
   630         mStackedWidget->setCurrentWidget(mErrorText);
   563         return true;
   631         return true;
   564     }
   632     }
   565     return false;
   633     return false;
   566 }
   634 }
   567 
   635 
   568 
   636 // ----------------------------------------------------------------------------
   569 
   637 // SifUiDialogContentWidget::saveSelectedDriveAsDefault()
       
   638 // ----------------------------------------------------------------------------
       
   639 //
       
   640 void SifUiDialogContentWidget::saveSelectedDriveAsDefault(const QChar& drive)
       
   641 {
       
   642     if (drive != readDefaultSelectedDrive()) {
       
   643         if (!mPublisher) {
       
   644             mPublisher = new QValueSpacePublisher(KSifUiCenRepPath, this);
       
   645         }
       
   646         FLOG2("SifUiDialogContentWidget::saveSelectedDriveAsDefault", drive);
       
   647         // QValueSpacePublisher supports integer and byte array types in Symbian
       
   648         int asciiValue = drive.toAscii();
       
   649         mPublisher->setValue(KSifUiCenRepDefaultDrive, asciiValue);
       
   650         mPublisher->sync();
       
   651     }
       
   652 }
       
   653 
       
   654 // ----------------------------------------------------------------------------
       
   655 // SifUiDialogContentWidget::readDefaultSelectedDrive()
       
   656 // ----------------------------------------------------------------------------
       
   657 //
       
   658 QChar SifUiDialogContentWidget::readDefaultSelectedDrive()
       
   659 {
       
   660     QChar selectedDrive = KInitialDefaultDrive;
       
   661 
       
   662     if (!mSubscriber) {
       
   663         mSubscriber = new QValueSpaceSubscriber(KSifUiCenRepPath, this);
       
   664     }
       
   665     QVariant variant = mSubscriber->value(KSifUiCenRepDefaultDrive);
       
   666     if (variant.isValid() && !variant.isNull()) {
       
   667         bool ok = false;
       
   668         int asciiValue = variant.toInt(&ok);
       
   669         if (ok) {
       
   670             selectedDrive = QChar(asciiValue);
       
   671         }
       
   672     }
       
   673 
       
   674     FLOG2("SifUiDialogContentWidget::readDefaultSelectedDrive", selectedDrive);
       
   675     return selectedDrive;
       
   676 }
       
   677