menu->addAction("&Load"),
&QAction::triggered,
parent,
- &BigintWidget::load_json
+ &BigintWidget::load_data
);
QObject::connect(
menu->addAction("&Save"),
&QAction::triggered,
parent,
- &BigintWidget::save_json
+ &BigintWidget::save_data
);
menu->addSeparator();
QObject::connect(
update_img();
}
-void BigintWidget::load_json() {
+void BigintWidget::load_data() {
QString file_name = QFileDialog::getOpenFileName(
- this, "Load JSON", "", "JSON Documents (*.json)"
+ this, "Load Data", "", "BigintMandel Data (*.bim)"
);
if (!file_name.isEmpty()) {
- settings.load_json(file_name);
+ settings.load_data(file_name);
update_img();
}
}
-void BigintWidget::save_json() {
+void BigintWidget::save_data() {
QString file_name = QFileDialog::getSaveFileName(
- this, "Save JSON", "", "JSON Documents (*.json)"
+ this, "Save Data", "", "BigintMandel Data (*.bim)"
);
if (!file_name.isEmpty())
- settings.save_json(file_name);
+ settings.save_data(file_name);
}
void settings_widget_accepted();
void finished_cell(int num);
void finished();
- void load_json();
- void save_json();
+ void load_data();
+ void save_data();
};
#endif // BIGINTWIDGET_H
}
void MandelSettings::finished_cell(int num, const MandelResultCell &result) {
- size_t iter = result.get_iter();
cells[num].set_result(result);
if (!img)
return;
img->setPixelColor(cells[num].get_pos(), cells[num].get_color());
+ return;
+ (void)colors;
}
void MandelSettings::save_img(QString file_name) {
setup_cells(cells, ¶ms);
}
-void MandelSettings::load_json(QString file_name) {
+void MandelSettings::load_data(QString file_name) {
QFile file(file_name);
QJsonObject json;
QJsonArray json_array;
qWarning("Couldn't open save file.");
return;
}
- json = QJsonDocument::fromJson(file.readAll()).object();
+ json = QJsonDocument::fromJson(qUncompress(file.readAll())).object();
params = MandelParams::from_json(json["params"].toObject());
json_array = json["cells"].toArray();
cells.resize(json_array.size(), MandelCell(¶ms));
file.close();
}
-void MandelSettings::save_json(QString file_name) {
+void MandelSettings::save_data(QString file_name) {
QVector<MandelCell>::iterator i;
QFile file(file_name);
QJsonObject json;
qWarning("Couldn't open save file.");
return;
}
- file.write(QJsonDocument(json).toJson());
+ file.write(qCompress(QJsonDocument(json).toJson(), 9));
file.close();
}
void finished_cell(int num, const MandelResultCell &cell);
void save_img(QString file_name);
void reset(size_t max_iter, QSize size);
- void load_json(QString file_name);
- void save_json(QString file_name);
+ void load_data(QString file_name);
+ void save_data(QString file_name);
};
extern QVector<QColor> colors;