From: Rene Gassmoeller Date: Tue, 28 Mar 2017 20:02:44 +0000 (-0600) Subject: Address comments X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2237bf9dcfaaf78b7a4dfd85d091e491e7059c6d;p=parameter_gui.git Address comments --- diff --git a/mainwindow.cpp b/mainwindow.cpp index 4e8b9de..6abd2df 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -310,15 +310,15 @@ namespace dealii return false; }; - if (filename.contains(".xml")) + if (filename.endsWith(".xml",Qt::CaseInsensitive)) { XMLParameterWriter writer(tree_widget); // create a xml writer if (!writer.write_xml_file(&file)) // and write the xml file return false; } - else if (filename.contains(".prm")) + else if (filename.endsWith(".prm",Qt::CaseInsensitive)) { - PRMParameterWriter writer(tree_widget); // create a prm writer + PRMParameterWriter writer(tree_widget); // create a prm writer if (!writer.write_prm_file(&file)) // and write the prm file return false; } diff --git a/prm_parameter_writer.cpp b/prm_parameter_writer.cpp index 0c61301..cd277a5 100644 --- a/prm_parameter_writer.cpp +++ b/prm_parameter_writer.cpp @@ -35,7 +35,7 @@ namespace dealii // loop over the elements for (int i = 0; i < tree_widget->topLevelItemCount(); ++i) { - const QString item_string = write_item(tree_widget->topLevelItem(i),0); + const QString item_string = item_to_string(tree_widget->topLevelItem(i),0); device->write(item_string.toAscii()); } @@ -44,8 +44,8 @@ namespace dealii - QString PRMParameterWriter::write_item(const QTreeWidgetItem *item, - const unsigned int indentation_level) + QString PRMParameterWriter::item_to_string(const QTreeWidgetItem *item, + const unsigned int indentation_level) { QString item_string; @@ -53,7 +53,7 @@ namespace dealii { // we have a parameter bool non_default_value; - if (item->text(5).contains("Double")) + if (item->text(5).startsWith("[Double")) non_default_value = item->data(1,Qt::DisplayRole).toReal() != item->data(2,Qt::DisplayRole).toReal(); else non_default_value = item->data(1,Qt::DisplayRole).toString() != item->data(2,Qt::DisplayRole).toString(); @@ -70,7 +70,7 @@ namespace dealii else { for (int i = 0; i < item->childCount(); ++i) - item_string.push_back(write_item(item->child(i),indentation_level+1)); + item_string.push_back(item_to_string(item->child(i),indentation_level+1)); if (!item_string.isEmpty()) { diff --git a/prm_parameter_writer.h b/prm_parameter_writer.h index a71f36a..1908418 100644 --- a/prm_parameter_writer.h +++ b/prm_parameter_writer.h @@ -59,21 +59,21 @@ namespace dealii private: /** - * This function writes a given @p item of tree_widget - * to a file in prm format. - * If the @p item is a parameter it is written if its value differs + * This function creates a string that corresponds to the data written + * to a prm file for a given @p item of tree_widget. + * If the @p item is a parameter it is only written if its value differs * from its default value. If the @p item is a subsection, a start element * subsection is written and write_item is called * recursively to write the next item. - * If not items in this subsection differ from their default value then + * If no items in this subsection differ from their default values then * the subsection is not written. * @p indentation_level describes the level the current item belongs to. * 0 describes a top level item and each subsection increases the level * by one. * */ - QString write_item (const QTreeWidgetItem *item, - const unsigned int indentation_level); + QString item_to_string (const QTreeWidgetItem *item, + const unsigned int indentation_level); /** * A pointer to the QTreeWidget structure