Esempio n. 1
0
inline const QString * KviModeEditor::getModeDescription(char cMode)
{
	if(!m_pChannel)
		return nullptr;
	KviIrcConnectionServerInfo * pServerInfo = m_pChannel->serverInfo();
	if(pServerInfo)
		return &(pServerInfo->getChannelModeDescription(cMode));
	return nullptr;
}
Esempio n. 2
0
KviMaskEditor::KviMaskEditor(QWidget * par, KviChannelWindow * pChannel, KviWindowToolPageButton * button, std::vector<KviMaskEntry *> maskList, char cMode, const char * name)
    : KviWindowToolWidget(par, button)
{
    setObjectName(name);
    m_pChannel = pChannel;

    setFocusPolicy(Qt::ClickFocus);

    QGridLayout * g = new QGridLayout(this);

    m_cFlag = cMode;

    KviIrcConnectionServerInfo * pServerInfo = nullptr;
    QString szDescription = "";
    if(m_pChannel)
        pServerInfo = m_pChannel->serverInfo();
    if(pServerInfo)
        szDescription = pServerInfo->getChannelModeDescription(cMode);
    if(szDescription.isEmpty())
        szDescription = __tr2qs("Mode \"%1\" masks").arg(cMode);
    switch(cMode)
    {
    case 'b':
        m_eIcon = KviIconManager::Ban;
        break;
    case 'e':
        m_eIcon = KviIconManager::BanExcept;
        break;
    case 'I':
        m_eIcon = KviIconManager::InviteExcept;
        break;
    case 'a':
        m_eIcon = KviIconManager::ChanAdmin;
        break;
    case 'q':
        // this could also be quiet bans..
        m_eIcon = KviIconManager::Kick;
        break;
    default:
        m_eIcon = KviIconManager::Ban;
        break;
    }

    KviTalHBox * pTitleLayout = new KviTalHBox(this);
    g->addWidget(pTitleLayout, 0, 0);

    QLabel * l = new QLabel("", pTitleLayout);
    l->setPixmap(*(g_pIconManager->getSmallIcon(m_eIcon)));

    l = new QLabel(szDescription, pTitleLayout);

    QFrame * pFrame = new QFrame(this);
    pFrame->setFrameStyle(QFrame::HLine | QFrame::Sunken);
    g->addWidget(pFrame, 1, 0, 1, -1);

    KviTalHBox * hb = new KviTalHBox(this);
    g->addWidget(hb, 2, 0, 1, 2);

    new QLabel(__tr2qs("Filter:"), hb);
    m_pSearch = new QLineEdit(hb);
    connect(m_pSearch, SIGNAL(textChanged(const QString &)), this, SLOT(searchTextChanged(const QString &)));

    l = new QLabel(__tr2qs("Use double-click to edit item"), this);
    g->addWidget(l, 2, 1);
    g->addWidget(l, 3, 0, 1, 2);

    m_pMaskBox = new QTreeWidget(this);
    m_pMaskBox->setFocusPolicy(Qt::ClickFocus);
    m_pMaskBox->setFocusProxy(this);
    m_pMaskBox->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
    m_pMaskBox->setSelectionMode(QAbstractItemView::ExtendedSelection);

    QStringList columnLabels;
    m_pMaskBox->setColumnCount(3);

    columnLabels.append(__tr2qs("Mask"));
    columnLabels.append(__tr2qs("Set by"));
    columnLabels.append(__tr2qs("Set at"));
    m_pMaskBox->setHeaderLabels(columnLabels);
    m_pMaskBox->setAllColumnsShowFocus(true);
    m_pMaskBox->setSortingEnabled(true);
    connect(m_pMaskBox, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem *, int)));
    g->addWidget(m_pMaskBox, 4, 0, 1, 2);

    m_pRemoveMask = new QPushButton(__tr2qs("Re&move"), this);

    m_pRemoveMask->setFocusPolicy(Qt::ClickFocus);
    m_pRemoveMask->setFocusProxy(this);
    g->addWidget(m_pRemoveMask, 5, 1);
    connect(m_pRemoveMask, SIGNAL(clicked()), this, SLOT(removeClicked()));
    m_pRemoveMask->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::DeleteItem)));

    m_pAddButton = new QPushButton(__tr2qs("&Add"), this);
    g->addWidget(m_pAddButton, 5, 0);
    connect(m_pAddButton, SIGNAL(clicked()), this, SLOT(addClicked()));
    m_pAddButton->setIcon(*(g_pIconManager->getSmallIcon(KviIconManager::NewItem)));

    g->setColumnStretch(1, 1);

    if(m_pChannel && (!m_pChannel->connection()))
    {
        m_pRemoveMask->setEnabled(false);
        m_pAddButton->setEnabled(false);
        return;
    }

    for(auto & e : maskList)
        addMask(e);

    updateOpStatus();

    if(m_pChannel)
        connect(m_pChannel, SIGNAL(opStatusChanged()), this, SLOT(updateOpStatus()));
}