From: Kern Sibbald Date: Fri, 9 Mar 2007 10:36:41 +0000 (+0000) Subject: Get bat select dialog working X-Git-Tag: Release-7.0.0~6774 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dba1953746129a868799cf4ad49e64b9fa2b0614;p=bacula%2Fbacula Get bat select dialog working git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4335 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index ed89f32b0f..ae5f9b989d 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -758,7 +758,11 @@ int do_prompt(UAContext *ua, const char *automsg, const char *msg, if (ua->api) user->signal(BNET_START_SELECT); bsendmsg(ua, ua->prompt[0]); for (i=1; i < ua->num_prompts; i++) { - bsendmsg(ua, "%6d: %s\n", i, ua->prompt[i]); + if (ua->api) { + bsendmsg(ua, "%s", ua->prompt[i]); + } else { + bsendmsg(ua, "%6d: %s\n", i, ua->prompt[i]); + } } if (ua->api) user->signal(BNET_END_SELECT); diff --git a/bacula/src/qt-console/Makefile b/bacula/src/qt-console/Makefile index 4b9f358fe6..6598099a4f 100644 --- a/bacula/src/qt-console/Makefile +++ b/bacula/src/qt-console/Makefile @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: bat -# Generated by qmake (2.01a) (Qt 4.2.1) on: Mon Mar 5 17:45:21 2007 +# Generated by qmake (2.01a) (Qt 4.2.1) on: Fri Mar 9 09:22:17 2007 # Project: bat.pro # Template: app # Command: /usr/bin/qmake -unix -o Makefile bat.pro @@ -17,7 +17,7 @@ CFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES) CXXFLAGS = -pipe -g -D_REENTRANT -Wall -W $(DEFINES) LEXFLAGS = YACCFLAGS = -d -INCPATH = -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -Iconsole -Irestore -I.. -Imoc -I. +INCPATH = -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include -I. -Iconsole -Irestore -Iselect -I.. -Imoc -I. LINK = g++ LFLAGS = LIBS = $(SUBLIBS) -L/usr/lib -L../lib -lbac -lssl -lcrypto -lQtGui -L/usr/lib -L/usr/X11R6/lib -lpng -lSM -lICE -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -ldl -lpthread @@ -55,11 +55,13 @@ SOURCES = main.cpp \ restore/restore.cpp \ restore/brestore.cpp \ label/label.cpp \ - run/run.cpp moc/moc_mainwin.cpp \ + run/run.cpp \ + select/select.cpp moc/moc_mainwin.cpp \ moc/moc_console.cpp \ moc/moc_restore.cpp \ moc/moc_label.cpp \ moc/moc_run.cpp \ + moc/moc_select.cpp \ qrc_main.cpp OBJECTS = obj/main.o \ obj/bat_conf.o \ @@ -72,11 +74,13 @@ OBJECTS = obj/main.o \ obj/brestore.o \ obj/label.o \ obj/run.o \ + obj/select.o \ obj/moc_mainwin.o \ obj/moc_console.o \ obj/moc_restore.o \ obj/moc_label.o \ obj/moc_run.o \ + obj/moc_select.o \ obj/qrc_main.o DIST = /usr/share/qt4/mkspecs/common/unix.conf \ /usr/share/qt4/mkspecs/common/g++.conf \ @@ -123,7 +127,7 @@ first: all all: Makefile $(TARGET) -$(TARGET): ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h $(OBJECTS) +$(TARGET): ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_select.h $(OBJECTS) $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS) Makefile: bat.pro /usr/share/qt4/mkspecs/default/qmake.conf /usr/share/qt4/mkspecs/common/unix.conf \ @@ -168,7 +172,7 @@ qmake: FORCE dist: @$(CHK_DIR_EXISTS) obj/bat1.0.0 || $(MKDIR) obj/bat1.0.0 - $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h qstd.h console/console.h restore/restore.h label/label.h run/run.h obj/bat1.0.0/ && $(COPY_FILE) --parents main.qrc obj/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp qstd.cpp console/authenticate.cpp console/console.cpp restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp label/label.cpp run/run.cpp obj/bat1.0.0/ && $(COPY_FILE) --parents main.ui label/label.ui console/console.ui restore/restore.ui restore/prerestore.ui restore/brestore.ui run/run.ui obj/bat1.0.0/ && (cd `dirname obj/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname obj/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r obj/bat1.0.0 + $(COPY_FILE) --parents $(SOURCES) $(DIST) obj/bat1.0.0/ && $(COPY_FILE) --parents mainwin.h bat.h bat_conf.h qstd.h console/console.h restore/restore.h label/label.h run/run.h select/select.h obj/bat1.0.0/ && $(COPY_FILE) --parents main.qrc obj/bat1.0.0/ && $(COPY_FILE) --parents main.cpp bat_conf.cpp mainwin.cpp qstd.cpp console/authenticate.cpp console/console.cpp restore/prerestore.cpp restore/restore.cpp restore/brestore.cpp label/label.cpp run/run.cpp select/select.cpp obj/bat1.0.0/ && $(COPY_FILE) --parents main.ui label/label.ui console/console.ui restore/restore.ui restore/prerestore.ui restore/brestore.ui run/run.ui select/select.ui obj/bat1.0.0/ && (cd `dirname obj/bat1.0.0` && $(TAR) bat1.0.0.tar bat1.0.0 && $(COMPRESS) bat1.0.0.tar) && $(MOVE) `dirname obj/bat1.0.0`/bat1.0.0.tar.gz . && $(DEL_FILE) -r obj/bat1.0.0 yaccclean: @@ -192,9 +196,9 @@ mocclean: compiler_moc_header_clean compiler_moc_source_clean mocables: compiler_moc_header_make_all compiler_moc_source_make_all -compiler_moc_header_make_all: moc/moc_mainwin.cpp moc/moc_console.cpp moc/moc_restore.cpp moc/moc_label.cpp moc/moc_run.cpp +compiler_moc_header_make_all: moc/moc_mainwin.cpp moc/moc_console.cpp moc/moc_restore.cpp moc/moc_label.cpp moc/moc_run.cpp moc/moc_select.cpp compiler_moc_header_clean: - -$(DEL_FILE) moc/moc_mainwin.cpp moc/moc_console.cpp moc/moc_restore.cpp moc/moc_label.cpp moc/moc_run.cpp + -$(DEL_FILE) moc/moc_mainwin.cpp moc/moc_console.cpp moc/moc_restore.cpp moc/moc_label.cpp moc/moc_run.cpp moc/moc_select.cpp moc/moc_mainwin.cpp: ui_main.h \ label/label.h \ ui_label.h \ @@ -230,6 +234,11 @@ moc/moc_run.cpp: ui_run.h \ /usr/bin/moc /usr/bin/moc $(DEFINES) $(INCPATH) run/run.h -o moc/moc_run.cpp +moc/moc_select.cpp: ui_select.h \ + select/select.h \ + /usr/bin/moc + /usr/bin/moc $(DEFINES) $(INCPATH) select/select.h -o moc/moc_select.cpp + compiler_rcc_make_all: qrc_main.cpp compiler_rcc_clean: -$(DEL_FILE) qrc_main.cpp @@ -256,9 +265,9 @@ compiler_image_collection_clean: -$(DEL_FILE) qmake_image_collection.cpp compiler_moc_source_make_all: compiler_moc_source_clean: -compiler_uic_make_all: ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h +compiler_uic_make_all: ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_select.h compiler_uic_clean: - -$(DEL_FILE) ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h + -$(DEL_FILE) ui_main.h ui_label.h ui_console.h ui_restore.h ui_prerestore.h ui_brestore.h ui_run.h ui_select.h ui_main.h: main.ui /usr/bin/uic main.ui -o ui_main.h @@ -280,6 +289,9 @@ ui_brestore.h: restore/brestore.ui ui_run.h: run/run.ui /usr/bin/uic run/run.ui -o ui_run.h +ui_select.h: select/select.ui + /usr/bin/uic select/select.ui -o ui_select.h + compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_image_collection_clean compiler_moc_source_clean compiler_uic_clean ####### Compile @@ -427,6 +439,23 @@ obj/run.o: run/run.cpp bat.h \ qstd.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/run.o run/run.cpp +obj/select.o: select/select.cpp bat.h \ + mainwin.h \ + ui_main.h \ + label/label.h \ + ui_label.h \ + run/run.h \ + ui_run.h \ + restore/restore.h \ + ui_brestore.h \ + ui_restore.h \ + ui_prerestore.h \ + bat_conf.h \ + qstd.h \ + select/select.h \ + ui_select.h + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/select.o select/select.cpp + obj/moc_mainwin.o: moc/moc_mainwin.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_mainwin.o moc/moc_mainwin.cpp @@ -442,6 +471,9 @@ obj/moc_label.o: moc/moc_label.cpp obj/moc_run.o: moc/moc_run.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_run.o moc/moc_run.cpp +obj/moc_select.o: moc/moc_select.cpp + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/moc_select.o moc/moc_select.cpp + obj/qrc_main.o: qrc_main.cpp $(CXX) -c $(CXXFLAGS) $(INCPATH) -o obj/qrc_main.o qrc_main.cpp diff --git a/bacula/src/qt-console/bat.pro b/bacula/src/qt-console/bat.pro index 40d4eb1916..f45400a204 100644 --- a/bacula/src/qt-console/bat.pro +++ b/bacula/src/qt-console/bat.pro @@ -6,7 +6,7 @@ CONFIG += qt debug TEMPLATE = app TARGET = bat DEPENDPATH += . -INCLUDEPATH += . ./console ./restore +INCLUDEPATH += . ./console ./restore ./select INCLUDEPATH += .. LIBS += -L../lib LIBS += -lbac @@ -21,6 +21,7 @@ FORMS += label/label.ui FORMS += console/console.ui FORMS += restore/restore.ui restore/prerestore.ui restore/brestore.ui FORMS += run/run.ui +FORMS += select/select.ui HEADERS += mainwin.h bat.h bat_conf.h qstd.h @@ -41,3 +42,7 @@ SOURCES += label/label.cpp # Run dialog HEADERS += run/run.h SOURCES += run/run.cpp + +# Select dialgo +HEADERS += select/select.h +SOURCES += select/select.cpp diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index 37af5b8e66..1da5d1826d 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -505,6 +505,9 @@ int Console::read() break; } continue; + case BNET_START_SELECT: + new selectDialog(this); + break; } if (is_bnet_stop(m_sock)) { /* error or term request */ m_sock->close(); @@ -549,4 +552,3 @@ void Console::setDirRes(DIRRES *dir) { m_dir = dir; } - diff --git a/bacula/src/qt-console/console/console.h b/bacula/src/qt-console/console/console.h index 1907f1c95b..29347ed0cf 100644 --- a/bacula/src/qt-console/console/console.h +++ b/bacula/src/qt-console/console/console.h @@ -36,6 +36,7 @@ #include #include "ui_console.h" #include "restore.h" +#include "select.h" #ifndef MAX_NAME_LENGTH #define MAX_NAME_LENGTH 128 diff --git a/bacula/src/qt-console/label/label.ui b/bacula/src/qt-console/label/label.ui index 99ed73599e..c97c139193 100644 --- a/bacula/src/qt-console/label/label.ui +++ b/bacula/src/qt-console/label/label.ui @@ -1,6 +1,9 @@ labelForm + + Qt::ApplicationModal + 0 diff --git a/bacula/src/qt-console/main.ui b/bacula/src/qt-console/main.ui index 57cc9a6fcc..1e04c09e50 100644 --- a/bacula/src/qt-console/main.ui +++ b/bacula/src/qt-console/main.ui @@ -34,25 +34,34 @@ 5 7 - 1 + 0 1 - 200 + 50 100 - 400 + 16777215 16777215 Qt::StrongFocus + + false + + + QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable|QDockWidget::NoDockWidgetFeatures + + + Qt::NoDockWidgetArea + Page Selector @@ -80,6 +89,12 @@ 0 + + + 16777215 + 16777215 + + 0 @@ -105,7 +120,7 @@ 7 7 - 200 + 1 0 diff --git a/bacula/src/qt-console/restore/prerestore.ui b/bacula/src/qt-console/restore/prerestore.ui index 57f81b04de..d1cf00abd9 100644 --- a/bacula/src/qt-console/restore/prerestore.ui +++ b/bacula/src/qt-console/restore/prerestore.ui @@ -1,6 +1,9 @@ prerestoreForm + + Qt::ApplicationModal + 0 diff --git a/bacula/src/qt-console/restore/restore.ui b/bacula/src/qt-console/restore/restore.ui index c9a542698b..6e89bc371d 100644 --- a/bacula/src/qt-console/restore/restore.ui +++ b/bacula/src/qt-console/restore/restore.ui @@ -1,6 +1,9 @@ restoreForm + + Qt::ApplicationModal + 0 @@ -130,7 +133,7 @@ - + 0 diff --git a/bacula/src/qt-console/run/run.ui b/bacula/src/qt-console/run/run.ui index 4924a28916..5c76ccf061 100644 --- a/bacula/src/qt-console/run/run.ui +++ b/bacula/src/qt-console/run/run.ui @@ -1,6 +1,9 @@ runForm + + Qt::ApplicationModal + 0 diff --git a/bacula/src/qt-console/select/select.cpp b/bacula/src/qt-console/select/select.cpp new file mode 100644 index 0000000000..8772bbdb85 --- /dev/null +++ b/bacula/src/qt-console/select/select.cpp @@ -0,0 +1,98 @@ +/* + Bacula® - The Network Backup Solution + + Copyright (C) 2007-2007 Free Software Foundation Europe e.V. + + The main author of Bacula is Kern Sibbald, with contributions from + many others, a complete list can be found in the file AUTHORS. + This program is Free Software; you can redistribute it and/or + modify it under the terms of version two of the GNU General Public + License as published by the Free Software Foundation plus additions + that are listed in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. + + Bacula® is a registered trademark of John Walker. + The licensor of Bacula is the Free Software Foundation Europe + (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, + Switzerland, email:ftf@fsfeurope.org. +*/ + +/* + * Select dialog class + * + * Kern Sibbald, March MMVII + * + * $Id: $ + */ + +#include "bat.h" +#include "select.h" + +/* + * Setup all the combo boxes and display the dialog + */ +selectDialog::selectDialog(Console *console) +{ + QDateTime dt; + int stat; + QListWidgetItem *item; + int row = 0; + + m_console = console; + setupUi(this); + connect(listBox, SIGNAL(currentRowChanged(int)), this, SLOT(index_change(int))); + m_console->read(); /* get title */ + labelWidget->setText(m_console->msg()); + while ((stat=m_console->read()) > 0) { + item = new QListWidgetItem; + item->setText(m_console->msg()); + listBox->insertItem(row++, item); + } +// Dmsg1(000, "Stat=%d\n", stat); + m_console->read(); /* get prompt signal */ + m_console->read(); /* get prompt */ +// Dmsg1(000, "Prompt=%s", m_console->msg()); + this->show(); +} + +void selectDialog::accept() +{ + char cmd[100]; + + this->hide(); + + bsnprintf(cmd, sizeof(cmd), "%d", m_index+1); + m_console->write_dir(cmd); + m_console->displayToPrompt(); + delete this; + mainWin->resetFocus(); +} + + +void selectDialog::reject() +{ + mainWin->set_status(" Canceled"); + this->hide(); + delete this; + mainWin->resetFocus(); +} + +/* + * Called here when the jobname combo box is changed. + * We load the default values for the new job in the + * other combo boxes. + */ +void selectDialog::index_change(int index) +{ +// Dmsg1(000, "Index=%d\n", index); + m_index = index; +} diff --git a/bacula/src/qt-console/select/select.h b/bacula/src/qt-console/select/select.h new file mode 100644 index 0000000000..4e035b1823 --- /dev/null +++ b/bacula/src/qt-console/select/select.h @@ -0,0 +1,27 @@ + +#ifndef _SELECT_H_ +#define _SELECT_H_ + +#include +#include "ui_select.h" +#include "console.h" + +class selectDialog : public QDialog, public Ui::selectForm +{ + Q_OBJECT + +public: + selectDialog(Console *console); + +public slots: + void accept(); + void reject(); + void index_change(int index); + +private: + Console *m_console; + int m_index; + +}; + +#endif /* _SELECT_H_ */ diff --git a/bacula/src/qt-console/select/select.ui b/bacula/src/qt-console/select/select.ui new file mode 100644 index 0000000000..8595a65087 --- /dev/null +++ b/bacula/src/qt-console/select/select.ui @@ -0,0 +1,82 @@ + + selectForm + + + Qt::NonModal + + + + 0 + 0 + 377 + 323 + + + + Selection dialog + + + + 9 + + + 6 + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + + + + + + + + + + + + + buttonBox + accepted() + selectForm + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + selectForm + reject() + + + 316 + 260 + + + 286 + 274 + + + + +