00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef ANATOMYPAGE_H
00021 #define ANATOMYPAGE_H
00022
00023
00024 #include <anatomylayout.h>
00025
00026
00027 #include <qwidget.h>
00028 #include <qtable.h>
00029 #include <qpushbutton.h>
00030 #include <qmap.h>
00031 #include <qregexp.h>
00032 #include <qheader.h>
00033 #include <qmemarray.h>
00034 #include <qlineedit.h>
00035
00036
00037
00038
00039
00040 #include <iostream>
00041 using namespace std;
00042
00043
00048 class AnatomyPage : public AnatomyLayout
00049 {
00050 Q_OBJECT
00051 public:
00053 AnatomyPage(QWidget* parent = 0, const char *name = 0);
00055 ~AnatomyPage();
00056
00060 void setAttributes(const QMap<QString, QMap<int,QString> >& attributes);
00061
00065 void getAttributes(QMap<QString, QMap<int,QString> >& attributesMap)const;
00066
00070 void setGroups(const QMap<int, QValueList<int> >& groups);
00071
00075 void getGroups(QMap<int, QValueList<int> >& groups)const;
00076
00080 inline void setNbChannels(int nbChannels){
00081 this->nbChannels = nbChannels;
00082 for(int i =0; i<attributesTable->numRows();++i) attributesTable->removeRow(i);
00083 attributesTable->setNumRows(nbChannels);
00084 };
00085
00087 inline bool isModified()const{return modified;};
00088
00089 protected:
00094 bool eventFilter(QObject* object,QEvent* event);
00095
00096 public slots:
00098 inline void addGroup(){
00099 if(isIncorrectRow) return;
00100 modified = true;
00101 groupTable->insertRows(groupTable->numRows());
00102
00103 QTableItem* item = new QTableItem(groupTable,QTableItem::WhenCurrent,"");
00104 item->setWordWrap(true);
00105 groupTable->setItem(groupTable->numRows() - 1,0,item);
00106 };
00107
00109 void removeGroup();
00110
00112 inline void slotValidate(){
00113 modified = true;
00114 if(isIncorrectRow){
00115 groupTable->selectRow(incorrectRow);
00116 groupTable->setCurrentCell(incorrectRow,0);
00117 }
00118 };
00119
00121 inline void groupChanged(int row,int column){
00122 modified = true;
00123 QString group = groupTable->text(row,column);
00124
00125 if(isIncorrectRow){
00126 QWidget* widget = groupTable->cellWidget(incorrectRow,0);
00127 QString incorrectGroup;
00128 if(widget != 0 && widget->isA("QLineEdit")) incorrectGroup = static_cast<QLineEdit*>(widget)->text();
00129 else if(widget == 0) incorrectGroup = groupTable->item(incorrectRow,0)->text();
00130 if(incorrectGroup.contains(QRegExp("[^\\d\\s]")) != 0){
00131 groupTable->selectRow(incorrectRow);
00132 groupTable->setCurrentCell(incorrectRow,0);
00133 return;
00134 }
00135 }
00136
00137 isIncorrectRow = false;
00138 incorrectRow = 0;
00139 groupTable->adjustRow(row);
00140
00141
00142 if(group.contains(QRegExp("[^\\d\\s]")) != 0){
00143 isIncorrectRow = true;
00144 incorrectRow = row;
00145 groupTable->selectRow(incorrectRow);
00146 groupTable->setCurrentCell(incorrectRow,0);
00147 }
00148 };
00149
00151 inline void attributeChanged(int row,int column){
00152 modified = true;
00153
00154 QHeader* header = attributesTable->horizontalHeader();
00155 QString attributName = header->label(column);
00156 if(attributName == "Skip"){
00157 bool ok;
00158 QString attribut = attributesTable->text(row,column);
00159 attribut.toInt(&ok);
00160 if(ok) attributesTable->adjustRow(row);
00161 else {
00162 attributesTable->selectRow(row);
00163 attributesTable->setCurrentCell(row,column);
00164 }
00165 }
00166 else attributesTable->adjustRow(row);
00167 };
00168
00170 inline void propertyModified(){modified = true;};
00171
00173 inline void resetModificationStatus(){modified = false;};
00174
00175 private:
00176 int nbChannels;
00177 bool isIncorrectRow;
00178 int incorrectRow;
00179 bool modified;
00180 };
00181
00182
00183
00184 #endif