]> git.sur5r.net Git - bacula/bacula/commitdiff
bat updates
authorKern Sibbald <kern@sibbald.com>
Tue, 6 Mar 2007 18:42:31 +0000 (18:42 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 6 Mar 2007 18:42:31 +0000 (18:42 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4323 91ce42f0-d328-0410-95d8-f526ca767f89

12 files changed:
bacula/src/dird/ua_tree.c
bacula/src/qt-console/console/console.cpp
bacula/src/qt-console/images/home.png [new file with mode: 0644]
bacula/src/qt-console/images/mark.png [new file with mode: 0644]
bacula/src/qt-console/images/next.png [new file with mode: 0644]
bacula/src/qt-console/images/prev.png [new file with mode: 0644]
bacula/src/qt-console/images/unmark.png [new file with mode: 0644]
bacula/src/qt-console/images/up.png [new file with mode: 0644]
bacula/src/qt-console/mainwin.cpp
bacula/src/qt-console/mainwin.h
bacula/src/qt-console/restore/restore.cpp
bacula/src/qt-console/restore/restore.ui

index 3a2d160a708a45bc0f6d4b959e2b962b86850ce9..1ff7d51353fbb5f299c4f90da8173cbdf86155df 100644 (file)
@@ -103,6 +103,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
    /* Get a new context so we don't destroy restore command args */
    UAContext *ua = new_ua_context(tree->ua->jcr);
    ua->UA_sock = tree->ua->UA_sock;   /* patch in UA socket */
+   BSOCK *user = ua->UA_sock;
 
    bsendmsg(tree->ua, _(
       "\nYou are now entering file selection mode where you add (mark) and\n"
@@ -121,9 +122,11 @@ bool user_select_files_from_tree(TREE_CTX *tree)
       if (!get_cmd(ua, "$ ")) {
          break;
       }
+      if (ua->api) user->signal(BNET_CMD_BEGIN);
       parse_args_only(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS);
       if (ua->argc == 0) {
          bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n"));
+         if (ua->api) user->signal(BNET_CMD_FAILED);
          continue;
       }
 
@@ -138,8 +141,10 @@ bool user_select_files_from_tree(TREE_CTX *tree)
          }
       if (!found) {
          bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n"));
+         if (ua->api) user->signal(BNET_CMD_FAILED);
          continue;
       }
+      if (ua->api) user->signal(BNET_CMD_OK);
       if (!stat) {
          break;
       }
index b0bde34df22f1b80cdcf558e37aec1eb4a9e5b4d..38b4a0cf2b25ae0461db7e877ac2f0a5b05f6dc3 100644 (file)
@@ -99,7 +99,7 @@ void Console::terminate()
       m_sock->close();
       m_sock = NULL;
    }
-   m_timer->stop();
+// m_timer->stop();
 }
 
 /*
diff --git a/bacula/src/qt-console/images/home.png b/bacula/src/qt-console/images/home.png
new file mode 100644 (file)
index 0000000..045339c
Binary files /dev/null and b/bacula/src/qt-console/images/home.png differ
diff --git a/bacula/src/qt-console/images/mark.png b/bacula/src/qt-console/images/mark.png
new file mode 100644 (file)
index 0000000..f066077
Binary files /dev/null and b/bacula/src/qt-console/images/mark.png differ
diff --git a/bacula/src/qt-console/images/next.png b/bacula/src/qt-console/images/next.png
new file mode 100644 (file)
index 0000000..0d15331
Binary files /dev/null and b/bacula/src/qt-console/images/next.png differ
diff --git a/bacula/src/qt-console/images/prev.png b/bacula/src/qt-console/images/prev.png
new file mode 100644 (file)
index 0000000..991a49d
Binary files /dev/null and b/bacula/src/qt-console/images/prev.png differ
diff --git a/bacula/src/qt-console/images/unmark.png b/bacula/src/qt-console/images/unmark.png
new file mode 100644 (file)
index 0000000..4f7ea94
Binary files /dev/null and b/bacula/src/qt-console/images/unmark.png differ
diff --git a/bacula/src/qt-console/images/up.png b/bacula/src/qt-console/images/up.png
new file mode 100644 (file)
index 0000000..fabe7bf
Binary files /dev/null and b/bacula/src/qt-console/images/up.png differ
index 767ae66cfc6f38049fb135f7f2abeeec2000ed75..306aea39d6372b34068f70fc496d0574769ddbcc 100644 (file)
@@ -61,6 +61,39 @@ void MainWin::resetFocus()
    lineEdit->setFocus();
 }   
 
+void MainWin::keyPressEvent(QKeyEvent *event)
+{
+   if (m_cmd_history.size() == 0) {
+      event->ignore();
+      return;
+   }
+   switch (event->key()) {
+   case Qt::Key_Down:
+//    Dmsg0(000, "Down key pressed\n");
+      if (m_cmd_last < 0 || m_cmd_last >= (m_cmd_history.size()-1)) {
+         event->ignore();
+         return;
+      }
+      m_cmd_last++;
+      break;
+   case Qt::Key_Up:
+//    Dmsg0(000, "Up key pressed\n");
+      if (m_cmd_last == 0) {
+         event->ignore();
+         return;
+      }
+      if (m_cmd_last < 0 || m_cmd_last > (m_cmd_history.size()-1)) {
+         m_cmd_last = m_cmd_history.size() - 1;
+      } else {
+         m_cmd_last--;
+      }
+      break;
+   default:
+      event->ignore();
+      return;
+   }
+   lineEdit->setText(m_cmd_history[m_cmd_last]);
+}
 
 void MainWin::createConnections()
 {
@@ -168,6 +201,8 @@ void MainWin::input_line()
    } else {
       set_status("Director not connected. Click on connect button.");
    }
+   m_cmd_history.append(cmdStr);
+   m_cmd_last = -1;
 }
 
 
index 9ec324080104142dd0d390ac7d03642b3ca9f00f..68d37bbb60af997c450d7a0b1f938754b03546c7 100644 (file)
@@ -69,6 +69,7 @@ public slots:
 
 protected:
    void closeEvent(QCloseEvent *event);
+   void keyPressEvent(QKeyEvent *event);
 
 private:
    void createConnections(); 
@@ -76,6 +77,8 @@ private:
 private:
    QString m_UserInput;
    Console *m_console;
+   QStringList m_cmd_history;
+   int m_cmd_last;
 };
 
 #endif /* _MAINWIN_H_ */
index 0a7c416788898dee04db7781e996e48c8bd938f3..144a17667a019a18605fcf20a2ccefda97590d0a 100644 (file)
@@ -122,7 +122,7 @@ void restoreDialog::fillDirectory()
       }
       split_path_and_filename(p, &path, &pnl, &file, &fnl);
       item.clear();
-      item << "" << file << modes << user << group << size << date;
+      item << marked << file << modes << user << group << size << date;
       QTreeWidgetItem *ti = new QTreeWidgetItem((QTreeWidget *)0, item);
       ti->setTextAlignment(5, Qt::AlignRight); /* right align size */
       items.append(ti);
@@ -159,13 +159,17 @@ void restoreDialog::fileDoubleClicked(QTreeWidgetItem *item, int column)
    char cmd[1000];
    if (column == 0) {                 /* mark/unmark */
       if (item->text(0) == "*") {
-         bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"\n", item->text(1).toUtf8().data());
+         bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
          item->setText(0, " ");
       } else {
-         bsnprintf(cmd, sizeof(cmd), "mark \"%s\"\n", item->text(1).toUtf8().data());
+         bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
          item->setText(0, "*");
       }
-      m_console->write(cmd);
+      m_console->write_dir(cmd);
+      if (m_console->read() > 0) {
+         strip_trailing_junk(m_console->msg());
+         statusLine->setText(m_console->msg());
+      }
       m_console->displayToPrompt();
       return;
    }    
@@ -191,14 +195,15 @@ void restoreDialog::markButtonPushed()
    QTreeWidgetItem *item;
    char cmd[1000];
    foreach (item, items) {
-      Dmsg1(000, "item=%s\n", item->text(1).toUtf8().data());
-      if (item->text(0) == " ") {
-         bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
-         item->setText(0, "*");
-         m_console->write(cmd);
-         Dmsg1(000, "cmd=%s\n", cmd);
-         m_console->displayToPrompt();
+      bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
+      item->setText(0, "*");
+      m_console->write_dir(cmd);
+      if (m_console->read() > 0) {
+         strip_trailing_junk(m_console->msg());
+         statusLine->setText(m_console->msg());
       }
+      Dmsg1(100, "cmd=%s\n", cmd);
+      m_console->discardToPrompt();
    }
 }
 
