bool AdditionConfigFrame::applyConfig()
{
    int largestNumberFirst = ui->largestNumberFirstCheckBox->isChecked();

    QString str = ui->minNumberLineEdit->text();
    BigFixedPoint firstMin(str.remove(QLocale::system().groupSeparator()));

    str = ui->maxNumberLineEdit->text();
    BigFixedPoint firstMax(str.remove(QLocale::system().groupSeparator()));

    str = ui->secondMinLineEdit->text();
    BigFixedPoint lastMin(str.remove(QLocale::system().groupSeparator()));

    str = ui->secondMaxLineEdit->text();
    BigFixedPoint lastMax(str.remove(QLocale::system().groupSeparator()));

    if (firstMax < firstMin)
    {
        QMessageBox::warning(this, tr("Range Validation Error"), tr("Maximum of first number is smaller than the minimum."), QMessageBox::Ok);
        return false;
    } else if (lastMax < lastMin) {
        QMessageBox::warning(this, tr("Range Validation Error"), tr("Maximum of last number is smaller than the minimum."), QMessageBox::Ok);
        return false;
    } else {
        module->setSettings(firstMin, firstMax, lastMin, lastMax,
                            largestNumberFirst);
    }

    return true;
}
uchar Algorithms::networkSortMedian(uchar array[])
{
    /* 012 *
     * 345 *
     * 678 */

    /* -------------------------- */
    /*       Sort in lines        */
    firstMax(array[1], array[2]);
    firstMax(array[4], array[5]);
    firstMax(array[7], array[8]);

    firstMax(array[0], array[1]);
    firstMax(array[3], array[4]);
    firstMax(array[6], array[7]);

    firstMax(array[1], array[2]);
    firstMax(array[4], array[5]);
    firstMax(array[7], array[8]);
    /* -------------------------- */

    /* Three group in cols:
     * maximums in her lines (036);
     * middles in lines (147);
     * minimins in lines (258).   */

    /* -------------------------- */
    /*         7 < 4 < 1          */
    firstMax(array[4], array[7]);
    firstMax(array[1], array[4]);
    firstMax(array[4], array[7]);

    /* 6 is min in 036 (maximums) */
    firstMax(array[0], array[3]);
    firstMax(array[3], array[6]);

    /* 2 is max in 258 (minimums) */
    firstMax(array[5], array[8]);
    firstMax(array[2], array[5]);
    /* -------------------------- */

    /* 0, 1, 3 more than others */
    /* 5, 7, 8 less than others */

    /* Median is 2, 4 or 6, sort them. */
    firstMax(array[4], array[2]);
    firstMax(array[6], array[4]);
    firstMax(array[4], array[2]);

    return array[4];
}