]> git.sur5r.net Git - bacula/bacula/commitdiff
Add tree selection of stacked widgets
authorKern Sibbald <kern@sibbald.com>
Sat, 27 Jan 2007 17:00:19 +0000 (17:00 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 27 Jan 2007 17:00:19 +0000 (17:00 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4058 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/qt-console/mainwindow.cpp
bacula/src/qt-console/mainwindow.h

index 3750f01133a106c9c84d2d16fffc46e743794c80..ae00cda6237d2cc4f751d32979c5a691c9bc1dd9 100644 (file)
 
 MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
 {
+   QTreeWidgetItem *item, *topItem;
    setupUi(this);                     /* Setup UI defined by main.ui (designer) */
    stackedWidget->setCurrentIndex(0);
    /* Dummy message ***FIXME*** remove a bit later */
    textEdit->setPlainText("Hello Baculites\nThis is the main console window.");
+   lineEdit->setFocus();
    /* Connect command line edit to input_line */
    connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
-   lineEdit->setFocus();
+   connect(actionAbout_qt_console, SIGNAL(triggered()), this, SLOT(about()));
+
+   connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this, 
+           SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+   connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, 
+           SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+   connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this, 
+           SLOT(treeItemClicked(QTreeWidgetItem *, int)));
+
+
+   /* Dummy setup of treeWidget */
+   treeWidget->clear();
+   treeWidget->setColumnCount(1);
+   treeWidget->setHeaderLabel("Selection");
+   topItem = new QTreeWidgetItem(treeWidget);
+   topItem->setText(0, "Rufus");
+   item = new QTreeWidgetItem(topItem);
+   item->setText(0, "Console");
+   item->setText(1, "0");
+   item = new QTreeWidgetItem(topItem);
+   item->setText(0, "Restore");
+   item->setText(1, "1");
+   treeWidget->expandItem(topItem);
 }
 
+void MainWindow::treeItemClicked(QTreeWidgetItem *item, int column)
+{
+   (void)column;
+   int index = item->text(1).toInt();
+   if (index >= 0 && index < 2) {
+      stackedWidget->setCurrentIndex(index);
+   }
+}
+
+
 /*
  * The user just finished typing a line in the command line edit box
  */
@@ -55,6 +89,14 @@ void MainWindow::input_line()
    lineEdit->clear();                    /* clear the lineEdit box */
    textEdit->append(cmdStr);             /* append text on screen */
 }
+void MainWindow::about()
+{
+   QMessageBox::about(this, tr("About qt-console"),
+            tr("<h2>Qt_console 0.1</h2>"
+            "<p>Copyright &copy; 2007 Free Software Foundation Europe e.V."
+            "<p>The <b>qt-console</b> is an administrative"
+               " interface to the Director."));
+}
 
 void set_textf(const char *fmt, ...)
 {
index f5bfe112173148552df3c9de4d6d61368a3f5248..a5d90a134cc3200b2e8c32bae12ae5aa8925c795 100644 (file)
@@ -45,6 +45,8 @@ public:
 
 public slots:
    void input_line();
+   void about();
+   void treeItemClicked(QTreeWidgetItem *item, int column);
 
 private:
    QString m_UserInput;