| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/qt/TeQtProgress.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraView - visualization and exploration of geographical databases
    00003 using TerraLib.
    00004 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio.
    00005 This file is part of TerraView. TerraView is free software; you can redistribute it
    00006 and/or modify 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 You should have received a copy of the GNU General Public License
    00011 along with TerraView.
    00012 The authors reassure the license terms regarding the warranties.
    00013 They specifically disclaim any warranties, including, but not limited to,
    00014 the implied warranties of merchantability and fitness for a particular purpose.
    00015 The software provided hereunder is on an "as is" basis, and the authors have no
    00016 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00017 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00018 indirect, special, incidental, or consequential damages arising out of the use of
    00019 this program and its documentation.
    00020 *************************************************************************************/
    00021
    00022 #ifndef  __TERRALIB_INTERNAL_QTPROGRESS_H
    00023 #define  __TERRALIB_INTERNAL_QTPROGRESS_H
    00024
    00025 #include <qprogressdialog.h>
    00026 #include <qapplication.h>
    00027 #include <qcursor.h>
    00028 #include <qaction.h>
    00029 #include "../../kernel/TeProgress.h"
    00030 #include <qeventloop.h>
    00031
    00032 #include "../../kernel/TeDefines.h"
    00033
    00034 class TL_DLL TeQtProgress : public QProgressDialog, public TeProgressBase
    00035 {
    00036            Q_OBJECT
    00037
    00038 protected:
    00039            int                   numberOfCursors_;     //<! Number of cursors that were pushed on application stack.
    00040
    00041            void enterEvent ( QEvent * )
    00042            {
    00043                       if(QApplication::overrideCursor())
    00044                       {
    00045                                  if(QApplication::overrideCursor()->shape() != Qt::ArrowCursor)
    00046                                  {
    00047                                             QApplication::setOverrideCursor( Qt::ArrowCursor );
    00048                                             numberOfCursors_++;
    00049                                  }
    00050                       }
    00051            }
    00052
    00053            void leaveEvent ( QEvent * )
    00054            {
    00055                       if(QApplication::overrideCursor())
    00056                       {
    00057                                  if(QApplication::overrideCursor()->shape() == Qt::ArrowCursor)
    00058                                  {
    00059                                             QApplication::restoreOverrideCursor();
    00060                                             numberOfCursors_--;
    00061                                  }
    00062                       }
    00063            }
    00064
    00065 public:
    00066            TeQtProgress( QWidget * creator = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0)
    00067                       : QProgressDialog(creator, name, modal, f)
    00068            {
    00069                       numberOfCursors_ = 0;
    00070            }
    00071
    00072            ~TeQtProgress() {}
    00073
    00074            void reset()
    00075            {
    00076                       int i;
    00077                       QProgressDialog::reset();
    00078                       QProgressDialog::setLabelText("");
    00079                       QProgressDialog::setCaption("");
    00080
    00081                       //Restore all cursors that were set by TeQtProgress.
    00082                       for (i=0; i<numberOfCursors_; i++)
    00083                       {
    00084                                  if(QApplication::overrideCursor())
    00085                                             QApplication::restoreOverrideCursor();
    00086                       }
    00087                       numberOfCursors_ = 0;
    00088            }
    00089
    00090            void setTotalSteps (int steps)
    00091            {
    00092                       QProgressDialog::setTotalSteps(steps);
    00093                       if(QApplication::overrideCursor())
    00094                       {
    00095                                  if(QApplication::overrideCursor()->shape() != Qt::WaitCursor)
    00096                                  {
    00097                                             QApplication::setOverrideCursor( Qt::WaitCursor );
    00098                                             numberOfCursors_++;
    00099                                  }
    00100                       }
    00101                       else
    00102                       {
    00103                                  QApplication::setOverrideCursor( Qt::WaitCursor );
    00104                                  numberOfCursors_++;
    00105                       }
    00106            }
    00107
    00108            void setMessage(const string& text)
    00109            {
    00110                       QProgressDialog::setLabelText(text.c_str());
    00111            }
    00112
    00113            string getMessage()
    00114            {
    00115                       return QProgressDialog::labelText().latin1();
    00116            }
    00117
    00118            void setProgress(int steps)
    00119            {
    00120                       QProgressDialog::setProgress(steps);
    00121            }
    00122
    00123             bool wasCancelled()
    00124             {
    00125                        hasMouse();
    00126                        return QProgressDialog::wasCancelled();
    00127             }
    00128
    00129             void setCaption(const string& cap)
    00130             {
    00131                        QProgressDialog::setCaption(cap.c_str());
    00132             }
    00133
    00134             void cancel()
    00135             {
    00136                        QProgressDialog::cancel();
    00137             }
    00138
    00139 };
    00140 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines