Ignore:
Timestamp:
Jun 18, 2008, 11:03:59 PM (16 years ago)
Author:
dai_9181
Message:

FileManager周りをリファクタリング

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/abdev/src/ProjectManager/ProjectManager.cpp

    r651 r655  
    3333
    3434    //解析
    35     this->pobj_DBFileInfo=new CDBFileInfo();
     35    this->fileSystem.root.Clear();
    3636    bool isUseWindow = false;
    3737    for(i=0;;i++){
     
    200200                    }
    201201                    if(temporary[0]=='\0') break;
    202                     this->pobj_DBFileInfo->add(temporary,0);
     202                    this->fileSystem.root.files.push_back( ActiveBasic::PM::FM::File( temporary, 0 ) );
    203203
    204204                    if(buffer[i]=='\0') break;
     
    265265
    266266void SetStatusText(char *MenuText);
     267void MakeSourceListToProjectFile( const ActiveBasic::PM::FM::Folder &folder, char *buffer )
     268{
     269    BOOST_FOREACH( const ActiveBasic::PM::FM::Folder &childFolder, folder.folders )
     270    {
     271        MakeSourceListToProjectFile( childFolder, buffer );
     272    }
     273
     274    BOOST_FOREACH( const ActiveBasic::PM::FM::File &file, folder.files )
     275    {
     276        lstrcat( buffer, file.GetRelationalPath().c_str() );
     277        lstrcat( buffer, "\r\n" );
     278    }
     279}
     280void MakeIncludeListToProjectFile( const ActiveBasic::PM::FM::Folder &folder, char *buffer, bool isRoot )
     281{
     282    BOOST_FOREACH( const ActiveBasic::PM::FM::Folder &childFolder, folder.folders )
     283    {
     284        MakeIncludeListToProjectFile( childFolder, buffer, false );
     285    }
     286
     287    bool isFirst = true;
     288    BOOST_FOREACH( const ActiveBasic::PM::FM::File &file, folder.files )
     289    {
     290        if( isRoot && isFirst )
     291        {
     292            // メインファイルは除く
     293            isFirst = false;
     294            continue;
     295        }
     296
     297        sprintf(buffer+lstrlen(buffer),"#include \"%s\"\r\n",file.GetRelationalPath().c_str());
     298        lstrcpy(buffer+lstrlen(buffer),"_ClearNamespaceImported\r\n");
     299    }
     300}
    267301void Project::Save()
    268302{
    269     int i,i2,i3,WndNum;
     303    int i2,i3,WndNum;
    270304    char temporary[MAX_PATH],buffer[32767];
    271305    HWND hChild;
     
    280314        WndNum=GetWndNum(hChild);
    281315        if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
    282             if( MdiInfo[WndNum]->pMdiTextEdit->IsModified() ){
    283                 for(i=0;i<this->pobj_DBFileInfo->iNum;i++){
    284                     this->pobj_DBFileInfo->ppobj_FileInfo[i]->GetFullPath(temporary);
    285                     if(lstrcmpi(MdiInfo[WndNum]->path.c_str(),temporary)==0){
    286                         SaveDocument(hChild,NULL);
    287                         break;
    288                     }
     316            if( MdiInfo[WndNum]->pMdiTextEdit->IsModified() )
     317            {
     318                if( this->fileSystem.root.IsExistFile( MdiInfo[WndNum]->path ) )
     319                {
     320                    SaveDocument(hChild,NULL);
    289321                }
    290322            }
     
    342374    sprintf(buffer+i2,"#SOURCE\r\n");
    343375    i2+=lstrlen(buffer+i2);
    344     for(i=0;i<this->pobj_DBFileInfo->iNum;i++){
    345         sprintf(buffer+i2,"%s\r\n",this->pobj_DBFileInfo->ppobj_FileInfo[i]->GetPath().c_str());
    346         i2+=lstrlen(buffer+i2);
    347     }
     376    MakeSourceListToProjectFile( this->fileSystem.root, buffer );
     377    i2 = lstrlen( buffer );
    348378
    349379    //保存
     
    469499        i2+=lstrlen(buffer+i2);
    470500    }
    471     if(this->pobj_DBFileInfo->iNum>1){
     501
     502    {
    472503        lstrcpy(buffer+i2,"\r\n");
    473504        i2+=lstrlen(buffer+i2);
    474505        lstrcpy(buffer+i2,"'プロジェクト内のプログラム ファイル\r\n");
    475506        i2+=lstrlen(buffer+i2);
    476         for(i=1;i<this->pobj_DBFileInfo->iNum;i++){
    477             //メインファイルは含まない
    478             sprintf(buffer+i2,"#include \"%s\"\r\n",this->pobj_DBFileInfo->ppobj_FileInfo[i]->GetPath().c_str());
    479             i2+=lstrlen(buffer+i2);
    480             lstrcpy(buffer+i2,"_ClearNamespaceImported\r\n");
    481             i2+=lstrlen(buffer+i2);
    482         }
     507        MakeIncludeListToProjectFile( this->fileSystem.root, buffer, true );
     508        i2 = lstrlen(buffer);
    483509    }
    484510    if( !this->windowInfos.empty() )
     
    548574        hChild=GetNextWindow(hChild,GW_HWNDNEXT);
    549575        WndNum=GetWndNum(hCloseChild);
    550         if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType)){
    551             for(i=0;i<this->pobj_DBFileInfo->iNum;i++){
    552                 this->pobj_DBFileInfo->ppobj_FileInfo[i]->GetFullPath(temporary);
    553                 if(lstrcmpi(MdiInfo[WndNum]->path.c_str(),temporary)==0){
    554 
    555                     //変更フラグをオフにする
    556                     MdiInfo[WndNum]->pMdiTextEdit->UnModify();
    557 
    558                     SendMessage(hCloseChild,WM_CLOSE,0,0);
    559                     break;
    560                 }
     576        if(IS_DOCUMENT_TEXT(MdiInfo[WndNum]->DocType))
     577        {
     578            if( this->fileSystem.root.IsExistFile( MdiInfo[WndNum]->path ) )
     579            {
     580                //変更フラグをオフにする
     581                MdiInfo[WndNum]->pMdiTextEdit->UnModify();
     582
     583                SendMessage(hCloseChild,WM_CLOSE,0,0);
    561584            }
    562585        }
     
    593616
    594617    //ファイル情報のメモリを解放
    595     delete this->pobj_DBFileInfo;
     618    this->fileSystem.root.Clear();
    596619
    597620    //ブレークポイントのオブジェクトを解放
Note: See TracChangeset for help on using the changeset viewer.