spikepage.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Lynn Hazan                                      *
00003  *   lynn.hazan@myrealbox.com                                              *
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 #ifndef SPIKEPAGE_H
00021 #define SPIKEPAGE_H
00022 
00023 //include files for the application
00024 #include <spikelayout.h>
00025 
00026 // include files for QT
00027 #include <qwidget.h>
00028 #include <qtable.h>
00029 #include <qpushbutton.h>
00030 #include <qregexp.h>
00031 #include <qlineedit.h>
00032 
00033 // include files for KDE
00034 
00035 //General C++ include files
00036 #include <iostream>
00037 using namespace std;
00038 
00043 class SpikePage : public SpikeLayout
00044 {
00045 Q_OBJECT
00046 public:
00048  SpikePage(QWidget*parent = 0, const char *name = 0);
00050  ~SpikePage();
00051  
00056  void setGroups(const QMap<int, QValueList<int> >& groups,const QMap<int,  QMap<QString,QString> >& information);
00057  
00061  void getGroups(QMap<int, QValueList<int> >& groups)const;
00062  
00066  void getGroupInformation(QMap<int,  QMap<QString,QString> >& groupInformation)const;
00067 
00069  inline bool isModified()const{return modified;};
00070 
00073  inline int getNbGroups(){return groupTable->numRows();}
00074  
00075 signals:
00076  void nbGroupsModified(int nbGroups);
00077  
00078 protected:
00083  bool eventFilter(QObject* object,QEvent* event);
00084  
00085 public slots:
00087  inline void addGroup(){
00088   if(isIncorrectRow) return; 
00089   modified = true;
00090   groupTable->insertRows(groupTable->numRows());
00091   for(int i = 0;i<groupTable->numCols();++i){
00092    //Use of the the 3 parameter constructor to be qt 3.1 compatible
00093    QTableItem* item = new QTableItem(groupTable,QTableItem::WhenCurrent,"");
00094    item->setWordWrap(true);
00095    groupTable->setItem(groupTable->numRows() - 1,i,item);
00096   }
00097   emit nbGroupsModified(groupTable->numRows());
00098  };
00099  
00101  void removeGroup();
00102  
00104  inline void slotValidate(){
00105   modified = true;
00106   if(isIncorrectRow){
00107    groupTable->selectRow(incorrectRow);
00108   // groupTable->selectColumn(incorrectColumn);
00109    groupTable->setCurrentCell(incorrectRow,incorrectColumn);
00110   }
00111  };
00112  
00114  inline void groupChanged(int row,int column){
00115   modified = true;
00116   QString group = groupTable->text(row,column);
00117     
00118   if(isIncorrectRow){
00119    QWidget* widget = groupTable->cellWidget(incorrectRow,incorrectColumn);
00120    QString incorrectGroup;
00121    if(widget != 0 && widget->isA("QLineEdit")) incorrectGroup = static_cast<QLineEdit*>(widget)->text();
00122    else if(widget == 0) incorrectGroup = groupTable->item(incorrectRow,incorrectColumn)->text();
00123    if(incorrectGroup.contains(QRegExp("[^\\d\\s]")) != 0){
00124     groupTable->selectRow(incorrectRow);
00125     groupTable->setCurrentCell(incorrectRow,incorrectColumn); 
00126     return;
00127    } 
00128   }
00129    
00130   isIncorrectRow = false;
00131   incorrectRow = 0;
00132   incorrectColumn = column;
00133   groupTable->adjustRow(row);   
00134    
00135   //the group entry should only contain digits and whitespaces
00136   if(group.contains(QRegExp("[^\\d\\s]")) != 0){
00137    isIncorrectRow = true;
00138    incorrectRow = row;
00139    incorrectColumn = column;
00140    groupTable->selectRow(incorrectRow);
00141    groupTable->setCurrentCell(incorrectRow,incorrectColumn);
00142   }   
00143  };
00144  
00146  inline void propertyModified(){modified = true;};
00147 
00149  inline void resetModificationStatus(){modified = false;};
00150  
00151 private:
00152  bool isIncorrectRow;
00153  int incorrectRow; 
00154  int incorrectColumn; 
00155  bool modified;
00156 };
00157 
00158 #endif

Generated on Sat Sep 15 16:04:45 2007 for ndmanager.kdevelop by  doxygen 1.5.1