1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-24 20:27:22 +01:00

see #1346 fixed navigation and cleaned up instDialog wizard

This commit is contained in:
Vadim Kurland 2010-06-27 19:22:37 +00:00
parent cbc2b1278a
commit cbd11fb9be
8 changed files with 222 additions and 182 deletions

View File

@ -1 +1 @@
#define BUILD_NUM 3030
#define BUILD_NUM 3032

View File

@ -23,8 +23,11 @@
*/
#include "global.h"
#include "fakeWizard.h"
#include <QtDebug>
FakeWizard::FakeWizard()
{
}
@ -120,30 +123,42 @@ int FakeWizard::pageCount() const
int FakeWizard::previousRelevant(const int page) const
{
if (fwbdebug)
qDebug() << "FakeWizard::previousRelevant(" << page << ")";
int prev_p = -1;
for (int i = page-1; i >= 0; i--)
if (appropriates[i] && appropriate(i))
return i;
return -1;
{
prev_p = i;
break;
}
if (fwbdebug)
qDebug() << "FakeWizard::previousRelevant: previous page" << prev_p;
return prev_p;
}
int FakeWizard::nextRelevant(const int page) const
{
if (fwbdebug)
qDebug() << "FakeWizard::nextRelevant(" << page << ")";
int next_p = -1;
for (int i = page+1; i < m_pageCount; i++)
if (appropriates[i] && appropriate(i))
return i;
return -1;
{
next_p = i;
break;
}
if (fwbdebug)
qDebug() << "FakeWizard::nextRelevant: next page" << next_p;
return next_p;
}
void FakeWizard::showPage(const int page)
{
if (page >= m_pageCount) return;
nextButton->setEnabled(nextEnabled[page] &&
(nextRelevant(page) > -1) );
backButton->setEnabled(backEnabled[page] &&
(previousRelevant(page) > -1) );
nextButton->setEnabled(nextEnabled[page] && (nextRelevant(page) > -1) );
backButton->setEnabled(backEnabled[page] && (previousRelevant(page) > -1) );
finishButton->setEnabled(finishEnabled[page]);
if (titleLabel)

View File

@ -180,7 +180,7 @@ void instDialog::show(ProjectPanel *proj,
installer = NULL;
finished = false;
page_1_op = INST_DLG_COMPILE;
state = NONE;
compile_complete = false;
rejectDialogFlag = false;
m_dialog->selectTable->clear();
@ -229,12 +229,12 @@ void instDialog::show(ProjectPanel *proj,
if (firewalls.size()==0 && clusters.size()==0)
{
setTitle( pageCount()-2, tr("There are no firewalls to process.") );
for (int i=0;i<pageCount()-2;i++)
setTitle(0, tr("There are no firewalls to process."));
for (int i=0; i<pageCount(); i++)
{
setAppropriate(i, false);
}
showPage(pageCount()-2);
showPage(CHOOSE_OBJECTS);
return;
}
@ -271,14 +271,11 @@ void instDialog::show(ProjectPanel *proj,
m_dialog->detailMCframe->show();
this->setVisible(true);
/*
if (firewalls.size() != 1)
m_dialog->inspectGeneratedFiles->hide();
else
m_dialog->inspectGeneratedFiles->show();
*/
// we just started, there is nothing to inspect in the workflow of
// this wizard yet. This button will be enabled when compile phase is complete
m_dialog->inspectGeneratedFiles->setEnabled(compile_complete);
showPage(0);
showPage(CHOOSE_OBJECTS);
}
instDialog::~instDialog()
@ -314,19 +311,22 @@ void instDialog::mainLoopCompile()
// that we "uncheck" "install" checkboxes in the first page of
// the wizard on compile failure, so we need to rebuild install_fw_list
// here.
state = COMPILE_DONE;
fillInstallOpList();
disableStopButton();
if (compile_only)
{
compile_complete = true;
finished = true;
setFinishEnabled(currentPage(), true);
m_dialog->inspectGeneratedFiles->setEnabled(compile_complete);
} else
{
page_1_op = INST_DLG_INSTALL;
setNextEnabled(1, true);
setFinishEnabled(currentPage(), false);
compile_complete = true;
showPage(COMPILE_INSTALL);
// setNextEnabled(currentPage(), true);
// setFinishEnabled(currentPage(), false);
// m_dialog->inspectGeneratedFiles->setEnabled(compile_complete);
}
}
}
@ -359,7 +359,6 @@ void instDialog::mainLoopInstall()
return;
}
state = INSTALL_DONE;
finished = true;
setFinishEnabled(currentPage(), true);
disableStopButton();
@ -377,75 +376,91 @@ void instDialog::showPage(const int page)
m_dialog->batchInstFlagFrame->hide();
}
m_dialog->inspectGeneratedFiles->setEnabled(
compile_complete && page_1_op == INST_DLG_COMPILE);
if (fwbdebug)
qDebug() << "instDialog::showPage page "
<< lastPage << "--->" << page << "page_1_op=" << page_1_op;
FakeWizard::showPage(page);
int p = page;
if (fwbdebug)
qDebug() << QString("State %1 page_1_op %2 page %3 ---> %4")
.arg(state).arg(page_1_op).arg(lastPage).arg(page);
/*
//I don't know why this was here, just commented it out
if (p==2)
switch (page)
{
showPage(1);
return;
}
*/
switch (p)
{
case 0: // select firewalls for compiling and installing
case CHOOSE_OBJECTS: // select firewalls for compiling and installing
{
// if user returned to this page from "compile" page, assume they
// want to recompile
finished = false;
compile_complete = false;
fillCompileSelectList();
setAppropriate(1, tableHasCheckedItems());
setNextEnabled(page, tableHasCheckedItems());
m_dialog->selectTable->setFocus();
if (lastPage<0) fillCompileSelectList();
setNextEnabled(0, tableHasCheckedItems());
break;
}
case 1: // compile and install firewalls
case COMPILE_INSTALL:
{
setBackEnabled(1, false);
setNextEnabled(1, false);
secondPageVisited = true;
fillCompileOpList();
// compile, install firewalls and inspect files, depending on
// the value of page_1_op
setNextEnabled(page, false);
setBackEnabled(page, false);
fillCompileOpList();
fillInstallOpList(); // fill install_fw_list
qDebug() << "compile_fw_list.size()=" << compile_fw_list.size()
<< "install_fw_list.size()=" << install_fw_list.size();
if (compile_fw_list.size()==0 && install_fw_list.size()==0)
{
showPage(CHOOSE_OBJECTS);
return;
}
if (compile_fw_list.size()==0) page_1_op = INST_DLG_INSTALL;
m_dialog->stackedWidget->widget(1)->layout()->removeWidget(m_dialog->logFrame);
m_dialog->stackedWidget->widget(1)->layout()->addWidget(m_dialog->firewallListFrame);
m_dialog->stackedWidget->widget(1)->layout()->addWidget(m_dialog->logFrame);
// Page 1 of the wizard does both compile and install
// controlled by flag page_1_op
// controlled by flag page_1_op. May be it would be less hacky if we
// used sepaarte page for installs, but that page would look exactly
// like the page for compile
switch (page_1_op)
{
case INST_DLG_COMPILE:
{
if (fwbdebug) qDebug("Page 1 compile");
if (compile_fw_list.size()==0)
if (fwbdebug) qDebug() << "Page 1 compile"
<< "compile_complete=" << compile_complete;
// run full compile cycle only if we haven't done it before
// User may click Back on the "Inspect" page, this should return
// them to the "compile" page but not trigger full recompile.
// Flag compile_complete is set in instDialog::mainLoopCompile()
if (compile_complete)
{
if (install_fw_list.size()==0)
{
showPage(0);
return;
}
page_1_op = INST_DLG_INSTALL;
showPage(1);
return;
setNextEnabled(page, true);
setBackEnabled(page, true);
} else
{
mw->fileSave();
currentFirewallsBar->reset();
currentFirewallsBar->setMaximum(compile_list_initial_size);
m_dialog->procLogDisplay->clear();
fillCompileUIList();
qApp->processEvents();
mainLoopCompile();
}
mw->fileSave();
currentFirewallsBar->reset();
currentFirewallsBar->setMaximum(compile_list_initial_size);
m_dialog->procLogDisplay->clear();
fillCompileUIList();
qApp->processEvents();
mainLoopCompile();
setBackEnabled(page, true);
break;
}
case INST_DLG_INSTALL:
{
if (fwbdebug) qDebug("Page 1 install");
@ -457,62 +472,70 @@ void instDialog::showPage(const int page)
fillInstallUIList();
qApp->processEvents();
mainLoopInstall();
break;
}
setBackEnabled(page, false);
break;
}
}
break;
}
case 3:
{
QStringList files;
foreach(Firewall *f, firewalls)
case INST_DLG_INSPECT:
{
//Firewall *f = firewalls.front();
QStringList files;
foreach(Firewall *f, firewalls)
{
QString mainFile = FirewallInstaller::getGeneratedFileFullPath(f);
instConf cnf;
cnf.fwobj = f;
cnf.script = mainFile;
QMap<QString, QString> res;
FirewallInstaller(NULL, &cnf, "").readManifest(mainFile, &res);
files.append(res.keys());
}
QString mainFile = FirewallInstaller::getGeneratedFileFullPath(f);
instConf cnf;
cnf.fwobj = f;
cnf.script = mainFile;
QMap<QString, QString> res;
FirewallInstaller(NULL, &cnf, "").readManifest(mainFile, &res);
files.append(res.keys());
// what is this?
if (m_dialog->stackedWidget->count() == 4 )
m_dialog->stackedWidget->removeWidget(m_dialog->stackedWidget->widget(3));
FirewallCodeViewer *viewer;
if (firewalls.size() == 1)
viewer = new FirewallCodeViewer(
files,
QString("<b>") + firewalls.front()->getName().c_str() + "</b>",
this);
else
viewer = new FirewallCodeViewer(
files, tr("<b>Multiple firewalls</b>"), this);
viewer->hideCloseButton();
viewer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
QWidget *container = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(container);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(6);
QFrame *frame = new QFrame(container);
frame->setLayout(new QHBoxLayout());
frame->layout()->addWidget(viewer);
frame->setFrameShape(QFrame::Box);
frame->setFrameShadow(QFrame::Plain);
frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_dialog->firewallListFrame->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Minimum);
m_dialog->progress_page->layout()->removeWidget(m_dialog->firewallListFrame);
layout->addWidget(m_dialog->firewallListFrame);
layout->addWidget(frame);
frame->layout()->setContentsMargins(0,0,0,0);
m_dialog->stackedWidget->addWidget(container);
m_dialog->stackedWidget->setCurrentIndex(m_dialog->stackedWidget->count()-1);
setNextEnabled(page, true);
setBackEnabled(page, true);
break;
}
} // end switch(page_1_op)
if (m_dialog->stackedWidget->count() == 4 )
m_dialog->stackedWidget->removeWidget(m_dialog->stackedWidget->widget(3));
FirewallCodeViewer *viewer;
if (firewalls.size() == 1)
viewer = new FirewallCodeViewer(files, QString("<b>") + firewalls.front()->getName().c_str() + "</b>", this);
else
viewer = new FirewallCodeViewer(files, tr("<b>Multiple firewalls</b>"), this);
viewer->hideCloseButton();
viewer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
QWidget *container = new QWidget(this);
QHBoxLayout *layout = new QHBoxLayout(container);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(6);
QFrame *frame = new QFrame(container);
frame->setLayout(new QHBoxLayout());
frame->layout()->addWidget(viewer);
frame->setFrameShape(QFrame::Box);
frame->setFrameShadow(QFrame::Plain);
frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_dialog->firewallListFrame->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Minimum);
m_dialog->progress_page->layout()->removeWidget(m_dialog->firewallListFrame);
layout->addWidget(m_dialog->firewallListFrame);
layout->addWidget(frame);
frame->layout()->setContentsMargins(0,0,0,0);
m_dialog->stackedWidget->addWidget(container);
m_dialog->stackedWidget->setCurrentIndex(m_dialog->stackedWidget->count()-1);
m_dialog->backButton->setEnabled(true);
}
break;
} // end case 1:
default: { }
}