@@ -208,13 +213,15 @@ void restoreDialog::unmarkButtonPushed()
    QTreeWidgetItem *item;
    char cmd[1000];
    foreach (item, items) {
-      if (item->text(0) == "*") {
-         bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
-         item->setText(0, " ");
-         m_console->write(cmd);
-         Dmsg1(000, "cmd=%s\n", cmd);
-         m_console->displayToPrompt();
+      bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
+      item->setText(0, " ");
+      m_console->write_dir(cmd);
+      if (m_console->read() > 0) {
+         strip_trailing_junk(m_console->msg());
+         statusLine->setText(m_console->msg());
       }
+      Dmsg1(100, "cmd=%s\n", cmd);
+      m_console->discardToPrompt();
    }
 }
 
@@ -226,7 +233,7 @@ bool restoreDialog::cwd(const char *dir)
    int stat;
    char cd_cmd[MAXSTRING];
 
-   bsnprintf(cd_cmd, sizeof(cd_cmd), "cd \"%s\"\n", dir);
+   bsnprintf(cd_cmd, sizeof(cd_cmd), "cd \"%s\"", dir);
    Dmsg2(100, "dir=%s cmd=%s\n", dir, cd_cmd);
    m_console->write_dir(cd_cmd);
    if ((stat = m_console->read()) > 0) {
index a746e40c0b75bada388cc92d18a01cbb3a587865..c9a542698b82565bbece3df903ec90a4d41149a0 100644 (file)
   <property name="windowTitle" >
    <string>Restore File Selection</string>
   </property>
-  <layout class="QVBoxLayout" >
+  <layout class="QGridLayout" >
    <property name="margin" >
     <number>9</number>
    </property>
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item>
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeType" >
-      <enum>QSizePolicy::Fixed</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>20</width>
-       <height>16</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item>
+   <item row="1" column="0" >
     <widget class="QSplitter" name="splitter" >
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
        </item>
       </layout>
      </widget>
-     <widget class="QWidget" name="layoutWidget" >
+     <widget class="QWidget" name="" >
       <layout class="QVBoxLayout" >
        <property name="margin" >
         <number>0</number>
          <property name="alternatingRowColors" >
           <bool>true</bool>
          </property>
+         <property name="selectionMode" >
+          <enum>QAbstractItemView::ExtendedSelection</enum>
+         </property>
+         <property name="horizontalScrollMode" >
+          <enum>QAbstractItemView::ScrollPerItem</enum>
+         </property>
+         <property name="uniformRowHeights" >
+          <bool>true</bool>
+         </property>
          <property name="columnCount" >
           <number>7</number>
          </property>
      </widget>
     </widget>
    </item>
-   <item>
+   <item row="0" column="0" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="2" column="0" >
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>
      </item>
     </layout>
    </item>
-   <item>
+   <item row="3" column="0" >
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>