Beispiel #1
0
void QxtSmtpPrivate::authenticate()
{
    if (!extensions.contains("AUTH") || username.isEmpty() || password.isEmpty())
    {
        state = Authenticated;
        emit qxt_p().authenticated();
    }
    else
    {
        QStringList auth = extensions["AUTH"].toUpper().split(' ', QString::SkipEmptyParts);
        if (auth.contains("CRAM-MD5"))
        {
            authCramMD5();
        }
        else if (auth.contains("PLAIN"))
        {
            authPlain();
        }
        else if (auth.contains("LOGIN"))
        {
            authLogin();
        }
        else
        {
            state = Authenticated;
            emit qxt_p().authenticated();
        }
    }
}
Beispiel #2
0
bool QxtCheckComboBoxPrivate::eventFilter(QObject* receiver, QEvent* event)
{
    switch (event->type())
    {
    case QEvent::KeyPress:
    case QEvent::KeyRelease:
    {
        QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
        if (receiver == &qxt_p() && (keyEvent->key() == Qt::Key_Up || keyEvent->key() == Qt::Key_Down))
        {
            qxt_p().showPopup();
            return true;
        }
        else if (keyEvent->key() == Qt::Key_Enter ||
                 keyEvent->key() == Qt::Key_Return ||
                 keyEvent->key() == Qt::Key_Escape)
        {
            // it is important to call QComboBox implementation
            qxt_p().QComboBox::hidePopup();
            if (keyEvent->key() != Qt::Key_Escape)
                return true;
        }
    }
    case QEvent::MouseButtonPress:
        containerMousePress = (receiver == qxt_p().view()->window());
        break;
    case QEvent::MouseButtonRelease:
        containerMousePress = false;;
        break;
    default:
        break;
    }
    return false;
}
void QxtCountryComboBoxPrivate::setCurrentCountry(QLocale::Country country)
{
    // column 3 is QLocale::Country
    QModelIndex start = qxt_p().model()->index(0, 3);
    QModelIndexList result = qxt_p().model()->match(start, Qt::DisplayRole, country, 1, Qt::MatchExactly);
    if (!result.isEmpty())
        qxt_p().setCurrentIndex(result.first().row());
}
Beispiel #4
0
void QxtCheckComboBoxPrivate::toggleCheckState(int index)
{
    QVariant value = qxt_p().itemData(index, Qt::CheckStateRole);
    if (value.isValid())
    {
        Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
        qxt_p().setItemData(index, (state == Qt::Unchecked ? Qt::Checked : Qt::Unchecked), Qt::CheckStateRole);
    }
}
/**
 * This function is used internally to handle pinging the server and detecting timeouts. Timeouts are enabled and disabled server side.
 */