View File

@ -72,10 +72,8 @@ namespace libfwbuilder
}
enum BatchOperation {BATCH_INSTALL, BATCH_COMPILE} ;
enum Page1Operation {INST_DLG_COMPILE, INST_DLG_INSTALL};
enum InstDialogState {NONE, COMPILE_DONE, INSTALL_DONE };
typedef std::pair<QString,QString> t_procMess; // first - compilation result, second - installation result;
enum Page1Operation {INST_DLG_COMPILE, INST_DLG_INSTALL, INST_DLG_INSPECT};
enum WizardPageNumber {CHOOSE_OBJECTS=0, COMPILE_INSTALL=1 };
#define FIREWALL_NAME_COLUMN 0
#define COMPILE_CHECKBOX_COLUMN 1
@ -93,12 +91,12 @@ class instDialog : public QDialog, public FakeWizard
Ui::instDialog_q *m_dialog;
instConf cnf;
Page1Operation page_1_op;
InstDialogState state;
FirewallInstaller *installer;
ProjectPanel *project;
instBatchOptionsDialog *batch_inst_opt_dlg;
bool compile_only;
bool compile_complete;
// proc is used to launch external oprocess, such as compiler or
// user-defined installer script
QProcess proc;

View File

@ -397,23 +397,63 @@ void instDialog::opCancelled(Firewall *fw)
void instDialog::nextClicked()
{
if (nextRelevant( currentPage() ) > -1)
showPage(nextRelevant( currentPage() ));
qDebug() << "instDialog::nextClicked() currentPage()=" << currentPage();
if (currentPage() == CHOOSE_OBJECTS)
{
page_1_op = INST_DLG_COMPILE;
showPage(COMPILE_INSTALL);
return;
}
if (currentPage() == COMPILE_INSTALL &&
(page_1_op == INST_DLG_COMPILE || page_1_op == INST_DLG_INSPECT))
{
// clicking "Next" on page 1 (compile/install) changes
// contents of the same page
page_1_op = INST_DLG_INSTALL;
showPage(COMPILE_INSTALL);
return;
}
}
void instDialog::backClicked()
{
if (currentPage() == 3)
if (currentPage() == COMPILE_INSTALL && page_1_op == INST_DLG_COMPILE)
{
m_dialog->stackedWidget->widget(1)->layout()->removeWidget(m_dialog->logFrame);
m_dialog->stackedWidget->widget(1)->layout()->addWidget(m_dialog->firewallListFrame);
m_dialog->stackedWidget->widget(1)->layout()->addWidget(m_dialog->logFrame);
m_dialog->stackedWidget->setCurrentIndex(1);
m_dialog->backButton->setEnabled(false);
// clicking "Back" on page 1 in mode "compile" returns to page 0
page_1_op = INST_DLG_COMPILE;
showPage(CHOOSE_OBJECTS);
return;
}
if (currentPage() == COMPILE_INSTALL && page_1_op == INST_DLG_INSTALL)
{
// clicking "Back" on page 1 in mode "install" changes
// contents of the same page. Ideally, I would like to be
// able to move back from "install" mode to "compile" mode
// without recompiling everything. This is impossible in the
// current implementation because we reuse the same widgets on
// the page. This will be possible when "install" becomes its
// own page of the wizard.
// page_1_op = INST_DLG_COMPILE;
// showPage(COMPILE_INSTALL);
return;
}
if (currentPage() == COMPILE_INSTALL && page_1_op == INST_DLG_INSPECT)
{
page_1_op = INST_DLG_COMPILE;
showPage(COMPILE_INSTALL);
return;
}
if (previousRelevant( currentPage() ) > -1)
showPage(previousRelevant( currentPage() ));
}
void instDialog::inspectFiles()
{
page_1_op = INST_DLG_INSPECT;
showPage(COMPILE_INSTALL);
}
void instDialog::prepareInstConf(Firewall *)
@ -481,6 +521,7 @@ void instDialog::fillCompileSelectList()
QDateTime dt;
creatingTable = true;
m_dialog->selectTable->clear();
list<Firewall*> working_list_of_firewalls = firewalls;
@ -691,20 +732,15 @@ void instDialog::saveLog()
}
}
void instDialog::inspectFiles()
{
showPage(3);
}
/*
* Adds one line of text to the log
*
*/
void instDialog::addToLog(const QString &buf)
{
if (fwbdebug)
qDebug() << "instDialog::addToLog" << QTime::currentTime().toString()
<< "buf.size()=" << buf.size();
// if (fwbdebug)
// qDebug() << "instDialog::addToLog" << QTime::currentTime().toString()
// << "buf.size()=" << buf.size();
if (buf.isEmpty()) return;
@ -731,9 +767,9 @@ void instDialog::addToLog(const QString &buf)
}
}
if (fwbdebug)
qDebug() << "instDialog::addToLog" << QTime::currentTime().toString()
<< "errors and warnings scan done";
// if (fwbdebug)
// qDebug() << "instDialog::addToLog" << QTime::currentTime().toString()
// << "errors and warnings scan done";
/* See sourceforge bug https://sourceforge.net/tracker/?func=detail&aid=2847263&group_id=5314&atid=1070394
*

View File

@ -60,7 +60,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="select_firewalls_page">
<property name="sizePolicy">
@ -540,38 +540,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_3">
<layout class="QGridLayout">
<item row="1" column="0">
<widget class="QTreeWidget" name="lastListView">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="indentation">
<number>20</number>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<column>
<property name="text">
<string>Firewall</string>
</property>
</column>
<column>
<property name="text">
<string>Compile</string>
</property>
</column>
<column>
<property name="text">
<string>Install</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="0">

View File

@ -100,7 +100,7 @@ void instDialogCompileTest::testCompile()
while (!checkProgress(list))
{
// test state of the buttons
QVERIFY(back->isEnabled() == false);
QVERIFY(back->isEnabled() == true);
QVERIFY(next->isEnabled() == false);
QVERIFY(cancel->isEnabled() == true);
QVERIFY(finish->isEnabled() == false);
@ -116,7 +116,7 @@ void instDialogCompileTest::testCompile()
}
// test state of the buttons
QVERIFY(back->isEnabled() == false);
QVERIFY(back->isEnabled() == true);
QVERIFY(next->isEnabled() == false);
QVERIFY(cancel->isEnabled() == true);
QVERIFY(finish->isEnabled() == true);

View File

@ -306,7 +306,7 @@ void instDialogInstallTest::testInstall2()
while (!checkProgress(list))
{
QVERIFY(back->isEnabled() == false);
QVERIFY(back->isEnabled() == true);
QVERIFY(next->isEnabled() == false);
QVERIFY(cancel->isEnabled() == true);
QVERIFY2(finish->isEnabled() == false, "Button Finish is enabled during operation");
@ -439,7 +439,7 @@ void instDialogInstallTest::testInstall3()
while (!checkProgress(list))
{
QVERIFY(back->isEnabled() == false);
QVERIFY(back->isEnabled() == true);
QVERIFY(next->isEnabled() == false);
QVERIFY(cancel->isEnabled() == true);
QVERIFY2(finish->isEnabled() == false, "Button Finish is enabled during operation");
@ -563,7 +563,7 @@ void instDialogInstallTest::executeCancelAndStopTests(const QString &button_name
while (!checkProgress(list))
{
QVERIFY(back->isEnabled() == false);
QVERIFY(back->isEnabled() == true);
QVERIFY(next->isEnabled() == false);
QVERIFY(cancel->isEnabled() == true);
QVERIFY2(finish->isEnabled() == false, "Button Finish is enabled during operation");