Example #1
0
File: main.cpp Project: Suneal/qt
void check(const QString &fileName)
{
    QFile file(fileName);
    if (!file.open(QIODevice::ReadOnly)) {
        qDebug("unable to open file: '%s' (%s)", fileName.toLocal8Bit().constData(), file.errorString().toLocal8Bit().constData());
        return;
    }
    QStringList lines;
    bool found = false;
    while (true) {
        QByteArray bline = file.readLine(16384);
        if (bline.isEmpty())
            break;
        QString line = QString::fromLocal8Bit(bline);
        Q_ASSERT_X(line.endsWith("\n"), "check()", fileName.toLocal8Bit().constData());
        found |= checkSignature(fileName, line, "SLOT");
        found |= checkSignature(fileName, line, "SIGNAL");
        if (modify)
            lines << line;
    }
    file.close();

    if (found && modify) {
        printf("Modifying file: '%s'\n", fileName.toLocal8Bit().constData());
        writeChanges(fileName, lines);
    }
}
void EnabledProtocolsDialog::on_buttonBox_accepted()
{
    if (applyChanges())
    {
        writeChanges();
        wsApp->queueAppSignal(WiresharkApplication::PacketDissectionChanged);
    }
}
// If we ever find and fix the bug behind queueAppSignal we can re-enable
// this.
void EnabledProtocolsDialog::on_buttonBox_clicked(QAbstractButton *button)
{
    if (button == ui->buttonBox->button(QDialogButtonBox::Apply))
    {
        if (applyChanges())
        {
            // if we don't have a Save button, just save the settings now
            if (!prefs.gui_use_pref_save)
                writeChanges();

            wsApp->emitAppSignal(WiresharkApplication::PacketDissectionChanged);
        }
    }
}