MailClient::MailClient() { QIcon folderIcon(style()->standardPixmap(QStyle::SP_DirClosedIcon)); QIcon trashIcon(style()->standardPixmap(QStyle::SP_FileIcon)); QStringList folderLabels; folderLabels << tr("Folders"); foldersTreeWidget = new QTreeWidget; foldersTreeWidget->setHeaderLabels(folderLabels); addFolder(folderIcon, tr("Inbox")); addFolder(folderIcon, tr("Outbox")); addFolder(folderIcon, tr("Sent")); addFolder(trashIcon, tr("Trash")); QStringList messageLabels; messageLabels << tr("Subject") << tr("Sender") << tr("Date"); messagesTreeWidget = new QTreeWidget; messagesTreeWidget->setHeaderLabels(messageLabels); addMessage(tr("Happy New Year!"), tr("Grace K. <*****@*****.**>"), tr("2006-12-31")); addMessage(tr("Radically new concept!"), tr("Grace K. <*****@*****.**>"), tr("2006-12-22")); addMessage(tr("Accounts"), tr("*****@*****.**"), tr("2006-12-31")); addMessage(tr("Expenses"), tr("Joe Bloggs <*****@*****.**>"), tr("2006-12-25")); addMessage(tr("Re: Expenses"), tr("Andy <*****@*****.**>"), tr("2007-01-02")); addMessage(tr("Re: Accounts"), tr("Joe Bloggs <*****@*****.**>"), tr("2007-01-03")); addMessage(tr("Re: Accounts"), tr("Andy <*****@*****.**>"), tr("2007-01-03")); messagesTreeWidget->resizeColumnToContents(0); messagesTreeWidget->resizeColumnToContents(1); textEdit = new QTextEdit; textEdit->setReadOnly(true); textEdit->setHtml("<table bolder=0>" "<tr><td align=right><b>Subject:</b>" "<td><p>Happy New Year!" "<tr><td align=right><b>Date:</b>" "<td><p>Sun, 31 Dec 2006" "<tr><td align=right><b>From:</b>" "<td><p>Grace K. <[email protected]>" "<tr><td align=right><b>To:</b>" "<td>[email protected]" "</table>" "<br>I want to seize this occasion to thank " "everybody for the year that has gone, and want " "to wish you the best for next year. It has been " "a pleasure to work with you all on the Hawk " "project, and I'm sure we'll get concrete " "results shortly." "<br><br>Happy New Year!" "<br>--Grace"); menuBar()->addMenu(tr("&File")); menuBar()->addMenu(tr("&Edit")); menuBar()->addMenu(tr("&View")); menuBar()->addMenu(tr("F&older")); menuBar()->addMenu(tr("&Message")); menuBar()->addMenu(tr("&Settings")); menuBar()->addMenu(tr("&Help")); statusBar()->showMessage(tr("No new messages on server")); rightSplitter = new QSplitter(Qt::Vertical); rightSplitter->addWidget(messagesTreeWidget); rightSplitter->addWidget(textEdit); rightSplitter->setStretchFactor(1, 1); mainSplitter = new QSplitter(Qt::Horizontal); mainSplitter->addWidget(foldersTreeWidget); mainSplitter->addWidget(rightSplitter); mainSplitter->setStretchFactor(1, 1); setCentralWidget(mainSplitter); setWindowTitle(tr("Mail Client")); readSettings(); }
// ----------------------------------------------------------------------------- // CAknFileSelectionModel::UpdateItemListL // ----------------------------------------------------------------------------- // TInt CAknFileSelectionModel::UpdateItemListL() { iEntryArray->Reset(); iImageIndexArray.Reset(); CDir* entryArray = ReadDirectory( iCurrentPath.DriveAndPath() ); if ( !entryArray ) { return KErrNotFound; } CleanupStack::PushL( entryArray ); TInt itemCount( entryArray->Count() ); if ( itemCount > 0 ) { TInt filterCount( iFilterArray->Count() ); TInt filterIndex; TBool accepted; CDesC16Array* desC16FoldersArray = new ( ELeave ) CDesC16ArrayFlat( KEntryArrayGranularity ); CleanupStack::PushL( desC16FoldersArray ); CDesC16Array* desC16FilesArray = new ( ELeave ) CDesC16ArrayFlat( KEntryArrayGranularity ); CleanupStack::PushL( desC16FilesArray ); CArrayPakFlat<TEntry>* tmpFoldersArray = new( ELeave ) CArrayPakFlat<TEntry>( KEntryArrayGranularity ); CleanupStack::PushL( tmpFoldersArray ); CArrayPakFlat<TEntry>* tmpFilesArray = new( ELeave ) CArrayPakFlat<TEntry>( KEntryArrayGranularity ); CleanupStack::PushL( tmpFilesArray ); tmpFoldersArray->Reset(); desC16FoldersArray->Reset(); tmpFilesArray->Reset(); desC16FilesArray->Reset(); for ( TInt i( 0 ); i < itemCount; i++ ) // Generate filtered list { accepted = ETrue; // If there are no filters, accept the entry TEntry entry = ( *entryArray )[i]; filterIndex = 0; // Go thru the filters while the entry is accepted while( ( filterIndex < filterCount ) && ( accepted ) ) { accepted = iFilterArray->At( filterIndex )->Accept( iCurrentPath.DriveAndPath(), entry ); filterIndex++; } if ( accepted ) // Directory entry has passed all filters { // Add filename to filtered list if ( entry.IsDir() ) { desC16FoldersArray->AppendL( GetLocalizedName( entry.iName ) ); tmpFoldersArray->AppendL( entry, sizeof( TEntry ) ); } else { desC16FilesArray->AppendL( GetLocalizedName( entry.iName ) ); tmpFilesArray->AppendL( entry, sizeof( TEntry ) ); } } } TInt entryCount = 0; TInt index; TKeyArrayPak key( _FOFF( TEntry, iName ), ECmpCollated ); // Add folder entries desC16FoldersArray->Sort( ECmpCollated ); entryCount = desC16FoldersArray->MdcaCount(); for( TInt j( 0 ); j < entryCount; j++ ) { for( TInt k( 0 ); k < entryCount; k++ ) { if( ( *desC16FoldersArray )[j] == GetLocalizedName( ( *tmpFoldersArray )[k].iName ) && iEntryArray->Find( ( *tmpFoldersArray )[k], key, index ) != 0 ) { TEntry tmpEntry = ( *tmpFoldersArray )[k]; iEntryArray->AppendL( tmpEntry, sizeof( TEntry ) ); // Entry is a directory TFileTypeIcon folderIcon( EFolderIcon ); if( !AknCFDUtility::IsRemoteDrive( iCurrentPath.Drive() ) ) { if ( ContainsSubfolders( tmpEntry.iName ) ) { folderIcon = ESubFolderIcon; } else if ( !ContainsFiles( tmpEntry.iName ) ) { folderIcon = EFolderEmptyIcon; } } iImageIndexArray.Append( folderIcon ); break; } } } // Add file entries desC16FilesArray->Sort( ECmpCollated ); entryCount = desC16FilesArray->MdcaCount(); for( TInt j( 0 ); j < entryCount; j++ ) { for( TInt k( 0 ); k < entryCount; k++ ) { if( ( *desC16FilesArray )[j] == GetLocalizedName( ( *tmpFilesArray )[k].iName ) && iEntryArray->Find( ( *tmpFilesArray )[k], key, index ) != 0 ) { TEntry tmpFile = ( *tmpFilesArray )[k]; iEntryArray->AppendL( tmpFile, sizeof( TEntry ) ); // Entry is a file AppendIconForFileL( tmpFile.iName ); break; } } } CleanupStack::PopAndDestroy( tmpFilesArray ); CleanupStack::PopAndDestroy( tmpFoldersArray ); CleanupStack::Pop( desC16FilesArray ); desC16FilesArray->Reset(); delete desC16FilesArray; CleanupStack::Pop( desC16FoldersArray ); desC16FoldersArray->Reset(); delete desC16FoldersArray; } CleanupStack::PopAndDestroy( entryArray ); if ( AknCFDUtility::DirectoriesOnly( iDialogType ) ) { // Set the current folder name as first item. // Current folder is for example "E:\Images\Holiday\" // Remove trailing backslash, we get "E:\Images\Holiday" // Parse the path with TParse and ask for NameAndExt(). // TParse interpretes "Holiday" as file name and returns it. HBufC * bufFolder = HBufC::NewLC(KMaxPath); * bufFolder = iCurrentPath.DriveAndPath() ; TPtr folder = bufFolder->Des(); AknCFDUtility::RemoveTrailingBackslash( folder ); // ignore error TParsePtr parsedFolder(folder); folder = parsedFolder.NameAndExt(); iFolderEntry.iName = folder; iEntryArray->InsertL( 0, iFolderEntry, sizeof( TEntry ) ); iImageIndexArray.Insert( EThisFolderIcon, 0 ); CleanupStack::PopAndDestroy(); //bufFolder } return iEntryArray->Count(); }
QIcon Theme::trayFolderIcon( const QString& backend ) const { return folderIcon( backend ); }