| 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/TeQtGrid.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_QTGRID_H
    00023 #define  __TERRALIB_INTERNAL_QTGRID_H
    00024
    00025 #include <qwidget.h>
    00026 #include <qtable.h>
    00027 #include <qcolor.h>
    00028 #include <qlabel.h>
    00029 #include <qpopupmenu.h>
    00030 #include <vector>
    00031 #include <map>
    00032 #include <set>
    00033 #include <string>
    00034 #include "../../kernel/TeDatabase.h"
    00035 #include "TeAppTheme.h"
    00036 #include "TeApplicationUtils.h"
    00037
    00038 #include "../../kernel/TeDefines.h"
    00039
    00040 using namespace std;
    00041
    00042 class TL_DLL TeQtGrid : public QTable
    00043 {
    00044            Q_OBJECT
    00045
    00046 protected:
    00047            TeDatabase                                  *db_;
    00048            TeAppTheme            *theme_;
    00049            TeDatabasePortal                 *portal_;
    00050            string                                                 sqlJoin_;
    00051            string                                                 orderBy_;
    00052            string                                                 sql_;
    00053            string                                                 CT_;
    00054            string                                                 CTE_;
    00055            vector<string>                              indexVector_;
    00056            vector<TeTable>                             tableVector_;
    00057            bool                                                   editing_;
    00058            bool                                                   doRefresh_;
    00059            bool                                                   doRepaint_;
    00060            bool                                                   shiftKeyPressed_;
    00061            bool                                                   showGridInformation_;
    00062            int                                                               uniqueIdPos_;
    00063            int                                                               objectIdPos_;
    00064            int                                                               resultIdPos_;
    00065            int                                                               gridStatusPos_;
    00066            int                                                               gridX_, gridY_;
    00067            int                                                               iLine_, fLine_;
    00068            int                                                               iCol_, fCol_;
    00069            int                                                               gridWidth_, gridHeight_;
    00070            int                                                               visibleLines_, visibleCols_;
    00071            long                                                   lastLinePressed_;
    00072            long                                                   dragLineReleased_;
    00073            map<string, ObjectInfo>          objectMap_;
    00074            map<string, string>              unique2ObjectMap_;
    00075            vector<int>                                            gridToPortalRowVector_;
    00076            vector<int>                                            gridToPortalColVector_;
    00077            vector<bool>                                gridColVisVector_;
    00078            vector<string>                              portalRow2UniqueIdVector_;
    00079            int                                                               rowToEdit_;
    00080            int                                                               colToEdit_;
    00081            bool                                                   verticalEdition_;
    00082            QPopupMenu                                  *popupHorizHeader_;
    00083            QPopupMenu                                  *popupVertHeader_;
    00084            QPopupMenu                                  *popupViewport_;
    00085            bool                                                   columnDragEnabled_;
    00086            bool                                                   mousePressedOnHorizontalHeader_;
    00087
    00088            virtual bool eventFilter(QObject*, QEvent*);
    00089
    00090            virtual void drawContents (QPainter *qp, int clipx, int clipy,
    00091                                                                                 int clipw, int cliph);
    00092
    00093            //void sort(vector<int> cols, string order);
    00094
    00095            bool writeCell();
    00096
    00097            void editNextRow();
    00098
    00099            void editNextColumn();
    00100
    00101            void update();
    00102
    00103            void goToEditNewCell();
    00104
    00105            virtual void endEdit(int row, int col, bool accept, bool replace);
    00106
    00107            void arrangeColumns(TeAttrTableVector cTableVec);
    00108
    00109 public:
    00110
    00111            bool autoPromote_;
    00112
    00113            TeQtGrid (QWidget* parent = 0, const char* name = 0);
    00114
    00115            ~TeQtGrid();
    00116
    00117            void init(TeAppTheme *theme);
    00118
    00119            void initPortal();
    00120
    00121            void updatePortalContents();
    00122
    00123            QPopupMenu* popupHorizHeader()
    00124                       { return popupHorizHeader_; }
    00125
    00126            QPopupMenu* popupVertHeader()
    00127                       { return popupVertHeader_; }
    00128
    00129            QPopupMenu* popupViewport()
    00130                       { return popupViewport_; }
    00131
    00132            TeDatabasePortal* getPortal()
    00133                       { return portal_; }
    00134            TeAppTheme* getTheme()
    00135     {  return theme_;}
    00136
    00137
    00138            bool isIndex(int col);
    00139
    00140            bool isDateTimeRegistered(int col);
    00141
    00142            bool isSortBy(int col);
    00143
    00144            bool isExternalTable(int col);
    00145
    00146            TeTable& findTable(int col);
    00147
    00148            TeTable& findTable(string colName);
    00149
    00150            void adjustColumns();
    00151
    00152            void swapColumns(int col1 = -1, int col2 = -1);
    00153
    00154            int        getColumn(int col) {return gridToPortalColVector_[col];}
    00155
    00156            void setVisColumn (bool vis, int col=-1);
    00157
    00158            bool getVisColumn (int col);
    00159
    00160            void putColorOnGrid(set<string> uniqueIdSet, set<string> objectIdSet, string operation, string attrQuery = "");
    00161
    00162            void setVerticalEdition(bool flag);
    00163
    00164            void refresh();
    00165
    00166            void clear();
    00167
    00168            void clearPortal();
    00169
    00170            string     getObject(int row);
    00171
    00172            bool isVerticalEdition() { return verticalEdition_; }
    00173
    00174            bool showGridInformation() { return showGridInformation_;}
    00175
    00176            void showGridInformation(bool b) { showGridInformation_ = b;}
    00177
    00178            void gridInformation ();
    00179
    00180            void insertObjectIntoCollection(string newId, string newTId = "");
    00181
    00182            void goToLastLine();
    00183
    00184            void goToLastColumn();
    00185
    00186            bool hasPointedLine();
    00187
    00188            void deletePointedLines();
    00189
    00190            vector<int> getSelectedColumns();
    00191
    00192            void arrangeGridToPortalRowVector(int col);
    00193
    00194 public slots:
    00195            void mouseReleasedOnVerticalHeaderSlot(int lin);
    00196
    00197            void promotePointedObjectsSlot();
    00198
    00199            void promoteQueriedObjectsSlot();
    00200
    00201            void sortAscOrderSlot();
    00202
    00203            void sortDescOrderSlot();
    00204
    00205            void sort(vector<int> cols, string order);
    00206
    00207            void removeQueryColorSlot();
    00208
    00209            void removePointingColorSlot();
    00210
    00211            void scrollToPrevPointedObjectSlot();
    00212
    00213            void scrollToNextPointedObjectSlot();
    00214
    00215            void scrollToPrevQueriedObjectSlot();
    00216
    00217            void scrollToNextQueriedObjectSlot();
    00218
    00219            void invertSelectionSlot();
    00220
    00221 protected slots:
    00222            void columnWidthChanged(int col);
    00223
    00224 signals:
    00225            void putColorOnObject(TeAppTheme*, set<string>&);
    00226            void horizHeaderSignal(int);
    00227            void vertHeaderSignal(int);
    00228            void viewportSignal();
    00229            void vertHeaderLeftDblClickSignal(int);
    00230            void linkTable(string, string, string);
    00231            void gridChangedSignal();
    00232            void displayGridInformation(QString);
    00233            void clearGridInformation();
    00234 };
    00235
    00236
    00237
    00238
    00239 class TL_DLL TeQtGridItem : public QTableItem
    00240 {
    00241            QColor color_;
    00242
    00243 public:
    00244     TeQtGridItem(QTable *t, EditType et, const QString &txt)
    00245                       : QTableItem( t, et, txt )
    00246            {}
    00247
    00248            void setColor(QColor& c)
    00249            { color_.setRgb(c.red(), c.green(), c.blue()); }
    00250
    00251     void paint(QPainter *p, const QColorGroup &cg,
    00252                              const QRect &cr, bool selected );
    00253 };
    00254
    00255 #endif

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines