|
From: <dhu...@us...> - 2007-01-06 18:34:16
|
Revision: 108
http://svn.sourceforge.net/qcell/?rev=108&view=rev
Author: dhubleizh
Date: 2007-01-06 10:34:13 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
- fixed FileDialog's bug (cancel didn't matter)
- added creation of basic structures after parsing
- Neighbourhood file writing
- handled Neighbourhood save action
Modified Paths:
--------------
trunk/qcell/visgui/MainWindow.cpp
Modified: trunk/qcell/visgui/MainWindow.cpp
===================================================================
--- trunk/qcell/visgui/MainWindow.cpp 2007-01-06 18:31:33 UTC (rev 107)
+++ trunk/qcell/visgui/MainWindow.cpp 2007-01-06 18:34:13 UTC (rev 108)
@@ -117,12 +117,12 @@
}
fd.setFilters(filters);
- fd.exec();
+ if(fd.exec())
+ { if(!fd.selectedFiles().isEmpty())
+ {
+ callParser(fd.selectedFiles().first(), "Neighbourhood");
- if(!fd.selectedFiles().isEmpty())
- {
- callParser(fd.selectedFiles().first(), "Neighbourhood");
-
+ }
}
}
@@ -160,12 +160,13 @@
}
fd.setFilters(filters);
- fd.exec();
-
- if(!fd.selectedFiles().isEmpty())
+ if(fd.exec())
{
- callParser(fd.selectedFiles().first(), "LocalFunction");
+ if(!fd.selectedFiles().isEmpty())
+ {
+ callParser(fd.selectedFiles().first(), "LocalFunction");
+ }
}
}
@@ -203,13 +204,16 @@
}
fd.setFilters(filters);
- fd.exec();
-
- if(!fd.selectedFiles().isEmpty())
+ if(fd.exec())
{
- callParser(fd.selectedFiles().first(), "World");
+ if(!fd.selectedFiles().isEmpty())
+ {
+ callParser(fd.selectedFiles().first(), "World");
+ }
+
}
+
}
void MainWindow::callParser(QString filename, QString type)
@@ -239,7 +243,8 @@
return;
}
- neighbourhood_parsers[subtype]->parse(file_content, type, subtype);
+ neighbourhood = new Neighbourhood;
+ neighbourhood->fromXmlString(&neighbourhood_parsers[subtype]->parse(file_content, type, subtype));
}
else if (type == "LocalFunction")
@@ -253,7 +258,8 @@
return;
}
- function_parsers[subtype]->parse(file_content, type, subtype);
+ local_function = new LocalFunction();
+ local_function->fromXmlString(&function_parsers[subtype]->parse(file_content, type, subtype));
}
else if (type == "World")
{
@@ -266,6 +272,10 @@
return;
}
+// data.clear();
+ /// @todo Fix that!
+// CalculationData* tmp_cd = new CalculationData();
+// data.append(*tmp_cd);
world_parsers[subtype]->parse(file_content, type, subtype);
}
else
@@ -282,7 +292,7 @@
QString XMLString;
QString subtype = filename.section('.', -1);
- if (!file.open(QIODevice::Truncate | QIODevice::Text))
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
qDebug(tr("Error opnening file %1.")
.arg(filename)
@@ -303,7 +313,7 @@
return;
}
- neighbourhood_parsers[subtype]->parseOut(neighbourhood->toXmlString(), type, subtype);
+ file.write(neighbourhood_parsers[subtype]->parseOut(neighbourhood->toXmlString(), type, subtype));
}
else if (type == "LocalFunction")
@@ -512,10 +522,50 @@
void MainWindow::on_action_Neighbourhood_save_activated()
{
- qDebug("UngaBunga!!!!!");
- callSaver("A cokolwiek", "Neighbourhood");
+ if(neighbourhood_parsers.count() == 0)
+ {
+ QMessageBox::warning(
+ /*parent*/ this,
+ /*title*/ tr("Plugins warning"),
+ /*message*/ tr("There are no plugins loaded to handle Neighbourhood saving.")
+ );
+ return;
+ }
+
+ QFileDialog fd(
+ /*parent*/ this,
+ /*cation*/ tr("Save Neighbourhood"),
+ /*dir*/ "."
+ );
+
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setFileMode(QFileDialog::AnyFile);
+
+ QStringList filters;
+ QString filter;
+ // Add filter in format %{name} files (*.%{name})
+ foreach(QString key, neighbourhood_parsers.keys())
+ {
+ // Don't shorten this, as it is made for translations
+ // purposes
+ filter = key + " " + tr("files") + " (*." + key + ")";
+ filters << filter;
+ }
+ fd.setFilters(filters);
+ fd.setDefaultSuffix("N");
+
+ if(fd.exec())
+ {
+ if(!fd.selectedFiles().isEmpty())
+ {
+ callSaver(fd.selectedFiles().first(), "Neighbourhood");
+
+ }
+
+ }
+
}
void MainWindow::on_action_Function_save_activated()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|