Esempio n. 1
0
void search_widget::save() const {
    model->save();
    Preferences pref;
    pref.beginGroup("SearchWidget");
    pref.setValue("CheckPlus", checkPlus->isChecked());
    pref.setValue("CheckOwn", checkOwn->isChecked());
    pref.setValue("CurrentTab", tabSearch->currentIndex());
    pref.setValue("SeachListHeader", treeResult->header()->saveState());

    pref.setValue("defValue", defValue->isChecked());
    pref.setValue("defKilos", defKilos->isChecked());
    pref.setValue("defMegas", defMegas->isChecked());

    pref.beginWriteArray("Tabs", tabSearch->count());

    for (int i = 0; i < tabSearch->count(); ++i) {
        pref.setArrayIndex(i);
        pref.setValue("Title", tabSearch->tabText(i));
        qDebug() << "save " << tabSearch->tabText(i);
    }

    pref.endArray();

    // save comboName
    pref.beginWriteArray("ComboNames", comboName->count());

    for(int index = 0; index < comboName->count(); ++index) {
        pref.setArrayIndex(index);
        pref.setValue("CName", comboName->itemText(index));
    }

    pref.endArray();
    pref.endGroup();
}
Esempio n. 2
0
void search_widget::load() {
    model->load();
    Preferences pref;
    pref.beginGroup("SearchWidget");
    checkPlus->setChecked(pref.value("CheckPlus", true).toBool());
    checkOwn->setChecked(pref.value("CheckOwn", true).toBool());

    if (pref.contains("SeachListHeader")) {
        treeResult->header()->restoreState(pref.value("SeachListHeader").toByteArray());
    }

    if (pref.value("defMegas", false).toBool()) {
        //defMegas->setChecked(true);
    }

    if (pref.value("defValue", true).toBool()) {
        //defValue->setChecked(true);
    }

    if (pref.value("defKilos", false).toBool()) {
        //defKilos->setChecked(true);
    }

    int size = pref.beginReadArray("Tabs");

    for (int i = 0; i < size; ++i) {
        pref.setArrayIndex(i);
        QString title = pref.value("Title", QString()).toString();
        qDebug() << "load " << title;
        tabSearch->addTab(QIcon(res::searchResult()), title);
    }

    pref.endArray();

    int currentTab = pref.value("CurrentTab", -1).toInt();
    if (currentTab < tabSearch->count()) {
        tabSearch->setCurrentIndex(currentTab);
    }

    // restore comboName
    size = pref.beginReadArray("ComboNames");
    for (int i = 0; i < size; ++i)
    {
        pref.setArrayIndex(i);
        comboName->addItem(pref.value("CName", QString()).toString());
    }

    pref.endArray();
    comboName->setCurrentIndex(-1);
    pref.endGroup();

    if (tabSearch->count() != 0) tabSearch->show();
}