filebrowser/engine/FBFileUtils.cpp
changeset 48 da3ec8478e66
parent 35 98924d2efce9
equal deleted inserted replaced
47:11fa016241a4 48:da3ec8478e66
   360 void CFileBrowserFileUtils::CheckForMoreCommandsL()
   360 void CFileBrowserFileUtils::CheckForMoreCommandsL()
   361     {
   361     {
   362     //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL");
   362     //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL");
   363     
   363     
   364     // update the progress bar
   364     // update the progress bar
   365     if (iProgressInfo)
   365 //    if (iProgressInfo)
   366         iProgressInfo->IncrementAndDraw(1);
   366 //        iProgressInfo->IncrementAndDraw(1);
   367 
   367 
   368 	// check if we have more commands to be executed
   368 	// check if we have more commands to be executed
   369 	if (iCurrentEntry >= CommandArrayCount() - 1)
   369 	if (iCurrentEntry >= CommandArrayCount() - 1)
   370 		{
   370 		{
   371         //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done");
   371         //LOGSTRING("Creator: CCreatorEngine::CheckForMoreCommandsL all done");
   404             {
   404             {
   405             // single operation cancelled -> show nothing
   405             // single operation cancelled -> show nothing
   406             }
   406             }
   407         else if (iSucceededOperations == 1 && iFailedOperations == 0)    
   407         else if (iSucceededOperations == 1 && iFailedOperations == 0)    
   408             {
   408             {
   409 //            _LIT(KMessage, "Operation succeeded");
   409             _LIT(KMessage, "Operation succeeded");
   410 //            iEngine->FileBrowserUI()->ShowConfirmationNote(KMessage);
   410             iEngine->FileBrowserUI()->ShowConfirmationNote(KMessage);
   411             }
   411             }
   412         else if (iSucceededOperations > 0 && iFailedOperations == 0)    
   412         else if (iSucceededOperations > 0 && iFailedOperations == 0)    
   413             {
   413             {
   414 //            _LIT(KMessage, "%d operations succeeded");
   414             _LIT(KMessage, "%d operations succeeded");
   415 //            TBuf<128> noteMsg;
   415             TBuf<128> noteMsg;
   416 //            noteMsg.Format(KMessage, iSucceededOperations);
   416             noteMsg.Format(KMessage, iSucceededOperations);
   417 //            iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg);
   417             iEngine->FileBrowserUI()->ShowConfirmationNote(noteMsg);
   418             }
   418             }
   419         else if (iSucceededOperations == 0 && iFailedOperations > 1)    
   419         else if (iSucceededOperations == 0 && iFailedOperations > 1)    
   420             {
   420             {
   421             _LIT(KMessage, "%d operations failed");
   421             _LIT(KMessage, "%d operations failed");
   422             TBuf<128> noteMsg;
   422             TBuf<128> noteMsg;
   441 
   441 
   442             CleanupStack::PopAndDestroy();  //textResolver
   442             CleanupStack::PopAndDestroy();  //textResolver
   443             }
   443             }
   444 
   444 
   445         RefreshViewL();
   445         RefreshViewL();
       
   446         iEngine->FileBrowserUI()->NotifyModelHasChanged();
   446 
   447 
   447             }
   448             }
   448 	else
   449 	else
   449             {
   450             {
   450             // maintain requests
   451             // maintain requests
   627     }        
   628     }        
   628 // --------------------------------------------------------------------------------------------
   629 // --------------------------------------------------------------------------------------------
   629 
   630 
   630 void CFileBrowserFileUtils::RefreshViewL()
   631 void CFileBrowserFileUtils::RefreshViewL()
   631     {
   632     {
   632 	// TODO
       
   633 
       
   634 //    if (iEngine->FileListContainer())
   633 //    if (iEngine->FileListContainer())
   635 //        {
   634 //        {
   636 //        // create a list box if it doesn't already exist
       
   637 //        if (!iEngine->FileListContainer()->ListBox())
       
   638 //            iEngine->FileListContainer()->CreateListBoxL(iEngine->Settings().iFileViewMode);
       
   639 //
       
   640 //        // clear selections if any
       
   641 //        iEngine->FileListContainer()->ListBox()->ClearSelection();
       
   642 //
   635 //
   643 //        // make sure that the search field is disabled
   636 //        // make sure that the search field is disabled
   644 //        iEngine->FileListContainer()->DisableSearchFieldL();
   637 //        iEngine->FileListContainer()->DisableSearchFieldL();
   645         
   638         
   646         // read directory listing
   639         // read directory listing
   649 //        // set an icon array
   642 //        // set an icon array
   650 //        iEngine->FileListContainer()->SetListBoxIconArrayL(GenerateIconArrayL());
   643 //        iEngine->FileListContainer()->SetListBoxIconArrayL(GenerateIconArrayL());
   651 //
   644 //
   652 //        // set text items
   645 //        // set text items
   653 //        iEngine->FileListContainer()->SetListBoxTextArrayL(GenerateItemTextArrayL());
   646 //        iEngine->FileListContainer()->SetListBoxTextArrayL(GenerateItemTextArrayL());
   654 
       
   655 //        // make sure that the current item index is not out of array
       
   656 //        if (iEngine->FileListContainer()->CurrentListBoxItemIndex() == -1 && // -1 is a hardcoded value meaning that no current item index
       
   657 //                iEngine->FileListContainer()->ListBox()->Model()->NumberOfItems() > 0)
       
   658 //            iEngine->FileListContainer()->ListBox()->SetCurrentItemIndex( iEngine->FileListContainer()->ListBox()->Model()->NumberOfItems() - 1 );
       
   659 //
       
   660 //        }
   647 //        }
   661     
   648     }
   662 //        iEngine->FileListContainer()->UpdateToolbar();
       
   663 
       
   664         }
       
   665     
   649     
   666 // --------------------------------------------------------------------------------------------
   650 // --------------------------------------------------------------------------------------------
   667 
   651 
   668 //CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray)
   652 //CAknIconArray* CFileBrowserFileUtils::GenerateIconArrayL(TBool aGenerateNewBasicIconArray)
   669 //    {
   653 //    {
  1535         }
  1519         }
  1536     return aFileEntryList->Count();
  1520     return aFileEntryList->Count();
  1537     }
  1521     }
  1538 
  1522 
  1539 // --------------------------------------------------------------------------------------------
  1523 // --------------------------------------------------------------------------------------------
  1540 //TInt CFileBrowserFileUtils::GetSelectedItemsOrCurrentItemL(CFileEntryList* aFileEntryList)
       
  1541 //    {
       
  1542 //    aFileEntryList->Reset();
       
  1543 //
       
  1544 //    const CArrayFix<TInt>* selectionIndexes = iEngine->GetSelectedIndices();
       
  1545 //    // by default use selected items
       
  1546 //    if (selectionIndexes && selectionIndexes->Count() > 0)
       
  1547 //        {
       
  1548 //        TInt ref(0);
       
  1549 //        TKeyArrayFix key(0, ECmpTUint16);
       
  1550 //        TInt index(0);
       
  1551 //
       
  1552 //        for (TInt i=0; i<iFileEntryList->Count(); i++)
       
  1553 //            {
       
  1554 //            ref = i;
       
  1555 //
       
  1556 //            if (selectionIndexes->Find(ref, key, index) == 0)
       
  1557 //                {
       
  1558 //                aFileEntryList->AppendL(iFileEntryList->At(i));
       
  1559 //                }
       
  1560 //            }
       
  1561 //        }
       
  1562 //
       
  1563 //    // or if none selected, use the current item index
       
  1564 //    else
       
  1565 //        {
       
  1566 ////        TInt currentItemIndex = iEngine->FileListContainer()->CurrentListBoxItemIndex();
       
  1567 //        TInt currentItemIndex = iEngine->QueryCurrentItemIndex();
       
  1568 //        if (iFileEntryList->Count() > currentItemIndex && currentItemIndex >= 0)
       
  1569 //            {
       
  1570 //            aFileEntryList->AppendL(iFileEntryList->At(currentItemIndex));
       
  1571 //            }
       
  1572 //        }
       
  1573 //
       
  1574 //    return aFileEntryList->Count();
       
  1575 //    }
       
  1576 
       
  1577 // --------------------------------------------------------------------------------------------
       
  1578 
  1524 
  1579 TInt CFileBrowserFileUtils::ClipboardCutL(const CArrayFix<TInt>* aSelectionIndices)
  1525 TInt CFileBrowserFileUtils::ClipboardCutL(const CArrayFix<TInt>* aSelectionIndices)
  1580     {
  1526     {
  1581 	
  1527 	
  1582     iClipBoardMode = EClipBoardModeCut;
  1528     iClipBoardMode = EClipBoardModeCut;
  1583     //TInt operations = GetSelectedItemsOrCurrentItemL(iClipBoardList);
       
  1584     TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList);
  1529     TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList);
  1585     return operations;
  1530     return operations;
  1586     }
  1531     }
  1587 
  1532 
  1588 // --------------------------------------------------------------------------------------------
  1533 // --------------------------------------------------------------------------------------------
  1589 
  1534 
  1590 TInt CFileBrowserFileUtils::ClipboardCopyL(const CArrayFix<TInt>* aSelectionIndices)
  1535 TInt CFileBrowserFileUtils::ClipboardCopyL(const CArrayFix<TInt>* aSelectionIndices)
  1591     {
  1536     {
  1592     iClipBoardMode = EClipBoardModeCopy;
  1537     iClipBoardMode = EClipBoardModeCopy;
  1593     //TInt operations = GetSelectedItemsOrCurrentItemL(iClipBoardList);
       
  1594     TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList);
  1538     TInt operations = SetSelectedItemsOrCurrentItemL(aSelectionIndices, iClipBoardList);
  1595     return operations;
  1539     return operations;
  1596     }
  1540     }
  1597 
  1541 
  1598 // --------------------------------------------------------------------------------------------
  1542 // --------------------------------------------------------------------------------------------
  1632     //    CleanupStack::PushL(iconArray);
  1576     //    CleanupStack::PushL(iconArray);
  1633 
  1577 
  1634     // run folder selection dialog
  1578     // run folder selection dialog
  1635     //    CFileBrowserDestinationFolderSelectionDlg* dlg = CFileBrowserDestinationFolderSelectionDlg::NewL(destinationFolder, iDriveEntryList, iconArray);
  1579     //    CFileBrowserDestinationFolderSelectionDlg* dlg = CFileBrowserDestinationFolderSelectionDlg::NewL(destinationFolder, iDriveEntryList, iconArray);
  1636 
  1580 
  1637     // get entry list
       
  1638     //CFileEntryList* entryList = new(ELeave) CFileEntryList(32);
       
  1639     //GetSelectedItemsOrCurrentItemL(entryList);
       
  1640     //CleanupStack::PushL(entryList);
       
  1641 
       
  1642     // do the file operations
  1581     // do the file operations
  1643     //DoCopyToFolderL(entryList, aTargetDir, aOverwriteOptions, aMove);
  1582     //DoCopyToFolderL(entryList, aTargetDir, aOverwriteOptions, aMove);
  1644     DoCopyToFolderL(iCurrentSelectionList, aTargetDir, aOverwriteOptions, aMove);
  1583     DoCopyToFolderL(iCurrentSelectionList, aTargetDir, aOverwriteOptions, aMove);
  1645 
       
  1646     //CleanupStack::PopAndDestroy(); // entryList
       
  1647 
  1584 
  1648     //    CleanupStack::Pop(); //iconArray
  1585     //    CleanupStack::Pop(); //iconArray
  1649     }
  1586     }
  1650 
  1587 
  1651 // --------------------------------------------------------------------------------------------
  1588 // --------------------------------------------------------------------------------------------
  1733                                           new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags)
  1670                                           new(ELeave)CCommandParamsCopyOrMove(fileEntry, targetEntry, aOverwriteOptions.iOverWriteFlags)
  1734                                          );
  1671                                          );
  1735                     }
  1672                     }
  1736 
  1673 
  1737                 }
  1674                 }
  1738 
       
  1739             // execute all operations
       
  1740             if (aDeleteSource)
       
  1741                 StartExecutingCommandsL(_L("Moving"));
       
  1742             else
       
  1743                 StartExecutingCommandsL(_L("Copying"));
       
  1744             }
  1675             }
  1745         }
  1676         }
  1746     }
  1677     }
  1747 
  1678 
  1748 // --------------------------------------------------------------------------------------------
  1679 // --------------------------------------------------------------------------------------------
  1767                                   new(ELeave)CCommandParamsDelete(fileEntry, 0)
  1698                                   new(ELeave)CCommandParamsDelete(fileEntry, 0)
  1768                                  );
  1699                                  );
  1769             }
  1700             }
  1770 
  1701 
  1771         }
  1702         }
  1772 
       
  1773     // execute all operations
       
  1774     StartExecutingCommandsL(_L("Deleting"));
       
  1775     }
  1703     }
  1776 
  1704 
  1777 
  1705 
  1778 // --------------------------------------------------------------------------------------------
  1706 // --------------------------------------------------------------------------------------------
  1779 
  1707 
  1821             AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
  1749             AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
  1822                                   new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, 0)
  1750                                   new(ELeave)CCommandParamsAttribs(fileEntry, NULL, NULL, now, 0)
  1823                                  );
  1751                                  );
  1824             }
  1752             }
  1825         }
  1753         }
  1826 
       
  1827     // execute all operations
       
  1828     StartExecutingCommandsL(_L("Touching"));
       
  1829     }
  1754     }
  1830 
  1755 
  1831 TBool CFileBrowserFileUtils::TargetExists(const TInt aIndex, const TFileName &newName)
  1756 TBool CFileBrowserFileUtils::TargetExists(const TInt aIndex, const TFileName &newName)
  1832     {
  1757     {
  1833     TBool alreadyExists(EFalse);
  1758     TBool alreadyExists(EFalse);
  1834     if (iDriveEntryList->Count() > aIndex && aIndex >= 0)
  1759     if (iFileEntryList->Count() > aIndex && aIndex >= 0)
  1835         {
  1760         {
  1836 
  1761 
  1837         TFileEntry fileEntry = iFileEntryList->At(aIndex);
  1762         TFileEntry fileEntry = iFileEntryList->At(aIndex);
  1838         TFileName targetEntry = fileEntry.iPath;
  1763         TFileName targetEntry = fileEntry.iPath;
  1839         targetEntry.Append(newName);
  1764         targetEntry.Append(newName);
  1852 
  1777 
  1853 // --------------------------------------------------------------------------------------------
  1778 // --------------------------------------------------------------------------------------------
  1854 
  1779 
  1855 void CFileBrowserFileUtils::RenameL(const TInt aIndex, const TFileName &newName)
  1780 void CFileBrowserFileUtils::RenameL(const TInt aIndex, const TFileName &newName)
  1856     {
  1781     {
  1857         if (iDriveEntryList->Count() > aIndex && aIndex >= 0)
  1782         if (iFileEntryList->Count() > aIndex && aIndex >= 0)
  1858         {
  1783         {
  1859             TFileEntry fileEntry = iFileEntryList->At(aIndex);
  1784             TFileEntry fileEntry = iFileEntryList->At(aIndex);
  1860 
  1785 
  1861             TFileName targetEntry = fileEntry.iPath;
  1786             TFileName targetEntry = fileEntry.iPath;
  1862             targetEntry.Append(newName);
  1787             targetEntry.Append(newName);
  1864             // append the new command to the command array
  1789             // append the new command to the command array
  1865             AppendToCommandArrayL(EFileBrowserFileOpCommandRename,
  1790             AppendToCommandArrayL(EFileBrowserFileOpCommandRename,
  1866                                   new(ELeave)CCommandParamsRename(fileEntry, targetEntry, CFileMan::EOverWrite)
  1791                                   new(ELeave)CCommandParamsRename(fileEntry, targetEntry, CFileMan::EOverWrite)
  1867                                  );
  1792                                  );
  1868         }
  1793         }
  1869     // execute all operations done from caller
  1794     }
  1870     // StartExecutingCommandsL(_L("Renaming"));
  1795 
  1871     }
  1796 // --------------------------------------------------------------------------------------------
  1872 
  1797 
  1873 // --------------------------------------------------------------------------------------------
  1798 void CFileBrowserFileUtils::SetAttributesL(TUint &aSetAttMask, TUint &aClearAttMask, TBool &aRecurse)
  1874 
  1799     {
  1875 void CFileBrowserFileUtils::SetAttributesL()
  1800     for (TInt i=0; i<iCurrentSelectionList->Count(); i++)
  1876     {
  1801         {
  1877 //    CFileEntryList* entries = new(ELeave) CFileEntryList(16);
  1802         TFileEntry fileEntry = iCurrentSelectionList->At(i);
  1878 //    GetSelectedItemsOrCurrentItemL(entries);
  1803 
  1879 //    CleanupStack::PushL(entries);
  1804         // append the new command to the command array
  1880 //
  1805         if (fileEntry.iEntry.IsDir() && aRecurse)
  1881 //    if (entries->Count() > 0)
  1806             {
  1882 //        {
  1807             AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
  1883 //        TFileName naviText = _L("Multiple entries");
  1808                                   new(ELeave)CCommandParamsAttribs(fileEntry, aSetAttMask, aClearAttMask, fileEntry.iEntry.iModified, CFileMan::ERecurse)
  1884 //
  1809                                  );
  1885 //        TUint setAttMask(0);
  1810             }
  1886 //        TUint clearAttMask(0);
  1811         else
  1887 //        //TBool recurse(EFalse);
  1812             {
  1888 //
  1813             AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
  1889 //        // set default masks if only one file selected
  1814                                   new(ELeave)CCommandParamsAttribs(fileEntry, aSetAttMask, aClearAttMask, fileEntry.iEntry.iModified, 0)
  1890 //        if (entries->Count() == 1)
  1815                                  );
  1891 //            {
  1816             }
  1892 //            TFileEntry fileEntry = entries->At(0);
  1817         }
  1893 //
  1818 
  1894 //            naviText.Copy(fileEntry.iEntry.iName);
  1819     // execute all operations
  1895 //
  1820     StartExecutingCommandsL(_L("Changing attributes"));
  1896 //            if (fileEntry.iEntry.IsArchive())
       
  1897 //                setAttMask |= KEntryAttArchive;
       
  1898 //            else
       
  1899 //                clearAttMask |= KEntryAttArchive;
       
  1900 //
       
  1901 //            if (fileEntry.iEntry.IsHidden())
       
  1902 //                setAttMask |= KEntryAttHidden;
       
  1903 //            else
       
  1904 //                clearAttMask |= KEntryAttHidden;
       
  1905 //
       
  1906 //            if (fileEntry.iEntry.IsReadOnly())
       
  1907 //                setAttMask |= KEntryAttReadOnly;
       
  1908 //            else
       
  1909 //                clearAttMask |= KEntryAttReadOnly;
       
  1910 //
       
  1911 //            if (fileEntry.iEntry.IsSystem())
       
  1912 //                setAttMask |= KEntryAttSystem;
       
  1913 //            else
       
  1914 //                clearAttMask |= KEntryAttSystem;
       
  1915 //            }
       
  1916 //
       
  1917         //iEngine->FileListContainer()->SetScreenLayoutL(EDisplayModeNormal);
       
  1918         //iEngine->FileListContainer()->SetNaviPaneTextL(naviText);
       
  1919 
       
  1920         //CFileBrowserAttributeEditorDlg* dlg = CFileBrowserAttributeEditorDlg::NewL(setAttMask, clearAttMask, recurse);
       
  1921         //TBool dlgResult = dlg->RunEditorLD();
       
  1922 
       
  1923         //iEngine->FileListContainer()->SetScreenLayoutL(iEngine->Settings().iDisplayMode);
       
  1924         //iEngine->FileListContainer()->SetNaviPaneTextL(iCurrentPath);        
       
  1925 //
       
  1926 //        if (dlgResult && (setAttMask > 0 || clearAttMask > 0))
       
  1927 //            {
       
  1928 //            for (TInt i=0; i<entries->Count(); i++)
       
  1929 //                {
       
  1930 //                TFileEntry fileEntry = entries->At(i);
       
  1931 //
       
  1932 //                // append the new command to the command array
       
  1933 //                if (fileEntry.iEntry.IsDir() && recurse)
       
  1934 //                    {
       
  1935 //                    AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
       
  1936 //                                          new(ELeave)CCommandParamsAttribs(fileEntry, setAttMask, clearAttMask, fileEntry.iEntry.iModified, CFileMan::ERecurse)
       
  1937 //                                         );
       
  1938 //                    }
       
  1939 //                else
       
  1940 //                    {
       
  1941 //                    AppendToCommandArrayL(EFileBrowserFileOpCommandAttribs,
       
  1942 //                                          new(ELeave)CCommandParamsAttribs(fileEntry, setAttMask, clearAttMask, fileEntry.iEntry.iModified, 0)
       
  1943 //                                         );
       
  1944 //                    }
       
  1945 //                }
       
  1946 //
       
  1947 //            // execute all operations
       
  1948 //            StartExecutingCommandsL(_L("Changing attributes"));
       
  1949 //            }
       
  1950 //
       
  1951 //        }
       
  1952 //
       
  1953 //    CleanupStack::PopAndDestroy(); //entries
       
  1954     }
  1821     }
  1955        
  1822        
  1956 // --------------------------------------------------------------------------------------------
  1823 // --------------------------------------------------------------------------------------------
  1957 
  1824 
  1958 void CFileBrowserFileUtils::SearchL()
  1825 void CFileBrowserFileUtils::SearchL()