Show
Ignore:
Timestamp:
03/15/08 06:23:52 (9 months ago)
Author:
flynd
Message:

Let user menu and event dialog user same enum for event type so we don't have to convert between them.

Location:
trunk/qt4-gui/src/core
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/core/gui-defines.h

    r6001 r6097  
    4747{ 
    4848 
    49 enum UserFunctions { 
    50   mnuUserView, 
    51   mnuUserSendMsg, 
    52   mnuUserSendUrl, 
    53   mnuUserSendChat, 
    54   mnuUserSendFile, 
    55   mnuUserSendContact, 
    56   mnuUserSendSms, 
    57   mnuUserGeneral, 
     49// Event types, used by event dialog but placed here since callers to 
     50//   LicqGui::showEventDialog also needs them 
     51enum EventType 
     52{ 
     53  MessageEvent, 
     54  UrlEvent, 
     55  ChatEvent, 
     56  FileEvent, 
     57  ContactEvent, 
     58  SmsEvent, 
    5859}; 
     60 
     61// Constant used to select opening page when calling LicqGui::showInfoDialog 
     62// Leave it for now as the fcn parameter may be needed when user info dialog has been remade 
     63static const int mnuUserGeneral = 0; 
    5964 
    6065} // namespace LicqQtGui 
  • trunk/qt4-gui/src/core/licqgui.cpp

    r6096 r6097  
    840840} 
    841841 
    842 UserEventCommon* LicqGui::showEventDialog(int fcn, QString id, unsigned long ppid, int convoId) 
     842UserViewEvent* LicqGui::showViewEventDialog(QString id, unsigned long ppid) 
    843843{ 
    844844  if (id.isEmpty() || ppid == 0) 
    845845    return NULL; 
    846846 
    847   switch (fcn) 
    848   { 
    849     case mnuUserView: 
     847  for (int i = 0; i < myUserViewList.size(); ++i) 
     848  { 
     849    UserViewEvent* e = myUserViewList.at(i); 
     850    if (id.compare(e->id(), Qt::CaseInsensitive) == 0 && e->ppid() == ppid) 
     851    { 
     852      e->show(); 
     853      if (Config::Chat::instance()->autoFocus() && 
     854          (!qApp->activeWindow() || !qApp->activeWindow()->inherits("UserEventCommon"))) 
    850855      { 
    851         for (int i = 0; i < myUserViewList.size(); ++i) 
     856        e->raise(); 
     857        e->activateWindow(); 
     858      } 
     859      return e; 
     860    } 
     861  } 
     862 
     863  UserViewEvent* e = new UserViewEvent(id, ppid); 
     864  connect(e, SIGNAL(viewUrl(QWidget*, QString)), SLOT(viewUrl(QWidget*, QString))); 
     865 
     866  e->show(); 
     867  userEventFinished(id, ppid); 
     868  connect(e, SIGNAL(finished(QString, unsigned long)), SLOT(userEventFinished(QString, unsigned long))); 
     869  myUserViewList.append(e); 
     870 
     871  return e; 
     872} 
     873 
     874UserEventCommon* LicqGui::showEventDialog(int fcn, QString id, unsigned long ppid, int convoId) 
     875{ 
     876  if (id.isEmpty() || ppid == 0) 
     877    return NULL; 
     878 
     879  if (Config::Chat::instance()->msgChatView()) 
     880  { 
     881    for (int i = 0; i < myUserSendList.size(); ++i) 
     882    { 
     883      UserSendCommon* e = myUserSendList.at(i); 
     884 
     885      // Protocols (MSN only atm) that support convo ids are differentiated from 
     886      // the icq protocol because the convo id will be the server socket.. which does 
     887      // not meet the requirement that convo ids must be unique for each conversation. 
     888      if ( ((ppid == MSN_PPID && e->ppid() == MSN_PPID) && (e->isUserInConvo(id) || 
     889              (e->convoId() == (unsigned long)(convoId) && e->convoId() != (unsigned long)(-1)))) || 
     890          (e->isUserInConvo(id) && e->ppid() == ppid)) 
     891      { 
     892        //if (!e->FindUserInConvo(id)) 
     893        //  e->convoJoin(id); 
     894 
     895        if (myUserEventTabDlg && myUserEventTabDlg->tabExists(e)) 
    852896        { 
    853           UserViewEvent* e = myUserViewList.at(i); 
    854           if (id.compare(e->id(), Qt::CaseInsensitive) == 0 && e->ppid() == ppid) 
     897          myUserEventTabDlg->show(); 
     898          if (Config::Chat::instance()->autoFocus()) 
    855899          { 
    856             e->show(); 
    857             if (Config::Chat::instance()->autoFocus() && 
    858                 (!qApp->activeWindow() || !qApp->activeWindow()->inherits("UserEventCommon"))) 
    859             { 
    860               e->raise(); 
    861               e->activateWindow(); 
    862             } 
    863             return e; 
     900            myUserEventTabDlg->selectTab(e); 
     901            myUserEventTabDlg->raise(); 
     902            myUserEventTabDlg->activateWindow(); 
    864903          } 
    865904        } 
    866       } 
    867       break; 
    868     case mnuUserSendMsg: 
    869     case mnuUserSendUrl: 
    870     case mnuUserSendChat: 
    871     case mnuUserSendFile: 
    872     case mnuUserSendContact: 
    873     case mnuUserSendSms: 
    874       { 
    875         if (!Config::Chat::instance()->msgChatView()) 
    876           break; 
    877  
    878         for (int i = 0; i < myUserSendList.size(); ++i) 
     905        else 
    879906        { 
    880           UserSendCommon* e = myUserSendList.at(i); 
    881  
    882           // Protocols (MSN only atm) that support convo ids are differentiated from 
    883           // the icq protocol because the convo id will be the server socket.. which does 
    884           // not meet the requirement that convo ids must be unique for each conversation. 
    885           if ( ((ppid == MSN_PPID && e->ppid() == MSN_PPID) && (e->isUserInConvo(id) || 
    886                   (e->convoId() == (unsigned long)(convoId) && e->convoId() != (unsigned long)(-1)))) || 
    887               (e->isUserInConvo(id) && e->ppid() == ppid)) 
     907          e->show(); 
     908          if (Config::Chat::instance()->autoFocus() && 
     909              (!qApp->activeWindow() || !qApp->activeWindow()->inherits("UserEventCommon"))) 
    888910          { 
    889             //if (!e->FindUserInConvo(id)) 
    890             //  e->convoJoin(id); 
    891  
    892             if (myUserEventTabDlg && myUserEventTabDlg->tabExists(e)) 
    893             { 
    894               myUserEventTabDlg->show(); 
    895               if (Config::Chat::instance()->autoFocus()) 
    896               { 
    897                 myUserEventTabDlg->selectTab(e); 
    898                 myUserEventTabDlg->raise(); 
    899                 myUserEventTabDlg->activateWindow(); 
    900               } 
    901             } 
    902             else 
    903             { 
    904               e->show(); 
    905               if (Config::Chat::instance()->autoFocus() && 
    906                   (!qApp->activeWindow() || !qApp->activeWindow()->inherits("UserEventCommon"))) 
    907               { 
    908                 e->raise(); 
    909                 e->activateWindow(); 
    910               } 
    911             } 
    912             // Make the existing event dialog change to the new event type 
    913             switch (fcn) 
    914             { 
    915               case mnuUserSendMsg: e->changeEventType(ET_MESSAGE); break; 
    916               case mnuUserSendUrl: e->changeEventType(ET_URL); break; 
    917               case mnuUserSendChat: e->changeEventType(ET_CHAT); break; 
    918               case mnuUserSendFile: e->changeEventType(ET_FILE); break; 
    919               case mnuUserSendContact: e->changeEventType(ET_CONTACT); break; 
    920               case mnuUserSendSms: e->changeEventType(ET_SMS); break; 
    921             } 
    922             return e; 
     911            e->raise(); 
     912            e->activateWindow(); 
    923913          } 
    924914        } 
     915        // Make the existing event dialog change to the new event type 
     916        e->changeEventType(fcn); 
     917        return e; 
    925918      } 
    926     default: 
    927       break; 
     919    } 
    928920  } 
    929921 
     
    954946  switch (fcn) 
    955947  { 
    956     case mnuUserView: 
    957       { 
    958         e = new UserViewEvent(id, ppid); 
    959         break; 
    960       } 
    961     case mnuUserSendMsg: 
    962       { 
    963         e = new UserSendMsgEvent(id, ppid, parent); 
    964         break; 
    965       } 
    966     case mnuUserSendUrl: 
    967       { 
    968         e = new UserSendUrlEvent(id, ppid, parent); 
    969         break; 
    970       } 
    971     case mnuUserSendChat: 
    972       { 
    973         e = new UserSendChatEvent(id, ppid, parent); 
    974         break; 
    975       } 
    976     case mnuUserSendFile: 
    977       { 
    978         e = new UserSendFileEvent(id, ppid, parent); 
    979         break; 
    980       } 
    981     case mnuUserSendContact: 
    982       { 
    983         e = new UserSendContactEvent(id, ppid, parent); 
    984         break; 
    985       } 
    986     case mnuUserSendSms: 
    987       { 
    988         e = new UserSendSmsEvent(id, ppid, parent); 
    989         break; 
    990       } 
     948    case MessageEvent: 
     949      e = new UserSendMsgEvent(id, ppid, parent); 
     950      break; 
     951 
     952    case UrlEvent: 
     953      e = new UserSendUrlEvent(id, ppid, parent); 
     954      break; 
     955 
     956    case ChatEvent: 
     957      e = new UserSendChatEvent(id, ppid, parent); 
     958      break; 
     959 
     960    case FileEvent: 
     961      e = new UserSendFileEvent(id, ppid, parent); 
     962      break; 
     963 
     964    case ContactEvent: 
     965      e = new UserSendContactEvent(id, ppid, parent); 
     966      break; 
     967 
     968    case SmsEvent: 
     969      e = new UserSendSmsEvent(id, ppid, parent); 
     970      break; 
     971 
    991972    default: 
    992973      gLog.Warn("%sunknown callFunction() fcn: %d\n", L_WARNxSTR, fcn); 
     
    996977  connect(e, SIGNAL(viewUrl(QWidget*, QString)), SLOT(viewUrl(QWidget*, QString))); 
    997978 
    998   if (Config::Chat::instance()->tabbedChatting() && fcn != mnuUserView) 
     979  if (Config::Chat::instance()->tabbedChatting()) 
    999980  { 
    1000981    myUserEventTabDlg->addTab(e); 
     
    1018999  // there might be more than one send window open 
    10191000  // make sure we only remember one, or it will get complicated 
    1020   if (fcn == mnuUserView) 
    1021   { 
    1022     userEventFinished(id, ppid); 
    1023     connect(e, SIGNAL(finished(QString, unsigned long)), SLOT(userEventFinished(QString, unsigned long))); 
    1024     myUserViewList.append(static_cast<UserViewEvent*>(e)); 
    1025   } 
    1026   else 
    1027   { 
    1028     sendEventFinished(id, ppid); 
    1029     connect(e, SIGNAL(finished(QString, unsigned long)), SLOT(sendEventFinished(QString, unsigned long))); 
    1030     myUserSendList.append(static_cast<UserSendCommon*>(e)); 
    1031   } 
     1001  sendEventFinished(id, ppid); 
     1002  connect(e, SIGNAL(finished(QString, unsigned long)), SLOT(sendEventFinished(QString, unsigned long))); 
     1003  myUserSendList.append(static_cast<UserSendCommon*>(e)); 
     1004 
    10321005  return e; 
    10331006} 
     
    10431016void LicqGui::showMessageDialog(QString id, unsigned long ppid) 
    10441017{ 
    1045   showEventDialog(mnuUserSendMsg, id, ppid); 
     1018  showEventDialog(MessageEvent, id, ppid); 
    10461019} 
    10471020 
    10481021void LicqGui::sendMsg(QString id, unsigned long ppid, const QString& message) 
    10491022{ 
    1050   UserSendCommon* event = dynamic_cast<UserSendCommon*>(showEventDialog(mnuUserSendMsg, id, ppid)); 
     1023  UserSendCommon* event = dynamic_cast<UserSendCommon*>(showEventDialog(MessageEvent, id, ppid)); 
    10511024  if (event == 0) 
    10521025    return; 
     
    10571030void LicqGui::sendFileTransfer(QString id, unsigned long ppid, const QString& filename, const QString& description) 
    10581031{ 
    1059   UserSendFileEvent* event = dynamic_cast<UserSendFileEvent*>(showEventDialog(mnuUserSendFile, id, ppid)); 
     1032  UserSendFileEvent* event = dynamic_cast<UserSendFileEvent*>(showEventDialog(FileEvent, id, ppid)); 
    10601033  if (event == 0) 
    10611034    return; 
     
    10661039void LicqGui::sendChatRequest(QString id, unsigned long ppid) 
    10671040{ 
    1068   UserSendCommon* event = dynamic_cast<UserSendCommon*>(showEventDialog(mnuUserSendChat, id, ppid)); 
     1041  UserSendCommon* event = dynamic_cast<UserSendCommon*>(showEventDialog(ChatEvent, id, ppid)); 
    10691042  if (event == 0) 
    10701043    return; 
     
    11471120  // set default function to read or send depending on whether or not 
    11481121  // there are new messages 
    1149   int fcn = (u->NewMessages() == 0 ? mnuUserSendMsg : mnuUserView); 
    1150   if (fcn == mnuUserView && Config::Chat::instance()->msgChatView()) 
     1122  bool send = (u->NewMessages() == 0); 
     1123  if (!send && Config::Chat::instance()->msgChatView()) 
    11511124  { 
    11521125    // if one of the new events is a msg in chatview mode, 
     
    11571130      { 
    11581131        convoId = u->EventPeek(i)->ConvoId(); 
    1159         fcn = mnuUserSendMsg; 
     1132        send = true; 
    11601133        break; 
    11611134      } 
     
    11631136  gUserManager.DropUser(u); 
    11641137 
     1138  if (!send) 
     1139  { 
     1140    // Messages pending and not open in chatview mode so open view event dialog 
     1141    showViewEventDialog(id, ppid); 
     1142    return; 
     1143  } 
     1144 
    11651145  // See if the clipboard contains a url 
    1166   if (fcn == mnuUserSendMsg && Config::Chat::instance()->sendFromClipboard()) 
     1146  if (Config::Chat::instance()->sendFromClipboard()) 
    11671147  { 
    11681148    QClipboard* clip = QApplication::clipboard(); 
     
    11791159    if (c.left(5) == "http:" || c.left(4) == "ftp:" || c.left(6) == "https:") 
    11801160    { 
    1181       UserEventCommon* ec = showEventDialog(mnuUserSendUrl, id, ppid); 
     1161      UserEventCommon* ec = showEventDialog(UrlEvent, id, ppid); 
    11821162      if (!ec || ec->objectName() != "UserSendUrlEvent") 
    11831163        return; 
     
    11911171    else if (c.left(5) == "file:" || c.left(1) == "/") 
    11921172    { 
    1193       UserEventCommon* ec = showEventDialog(mnuUserSendFile, id, ppid); 
     1173      UserEventCommon* ec = showEventDialog(FileEvent, id, ppid); 
    11941174      if (!ec || ec->objectName() != "UserSendFileEvent") 
    11951175        return; 
     
    12081188  } 
    12091189 
    1210   showEventDialog(fcn, id, ppid, convoId); 
     1190  showEventDialog(MessageEvent, id, ppid, convoId); 
    12111191} 
    12121192 
     
    12231203 
    12241204    if (nNumMsg > 0) 
    1225       showEventDialog(mnuUserView, id, (*_ppit)->PPID()); 
     1205      showViewEventDialog(id, (*_ppit)->PPID()); 
    12261206  } 
    12271207  FOR_EACH_PROTO_PLUGIN_END 
     
    13051285        { 
    13061286          gUserManager.DropUser(u); 
    1307           showEventDialog(mnuUserSendMsg, id, ppid, u->EventPeek(i)->ConvoId()); 
     1287          showEventDialog(MessageEvent, id, ppid, u->EventPeek(i)->ConvoId()); 
    13081288          return; 
    13091289        } 
     
    13121292    } 
    13131293 
    1314     showEventDialog(mnuUserView, id, ppid); 
     1294    showViewEventDialog(id, ppid); 
    13151295  } 
    13161296} 
     
    15421522 
    15431523            if (bCallSendMsg) 
    1544               showEventDialog(mnuUserSendMsg, id, ppid, sig->CID()); 
     1524              showEventDialog(MessageEvent, id, ppid, sig->CID()); 
    15451525            if (bCallUserView) 
    1546               showEventDialog(mnuUserView, id, ppid, sig->CID()); 
     1526              showViewEventDialog(id, ppid); 
    15471527          } 
    15481528        } 
  • trunk/qt4-gui/src/core/licqgui.h

    r6093 r6097  
    130130 
    131131  /** 
     132   * Show contact view event dialog (used when chat mode is disabled) 
     133   * 
     134   * @param id Contact id 
     135   * @param ppid Contact protocol id 
     136   */ 
     137  UserViewEvent* showViewEventDialog(QString id, unsigned long ppid); 
     138 
     139  /** 
    132140   * Show contact event dialog 
    133141   * 
  • trunk/qt4-gui/src/core/mainwin.cpp

    r6090 r6097  
    161161  a->setData(data); 
    162162 
    163   ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_V, mnuUserView) 
    164   ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_S, mnuUserSendMsg) 
    165   ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_U, mnuUserSendUrl) 
    166   ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_C, mnuUserSendChat) 
    167   ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_F, mnuUserSendFile) 
     163  ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_V, -1) 
     164  ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_S, MessageEvent) 
     165  ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_U, UrlEvent) 
     166  ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_C, ChatEvent) 
     167  ADD_USERFUNCACTION(Qt::CTRL + Qt::Key_F, FileEvent) 
    168168#undef ADD_USERFUNCACTION 
    169169  addActions(userFuncGroup->actions()); 
     
    520520  myUserView->MainWindowSelectedItemUser(id, ppid); 
    521521 
    522   LicqGui::instance()->showEventDialog(index, id, ppid); 
     522  if (index == -1) 
     523    LicqGui::instance()->showViewEventDialog(id, ppid); 
     524  else 
     525    LicqGui::instance()->showEventDialog(index, id, ppid); 
    523526} 
    524527 
  • trunk/qt4-gui/src/core/usermenu.cpp

    r6000 r6097  
    345345void UserMenu::viewEvent() 
    346346{ 
    347   LicqGui::instance()->showEventDialog(mnuUserView, myId, myPpid); 
     347  LicqGui::instance()->showViewEventDialog(myId, myPpid); 
    348348} 
    349349 
  • trunk/qt4-gui/src/core/usermenu.h

    r5822 r6097  
    107107  enum SendModes 
    108108  { 
    109     SendMessage = mnuUserSendMsg, 
    110     SendUrl = mnuUserSendUrl, 
    111     SendChat = mnuUserSendChat, 
    112     SendFile = mnuUserSendFile, 
    113     SendContact = mnuUserSendContact, 
    114     SendSms = mnuUserSendSms, 
     109    SendMessage = MessageEvent, 
     110    SendUrl = UrlEvent, 
     111    SendChat = ChatEvent, 
     112    SendFile = FileEvent, 
     113    SendContact = ContactEvent, 
     114    SendSms = SmsEvent, 
    115115    SendAuthorize, 
    116116    SendReqAuthorize,