source/MainGUI.cpp
/**
 * Slot which is emitted when the channellist was clicked.
 *
 * @param mouseEvent QMouseEvent* holding additional information.
 */
Slot which is emitted when the channellist was clicked.
@param mouseEvent QMouseEvent* holding additional information.
Slot which is emitted when the channellist was clicked . @param mouseEvent QMouseEvent * holding additional information .
void MainGUI::onChannellistItemClicked (QMouseEvent *mouseEvent)
{
    widget.inputTextArea->setFocus();
    QListWidgetItem* item = widget.channelList->itemAt(mouseEvent->pos());
    if (!item)
    {
        return;
    }
    if (mouseEvent->button() == Qt::LeftButton)
    {
        QString user = item->data(ChannellistDelegate::USER).toString();
        int slotStatus = item->data(ChannellistDelegate::SLOT_STATUS).toInt();
        int computerStatus = item->data(ChannellistDelegate::SLOT_COMPUTER_STATUS).toInt();
        int team = item->data(ChannellistDelegate::SLOT_TEAM).toInt();
        if (gproxy->m_BNET->GetInGame())
        {
            if (user == "The Sentinel" || user == "The Scourge"
                    || user.startsWith("Team "))
            {
                gproxy->changeTeam(team);
            }
            else if (slotStatus == 0)
            {
                if (gproxy->isDotaMap())
                {
                    return; 
                    int requestedSlotNumber = 1;
                    for (int i = 0; i < widget.channelList->count(); i++)
                    {
                        if (item == widget.channelList->item(i))
                        {
                            requestedSlotNumber = i;
                            break;
                        }
                    }
                    int currentSlotNumber = 1;
                    foreach (Slot* slot, gproxy->getSlotList())
                    {
                        if (slot->getPlayer()) 
                        {
                            if (slot->getPlayer()->getPlayerId() == gproxy->m_ChatPID)
                            {
                                currentSlotNumber = slot->getColor();
                                break;
                            }
                        }
                    }
                    if ((currentSlotNumber < 6 && requestedSlotNumber < 6)
                            || (currentSlotNumber > 6 && requestedSlotNumber > 6))
                    {
                        for (int i = currentSlotNumber + 1; i != requestedSlotNumber +1; i++)
                        {
                            if (team == 0 && i > 5)
                            {
                                i = 1;
                            }
                            else if (i > 11)
                            {
                                i = 7;
                            }
                            if (!gproxy->getSlotList().at(i)->getPlayer())
                            {
                                gproxy->changeTeam(team);
                            }
                        }
                    }
                    else
                    {
                        int i;
                        if (team == 0)
                        {
                            i = 1;
                        }
                        else
                        {
                            i = 7;
                        }
                        while (i != requestedSlotNumber)
                        {
                            if (!gproxy->getSlotList().at(i)->getPlayer())
                            {
                                gproxy->changeTeam(team);
                            }
                            i++;
                        }
                    }
                }
            }
            else if (slotStatus == 2 && computerStatus == 0)
            {
                widget.inputTextArea->setPlainText("/w " + user + " ");
                widget.inputTextArea->moveCursor(QTextCursor::End);
            }
        }
        else
        {
            widget.inputTextArea->setPlainText("/w " + user + " ");
            widget.inputTextArea->moveCursor(QTextCursor::End);
        }
    }
}
void MainGUI :: onChannellistItemClicked ( QMouseEvent * mouseEvent ) { widget . inputTextArea -> setFocus ( ) ; QListWidgetItem * item = widget . channelList -> itemAt ( mouseEvent -> pos ( ) ) ; if ( ! item ) { return ; } if ( mouseEvent -> button ( ) == Qt :: LeftButton ) { QString user = item -> data ( ChannellistDelegate :: USER ) . toString ( ) ; int slotStatus = item -> data ( ChannellistDelegate :: SLOT_STATUS ) . toInt ( ) ; int computerStatus = item -> data ( ChannellistDelegate :: SLOT_COMPUTER_STATUS ) . toInt ( ) ; int team = item -> data ( ChannellistDelegate :: SLOT_TEAM ) . toInt ( ) ; if ( gproxy -> m_BNET -> GetInGame ( ) ) { if ( user == " " || user == " " || user . startsWith ( " " ) ) { gproxy -> changeTeam ( team ) ; } else if ( slotStatus == 0 ) { if ( gproxy -> isDotaMap ( ) ) { return ; int requestedSlotNumber = 1 ; for ( int i = 0 ; i < widget . channelList -> count ( ) ; i ++ ) { if ( item == widget . channelList -> item ( i ) ) { requestedSlotNumber = i ; break ; } } int currentSlotNumber = 1 ; foreach ( Slot * slot , gproxy -> getSlotList ( ) ) { if ( slot -> getPlayer ( ) ) { if ( slot -> getPlayer ( ) -> getPlayerId ( ) == gproxy -> m_ChatPID ) { currentSlotNumber = slot -> getColor ( ) ; break ; } } } if ( ( currentSlotNumber < 6 && requestedSlotNumber < 6 ) || ( currentSlotNumber > 6 && requestedSlotNumber > 6 ) ) { for ( int i = currentSlotNumber + 1 ; i != requestedSlotNumber + 1 ; i ++ ) { if ( team == 0 && i > 5 ) { i = 1 ; } else if ( i > 11 ) { i = 7 ; } if ( ! gproxy -> getSlotList ( ) . at ( i ) -> getPlayer ( ) ) { gproxy -> changeTeam ( team ) ; } } } else { int i ; if ( team == 0 ) { i = 1 ; } else { i = 7 ; } while ( i != requestedSlotNumber ) { if ( ! gproxy -> getSlotList ( ) . at ( i ) -> getPlayer ( ) ) { gproxy -> changeTeam ( team ) ; } i ++ ; } } } } else if ( slotStatus == 2 && computerStatus == 0 ) { widget . inputTextArea -> setPlainText ( " " + user + " " ) ; widget . inputTextArea -> moveCursor ( QTextCursor :: End ) ; } } else { widget . inputTextArea -> setPlainText ( " " + user + " " ) ; widget . inputTextArea -> moveCursor ( QTextCursor :: End ) ; } } }
Slot which is emitted when the channellist was clicked.
Slot which is emitted when the channellist was clicked .
// Still buggy. // Check for existing player. /**
                         * SENT
                         * 1
                         * 2
                         * 3
                         * 4
                         * 5
                         * SCOU
                         * 7
                         * 8
                         * 9
                         * 10
                         * 11
                         */