]> https://gitweb.dealii.org/ - parameter_gui.git/commitdiff
Add context menu and set to default 7/head
authorRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 31 Mar 2017 16:42:06 +0000 (10:42 -0600)
committerRene Gassmoeller <rene.gassmoeller@mailbox.org>
Fri, 31 Mar 2017 16:48:25 +0000 (10:48 -0600)
mainwindow.cpp
mainwindow.h

index 3b75cb900437aebb9309f7f27b2ea946a4b99caf..615e521d88494909a3f7b4a60a64222072e9de93 100644 (file)
@@ -50,6 +50,11 @@ namespace dealii
       tree_widget->setEditTriggers(QAbstractItemView::DoubleClicked|
                                    QAbstractItemView::SelectedClicked|
                                    QAbstractItemView::EditKeyPressed);
+
+      //Enable right click menu in tree
+      tree_widget->setContextMenuPolicy(Qt::ActionsContextMenu);
+      context_menu = new QMenu(tree_widget);
+
                                                                                // set which actions will initiate item editing: Editing starts when:
                                                                                // DoubleClicked: an item is double clicked
                                                                                // SelectedClicked: clicking on an already selected item
@@ -94,6 +99,14 @@ namespace dealii
 
 
 
+    void MainWindow::set_to_default()
+    {
+      QTreeWidgetItem * current_item = tree_widget->currentItem();
+      current_item->setText(1,current_item->text(2));
+    }
+
+
+
     void MainWindow::open()
     {
       if (maybe_save())                                                                // check, if the content was modified
@@ -275,6 +288,10 @@ namespace dealii
       about_qt_act = new QAction(tr("About &Qt"), this);
       about_qt_act->setStatusTip(tr("Show the Qt library's About box"));
       connect(about_qt_act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+
+      set_to_default_act = new QAction("Set to default",context_menu);
+      tree_widget->addAction(set_to_default_act);
+      connect(set_to_default_act, SIGNAL(triggered()), this, SLOT(set_to_default()));
     }
 
 
index a6eecfeb5d8e962b734544031b87c306b62c04db..360d59b3b06e27fb3e5d209c7af76c4ee94a1c3d 100644 (file)
@@ -98,6 +98,12 @@ namespace dealii
                                       */
         void set_documentation_text(QTreeWidgetItem *selected_item,
                                     QTreeWidgetItem *previous_item);
+
+                                    /**
+                                     * A <tt>slot</tt> that is called when the active
+                                     * tree item should be set to its default value.
+                                     */
+        void set_to_default();
       private:
                                     /**
                                      * Show an information dialog, how
@@ -150,6 +156,10 @@ namespace dealii
                                      * and <tt>about Qt</tt>
                                      */
         QMenu * help_menu;
+                                     /**
+                                      * This menu provides context menu options for the active tree item.
+                                      */
+        QMenu * context_menu;
                                     /**
                                      * QAction <tt>open</tt> a file.
                                      */
@@ -174,6 +184,11 @@ namespace dealii
                                      * QAction <tt>about</tt> Qt.
                                      */
         QAction * about_qt_act;
+                                     /**
+                                      * QAction <tt>set_to_default</tt>.
+                                      */
+        QAction * set_to_default_act;
+
                                     /**
                                      * This value stores the current <tt>filename</tt> we work on.
                                      */

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.