示例#1
0
// dispatcher code for entering one of the available states
void PlanExecutor::enterAvailableState() {
	if(mState == NOT_AVAILABLE) {
		mState = WAITING_FOR_FIRST_BACKUP; //initial child state of "Available" state
		emit stateChanged();
	}

	bool lShouldBeTakenNow = false;
	bool lShouldBeTakenLater = false;
	int lTimeUntilNextWakeup;
	QString lUserQuestion;
	QDateTime lNow = QDateTime::currentDateTime().toUTC();

	switch(mPlan->mScheduleType) {
	case BackupPlan::MANUAL:
		break;
	case BackupPlan::INTERVAL: {
		QDateTime lNextTime = mPlan->nextScheduledTime();
		if(!lNextTime.isValid() || lNextTime < lNow) {
			lShouldBeTakenNow = true;
			if(!mPlan->mLastCompleteBackup.isValid())
				lUserQuestion = xi18nc("@info", "Do you want to save a first backup now?");
			else {
				QString t = KFormat().formatSpelloutDuration(mPlan->mLastCompleteBackup.secsTo(lNow) * 1000);
				lUserQuestion = xi18nc("@info", "It has been %1 since last backup was saved.\n"
				                                "Save a new backup now?", t);
			}
		} else {
			lShouldBeTakenLater = true;
			lTimeUntilNextWakeup = lNow.secsTo(lNextTime)*1000;
		}
		break;
	}
	case BackupPlan::USAGE:
		if(!mPlan->mLastCompleteBackup.isValid()) {
			lShouldBeTakenNow = true;
			lUserQuestion = xi18nc("@info", "Do you want to save a first backup now?");
		} else if(mPlan->mAccumulatedUsageTime > (quint32)mPlan->mUsageLimit * 3600) {
			lShouldBeTakenNow = true;
			QString t = KFormat().formatSpelloutDuration(mPlan->mAccumulatedUsageTime * 1000);
			lUserQuestion = xi18nc("@info", "You have been active for %1 since last backup was saved.\n"
			                                "Save a new backup now?", t);
		}
		break;
	}

	if(lShouldBeTakenNow) {
		// Only ask the first time after destination has become available.
		// Always ask if power saving is active.
		if( (mPlan->mAskBeforeTakingBackup && mState == WAITING_FOR_FIRST_BACKUP) ||
		    powerSaveActive()) {
			askUser(lUserQuestion);
		} else {
			startBackupSaveJob();
		}
	} else if(lShouldBeTakenLater){
		// schedule a wakeup for asking again when the time is right.
		mSchedulingTimer->start(lTimeUntilNextWakeup);
	}
}
示例#2
0
文件: StatusWidget.cpp 项目: KDE/muon
void StatusWidget::updateStatus()
{
    if (m_backend->xapianIndexNeedsUpdate())
        m_backend->updateXapianIndex();

    int upgradeable = m_backend->packageCount(QApt::Package::Upgradeable);
    bool showChanges = m_backend->areChangesMarked();

    QString availableText = i18ncp("@info:status", "1 package available, ", "%1 packages available, ", m_backend->packageCount());
    QString installText = i18nc("@info:status", "%1 installed, ", m_backend->installedCount());
    QString upgradeableText;

    if (upgradeable > 0 && showChanges) {
        upgradeableText = i18nc("@info:status", "%1 upgradeable,", upgradeable);
    } else {
        upgradeableText = i18nc("@info:status", "%1 upgradeable", upgradeable);
        m_countsLabel->setText(availableText % installText % upgradeableText);
    }

    if (showChanges) {
        int toInstallOrUpgrade = m_backend->toInstallCount();
        int toRemove = m_backend->toRemoveCount();

        QString toInstallOrUpgradeText;
        QString toRemoveText;

        if (toInstallOrUpgrade > 0) {
            toInstallOrUpgradeText = i18nc("@info:status Part of the status label", " %1 to install/upgrade", toInstallOrUpgrade);
        }

        if (toRemove > 0 && toInstallOrUpgrade > 0) {
            toRemoveText = i18nc("@info:status Label for the number of packages pending removal when packages are also pending upgrade",
                                 ", %1 to remove", toRemove);
        } else if (toRemove > 0) {
            toRemoveText = i18nc("@info:status Label for the number of packages pending removal when there are only removals",
                                 " %1 to remove", toRemove);
        }

        m_countsLabel->setText(availableText % installText % upgradeableText %
                               toInstallOrUpgradeText % toRemoveText);

        qint64 installSize = m_backend->installSize();
        if (installSize < 0) {
            installSize = -installSize;
            m_downloadLabel->setText(i18nc("@label showing download and install size", "%1 to download, %2 of space to be freed",
                                           KFormat().formatByteSize(m_backend->downloadSize()),
                                           KFormat().formatByteSize(installSize)));
        } else {
            m_downloadLabel->setText(i18nc("@label showing download and install size", "%1 to download, %2 of space to be used",
                                           KFormat().formatByteSize(m_backend->downloadSize()),
                                           KFormat().formatByteSize(installSize)));
        }

        m_downloadLabel->show();
    } else {
        m_downloadLabel->hide();
    }
}
示例#3
0
void TopLevel::answerReceived( int id, const QList<QByteArray> &answerList )
{
  // we have received an answer from the daemon.
  QByteArray answer;
  if(!answerList.isEmpty()) answer = answerList[0];
  QString s;
  static QString unit;
  static qlonglong mFree = 0;
  static qlonglong mUsedApplication = 0;
  static qlonglong mUsedTotal = 0;
  static qlonglong sUsed = 0;
  static qlonglong sFree = 0;

  switch ( id ) {
    case 1:
      s = i18n( "CPU: %1%\xc2\x9c%1%", (int) (100 - answer.toFloat()) );
      sbCpuStat->setText( s );
      break;

    case 2:
      mFree = answer.toLongLong();
      break;

    case 3:
      mUsedTotal = answer.toLongLong();
      break;

    case 4:
      mUsedApplication = answer.toLongLong();
      //Use a multi-length string
      s = i18nc( "Arguments are formatted byte sizes (used/total)", "Memory: %1 / %2" "\xc2\x9c" "Mem: %1 / %2" "\xc2\x9c" "Mem: %1" "\xc2\x9c" "%1",
                 KFormat().formatByteSize( mUsedApplication*1024),
                 KFormat().formatByteSize( (mFree+mUsedTotal)*1024 ) );
      sbMemTotal->setText( s );
      break;

    case 5:
      sFree = answer.toLongLong();
      break;

    case 6:
      sUsed = answer.toLongLong();
      setSwapInfo( sUsed, sFree, unit );
      break;

    case 7: {
      KSGRD::SensorIntegerInfo info( answer );
      unit = KSGRD::SensorMgr->translateUnit( info.unit() );
      break;
    }
  }
}
示例#4
0
void TopLevel::setSwapInfo( qlonglong used, qlonglong free, const QString & )
{
  QString msg;
  if ( used == 0 && free == 0 ) // no swap available
    msg = i18n( " No swap space available " );
  else {
    msg = i18nc( "Arguments are formatted byte sizes (used/total)", "Swap: %1 / %2" "\xc2\x9c" "Swap: %1" "\xc2\x9c" "%1" ,
                 KFormat().formatByteSize( used*1024 ),
                 KFormat().formatByteSize( (free+used)*1024) );
  }

  sbSwapTotal->setText( msg );
}
QStringList
buildUnknownDisklabelTexts( Device* dev )
{
    QStringList texts = { QObject::tr( "Unpartitioned space or unknown partition table" ),
                          KFormat().formatByteSize( dev->totalSectors() * dev->logicalSectorSize() ) };
    return texts;
}
示例#6
0
QVariant UpdateModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid()) {
        return QVariant();
    }

    UpdateItem *item = itemFromIndex(index);

    switch (role) {
    case Qt::DisplayRole:
        return item->name();
    case Qt::DecorationRole:
        return item->icon();
    case Qt::CheckStateRole:
        return item->checked();
    case VersionRole:
        return item->version();
    case SizeRole:
        return KFormat().formatByteSize(item->size());
    case ResourceRole:
        return QVariant::fromValue<QObject*>(item->resource());
    case ResourceProgressRole:
        return item->progress();
    case ChangelogRole:
        return item->changelog();
    case SectionRole:
        return item->section();
    default:
        break;
    }

    return QVariant();
}
示例#7
0
QVariant
DeviceModel::data( const QModelIndex& index, int role ) const
{
    int row = index.row();
    if ( row < 0 || row >= m_devices.count() )
        return QVariant();

    Device* device = m_devices.at( row );

    switch ( role )
    {
    case Qt::DisplayRole:
    case Qt::ToolTipRole:
        if ( device->name().isEmpty() )
            return device->deviceNode();
        else
            return tr( "%1 - %2 (%3)" )
                   .arg( device->name() )
                   .arg( KFormat().formatByteSize( device->capacity() ) )
                   .arg( device->deviceNode() );
    case Qt::DecorationRole:
        return CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionDisk,
                                              CalamaresUtils::Original,
                                              QSize( CalamaresUtils::defaultIconSize().width() * 3,
                                                     CalamaresUtils::defaultIconSize().height() * 3 ) );
    default:
        return QVariant();
    }
}
QVariant
PartitionModel::data( const QModelIndex& index, int role ) const
{
    int row = index.row();
    if ( row < 0 || row >= m_partitionList.count() )
    {
        return QVariant();
    }

    Partition* partition = m_partitionList.at( row );

    switch ( role )
    {
    case Qt::DisplayRole:
    {
        int col = index.column();
        if ( col == NameColumn )
        {
            // FIXME: Turn model into a tree model, will make implementing the
            // preview easier
            QString prefix = partition->roles().has( PartitionRole::Logical )
                             ? QStringLiteral( "    " ) : QStringLiteral();
            if ( PMUtils::isPartitionFreeSpace( partition ) )
            {
                return prefix + tr( "Free Space" );
            }
            else
            {
                return prefix + ( partition->partitionPath().isEmpty()
                                  ? tr( "New partition" )
                                  : partition->partitionPath() );
            }
        }
        if ( col == FileSystemColumn )
        {
            return partition->fileSystem().name();
        }
        if ( col == MountPointColumn )
        {
            PartitionInfo* info = m_infoProvider->infoForPartition( partition );
            return info ? info->mountPoint : QString();
        }
        if ( col == SizeColumn )
        {
            qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
            return KFormat().formatByteSize( size );
        }
        cDebug() << "Unknown column" << col;
        return QVariant();
    }
    default:
        return QVariant();
    }
}
QVariant
PartitionModel::data( const QModelIndex& index, int role ) const
{
    Partition* partition = partitionForIndex( index );
    if ( !partition )
        return QVariant();

    switch ( role )
    {
    case Qt::DisplayRole:
    {
        int col = index.column();
        if ( col == NameColumn )
        {
            if ( PMUtils::isPartitionFreeSpace( partition ) )
                return tr( "Free Space" );
            else
            {
                return PMUtils::isPartitionNew( partition )
                       ? tr( "New partition" )
                       : partition->partitionPath();
            }
        }
        if ( col == FileSystemColumn )
            return partition->fileSystem().name();
        if ( col == MountPointColumn )
            return PartitionInfo::mountPoint( partition );
        if ( col == SizeColumn )
        {
            qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
            return KFormat().formatByteSize( size );
        }
        cDebug() << "Unknown column" << col;
        return QVariant();
    }
    case Qt::DecorationRole:
        if ( index.column() == NameColumn )
            return ColorUtils::colorForPartition( partition );
        else
            return QVariant();
    case SizeRole:
        return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
    case IsFreeSpaceRole:
        return PMUtils::isPartitionFreeSpace( partition );
    default:
        return QVariant();
    }
}
示例#10
0
void CollectionQuotaWidget::setQuotaInfo(qint64 current, qint64 maxValue)
{
    mProgressBar->setMaximum(maxValue);
    mProgressBar->setValue(current);
    mUsage->setText(i18n("%1 of %2 used", KFormat().formatByteSize(qMax(0LL, current)), KFormat().formatByteSize(qMax(0LL, maxValue))));
}
示例#11
0
QVariant
PartitionModel::data( const QModelIndex& index, int role ) const
{
    Partition* partition = partitionForIndex( index );
    if ( !partition )
        return QVariant();

    switch ( role )
    {
    case Qt::DisplayRole:
    {
        int col = index.column();
        if ( col == NameColumn )
        {
            if ( KPMHelpers::isPartitionFreeSpace( partition ) )
                return tr( "Free Space" );
            else
            {
                return KPMHelpers::isPartitionNew( partition )
                       ? tr( "New partition" )
                       : partition->partitionPath();
            }
        }
        if ( col == FileSystemColumn )
            return KPMHelpers::prettyNameForFileSystemType( partition->fileSystem().type() );
        if ( col == MountPointColumn )
            return PartitionInfo::mountPoint( partition );
        if ( col == SizeColumn )
        {
            qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
            return KFormat().formatByteSize( size );
        }
        cDebug() << "Unknown column" << col;
        return QVariant();
    }
    case Qt::DecorationRole:
        if ( index.column() == NameColumn )
            return ColorUtils::colorForPartition( partition );
        else
            return QVariant();
    case Qt::ToolTipRole:
    {
        int col = index.column();
        QString name;
        if ( col == NameColumn )
        {
            if ( KPMHelpers::isPartitionFreeSpace( partition ) )
                name = tr( "Free Space" );
            else
            {
                name = KPMHelpers::isPartitionNew( partition )
                        ? tr( "New partition" )
                        : partition->partitionPath();
            }
        }
        QString prettyFileSystem = KPMHelpers::prettyNameForFileSystemType( partition->fileSystem().type() );
        qint64 size = ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
        QString prettySize = KFormat().formatByteSize( size );
        return QVariant(name + " " + prettyFileSystem + " " + prettySize);
    }
    case SizeRole:
        return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSectorSize();
    case IsFreeSpaceRole:
        return KPMHelpers::isPartitionFreeSpace( partition );

    case IsPartitionNewRole:
        return KPMHelpers::isPartitionNew( partition );

    case FileSystemLabelRole:
        if ( partition->fileSystem().supportGetLabel() != FileSystem::cmdSupportNone &&
             !partition->fileSystem().label().isEmpty() )
            return partition->fileSystem().label();
        return QVariant();

    case FileSystemTypeRole:
        return partition->fileSystem().type();

    case PartitionPathRole:
        return partition->partitionPath();

    case PartitionPtrRole:
        return qVariantFromValue( (void*)partition );

    // Osprober roles:
    case OsproberNameRole:
        foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
            if ( osproberEntry.path == partition->partitionPath() )
                return osproberEntry.prettyName;
        return QVariant();
    case OsproberPathRole:
        foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
            if ( osproberEntry.path == partition->partitionPath() )
                return osproberEntry.path;
        return QVariant();
    case OsproberCanBeResizedRole:
        foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
            if ( osproberEntry.path == partition->partitionPath() )
                return osproberEntry.canBeResized;
        return QVariant();
    case OsproberRawLineRole:
        foreach ( const OsproberEntry& osproberEntry, m_osproberEntries )
            if ( osproberEntry.path == partition->partitionPath() )
                return osproberEntry.line;
        return QVariant();
    // end Osprober roles.

    default:
        return QVariant();
    }
}
示例#12
0
QString Duration::toString(Format format) const {
    qint64 ms;
    double days;
    unsigned hours;
    unsigned minutes;
    unsigned seconds;
    QString result;

    switch (format) {
        case Format_Hour:
            ms = m_ms;
            hours = ms / (1000 * 60 * 60);
            ms -= (qint64)hours * (1000 * 60 * 60);
            minutes = ms / (1000 * 60);
            result = QString("%1h%2m").arg(hours).arg(minutes);
            break;
        case Format_Day:
            days = m_ms / (1000 * 60 * 60 * 24.0);
            result = QString("%1d").arg(QString::number(days, 'f', 4));
            break;
        case Format_DayTime:
            ms = m_ms;
            days = m_ms / (1000 * 60 * 60 * 24);
            ms -= (qint64)days * (1000 * 60 * 60 * 24);
            hours = ms / (1000 * 60 * 60);
            ms -= (qint64)hours * (1000 * 60 * 60);
            minutes = ms / (1000 * 60);
            ms -= minutes * (1000 * 60);
            seconds = ms / (1000);
            ms -= seconds * (1000);
            result.sprintf("%u %02u:%02u:%02u.%u", (unsigned)days, hours, minutes, seconds, (unsigned)ms);
            break;
        case Format_HourFraction:
            result = QLocale().toString(toDouble(Unit_h), 'f', 2);
            break;
        // i18n
        case Format_i18nHour:
            ms = m_ms;
            hours = ms / (1000 * 60 * 60);
            ms -= (qint64)hours * (1000 * 60 * 60);
            minutes = ms / (1000 * 60);
            result = i18nc("<hours>h:<minutes>m", "%1h:%2m", hours, minutes);
            break;
        case Format_i18nDay:
            result = KFormat().formatSpelloutDuration( m_ms );
            break;
        case Format_i18nWeek:
            result = this->format( Unit_w, 2 );
            break;
        case Format_i18nMonth:
            result = this->format( Unit_M, 2 );
            break;
        case Format_i18nYear:
            result = this->format( Unit_Y, 2 );
            break;
        case Format_i18nDayTime:
            ms = m_ms;
            days = m_ms / (1000 * 60 * 60 * 24);
            ms -= (qint64)days * (1000 * 60 * 60 * 24);
            hours = ms / (1000 * 60 * 60);
            ms -= (qint64)hours * (1000 * 60 * 60);
            minutes = ms / (1000 * 60);
            ms -= minutes * (1000 * 60);
            seconds = ms / (1000);
            ms -= seconds * (1000);
            if (days == 0) {
                result = toString(Format_i18nHour);
            } else {
                result = i18nc("<days>d <hours>h:<minutes>m", "%1d %2h:%3m", days, hours, minutes);
            }
            break;
        case Format_i18nHourFraction:
            result = QLocale().toString(toDouble(Unit_h), 'f', 2);
            break;
        default:
            qFatal("Unknown format");
            break;
    }
    return result;
}
// ---------------------------------------------------------------------------------
// CUpnpTmFilteredAppList::TmInfoElementMatchingL
// Method is used to compare with each of the desired key-value of a particular
// info element.
// @param aTmInfoElement Reference to Terminal Mode Info Element object.
// @return Returns the boolean value ( ETrue/EFalse )
// ---------------------------------------------------------------------------------
//
TBool CUpnpTmFilteredAppList::TmInfoElementMatchingL( const CUpnpTmInfoElement& aTmInfoElement,
                                                                            TInt aIndex )const
    {
    OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_TMINFOELEMENTMATCHINGL_ENTRY );
    TBool match(EFalse);
    RBuf8 elementName;
    CleanupClosePushL(elementName);
    RBuf8 elementValue;
    CleanupClosePushL(elementValue);
    aTmInfoElement.GetTmInfoElementL(elementName,elementValue,aIndex );
    // Check for required "protocolID" element
    if ( elementName.Compare(KProtocolId()) == KErrNone ) 
     {
     const TDesC8& filterProtocol = iFilterInfo->ProtocolId();
     if ( ( filterProtocol.Length() == KErrNone) || 
         elementValue.MatchC(filterProtocol) != KErrNotFound )
         {
         // Either protocolID( required element )is unavailable or desired 
         // protocolID matches
         match = ETrue;     
         }
     }
    // Check for optional "format" element
    else if ( elementName.Compare(KFormat()) == KErrNone ) 
         {
         const TDesC8& filterFormat = iFilterInfo->Format();
         if ( ( filterFormat.Length() == KErrNone) || 
             elementValue.MatchC(filterFormat) != KErrNotFound )  
             {
             // Either format ( optional element )is unavailable or desired "format" matches
             match = ETrue;   
             }
         }
    // Check for optional "direction" element
    else if ( elementName.Compare(KRemotingDirection()) == KErrNone ) 
         {
         const TDesC8& filterDirection = iFilterInfo->Direction();
         if ( ( filterDirection.Length() == KErrNone) || 
             elementValue.MatchC(filterDirection) != KErrNotFound )  
             {
             // Either direction ( optional element )is unavailable or desired "direction" matches
             match = ETrue;      
             }
         }
    // Check for optional "appCategory" element
    else if ( elementName.Compare(KAppCategory()) == KErrNone ) 
         {
         const TDesC8& filterAppCategory = iFilterInfo->AppCategory(); 
         if ( ( filterAppCategory.Length() == KErrNone) || 
             elementValue.MatchC(filterAppCategory) != KErrNotFound )
             {
             // Either appCategory ( optional element )is unavailable or desired "appCategory" matches
             match = ETrue;     
             }
         }
    // Check for optional "trustLevel" element for App Info Type
    else if ( ( elementName.Compare(KTrustLevel()) == KErrNone ) &&
                           ( aTmInfoElement.TerminalModeInfoType() == KAppInfo()) )
         {
         const TDesC8& filterAppTrustLevel = iFilterInfo->AppTrustLevel();
         if ( ( filterAppTrustLevel.Length() == KErrNone) || 
             elementValue.MatchC(filterAppTrustLevel) != KErrNotFound )
             {
             // Either trustLevel ( optional element )is unavailable or desired "trustLevel" matches
             match = ETrue;    
             }
     }
    // Check for optional "contentCategory" element
    else if ( elementName.Compare(KContCategory()) == KErrNone ) 
         {
         const TDesC8& filterContCategory = iFilterInfo->ContentCategory();
         if ( ( filterContCategory.Length() == KErrNone) || 
             elementValue.MatchC(filterContCategory) != KErrNotFound )
             {
             // Either contentCategory ( optional element )is unavailable or desired
             // "contentCategory" matches
             match = ETrue;     
             }
         }
    // Check for optional "contentRules" element
    else if ( elementName.Compare(KContentRules()) == KErrNone ) 
         {
         const TDesC8& filterContentRules = iFilterInfo->ContentRules();
         if ( ( filterContentRules.Length() == KErrNone) || 
             elementValue.MatchC(filterContentRules) != KErrNotFound )
             {
             // Either contentRules ( optional element )is unavailable or desired "contentRules" matches
             match = ETrue;  
             }
         }
    // Check for optional "trustLevel" element for Display Info type
    else if ( ( elementName.Compare(KTrustLevel()) == KErrNone ) &&
                        ( aTmInfoElement.TerminalModeInfoType() == KDisplayInfo()) )
         {
         const TDesC8& filterContTrustLevel = iFilterInfo->ContentTrustLevel();
         if ( ( filterContTrustLevel.Length() == KErrNone) || 
             elementValue.MatchC(filterContTrustLevel) != KErrNotFound )
             {
             // Either trustLevel ( optional element )is unavailable or desired "trustLevel" matches
             match = ETrue;  
             }
         }
    // Check for optional "audioType" element
    else if ( elementName.Compare(KAudioType()) == KErrNone ) 
         {
         const TDesC8& filterAudioType = iFilterInfo->AudioType();
         if ( ( filterAudioType.Length() == KErrNone) || 
             elementValue.MatchC(filterAudioType) != KErrNotFound )
             {
             // Either audioType ( optional element )is unavailable or desired "audioType" matches
             match = ETrue;     
             }
         }
    CleanupStack::PopAndDestroy(2,&elementName);
    OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_TMINFOELEMENTMATCHINGL_EXIT );
    return match;
    }
