00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #include "wizardcontrol.h"
00028
00029 namespace inspectorj {
00030 namespace client {
00031
00032
00033
00040 WizardControl::WizardControl(QList<QWidget*> *pages, QAbstractButton* backNavCtrl, QAbstractButton* nextNavCtrl)
00041 : currentPage(1), pages(pages), backNavCtrl(backNavCtrl), nextNavCtrl(nextNavCtrl)
00042 {
00043
00044 connect (backNavCtrl, SIGNAL(clicked()), this, SLOT(previousPage()));
00045 connect (nextNavCtrl, SIGNAL(clicked()), this, SLOT(nextPage()));
00046
00047
00048 for (int i = 0; i < pages->size(); ++i) {
00049 if (i == 0) {
00050 pages->at(i)->setVisible(true);
00051 } else {
00052 pages->at(i)->setVisible(false);
00053 }
00054 }
00055
00056 updateNavigationBtns();
00057 }
00058
00062 WizardControl::~WizardControl()
00063 {
00064 }
00065
00070 int WizardControl::getNumPages()
00071 {
00072 return pages->size();
00073 }
00074
00079 int WizardControl::getCurrentPageNum()
00080 {
00081 return currentPage;
00082 }
00083
00087 void WizardControl::previousPage()
00088 {
00089 if (currentPage > 1) {
00090 pages->at(currentPage - 1)->setVisible(false);
00091 currentPage--;
00092 pages->at(currentPage - 1)->setVisible(true);
00093 nextNavCtrl->setEnabled(true);
00094 updateNavigationBtns();
00095
00096 if (currentPage == 1) {
00097 emit firstPage();
00098 }
00099
00100 emit pageChanged(currentPage);
00101 emit pageBackward(currentPage);
00102 }
00103 }
00104
00108 void WizardControl::nextPage()
00109 {
00110 if (currentPage < pages->size()) {
00111 pages->at(currentPage - 1)->setVisible(false);
00112 currentPage++;
00113 pages->at(currentPage - 1)->setVisible(true);
00114 backNavCtrl->setEnabled(true);
00115 updateNavigationBtns();
00116
00117 if (currentPage == pages->size()) {
00118 emit lastPage(currentPage);
00119 }
00120
00121 emit pageChanged(currentPage);
00122 emit pageForward(currentPage);
00123 }
00124 }
00125
00129 void WizardControl::updateNavigationBtns()
00130 {
00131 if (currentPage <= 1) {
00132 backNavCtrl->setEnabled(false);
00133 }
00134
00135 if (currentPage >= pages->size()){
00136 nextNavCtrl->setEnabled(false);
00137 }
00138 }
00139
00140 }
00141 }