From: Kern Sibbald Date: Tue, 6 Mar 2007 18:42:31 +0000 (+0000) Subject: bat updates X-Git-Tag: Release-7.0.0~6781 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=42fe6350082bd564e8d6edfe58739e76d4075b27;p=bacula%2Fbacula bat updates git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4323 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 3a2d160a70..1ff7d51353 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -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; } diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index b0bde34df2..38b4a0cf2b 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -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 index 0000000000..045339ceab 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 index 0000000000..f066077ec2 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 index 0000000000..0d15331f06 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 index 0000000000..991a49dc95 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 index 0000000000..4f7ea94020 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 index 0000000000..fabe7bf7df Binary files /dev/null and b/bacula/src/qt-console/images/up.png differ diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 767ae66cfc..306aea39d6 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -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; } diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 9ec3240801..68d37bbb60 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -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_ */ diff --git a/bacula/src/qt-console/restore/restore.cpp b/bacula/src/qt-console/restore/restore.cpp index 0a7c416788..144a17667a 100644 --- a/bacula/src/qt-console/restore/restore.cpp +++ b/bacula/src/qt-console/restore/restore.cpp @@ -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) { diff --git a/bacula/src/qt-console/restore/restore.ui b/bacula/src/qt-console/restore/restore.ui index a746e40c0b..c9a542698b 100644 --- a/bacula/src/qt-console/restore/restore.ui +++ b/bacula/src/qt-console/restore/restore.ui @@ -12,30 +12,14 @@ Restore File Selection - + 9 6 - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - + Qt::Horizontal @@ -146,7 +130,7 @@ - + 0 @@ -327,6 +311,15 @@ true + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::ScrollPerItem + + + true + 7 @@ -371,7 +364,23 @@ - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + 0 @@ -435,7 +444,7 @@ - + 0