chxavfileviewwindow.cpp
来自「symbian 下的helix player源代码」· C++ 代码 · 共 1,905 行 · 第 1/4 页
CPP
1,905 行
}
////////////////////////////////////////////////////////////
// prompt for a new folder and create it (relative to current path)
//
void CHXAvFileViewWindow::UserNewFolderL()
{
TInt err = m_spFileUI->DoNewFolderL(R_PROMPT_NEW_FOLDER_NAME);
if(KErrNone == err)
{
// set focus to new folder item
TPtrC ptrName = m_spFileUI->GetLastNewItemName();
if( err != KErrNone )
{
ptrName.Set(KNullDesC);
}
TInt idxCurrent = m_pListBox->CurrentItemIndex();
RefreshListBoxL(idxCurrent, ptrName);
}
}
////////////////////////////////////////////////////////////
//
// delete selected items, or delete current hilighted item
//
void CHXAvFileViewWindow::UserDeleteSelectedItemsL()
{
TInt idxHilightItem = m_pListBox->CurrentItemIndex();
const CArrayFix<TInt>* pSelectedItems = m_pListBox->SelectionIndexes();
//utVector<TInt> removeIndexes;
TInt selectedCount = pSelectedItems->Count();
TInt err = KErrCancel;
if( selectedCount > 0)
{
// delete marked items
err = m_spFileUI->DoDeleteItemsL(*pSelectedItems);
}
else if(idxHilightItem >= 0) // -1 == empty view
{
// no mark list; delete hilight item
err = m_spFileUI->DoDeleteItemL(idxHilightItem);
}
#if(0)
if(removeIndexes.Nelements() > 0)
{
RefreshListBoxL(removeIndexes, idxHilightItem);
}
#endif
}
////////////////////////////////////////////////////
// rename the currently hilighted file or folder
//
void CHXAvFileViewWindow::UserRenameCurrentItemL()
{
HX_ASSERT(GetMarkedItemCount() == 0); // can't rename when selection list exists!
TInt idxItem = m_pListBox->CurrentItemIndex();
HX_ASSERT(idxItem >= 0);
TInt err = m_spFileUI->DoRenameL(idxItem, R_PROMPT_ENTER_NEW_NAME);
if(KErrNone == err)
{
// set focus to newly renamed item
TPtrC ptrName = m_spFileUI->GetLastNewItemName();
if( err != KErrNone )
{
ptrName.Set(KNullDesC);
}
// update selection to new name
TInt idxCurrent = m_pListBox->CurrentItemIndex();
RefreshListBoxL(idxCurrent, ptrName);
}
}
////////////////////////////////////////////////////////////
// move selected items, or move current hilighted item, to
// user-specified folder (relative to root)
//
void CHXAvFileViewWindow::UserCopySelectedItemsL()
{
TInt idxHilightItem = m_pListBox->CurrentItemIndex();
const CArrayFix<TInt>* pSelectedItems = m_pListBox->SelectionIndexes();
TInt err = KErrNone;
if( pSelectedItems->Count() > 0)
{
//XXXLCM implement
//err = m_spFileUI->DoCopyItemsL(*pSelectedItems, R_PROMPT_COPY_TO);
}
else
{
HX_ASSERT(idxHilightItem >= 0);
//err = m_spFileUI->DoCopyItemL(idxHilightItem, R_PROMPT_COPY_TO);
}
}
////////////////////////////////////////////////////////////
// move selected items, or move current hilighted item, to
// user-specified folder (relative to root)
//
void CHXAvFileViewWindow::UserMoveSelectedItemsL()
{
TInt idxHilightItem = m_pListBox->CurrentItemIndex();
const CArrayFix<TInt>* pSelectedItems = m_pListBox->SelectionIndexes();
TInt err = KErrNone;
if( pSelectedItems->Count() > 0)
{
err = m_spFileUI->DoMoveItemsL(*pSelectedItems, R_PROMPT_MOVE_TO);
}
else
{
HX_ASSERT(idxHilightItem >= 0);
err = m_spFileUI->DoMoveItemL(idxHilightItem, R_PROMPT_MOVE_TO);
}
}
////////////////////////////////////////////////////////////
// send selected items as attachments via the selected mtm
//
void CHXAvFileViewWindow::UserSendSelectedItemsL(TInt command,
CSendAppUi* pSendAppUi)
{
TSendingCapabilities caps(0, 1024,
TSendingCapabilities::ESupportsAttachments);
if (pSendAppUi->CommandIsValidL(command, caps, NULL ))
{
CDesCArray* pSelectedNames = new (ELeave) CDesCArrayFlat(4);
AUTO_PUSH_POP_DEL(pSelectedNames);
const CArrayFix<TInt>* pSelectedItems = m_pListBox->SelectionIndexes();
if (pSelectedItems->Count() > 0)
{
for (TInt i = 0; i < pSelectedItems->Count(); ++i)
{
TFileName* pName = m_spStore->AllocFullPathL((*pSelectedItems)[i]);
AUTO_PUSH_POP_DEL(pName);
pSelectedNames->AppendL(*pName);
}
}
else
{
TFileName* pName =
m_spStore->AllocFullPathL(m_pListBox->CurrentItemIndex());
AUTO_PUSH_POP_DEL(pName);
pSelectedNames->AppendL(*pName);
}
pSendAppUi->CreateAndSendMessageL(command, NULL, pSelectedNames);
}
}
////////////////////////////////////////////////////////////////////
//
void CHXAvFileViewWindow::UserMarkL(TInt command)
{
HX_ASSERT(m_spStore);
HX_ASSERT(m_pListBox != 0);
if(command == EAknMarkAll)
{
//
// handle this ourselves since we don't want to mark folders
//
CArrayFixFlat<TInt>* pSelections = new (ELeave) CArrayFixFlat<TInt>(20);
AUTO_PUSH_POP_DEL(pSelections);
const CHXAvFileStore::Entries& entries = m_spStore->GetEntries();
TInt count = entries.Nelements();
for(TInt idx = 0; idx < count; ++idx)
{
if( !entries[idx].m_entry.IsDir() )
{
// add index to file
pSelections->AppendL(idx);
}
}
m_pListBox->SetSelectionIndexesL(pSelections);
m_pListBox->DrawNow();
}
else
{
AknSelectionService::HandleMarkableListProcessCommandL(command, m_pListBox);
}
}
////////////////////////////////////////////////////
// get number of items (files) in view that are not
// in the selection list
TInt CHXAvFileViewWindow::GetUnmarkedItemCount() const
{
HX_ASSERT(m_spStore);
TInt totalCount = m_spStore->GetCurrentFolderFileCount();
TInt markedCount = GetMarkedItemCount();
HX_ASSERT(totalCount >= markedCount);
return totalCount - markedCount;
}
//////////////////////////////////////
//
bool CHXAvFileViewWindow::IsDriveLocked() const
{
bool bIsLocked = false;
CHXAvMediaFolderInfo* pFolderInfo = m_spCurrentPage->FolderInfo();
if(pFolderInfo)
{
TInt idx = CHXAvFile::GetDriveIndex(pFolderInfo->GetRoot());
bIsLocked = CHXAvFile::IsDriveLocked(idx);
}
return bIsLocked;
}
////////////////////////////////////////////////////////////
//
void CHXAvFileViewWindow::OnCompleteUnlockAttempt(TInt err)
{
if( KErrNone == err )
{
// drive was unlocked
ReloadCurrentPageL();
}
}
////////////////////////////////////////////////////////////
// attempt to unlock drive for current store
void CHXAvFileViewWindow::UserUnlockDriveL()
{
// m_memCardUnlock.DoUiL();
TInt idx = CHXAvFile::GetDriveIndex(GetFullPath());
TInt err = util::DoUnlockDriveUi(idx);
OnCompleteUnlockAttempt(err);
}
////////////////////////////////////////////////////////////////////
// called when page is deactivating/going away
//
// save state (current path and index) for current page so we can restore
// state in case user returns back to page later on
//
void CHXAvFileViewWindow::SaveCurrentPageInfoL()
{
if(m_spStore && m_spCurrentPage)
{
HX_ASSERT(m_pListBox != 0);
m_spCurrentPage->FolderInfo()->SetCurrentPathL(m_spStore->GetCurrentPath());
m_spCurrentPage->SetCurrentIndex(m_pListBox->CurrentItemIndex());
}
}
////////////////////////////////////////////////////////////
//
void CHXAvFileViewWindow::UserEditCurrentItemL()
{
HX_ASSERT(GetMarkedItemCount() == 0); // can't open when items are in selection list!
TInt idxItem = m_pListBox->CurrentItemIndex();
const CHXAvFile::FileInfo& info = GetFileInfoL(idxItem);
const TEntry& entry = info.m_entry;
HX_ASSERT(CHXAvFile::ftRam == info.m_type);
HX_ASSERT(!entry.IsDir());
TFileName* pPath = CHXAvFile::AllocFileNameL(GetFullPath(), entry.iName);
AUTO_PUSH_POP_DEL(pPath);
// hide tabs while dialog is up
m_bHideTabs = true; // in case switch away, then activate
UpdateNaviPaneL();
m_playerUI->DoEditPlaylistL(*pPath);
// make sure ram file is still valid
CHXAvFile::FileType fileType = CHXAvFile::GetFileType(*pPath);
if(!CHXAvFile::IsNanoPlayerFileType(fileType))
{
// user made unusable file; delete it since it will no longer be recognized and show in our view
m_spStore->DeleteFileL(*pPath);
}
// show tabs again
m_bHideTabs = false;
UpdateNaviPaneL();
// after edit, refresh list box to reflect possible changes (e.g. in file size, link count)
TInt idxCurrent = m_pListBox->CurrentItemIndex();
RefreshListBoxL(idxCurrent);
}
//////////////////////////////////////
//
TKeyResponse CHXAvFileViewWindow::HandleKeyDownEventL(const TKeyEvent& event)
{
if(EStdKeyLeftShift == event.iScanCode)
{
DPRINTF(SYMP_WSEVENTS, ("CHXAvFileViewWindow::HandleKeyDownEventL(): shift down\n"));
//HX_ASSERT(smNotMarking == m_shiftMarkState);
// note: we do not always get key up
if(HasHilightItem() && HilightItemIsFile())
{
m_shiftMarkState = (HilightItemIsMarked() ? smShiftUnMark : smShiftMark);
}
}
return EKeyWasNotConsumed;
}
//////////////////////////////////////
//
TKeyResponse CHXAvFileViewWindow::HandleKeyUpEventL(const TKeyEvent& event)
{
if(EStdKeyLeftShift == event.iScanCode)
{
DPRINTF(SYMP_INFO, ("CHXAvFileViewWindow::HandleKeyUpEventL(): shift up\n"));
m_shiftMarkState = smNotMarking;
}
#if defined(SYMBIANPLAYER_INCLUDE_LOCK_DRIVE_UI)
else if( event.iScanCode == EStdKeyHash)
{
if( !CHXAvFile::IsDriveLocked(CHXAvMisc::KIdxMmcDrive))
{
util::DoLockDriveUiL();
}
}
#endif
return EKeyWasNotConsumed;
}
/*
* GetCurrentPageIndex
* -------------------
* Return the index of the current page.
*
*/
TInt
CHXAvFileViewWindow::GetCurrentPageIndex() const
{
TInt idx = 0;
if( m_wpTabGroup )
{
idx = m_wpTabGroup->ActiveTabIndex();
}
return idx;
}
#if(0)
//////////////////////////////////////
// optimized version of refreshlistbox
//
// update list info and listbox model after actual folder
// items corresponding to given indexes have been removed
//
// called after move or delete
//
// idHilightItem is the index for the last known current item
// (i.e., just before the move or delete took place)
//
void CHXAvFileViewWindow::RefreshListBoxL(const Vector<TInt>& removeIndexes,
TInt idxHilightItem)
{
CDesCArray* pTextItems = GetModelTextArray();
HX_ASSERT(pTextItems);
if(m_spStore)
{
//
// update model text
//
// the fact that descriptor array deletion causes indexes
// to change necessitates this weird way of deleting model
// items
//
TInt idxItem = 0;
TInt idxNextRemoveIndex = 0;
TInt count = pTextItems->Count();
for( TInt idxDelete = 0; idxDelete < count; ++idxDelete)
{
if( idxNextRemoveIndex >= removeIndexes.Nelements() )
{
// all items have been removed
break;
}
if( idxDelete == removeIndexes[idxNextRemoveIndex] )
{
++idxNextRemoveIndex;
pTextItems->Delete(idxItem);
continue;
}
// only update this index if an item not deleted
++idxItem;
}
// scrunch up the list box model
pTextItems->Compress();
//
// update list info items
//
m_spStore->RemoveEntries(removeIndexes);
// update the listbox UI and redraw
m_pListBox->HandleItemRemovalL();
if(m_pListBox->CurrentItemIndex() == -1)
{
// hilight item was deleted; set hilight to next best index
idxHilightItem = GetBestIndex(idxHilightItem);
HX_ASSERT(idxHilightItem < pTextItems->Count());
m_pListBox->SetCurrentItemIndex(idxHilightItem);
}
}
else
{
pTextItems->Reset();
}
CHXAvMisc:UpdateScrollBar(m_pListBox);
m_pListBox->DrawNow();
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?