GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/gui/widgets/tabs/chat/channeltab.cpp Lines: 0 20 0.0 %
Date: 2017-11-29 Branches: 0 14 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2008-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "gui/widgets/tabs/chat/channeltab.h"
24
25
#include "gui/widgets/windowcontainer.h"
26
27
#include "gui/windows/chatwindow.h"
28
29
#include "net/chathandler.h"
30
31
#include "debug.h"
32
33
ChannelTab::ChannelTab(const Widget2 *const widget,
34
                       const std::string &channel) :
35
    ChatTab(widget, channel, channel, channel, ChatTabType::CHANNEL)
36
{
37
    setTabColors(ThemeColorId::CHANNEL_CHAT_TAB);
38
}
39
40
ChannelTab::~ChannelTab()
41
{
42
    if (chatWindow != nullptr)
43
        chatWindow->removeChannel(mChannelName);
44
}
45
46
void ChannelTab::handleInput(const std::string &msg)
47
{
48
    std::string newMsg;
49
    newMsg = ChatWindow::doReplace(msg);
50
    chatHandler->channelMessage(mChannelName, newMsg);
51
}
52
53
bool ChannelTab::handleCommand(const std::string &restrict type,
54
                               const std::string &restrict args A_UNUSED)
55
{
56
    if (type == "close")
57
    {
58
        if (windowContainer != nullptr)
59
            windowContainer->scheduleDelete(this);
60
        else
61
            delete this;
62
        if (chatWindow != nullptr)
63
            chatWindow->defaultTab();
64
    }
65
    else
66
    {
67
        return false;
68
    }
69
70
    return true;
71
}
72
73
void ChannelTab::getAutoCompleteCommands(StringVect& commands) const
74
{
75
    commands.push_back("/close");
76
    commands.push_back(mChannelName);
77
}