ij-16.png   inspectorJ -- JavaTM Profiler
sf project site browse source checkout source
SourceForge.net Logo



src/inspectorj/client/wizardcontrol.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   inspectorJ - java profiler                                            *
00003  *   Copyright (C) 2007 by James May
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
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     // wire up the navigation buttons
00044     connect (backNavCtrl, SIGNAL(clicked()), this, SLOT(previousPage()));
00045     connect (nextNavCtrl, SIGNAL(clicked()), this, SLOT(nextPage()));
00046     
00047     // make only the first page visible
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 }

Generated on Sun Aug 19 17:07:53 2007 for inspectorJ by  doxygen 1.5.1