Esempio n. 1
0
void tst_IrcBuffer::testTitleNamePrefix()
{
    IrcBuffer buffer;

    QSignalSpy titleSpy(&buffer, SIGNAL(titleChanged(QString)));
    QSignalSpy nameSpy(&buffer, SIGNAL(nameChanged(QString)));
    QSignalSpy prefixSpy(&buffer, SIGNAL(prefixChanged(QString)));
    QVERIFY(titleSpy.isValid());
    QVERIFY(nameSpy.isValid());
    QVERIFY(prefixSpy.isValid());

    buffer.setName("name");
    QCOMPARE(buffer.title(), QString("name"));
    QCOMPARE(buffer.name(), QString("name"));
    QCOMPARE(buffer.prefix(), QString());
    QCOMPARE(titleSpy.count(), 1);
    QCOMPARE(titleSpy.last().first().toString(), QString("name"));
    QCOMPARE(nameSpy.count(), 1);
    QCOMPARE(nameSpy.last().first().toString(), QString("name"));
    QCOMPARE(prefixSpy.count(), 0);

    buffer.setPrefix("prefix");
    QCOMPARE(buffer.title(), QString("prefixname"));
    QCOMPARE(buffer.name(), QString("name"));
    QCOMPARE(buffer.prefix(), QString("prefix"));
    QCOMPARE(titleSpy.count(), 2);
    QCOMPARE(titleSpy.last().first().toString(), QString("prefixname"));
    QCOMPARE(nameSpy.count(), 1);
    QCOMPARE(prefixSpy.count(), 1);
    QCOMPARE(prefixSpy.last().first().toString(), QString("prefix"));
}
Esempio n. 2
0
void IrcClient::onBufferActivated(const QModelIndex& index)
{
    IrcBuffer* buffer = index.data(Irc::BufferRole).value<IrcBuffer*>();

    // document, user list and nick completion for the current buffer
    textEdit->setDocument(documents.value(buffer));
    userList->setModel(userModels.value(buffer));
    completer->setBuffer(buffer);

    // keep the command parser aware of the context
    if (buffer)
        parser->setTarget(buffer->title());
}
Esempio n. 3
0
    void IrcClientPage::onBufferActivated(const QModelIndex& index)
    {
        IrcBuffer* buffer = index.data(Irc::BufferRole).value<IrcBuffer*>();

        // document, user list and nick completion for the current buffer
        ui->textEdit->setDocument(documents.value(buffer));
        ui->textEdit->verticalScrollBar()->triggerAction(QScrollBar::SliderToMaximum);
        ui->userList->setModel(userModels.value(buffer));
        completer->setBuffer(buffer);

        // keep the command parser aware of the context
        if (buffer)
            parser->setTarget(buffer->title());
    }
Esempio n. 4
0
void tst_IrcBuffer::testDefaults()
{
    IrcBuffer buffer;
    QVERIFY(buffer.title().isEmpty());
    QVERIFY(buffer.name().isEmpty());
    QVERIFY(buffer.prefix().isEmpty());
    QVERIFY(!buffer.isChannel());
    QVERIFY(!buffer.toChannel());
    QVERIFY(!buffer.connection());
    QVERIFY(!buffer.network());
    QVERIFY(!buffer.model());
    QVERIFY(!buffer.isActive());
    QVERIFY(!buffer.isSticky());
    QVERIFY(!buffer.isPersistent());
}
bool BufferFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
    if (m_status == 0 && m_filter.isEmpty())
        return true;

    QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
    IrcBuffer* buffer = index.data(Irc::BufferRole).value<IrcBuffer*>();
    if (buffer && !buffer->isSticky()) {
        if (!m_filter.isEmpty() && !buffer->title().contains(m_filter, Qt::CaseInsensitive))
            return false;
        if (m_status > 0) {
            MessageModel* model = m_storage->model(buffer);
            if (model) {
                if (m_status == 1 && model->badge() <= 0)
                    return false;
                if (m_status == 2 && model->activeHighlights() <= 0)
                    return false;
            }
        }
    }
    return true;
}