示例#14
0
QString AbstractResource::sizeDescription()
{
    return KFormat().formatByteSize(size());
}
示例#15
0
void CSubViewTest::SubAndLocalViewCompareTestL() const
	{
	test.Printf(_L("Testing subview is accurate compared to the local view."));

	const TInt KSubViewCount = iSubView->CountL();
	const TInt KLocalViewCount = iNamedLocalView->CountL();
	const TInt KFirstFieldIdx(0);
	
	TInt subViewIdx(0);
	TBool foundFirstInSubView(EFalse);
	TBool foundLastInSubView(EFalse);
	
	TInt subCntItemId(iSubView->AtL(subViewIdx));
	TInt localCntItemId(-1); // initialise with a value that can't be a real Id 
	for(TInt localViewIdx = 0; localViewIdx < KLocalViewCount && !foundLastInSubView; ++localViewIdx)
		{
		localCntItemId = iNamedLocalView->AtL(localViewIdx);

		// already found the first item in the sub view within
		// the underlying local view.
		if (foundFirstInSubView)
			{
			++subViewIdx;
			subCntItemId = iSubView->AtL(subViewIdx);
			// check that the contact ids in the sub view and local view match
			if (subCntItemId != localCntItemId)
				{
				test.Printf(_L("Mismatch of contacts between subview and local view"));
				test(EFalse);
				}

			// if we've found the last sub view item, do boundary checking to 
			// ensure we have the right things from the local view in the sub view. 
			if (subViewIdx == KSubViewCount - 1)
				{
				foundLastInSubView = ETrue;

				// Haven't checked localViewIdx < KLocalViewCount but it's not
				// likely that the last contact in the sub view will legitimately 
				// be the same as the last one in the local view.    
				const TPtrC nextLocalName = iNamedLocalView->ContactAtL(localViewIdx + 1).Field(KFirstFieldIdx);
				const TPtrC subName = iSubView->ContactAtL(subViewIdx).Field(KFirstFieldIdx);

				// check that the first character of the last contact in the subview
				// is within the proper range and that the next contact in the
				// local view is outside the range.
				test.Printf(_L("Found last contact from subview in local view. Testing for errors."));
				test(subName.Left(1).CompareF(KHighChar) <= 0 ||
						nextLocalName.Left(1).CompareF(KHighChar) > 0);
				test.Printf(_L("-- check okay."));
				}
			}

		// we've found the first contact item from the sub view in the local
		// view. check 
		else if (localCntItemId == subCntItemId && !foundFirstInSubView)
			{
			foundFirstInSubView = ETrue;

			// Haven't checked localViewIdx != 0 but it is not likely that the 
			// first contact in the local view will legitimately be the same as 
			// the first one in the sub view.
			const TPtrC prevLocalName = iNamedLocalView->ContactAtL(localViewIdx - 1).Field(KFirstFieldIdx);
			const TPtrC subName = iSubView->ContactAtL(subViewIdx).Field(KFirstFieldIdx);
						
			// check that the first character of the first contact in the subview
			// is within the proper range and that the previous contact in the
			// local view is outside the range.
			test.Printf(_L("Found first contact from subview in local view. Testing for errors."));
			test(subName.Left(1).CompareF(KLowChar) >= 0 &&
					prevLocalName.Left(1).CompareF(KLowChar) < 0);
			test.Printf(_L("-- check okay."));
			
			// check that we can find an expected contact item in the subview
			// and cannot find something that should not be there.
			test.Printf(_L("Testing FindL() functionality."));
			test(iSubView->FindL(subCntItemId) == subViewIdx &&
					iSubView->FindL(iNamedLocalView->AtL(localViewIdx - 1)) == KErrNotFound);
			test.Printf(_L("-- check okay."));
			
			// check the AllFieldsLC functionality
			test.Printf(_L("Testing AllFieldsLC() functionality."));
			
			_LIT(KDelimiter, ";");
			HBufC* allFields = iSubView->AllFieldsLC(subViewIdx, KDelimiter());
			TPtrC allFieldsPtr = allFields->Des();

			TBufC<16> field0 = iSubView->ContactAtL(subViewIdx).Field(0);
			TBufC<16> field1 = iSubView->ContactAtL(subViewIdx).Field(1);
			TBufC<16> field2 = iSubView->ContactAtL(subViewIdx).Field(2);
			TBufC<16> field3 = iSubView->ContactAtL(subViewIdx).Field(3);
			
			TBuf<48> fieldsBuf;
			_LIT(KFormat, "%S;%S;%S;%S");
			fieldsBuf.AppendFormat(KFormat(), &field0, &field1, &field2, &field3);
			
			test(fieldsBuf.Compare(allFieldsPtr) == 0); // they should be the same
			test.Printf(_L("-- check okay."));
			CleanupStack::PopAndDestroy(allFields);
			}
		}
	}