]> https://gitweb.dealii.org/ - parameter_gui.git/commitdiff
Add documentation panel 2/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 24 Mar 2017 21:42:30 +0000 (15:42 -0600)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Tue, 28 Mar 2017 17:33:41 +0000 (11:33 -0600)
mainwindow.cpp
mainwindow.h

index 533fa8bfbea7871080e6340fa627346165a07876..5626bc8d1a327351002495c7c6bd5dd0082650fc 100644 (file)
@@ -56,16 +56,27 @@ namespace dealii
                                                                                // AnyKeyPressed: any key is pressed over an item
 
       tree_widget->setItemDelegate(new ParameterDelegate(1));                  // set the delegate for editing items
-      setCentralWidget(tree_widget);
-                                                                               // connect: if the tree changes, the window will know
+
+      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(tree_was_modified()));
 
+      QDockWidget *documentation_widget = new QDockWidget(tr("Parameter documentation:"), this);
+      documentation_text_widget = new QTextEdit(QString (""), documentation_widget);
+      documentation_text_widget->setReadOnly(true);
+
+      documentation_widget->setAllowedAreas(Qt::AllDockWidgetAreas);
+      documentation_widget->setWidget(documentation_text_widget);
+
+      addDockWidget(Qt::BottomDockWidgetArea, documentation_widget);
+
       create_actions();                                                                // create window actions as "Open",...
       create_menus();                                                          // and menus
       statusBar()->showMessage(tr("Ready, start editing by double-clicking or hitting F2!"));
       setWindowTitle(tr("[*]parameterGUI"));                                   // set window title
 
-      resize(800, 600);                                                                // set window height and width
+      showMaximized();
 
       if (filename.size() > 3)                                                 // if there is a file_name, try to load the file.
         load_file(filename);                                                   // a vliad file has the xml extension, so we require size() > 3
@@ -73,6 +84,15 @@ namespace dealii
 
 
 
+    void MainWindow::set_documentation_text(QTreeWidgetItem *selected_item,
+                                            QTreeWidgetItem *previous_item)
+    {
+      documentation_text_widget->clear();
+      documentation_text_widget->insertPlainText(selected_item->text(3));
+    }
+
+
+
     void MainWindow::open()
     {
       if (maybe_save())                                                                // check, if the content was modified
index c9c49e520fb57670d1877a7c1ed2e8f1a17358e3..a6eecfeb5d8e962b734544031b87c306b62c04db 100644 (file)
@@ -91,6 +91,13 @@ namespace dealii
                                      */
         void tree_was_modified();
 
+                                     /**
+                                      * A <tt>slot</tt> that is called when the active
+                                      * item has changed. It updates the documentation
+                                      * text in the documentation panel.
+                                      */
+        void set_documentation_text(QTreeWidgetItem *selected_item,
+                                    QTreeWidgetItem *previous_item);
       private:
                                     /**
                                      * Show an information dialog, how
@@ -124,10 +131,15 @@ namespace dealii
                                      * This functions writes the current @p filename to the window title.
                                      */
         void set_current_file (const QString  &filename);
+
                                     /**
                                      * This is the tree structure in which we store all parameters.
                                      */
         QTreeWidget * tree_widget;
+                                     /**
+                                      * This is the documentation text area.
+                                      */
+        QTextEdit *documentation_text_widget;
                                     /**
                                      * This menu provides all file actions as <tt>open</tt>, <tt>save</tt>, <tt>save as</tt>
                                      * and <tt>exit</tt>

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.