]> https://gitweb.dealii.org/ - parameter_gui.git/commitdiff
Show non-default values in bold 6/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Thu, 30 Mar 2017 22:08:01 +0000 (16:08 -0600)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 31 Mar 2017 17:23:38 +0000 (11:23 -0600)
mainwindow.cpp
mainwindow.h

index 615e521d88494909a3f7b4a60a64222072e9de93..b054d7aa0316be5e4b83fc2301ce6d26fcfa2835 100644 (file)
@@ -66,6 +66,7 @@ namespace dealii
       setCentralWidget(tree_widget);                                                                   // connect: if the tree changes, the window will know
 
       connect(tree_widget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(set_documentation_text(QTreeWidgetItem *, QTreeWidgetItem *)));         // and connect
+      connect(tree_widget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(item_changed(QTreeWidgetItem *, int)));         // and connect
       connect(tree_widget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(tree_was_modified()));
 
       QDockWidget *documentation_widget = new QDockWidget(tr("Parameter documentation:"), this);
@@ -97,6 +98,33 @@ namespace dealii
       documentation_text_widget->insertPlainText(selected_item->text(3));
     }
 
+    void MainWindow::item_changed(QTreeWidgetItem *item,
+                                  int column)
+    {
+      if (column != 1)
+        return;
+
+      bool has_default_value;
+
+      if (item->text(5).startsWith("[Double"))
+        has_default_value = item->data(1,Qt::DisplayRole).toReal() == item->data(2,Qt::DisplayRole).toReal();
+      else
+        has_default_value = item->data(1,Qt::DisplayRole).toString() == item->data(2,Qt::DisplayRole).toString();
+
+      if (has_default_value)
+        {
+          QFont font = item->font(1);
+          font.setWeight(QFont::Normal);
+          item->setFont(1,font);
+        }
+      else
+        {
+          QFont font = item->font(1);
+          font.setWeight(QFont::Bold);
+          item->setFont(1,font);
+        }
+    }
+
 
 
     void MainWindow::set_to_default()
index 360d59b3b06e27fb3e5d209c7af76c4ee94a1c3d..6671a738084a62813d7b2aa392a792148a5f525d 100644 (file)
@@ -104,6 +104,14 @@ namespace dealii
                                      * tree item should be set to its default value.
                                      */
         void set_to_default();
+
+                                    /**
+                                     * A <tt>slot</tt> that is called when any
+                                     * item value has changed. It updates the font depending
+                                     * on whether the item has a default value or not.
+                                     */
+        void item_changed(QTreeWidgetItem *item,
+                          int column);
       private:
                                     /**
                                      * Show an information dialog, how

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.