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
+ 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
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()));
}
*/
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
* 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.
*/
* 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.
*/