void ClientProtocolTcpPrivate::ping()
{
	if (lastPing.secsTo(QDateTime::currentDateTime()) > timeout)
	{
		qCritical() << "Remove host has timed out.";
		qxt_p().protocolDisconnect();
		return;
	}
	qxt_p().callProtocolFunction(Signature("ping()"), Arguments());
}
QString QxtConfirmationMessagePrivate::key() const
{
    QString value = overrideKey;
    if (value.isEmpty())
    {
        const QString all = qxt_p().windowTitle() + qxt_p().text() + qxt_p().informativeText();
        const QByteArray data = all.toLocal8Bit();
        value = QString::number(qChecksum(data.constData(), data.length()));
    }
    return value;
}
Beispiel #7
0
void QxtCheckComboBoxPrivate::updateCheckedItems()
{
    QStringList items = qxt_p().checkedItems();
    if (items.isEmpty())
        qxt_p().setEditText(defaultText);
    else
        qxt_p().setEditText(items.join(separator));

    // TODO: find a way to recalculate a meaningful size hint

    emit qxt_p().checkedItemsChanged(items);
}
Beispiel #8
0
void QxtConfigWidgetPrivate::setCurrentIndex(int index)
{
    int previousIndex = stack->currentIndex();
    if (previousIndex != -1 && previousIndex != index)
        qxt_p().cleanupPage(previousIndex);

    stack->setCurrentIndex(index);
    table->setCurrentItem(item(index));

    if (index != -1)
        qxt_p().initializePage(index);
}
Beispiel #9
0
void QxtRPCServicePrivate::clientDisconnected(QIODevice* dev, quint64 id)
{
    // When a device is disconnected, disconnect all signals connected to the object...
    QObject::disconnect(dev, 0, this, 0);
    QObject::disconnect(dev, 0, &qxt_p(), 0);

    // ... remove its buffer object...
    buffers.remove(id);

    // ... and inform other objects that the disconnection has happened.
    emit qxt_p().clientDisconnected(id);
}
Beispiel #10
0
void QxtSmtpPrivate::socketError(QAbstractSocket::SocketError err)
{
    if (err == QAbstractSocket::SslHandshakeFailedError)
    {
        emit qxt_p().encryptionFailed();
        emit qxt_p().encryptionFailed( socket->errorString().toAscii() );
    }
    else if (state == StartState)
    {
        emit qxt_p().connectionFailed();
        emit qxt_p().connectionFailed( socket->errorString().toAscii() );
    }
}
Beispiel #11
0
void QxtStdioPrivate::activated(int)
{
    char c = getchar();
    if (c == EOF)
    {
#if QT_VERSION >= 0x040400
        emit qxt_p().readChannelFinished();
#endif
        hadeof = true;
        return;
    }
    QByteArray b(1, c);
    qxt_p().enqueData(b);
    qxt_p().sendData(b);
}
Beispiel #12
0
void QxtRPCServicePrivate::serverData()
{
    // This function does the same thing as clientData() except there's only one server connection instead of
    // multiple client connections.

    // Read all available data on the device.
    serverBuffer.append(device->readAll());

    while(serializer->canDeserialize(serverBuffer)) {
        // Extract one deserialized signal from the buffer.
        QxtAbstractSignalSerializer::DeserializedData data = serializer->deserialize(serverBuffer);

        // Check to see if it's a blank command.
        if(serializer->isNoOp(data))
            continue;

        // Check for protocol errors.
        if(serializer->isProtocolError(data)) {
            qWarning() << "QxtRPCService: Invalid data received; disconnecting";
            qxt_p().disconnectServer();
            return;
        }

        // Pad the arguments to 8, because that's what dispatchFromServer() expects.
        while(data.second.count() < 8)
            data.second << QVariant();

        // And finally, invoke the dispatcher.
        dispatchFromServer(data.first, data.second[0], data.second[1], data.second[2], data.second[3], data.second[4],
                data.second[5], data.second[6], data.second[7]);
    }
}
Beispiel #13
0
void QxtSpanSliderPrivate::updateRange(int min, int max)
{
    Q_UNUSED(min);
    Q_UNUSED(max);
    // setSpan() takes care of keeping span in range
    qxt_p().setSpan(lower, upper);
}
Beispiel #14
0
void QxtSpanSliderPrivate::initStyleOption(QStyleOptionSlider* option, QxtSpanSlider::SpanHandle handle) const
{
    const QxtSpanSlider* p = &qxt_p();
    p->initStyleOption(option);
    option->sliderPosition = (handle == QxtSpanSlider::LowerHandle ? lowerPos : upperPos);
    option->sliderValue = (handle == QxtSpanSlider::LowerHandle ? lower : upper);
}
Beispiel #15
0
int QxtSpanSliderPrivate::pixelPosToRangeValue(int pos) const
{
    QStyleOptionSlider opt;
    initStyleOption(&opt);

    int sliderMin = 0;
    int sliderMax = 0;
    int sliderLength = 0;
    const QSlider* p = &qxt_p();
    const QRect gr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p);
    const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p);
    if (p->orientation() == Qt::Horizontal)
    {
        sliderLength = sr.width();
        sliderMin = gr.x();
        sliderMax = gr.right() - sliderLength + 1;
    }
    else
    {
        sliderLength = sr.height();
        sliderMin = gr.y();
        sliderMax = gr.bottom() - sliderLength + 1;
    }
    return QStyle::sliderValueFromPosition(p->minimum(), p->maximum(), pos - sliderMin,
                                           sliderMax - sliderMin, opt.upsideDown);
}
Beispiel #16
0
void QxtScheduleViewPrivate::itemGeometryChanged(QxtScheduleInternalItem * item, QVector< QRect > oldGeometry)
{
    QRegion oldRegion;

    if (item->geometry() == oldGeometry)
        return;

    QVectorIterator<QRect> iter(oldGeometry);
    QRect currRect;
    while (iter.hasNext())
    {
        currRect = iter.next();
        currRect.adjust(-1, -1, 2, 2);
        oldRegion += currRect;
    }
    //viewport()->update(oldRegion);


    QRegion newRegion;
    QVectorIterator<QRect> newIter(item->geometry());
    while (newIter.hasNext())
    {
        currRect = newIter.next();
        currRect.adjust(-1, -1, 2, 2);
        newRegion += currRect;
    }
    //viewport()->update(newRegion);
    qxt_p().viewport()->update();
}
Beispiel #17
0
void QxtRPCServicePrivate::clientData(quint64 id)
{
    // Get the device from the connection manager.
    QIODevice* dev = manager->client(id);

    // Cache a reference to the buffer.
    QByteArray& buf = buffers[id]; 

    // Read all available data on the device.
    buf.append(dev->readAll());

    while(serializer->canDeserialize(buf)) {
        // Extract one deserialized signal from the buffer.
        QxtAbstractSignalSerializer::DeserializedData data = serializer->deserialize(buf);

        // Check to see if it's a blank command.
        if(serializer->isNoOp(data))
            continue;

        // Check for protocol errors.
        if(serializer->isProtocolError(data)) {
            qWarning() << "QxtRPCService: Invalid data received; disconnecting";
            qxt_p().disconnectClient(id);
            return;
        }

        // Pad the arguments to 8, because that's what dispatchFromClient() expects.
        while(data.second.count() < 8)
            data.second << QVariant();

        // And finally, invoke the dispatcher.
        dispatchFromClient(id, data.first, data.second[0], data.second[1], data.second[2], data.second[3],
                data.second[4], data.second[5], data.second[6], data.second[7]);
    }
}
void QxtItemDelegatePrivate::closeEditor(QWidget* editor)
{
    if (currentEdited.isValid() && editor == currentEditor)
    {
        setCurrentEditor(0, QModelIndex());
        emit qxt_p().editingFinished(currentEdited);
    }
}
Beispiel #19
0
void QxtScheduleViewPrivate::init()
{
    if (qxt_p().model())
    {
        qxt_p().viewport()->setMouseTracking(true);

        if (!m_vHeader)
        {
            m_vHeader = new QxtScheduleHeaderWidget(Qt::Vertical, &qxt_p());
            connect(m_vHeader, SIGNAL(geometriesChanged()), &qxt_p(), SLOT(updateGeometries()));
        }
        m_vHeader->show();

        if (!m_hHeader)
        {
            m_hHeader = new QxtScheduleHeaderWidget(Qt::Horizontal, &qxt_p());
            connect(m_hHeader, SIGNAL(geometriesChanged()), &qxt_p(), SLOT(updateGeometries()));
        }
        m_hHeader->show();

        /*here we also initialize the items*/
        m_vHeader->setDefaultSectionSize(20);
        m_vHeader->setResizeMode(QHeaderView::Fixed);
        reloadItemsFromModel();
    }
    qxt_p().updateGeometries();
}
Beispiel #20
0
void QxtSmtpPrivate::sendNext()
{
    if (state == Disconnected)
    {
        // leave the mail in the queue if not ready to send
        return;
    }

    if (pending.isEmpty())
    {
        // if there are no additional mails to send, finish up
        state = Waiting;
        emit qxt_p().finished();
        return;
    }

    if(state != Waiting) {
        state = Resetting;
        socket->write("rset\r\n");
        return;
    }
    const QxtMailMessage& msg = pending.first().second;
    rcptNumber = rcptAck = mailAck = 0;
    recipients = msg.recipients(QxtMailMessage::To) +
                 msg.recipients(QxtMailMessage::Cc) +
                 msg.recipients(QxtMailMessage::Bcc);
    if (recipients.count() == 0)
    {
        // can't send an e-mail with no recipients
        emit qxt_p().mailFailed(pending.first().first, QxtSmtp::NoRecipients );
        emit qxt_p().mailFailed(pending.first().first, QxtSmtp::NoRecipients, QByteArray( "e-mail has no recipients" ) );
        pending.removeFirst();
        sendNext();
        return;
    }
    // We explicitly use lowercase keywords because for some reason gmail
    // interprets any string starting with an uppercase R as a request
    // to renegotiate the SSL connection.
    socket->write("mail from:<" + qxt_extract_address(msg.sender()) + ">\r\n");
    if (extensions.contains("PIPELINING"))  // almost all do nowadays
    {
        foreach(const QString& rcpt, recipients)
        {
            socket->write("rcpt to:<" + qxt_extract_address(rcpt) + ">\r\n");
        }
Beispiel #21
0
void QxtScheduleViewPrivate::reloadItemsFromModel()
{
    qDeleteAll(m_Items.begin(), m_Items.end());
    m_Items.clear();
    m_selectedItem = NULL;

    int iNumItems = qxt_p().model()->rowCount();
    //delete all old stuff here
    QxtScheduleInternalItem *currentItem;
    for (int iLoop = 0; iLoop < iNumItems; iLoop++)
    {
        currentItem = new QxtScheduleInternalItem(&qxt_p(), qxt_p().model()->index(iLoop, 0));
        m_Items.append(currentItem);
        connect(currentItem, SIGNAL(geometryChanged(QxtScheduleInternalItem*, QVector<QRect>)), this, SLOT(itemGeometryChanged(QxtScheduleInternalItem * , QVector< QRect >)));
    }

    handleItemConcurrency(0, (qxt_p().rows()*qxt_p().cols()) - 1);
}
Beispiel #22
0
bool QxtPushButtonPrivate::isRichText() const
{
    bool rich = (format == Qt::RichText) || (format == Qt::AutoText && Qt::mightBeRichText(qxt_p().text()));
    if (rich && !doc)
    {
        doc = new QTextDocument(const_cast<QxtPushButton*>(&qxt_p()));
        doc->setUndoRedoEnabled(false);
    }
    return rich;
}
Beispiel #23
0
QSize QxtStarsPrivate::getStarSize() const
{
    QSize size = starSize;
    if (!size.isValid() || size.isNull())
    {
        const int width = qxt_p().style()->pixelMetric(QStyle::PM_SmallIconSize);
        size = QSize(width, width);
    }
    return size;
}
Beispiel #24
0
void QxtConfigDialogPrivate::init( QxtConfigWidget::IconPosition pos )
{
    QxtConfigDialog* p = &qxt_p();
    configWidget = new QxtConfigWidget(pos);
    buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, p);
    QObject::connect(buttons, SIGNAL(accepted()), p, SLOT(accept()));
    QObject::connect(buttons, SIGNAL(rejected()), p, SLOT(reject()));
    layout = new QVBoxLayout(p);
    layout->addWidget(configWidget);
    layout->addWidget(buttons);
}
void QxtConfirmationMessagePrivate::init(const QString& message)
{
    remember = false;
    confirm = new QCheckBox(&qxt_p());
    if (!message.isNull())
        confirm->setText(message);
    else
        confirm->setText(QxtConfirmationMessage::tr("Do not show again."));

    QGridLayout* grid = qobject_cast<QGridLayout*>(qxt_p().layout());
    QDialogButtonBox* buttons = qFindChild<QDialogButtonBox*>(&qxt_p());
    if (grid && buttons)
    {
        const int idx = grid->indexOf(buttons);
        int row, column, rowSpan, columnSpan = 0;
        grid->getItemPosition(idx, &row, &column, &rowSpan, &columnSpan);
        QLayoutItem* buttonsItem = grid->takeAt(idx);
        grid->addWidget(confirm, row, column, rowSpan, columnSpan, Qt::AlignLeft | Qt::AlignTop);
        grid->addItem(buttonsItem, ++row, column, rowSpan, columnSpan);
    }
}
Beispiel #26
0
void QxtFilterDialogPrivate::filterModeChoosen(int index)
{
    if(index < 0)
        return;

    if( filterMode->itemData(index).isValid())
    {
        QRegExp::PatternSyntax mode = static_cast<QRegExp::PatternSyntax>(filterMode->itemData(index).toInt());
        qxt_p().setPatternSyntax(mode);
    }

}
Beispiel #27
0
bool QtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut)
{
    Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier;
    key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]);
    mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods);
    const quint32 nativeKey = nativeKeycode(key);
    const quint32 nativeMods = nativeModifiers(mods);
    const bool res = registerShortcut(nativeKey, nativeMods);
    shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p());
    if (!res)
        qWarning() << "QtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString();
    return res;
}
Beispiel #28
0
void QxtSpanSliderPrivate::setupPainter(QPainter* painter, Qt::Orientation orientation, qreal x1, qreal y1, qreal x2, qreal y2) const
{
    QColor highlight = qxt_p().palette().color(QPalette::Highlight);
    QLinearGradient gradient(x1, y1, x2, y2);
    gradient.setColorAt(0, highlight.dark(120));
    gradient.setColorAt(1, highlight.light(108));
    painter->setBrush(gradient);

    if (orientation == Qt::Horizontal)
        painter->setPen(QPen(highlight.dark(130), 0));
    else
        painter->setPen(QPen(highlight.dark(150), 0));
}
Beispiel #29
0
void QxtConfigWidgetPrivate::init(QxtConfigWidget::IconPosition position)
{
    QxtConfigWidget* p = &qxt_p();
    splitter = new QSplitter(p);
    stack = new QStackedWidget(p);
    table = new QxtConfigTableWidget(p);
    pos = position;
    QObject::connect(table, SIGNAL(currentCellChanged(int, int, int, int)), this, SLOT(setCurrentIndex(int, int)));
    QObject::connect(stack, SIGNAL(currentChanged(int)), p, SIGNAL(currentIndexChanged(int)));
    QVBoxLayout* layout = new QVBoxLayout(p);
    layout->addWidget(splitter);
    initTable();
    relayout();
}
Beispiel #30
0
bool QxtGlobalShortcutPrivate::unsetShortcut()
{
    bool res = false;
    const quint32 nativeKey = nativeKeycode(key);
    const quint32 nativeMods = nativeModifiers(mods);
    if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p())
        res = unregisterShortcut(nativeKey, nativeMods);
    if (res)
        shortcuts.remove(qMakePair(nativeKey, nativeMods));
    else
        qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString();
    key = Qt::Key(0);
    mods = Qt::KeyboardModifiers(0);
    return res;
}