git-svn-id: svn://db.shs.com.ru/libs@240 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
BlockEditor::BlockEditor(QWidget *parent) : QWidget(parent), ui(new Ui::BlockEditor) {
|
||||
init = false;
|
||||
ui->setupUi(this);
|
||||
src_title = windowTitle();
|
||||
connect(ui->blockView->scene(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
|
||||
block.setFlags(0);
|
||||
ui->blockView->addItem(&block);
|
||||
@@ -50,6 +51,17 @@ BlockEditor::~BlockEditor() {
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::loadFile(QString path) {
|
||||
if (path.isEmpty()) return;
|
||||
QFile f(path);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
cur_file = path;
|
||||
loadModel(f.readAll());
|
||||
}
|
||||
setWindowTitle(src_title + QString(" - %1").arg(QFileInfo(path).baseName()));
|
||||
}
|
||||
|
||||
|
||||
void BlockEditor::loadModel(const QByteArray &model) {
|
||||
BlockItem b;
|
||||
b.loadModel(model);
|
||||
@@ -153,6 +165,7 @@ void BlockEditor::on_buttonSave_clicked() {
|
||||
if (f.open(QIODevice::WriteOnly)) {
|
||||
cur_file = c;
|
||||
f.write(saveModel());
|
||||
setWindowTitle(src_title + QString(" - %1").arg(QFileInfo(c).baseName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,13 +173,7 @@ void BlockEditor::on_buttonSave_clicked() {
|
||||
|
||||
void BlockEditor::on_buttonLoad_clicked() {
|
||||
QString c = QFileDialog::getOpenFileName(this, "Save block model to file", cur_file, "*.blockmodel");
|
||||
if (!c.isEmpty()) {
|
||||
QFile f(c);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
cur_file = c;
|
||||
loadModel(f.readAll());
|
||||
}
|
||||
}
|
||||
loadFile(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user