Logo Search packages:      
Sourcecode: qtsmbstatus version File versions  Download package

void main_windows::search ( T_Item  typeOfSearch,
const QString &  str,
T_Direction  direction = to_first 
) [private]

Search item.

Parameters:
typeOfSearch see T_Item
str string to search
direction see T_direction
See also:
T_Item T_direction selectItem

Definition at line 604 of file main_windows.cpp.

References nextItem(), selectItem(), and service::TypeOfService.

Referenced by AllSearchSlot(), FileSearchSlot(), MachineSearchSlot(), NextSlot(), ShareSearchSlot(), and UserSearchSlot().

{
      debugQt("main_windows::search()");
      if (str.isEmpty()) return;
      searchNextAction->setEnabled ( true );
      currentSearchStr=str;
      currentSearchItem=typeOfSearch;
      service * currentItemService;
      user * currentItemUser;
      machine * currentItemMachine;
      Q3PtrList<Q3ListViewItem> list;
      bool noText=false;

      if (direction==to_next)
      {
            // check if exist
            FindItem=listView->currentItem();
            if (FindItem)
            {
                  FindItem=nextItem(FindItem); // find next
                  if (!FindItem) return;
            }
            else direction=to_first; // go to begin
      }

      if (direction==to_first)
      {
            FindItem=dynamic_cast<server *>(listView->firstChild());
            if (!FindItem) return; // nothing
      }

      while (FindItem)
      {

            listView->setCurrentItem(FindItem);
            // find string char
            FindItem=listView->findItem ( str, 0,Q3ListView::Contains );

            if (!FindItem) noText=true;

            if (!list.containsRef (FindItem))
                  list.append(FindItem);
            else noText=true;

            if (noText==true)
            {
                  listView->clearSelection ();
                  statusBar ()->showMessage  ( tr("Text not found."), 2000 );
                  QApplication::beep ();
                  searchNextAction->setEnabled ( false );
                  return;
            }

            switch (typeOfSearch)
            {
                  case T_All:
                        selectItem(FindItem);
                        return; break;
                  case T_Machine:
                        currentItemMachine= dynamic_cast<machine *>(FindItem);
                        if (currentItemMachine)
                        {
                              selectItem(currentItemMachine);
                              return;
                        }
                        break;
                  case T_User:
                        currentItemUser= dynamic_cast<user *>(FindItem);
                        if (currentItemUser)
                        {
                              selectItem(currentItemUser);
                              return;
                        }
                        break;
                  case T_Share:
                        currentItemService= dynamic_cast<service *>(FindItem);
                        if (currentItemService)
                        {
                              // if search share
                              if  (currentItemService->TypeOfService==service::Tshare)
                              {
                                    selectItem(currentItemService);
                                    return;
                              }
                        }
                        break;
                  case T_File:
                        currentItemService= dynamic_cast<service *>(FindItem);
                        if (currentItemService)
                        {
                              // if search file
                              if  (currentItemService->TypeOfService==service::Tlockedfile)
                              {
                                    selectItem(currentItemService);
                                    return;
                              }
                        }
                        break;
                  default: // nothing
                        return; break;
            }
            FindItem=nextItem(FindItem); // find next
      }
}


Generated by  Doxygen 1.6.0   Back to index