root/_Search/BF_GUI_FilesPanel_Search.cpp

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. Action_Search_0
  2. Action_Search_1
  3. Message_AddItem
  4. Run_OnOtherVolume
  5. Search_CheckTextFile
  6. Run_OnBootVolume
  7. Search_InFileCheck
  8. Search_AddResult
  9. Run
  10. Close
  11. BF_GUI_FilesPanel_SearchDialog_Thread
  12. ReadyForClose
  13. MessageReceived
  14. AttachedToWindow

   1 /*
   2 ===============================================
   3 Project:        BeFar
   4 File:           BF_GUI_FilesPanel_Search.cpp
   5 Desc:           Methods for Search files
   6 Author:         Baza
   7 Created:        20.11.99
   8 Modified:       20.11.99
   9 ===============================================
  10 */
  11 #include <Volume.h>
  12 #include <Path.h>
  13 
  14 #include "BF_Dict.h"
  15 #include "BF_GUI_FilesPanel_Search.h"
  16 #include "BF_GUI_Func.h"
  17 #include "BF_GUI_WinMain.h"
  18 #include "BF_Roster.h"
  19 #include "BL_File.h"
  20 
  21 void
  22 BF_GUI_FilesPanel::Action_Search_0()    /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24         ///////////////////////////////
  25         /* prepare message */
  26         BMessage oMessage(BF_MSG_FILEPANEL_SEARCH_SETUP_CLOSE);
  27         oMessage.AddPointer("bf_focus",this);
  28         oMessage.AddPointer("bf_current_folder",Path().String());
  29         /* */
  30         BF_GUI_Func_PanelsEnable(false);
  31         /* make dialog */       
  32         BF_GUI_Dialog *poDialog = new BF_GUI_Dialog(BRect(0,0,300,0),
  33                 BF_DictAt(BF_DICT_SEARCH),"dialog",oMessage,BG_GUI_DIALOG_WINRESIZE_MOVE_CENTER);
  34         /* resize dialog */     
  35         BRect oRect;
  36         poDialog->LocalBounds(oRect);   
  37         
  38         /* name */
  39         poDialog->LocalBounds(oRect);   
  40         oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
  41         BF_GUI_ViewEdit_Create(oRect,BF_DictAt(BF_DICT_FILESEARCH_FILENAME),poDialog,"name","*",
  42                                         B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_NAVIGABLE);  
  43         oRect.top = oRect.bottom + 5;                                   
  44         /* text */      
  45         oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
  46         BF_GUI_ViewEdit_Create(oRect,BF_DictAt(BF_DICT_FILESEARCH_BYTEXT),poDialog,"text","",
  47                                         B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_NAVIGABLE);                                  
  48         oRect.top = oRect.bottom + 5;                                   
  49         // check "from current folder" //
  50         oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
  51         poDialog->AddChild(new BF_GUI_ViewCheck(oRect,"from_current_folder",
  52                 BF_DictAt(BF_DICT_FILESEARCH_FROMCURFOLDER),
  53                 false,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_NAVIGABLE));
  54         oRect.top = oRect.bottom + 5;                                   
  55         /* divider */                                           
  56         oRect.bottom = oRect.top;
  57         poDialog->AddChild(new BF_GUI_ViewFrame(oRect,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP));
  58         oRect.top = oRect.bottom + 5;
  59         /* comment */   
  60         oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
  61         poDialog->AddChild(new BF_GUI_ViewText(oRect,"comment",BF_DictAt(BF_DICT_FILESEARCH_ONVOLUMES)
  62                         ,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_WILL_DRAW,false));
  63         oRect.top = oRect.bottom+5;     
  64         /* volumes */
  65         {
  66                 BL_List                                 *ploItem = new BL_List();
  67                 BF_GUI_ViewMenu_Item    *poItem = NULL;
  68                 
  69                 /* prepare volume_list */
  70                 bool    bShowIcons = poSysSetup->MainStyle() & BF_SETUP_SEARCH_SETUP_VOLICONS;
  71                 
  72                 BF_NodeList loNodeVol;
  73                 BF_Roster_VolumeList(loNodeVol,
  74                         ( (bShowIcons)?BF_ROSTER_LOADVOLS_SICON:0 )             
  75                 );                      
  76                 BF_Volume *poNode;
  77                                         
  78                 for(int i=0;i<loNodeVol.CountItems();i++){
  79                         poNode = (BF_Volume*)loNodeVol.ItemAt(i);
  80                         ///
  81                         if(poNode->bBootVolume) poNode->sName="boot";
  82                         ///
  83                         poItem = new BF_GUI_ViewMenu_Item(poNode->sName.String(),poNode->sName.String() );
  84                         ploItem->AddItem(poItem);
  85                         if(poNode->poSIcon && bShowIcons)       poItem->poSIcon = new BBitmap( poNode->poSIcon );
  86                         //
  87                         poItem->bSelected = poNode->bBootVolume;
  88                 }                       
  89                 oRect.bottom = oRect.top+70;
  90                 BF_GUI_DlgView_VMenu *poMenu = new BF_GUI_DlgView_VMenu(oRect,"volumes",B_FOLLOW_ALL,
  91                         ploItem,BF_GUI_DLGVIEW_VMENU_SICON|BF_GUI_DLGVIEW_VMENU_CAN_SELECTING);
  92                 poDialog->AddChild(poMenu);
  93                 oRect.top = oRect.bottom+5;
  94         }               
  95         /* divider */                                           
  96         oRect.bottom = oRect.top;
  97         poDialog->AddChild(new BF_GUI_ViewFrame(oRect,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP));
  98         oRect.top = oRect.bottom + 5;   
  99         ///////////////////////////////         
 100         /* menu */
 101         poDialog->AddOkCancelMenu(oRect);               
 102         /* finish */
 103         poDialog->SetHeightFromLastChild();
 104         poDialog->MoveToCenter( poWinView );
 105         BF_GUI_Func_AddChildToMainView ( poDialog );    
 106 }
 107 
 108 void
 109 BF_GUI_FilesPanel::Action_Search_1(BMessage* po_Message)    /* [previous][next][first][last][top][bottom][index][help] */
 110 {
 111         ASSERT(po_Message);
 112         
 113         bool    bOk;
 114         ASSERT(B_OK==po_Message->FindBool(BF_GUI_DIALOG_MESSAGE_DATA_OK,&bOk));
 115         if(!bOk){       
 116                 BF_GUI_Func_PanelsEnable(true);
 117                 MakeFocus();    
 118                 return;
 119         }               
 120         
 121         // get other //
 122         
 123         const   char *pcFileName = po_Message->FindString("name");
 124         const   char *pcText = po_Message->FindString("text");
 125         bool    bFromCurrentFolder=false;
 126         ASSERT(B_OK==po_Message->FindBool("from_current_folder",&bFromCurrentFolder));;
 127         
 128         ASSERT(pcFileName && pcText);
 129         
 130         BRect oRect(poWinView->Bounds());
 131         oRect.left+=40;
 132         oRect.right-=40;
 133         oRect.top+=40;
 134         oRect.bottom-=40;
 135         BF_GUI_FilesPanel_SearchDialog *poDialog = new BF_GUI_FilesPanel_SearchDialog(oRect,
 136                 pcFileName,this,oPath);
 137         poDialog->sSearchText = pcText;
 138         poDialog->bFromCurrentFolder = bFromCurrentFolder;
 139         
 140         poDialog->oCurrentFolder.SetTo(po_Message->FindString("bf_current_folder"));
 141         
 142         // get volume_list//    
 143         BL_Get_SList_FromMessage(*po_Message,"volumes_sel",poDialog->lsVol);
 144                 
 145         poDialog->MoveToCenter( poWinView );                    
 146         BF_GUI_Func_AddChildToMainView ( poDialog );            
 147 }
 148 
 149 BF_GUI_FilesPanel_SearchDialog::BF_GUI_FilesPanel_SearchDialog(
 150         const BRect & o_Rect,
 151         const char *pc_SearchName,
 152         BF_GUI_FilesPanel *po_Panel,
 153         BF_Path  & o_Path)
 154 :BF_GUI_Dialog(o_Rect,BF_DictAt(BF_DICT_SEARCH),"search",BMessage(),BG_GUI_DIALOG_WINRESIZE_RESIZE_ALL)
 155 {
 156         oMessage.what = BF_MSG_FILEPANEL_SEARCH_CLOSE;
 157         oMessage.AddPointer("bf_focus",po_Panel);
 158         //
 159         sSearchName = pc_SearchName;            
 160         poPanel = po_Panel;
 161         idThreadQuery = 0;
 162         poSearch = NULL;
 163         oPath = o_Path;
 164         bFromCurrentFolder = false;
 165         //// nodes list ////
 166         BRect oRect;
 167         LocalBounds(oRect);
 168         oRect.bottom-=poSysSetup->oFontToolView.fHeight*3+5;
 169         BL_List *ploCol = new BL_List();
 170         float fWidthSize = poSysSetup->oFontToolView.oFont.StringWidth("1234567890121")+10;
 171         ploCol->AddItem(new BF_GUI_DlgView_VCMenu_Column(BF_DictAt(BF_DICT_NAME),oRect.Width()-fWidthSize));
 172         ploCol->AddItem(new BF_GUI_DlgView_VCMenu_Column(BF_DictAt(BF_DICT_NAME),fWidthSize));
 173         poList = new BF_GUI_DlgView_VCMenu(oRect,"results",B_FOLLOW_ALL,new BL_List(),BF_GUI_DLGVIEW_VMENU_SICON,
 174                 ploCol);
 175         AddChild(poList);
 176         /////
 177         oRect.top = oRect.bottom + 5;
 178         oRect.bottom = oRect.top+poSysSetup->oFontToolView.fHeight;
 179         poComment = new BF_GUI_ViewText(oRect,"comment",BF_DictAt(BF_DICT_FILESEARCH_PROGRESS),B_FOLLOW_BOTTOM|B_FOLLOW_LEFT_RIGHT,0,false);
 180         AddChild(poComment);
 181         /////
 182         BL_List *ploMenu = new BL_List();
 183         ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_GOTO),"go"));
 184         ploMenu->AddItem(new BF_GUI_ViewMenu_Item(BF_DictAt(BF_DICT_CANCEL),"cancel"));
 185         AddMenu(oRect,ploMenu); 
 186 }
 187 
 188 BF_GUI_FilesPanel_SearchDialog::~BF_GUI_FilesPanel_SearchDialog()
 189 {
 190         if(idThreadQuery) kill_thread(idThreadQuery);
 191 }
 192 
 193 BF_GUI_FilesPanel_Search::BF_GUI_FilesPanel_Search(BF_GUI_FilesPanel_SearchDialog *po_Dialog)
 194 {
 195         ASSERT(po_Dialog);
 196         poDialogParent = po_Dialog;
 197         bReqClose = false;
 198         {
 199                 LOCK_WIN();
 200                 oPath = poDialogParent->oPath;  
 201                 sSearchName = poDialogParent->sSearchName;
 202                 sSearchText =  poDialogParent->sSearchText;
 203                 poDialogParent->poSearch = this;
 204                 bFromCurrentFolder = poDialogParent->bFromCurrentFolder;
 205                 oCurrentFolder = poDialogParent->oCurrentFolder;
 206         }       
 207         oMsgAdd.what = BF_MSG_FILEPANEL_SEARCH_ADDITEM;
 208 }
 209 
 210 void
 211 BF_GUI_FilesPanel_Search::Message_AddItem(BF_GUI_ViewMenu_Item *po_MenuItem)    /* [previous][next][first][last][top][bottom][index][help] */
 212 {
 213         ASSERT(po_MenuItem);
 214         oMsgAdd.MakeEmpty();
 215         oMsgAdd.AddPointer("bf_Item",po_MenuItem);
 216         
 217         BMessenger      oMessenger(poDialogParent);     
 218         oMessenger.SendMessage(&oMsgAdd);               
 219 }
 220 
 221 void                                                    
 222 BF_GUI_FilesPanel_Search::Run_OnOtherVolume(const char *pc_Path)    /* [previous][next][first][last][top][bottom][index][help] */
 223 {
 224         // load nodes //
 225         ASSERT(pc_Path);
 226         BF_Path         oPath(pc_Path);
 227         BF_NodeList loNode;
 228         BL_String       s;
 229         if(!BF_Roster_LoadNodeList(oPath,loNode,BF_ROSTER_LOAD_NODE_ALL_REAL)) return;
 230 
 231         BF_Node *poNode=NULL;
 232         
 233         Debug_Info(pc_Path);
 234 
 235         //scan files and links //       
 236         for(int i=0;i<loNode.CountItems();i++){
 237                 poNode = loNode.NodeAt(i);
 238                 
 239                 // drop links //
 240                 if(poNode->bLink && poNode->iType==BF_NODE_TYPE_DIR) continue;
 241                 
 242                 // check name //
 243                 if(poNode->CheckByMask(sSearchName.String())){  
 244                         s = pc_Path;
 245                         s<<"/";
 246                         s<<poNode->sName;
 247                         Search_AddResult(poNode,s);                     
 248                 }
 249                 // is it folder ? //
 250                 if(poNode->iType==BF_NODE_TYPE_DIR){
 251                         s = pc_Path;
 252                         s<<"/";
 253                         s<<poNode->sName;
 254                         Run_OnOtherVolume(s.String());
 255                 }
 256                 //
 257                 loNode.DeleteItem(poNode);
 258                 i--;
 259         }
 260 }
 261 
 262 // open file as text_file and check for text inside //
 263 bool
 264 BF_GUI_FilesPanel_Search::Search_CheckTextFile(const char *pc_PathName,BL_String & s1)    /* [previous][next][first][last][top][bottom][index][help] */
 265 {
 266         BL_File         oFile(pc_PathName,B_READ_ONLY);
 267         if(B_OK!=oFile.InitCheck()) return false;
 268         while(B_OK==oFile.ReadString(&s1)){
 269                 if(bReqClose) return false;
 270                 if(s1.FindFirst(poDialogParent->sSearchText.String())>=0){
 271                         return true;
 272                 }
 273         }
 274         return false;
 275 }
 276 
 277 void                                                    
 278 BF_GUI_FilesPanel_Search::Run_OnBootVolume()    /* [previous][next][first][last][top][bottom][index][help] */
 279 {               
 280         status_t uRes;
 281         BL_String s,s1,s2;
 282         
 283         // init query //
 284         oQuery.Clear();
 285         
 286         s="/boot";
 287         // set volume //
 288         {
 289                 s = (const char*)oPath.GetVolume(true);
 290                 entry_ref uRef;
 291                 uRes = BF_Roster_LoadEntryRef(s.String(),uRef);
 292                 if(uRes!=B_OK){
 293                         BF_Dialog_Alert_Sep_Error(uRes,poDialogParent);
 294                         return;
 295                 }
 296                 BVolume oVol(uRef.device);
 297                 uRes = oVol.InitCheck();
 298                 if(uRes!=B_OK){
 299                         BF_Dialog_Alert_Sep_Error(uRes,poDialogParent);         
 300                         return;
 301                 }
 302                 uRes = oQuery.SetVolume(&oVol);
 303                 if(uRes!=B_OK){
 304                         BF_Dialog_Alert_Sep_Error(uRes,poDialogParent);
 305                         return;
 306                 }
 307         }                               
 308         // set filter by name //
 309         oQuery.PushAttr("name");
 310         oQuery.PushString(sSearchName.String());        
 311         oQuery.PushOp(B_EQ);
 312         // start search
 313         uRes =  oQuery.Fetch();
 314         if(B_OK!=uRes){
 315                 BF_Dialog_Alert_Sep_Error(uRes,poDialogParent);         
 316                 return;
 317         }
 318         //
 319         BEntry          oEntry,oEntryParent;
 320         BPath           oPath;
 321         char            pc[500];
 322         BF_Node         oNode;
 323         
 324         
 325         while(B_OK==oQuery.GetNextEntry(&oEntry)){
 326                 oEntry.GetName(pc);
 327                 s1 = pc;                
 328                 oEntry.GetParent(&oEntryParent);
 329                 oPath.SetTo(&oEntryParent);
 330                 s = oPath.Path();
 331                 s<<"/";
 332                 s<<s1;
 333                 // check for current_folder
 334                 if(bFromCurrentFolder){
 335                         if(!oCurrentFolder.InFolder(oPath.Path())) continue;
 336                 }
 337                 //
 338                 BF_Node *poNode = BF_Roster_LoadNode(oPath.Path(),s1.String(),BF_ROSTER_LOAD_SICON);
 339                 // check for text_string //
 340                 if(sSearchText!=""){
 341                         oNode.Set(poNode,true);
 342                         DELETE(poNode);
 343                         poNode = &oNode;
 344                         // check for type=file
 345                         if(poNode->iType!=BF_NODE_TYPE_FILE) continue;
 346                         // update info 
 347                         if(poDialogParent->poComment){
 348                                 s2=BF_DictAt(BF_DICT_FILESEARCH_PROGRESS);
 349                                 s2<<s1;
 350                                 LOCK_WIN();
 351                                 poDialogParent->poComment->sTitle = s2;
 352                                 poDialogParent->poComment->Draw(poDialogParent->poComment->Bounds());
 353                         }
 354                         
 355                         // open file as text_file
 356                         BL_File         oFile(s.String(),B_READ_ONLY);
 357                         bool            bFounded=false;
 358                         if(B_OK!=oFile.InitCheck()) continue;
 359                         while(B_OK==oFile.ReadString(&s1)){
 360                                 if(bReqClose) return;
 361                                 if(s1.FindFirst(poDialogParent->sSearchText.String())>=0){
 362                                         bFounded = true;
 363                                         break;
 364                                 }
 365                         }
 366                         if(!bFounded)   continue;
 367                         // update info 
 368                         if(poDialogParent->poComment){
 369                                 LOCK_WIN();
 370                                 poDialogParent->poComment->sTitle = BF_DictAt(BF_DICT_FILESEARCH_PROGRESS);
 371                                 poDialogParent->poComment->Draw(poDialogParent->poComment->Bounds());
 372                         }
 373                 }
 374                 ///
 375                 if(bReqClose) return;           
 376                 // add item to list ///         
 377                 Search_AddResult(poNode,s);
 378                 /*
 379                 poItem = new BF_GUI_ViewMenu_Item(s.String(),s.String(),NULL,poNode?new BBitmap(poNode->poSIcon):NULL);         
 380                 switch(poNode->iType){
 381                 case BF_NODE_TYPE_DIR:
 382                         s="Dir";
 383                         break;
 384                 default:                        
 385                         s = poNode->iSize;
 386                 }
 387                 poItem->loColItem.AddItem(new BF_GUI_ViewMenu_Item(s.String(),""));
 388                 // send add_message to parent
 389                 Message_AddItem(poItem);
 390                 */
 391                 // delete node //
 392                 if(poNode!=&oNode)      DELETE(poNode);
 393                 //                              
 394         }
 395         return; 
 396         
 397 }
 398 
 399 bool
 400 BF_GUI_FilesPanel_Search::Search_InFileCheck(BF_Node *po_Node,BL_String &s_FullPath)    /* [previous][next][first][last][top][bottom][index][help] */
 401 {
 402         ASSERT(po_Node);
 403         
 404         if(sSearchText=="") return true;        
 405         if(po_Node->iType!=BF_NODE_TYPE_FILE) return false;
 406 
 407         BL_String s;    
 408         
 409         // update info 
 410         if(poDialogParent->poComment){
 411 
 412                 s=BF_DictAt(BF_DICT_FILESEARCH_PROGRESS);
 413                 s<<po_Node->sName;
 414                 LOCK_WIN();
 415                 poDialogParent->poComment->sTitle = s;
 416                 poDialogParent->poComment->Draw(poDialogParent->poComment->Bounds());
 417         }
 418         
 419         ////////
 420 
 421         // open file as text_file
 422         BL_File         oFile(s_FullPath.String(),B_READ_ONLY);
 423         bool            bFounded=false;
 424         if(B_OK!=oFile.InitCheck()) return false;
 425         while(B_OK==oFile.ReadString(&s)){
 426                 if(bReqClose) return false;
 427                 if(s.FindFirst(poDialogParent->sSearchText.String())>=0){
 428                         bFounded = true;
 429                         break;
 430                 }
 431         }       
 432         // update info 
 433         if(poDialogParent->poComment){  
 434                 LOCK_WIN();
 435                 poDialogParent->poComment->sTitle = BF_DictAt(BF_DICT_FILESEARCH_PROGRESS);
 436                 poDialogParent->poComment->Draw(poDialogParent->poComment->Bounds());
 437         }
 438         return  bFounded;
 439 }
 440 
 441 void
 442 BF_GUI_FilesPanel_Search::Search_AddResult(BF_Node *po_Node,BL_String &s_FullPath)    /* [previous][next][first][last][top][bottom][index][help] */
 443 {
 444         ASSERT(po_Node);
 445         
 446         if(!po_Node->poSIcon) BF_Roster_ReloadNode(s_FullPath.String(),po_Node,BF_ROSTER_LOAD_SICON,true);
 447         
 448         if(!Search_InFileCheck(po_Node,s_FullPath)) return;
 449         
 450         // add item to list ///         
 451         BF_GUI_ViewMenu_Item *poItem = new BF_GUI_ViewMenu_Item(s_FullPath.String(),s_FullPath.String(),
 452                 (po_Node && po_Node->poSIcon)?new BBitmap(po_Node->poSIcon):NULL);              
 453         switch(po_Node->iType){
 454         case BF_NODE_TYPE_DIR:
 455                 s_FullPath=BF_DictAt(BF_DICT_DIR);
 456                 break;
 457         default:                        
 458                 s_FullPath = po_Node->iSize;
 459         }
 460         poItem->loColItem.AddItem(new BF_GUI_ViewMenu_Item(s_FullPath.String(),""));
 461         // send add_message to parent
 462         Message_AddItem(poItem);
 463 }
 464 
 465 void                                                    
 466 BF_GUI_FilesPanel_Search::Run()    /* [previous][next][first][last][top][bottom][index][help] */
 467 {                       
 468         // scan volumes //      
 469         for(int iVol=0;iVol<poDialogParent->lsVol.CountItems();iVol++){         
 470                 BL_String       *ps = poDialogParent->lsVol.StringAt(iVol);
 471                 ASSERT(ps);
 472                 /*              
 473                 BF_Volume       oVol;           
 474                 if(!oVol.Load(ps->String(),BF_ROSTER_LOAD_NORMAL)) continue;            
 475                 if(oVol.bBootVolume){
 476                 */
 477                 
 478                 if(*ps=="boot"){
 479                         Run_OnBootVolume();
 480                 }else{                  
 481                         BL_String s("/");
 482                         s<<*ps;
 483                         Run_OnOtherVolume(s.String());
 484                 }
 485         }               
 486         
 487         // search in boot_folder
 488         //Run_BootVolume();
 489         // searh in ... 
 490         /// list ////   
 491 }
 492 
 493 void                                                    
 494 BF_GUI_FilesPanel_Search::Close()    /* [previous][next][first][last][top][bottom][index][help] */
 495 {
 496         oMsgAdd.what = BF_MSG_FILEPANEL_SEARCH_THREAD_FINISHED;
 497         
 498         BMessenger      oMessenger(poDialogParent);     
 499         oMessenger.SendMessage(&oMsgAdd);               
 500 }
 501 
 502 
 503 int32 
 504 BF_GUI_FilesPanel_SearchDialog_Thread(void *data)    /* [previous][next][first][last][top][bottom][index][help] */
 505 {       
 506         BF_GUI_FilesPanel_SearchDialog *poDialog = (BF_GUI_FilesPanel_SearchDialog*)data;       
 507         //
 508         BF_GUI_FilesPanel_Search oSearch(poDialog);
 509         oSearch.Run();                          
 510         oSearch.Close();
 511         return 0;
 512 }
 513 
 514 bool                                    
 515 BF_GUI_FilesPanel_SearchDialog::ReadyForClose()    /* [previous][next][first][last][top][bottom][index][help] */
 516 {
 517         if(poSearch) poSearch->bReqClose = true;
 518         return 0==idThreadQuery;        
 519 }
 520 
 521 void
 522 BF_GUI_FilesPanel_SearchDialog::MessageReceived(BMessage* po_Message)    /* [previous][next][first][last][top][bottom][index][help] */
 523 {
 524         switch(po_Message->what){       
 525         case BF_MSG_FILEPANEL_SEARCH_THREAD_FINISHED:{
 526                 idThreadQuery = 0;
 527                 poSearch = NULL;
 528                 
 529                 BL_String s;
 530                 s = BF_DictAt(BF_DICT_FILESEARCH_FOUNDED);
 531                 s<<" ";
 532                 s<<poList->ploMenu->CountItems();
 533                 s<<" ";
 534                 s<<BF_DictAt(BF_DICT_FILESEARCH_FILES);
 535                 poComment->sTitle = s;
 536                 poComment->Draw(poComment->Bounds());
 537                 break;}
 538         case BF_MSG_FILEPANEL_SEARCH_ADDITEM:{
 539                 BF_GUI_ViewMenu_Item *poItem = NULL;            
 540                 ASSERT(B_OK==po_Message->FindPointer("bf_Item",(void**)&poItem) && poItem);
 541                 
 542                 poList->AddItem(poItem);
 543                 /*
 544                 poList->ploMenu->AddItem(poItem);
 545                 if(poList->ploMenu->CountItems()<=poList->iPageSize){
 546                         poList->Draw(poList->Bounds());
 547                         if(poList->iNavCursorIndex<0) poList->NavChangeCursor(0,BF_GUI_TOOLMENU_MOVE_POS);
 548                 }
 549                 */
 550                 // update comment //
 551                 {
 552                         BL_String s;
 553                         s=BF_DictAt(BF_DICT_FILESEARCH_FOUNDED);
 554                         s<<" ";
 555                         s<<poList->ploMenu->CountItems();
 556                         s<<" ";
 557                         s<<BF_DictAt(BF_DICT_FILESEARCH_FILES);
 558                         poComment->sTitle = s;
 559                         poComment->Draw(poComment->Bounds());
 560                 }
 561                 //
 562                 break;}
 563         default:
 564                 BF_GUI_Dialog::MessageReceived(po_Message);
 565         }
 566 }
 567 
 568 void                                    
 569 BF_GUI_FilesPanel_SearchDialog::AttachedToWindow(void)    /* [previous][next][first][last][top][bottom][index][help] */
 570 {
 571         BF_GUI_Dialog::AttachedToWindow();
 572         //////////////
 573         idThreadQuery = spawn_thread(BF_GUI_FilesPanel_SearchDialog_Thread,"search",B_THREAD_SUSPENDED,(void*)this);    
 574         ASSERT(idThreadQuery>0,"can`t start search_thread\n");  
 575         ASSERT(B_OK==resume_thread(idThreadQuery));             
 576         set_thread_priority(idThreadQuery,1);                   
 577         //
 578 }

/* [previous][next][first][last][top][bottom][index][help] */