- Timestamp:
- 03/31/10 17:48:54 (14 years ago)
- Location:
- trunk/yao/src/interface/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yao/src/interface/src/ConstantWindow.cpp
r296 r300 21 21 22 22 /*************************************************************** The constructor **********************************************************************/ 23 ConstantWindow::ConstantWindow(Table <Constant> *aConstantTable, HatNameWindow *aHatWindow,QWidget *parent): QWidget(parent) { /*!< The constructor. */23 ConstantWindow::ConstantWindow(Table <Constant> *aConstantTable, QWidget *parent): QWidget(parent) { /*!< The constructor. */ 24 24 25 25 setWindowTitle("Directive Constant."); /*!< To set the window's title. */ 26 26 m_localConstantTable = aConstantTable; 27 27 //localConstantController = aConstantController; 28 localHatWindow = aHatWindow; 29 28 //localHatWindow = aHatWindow; 30 29 31 30 m_nameLabel = new QLabel("Nom constante: ", this); /*!< QLabel for Nom de la constante . */ … … 44 43 QStringList horizontalHeaders; 45 44 horizontalHeaders << "Constante(s)" << "Valeur(s)" << " "; /*!< added Nom Netward Entrees and sorties in table */ 46 47 m_tableView = new QTableWidget(0, 2); /*!< QTableWidget's in whitch the objects are listed for thue view. */ 45 46 modele = new QStandardItemModel(0, 2);//Nombre de lignes et colonnes du modÚle. 47 modele->setHorizontalHeaderLabels(QStringList() << "Constante(s)" << "Valeur(s)"); /*!< displays the QTableWidget */ 48 49 m_tableView = new QTableView; /*!< QTableWidget's in whitch the objects are listed for thue view. */ 50 m_tableView->setModel(modele); 48 51 m_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); /*!< this ligne give no edit mode*/ 49 52 m_tableView->setShowGrid(false); /*!< this ligne cover the grille in table */ 50 53 m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows); /*!< this ligne give a section of the ligne */ 51 m_tableView->setHorizontalHeaderLabels(horizontalHeaders); /*!< displays the QTableWidget */54 //QHeaderView *horiz = new QHeaderView(Qt::Horizontal); 52 55 53 56 m_layoutGrid = new QGridLayout; /*!< set QGridLayout m-layoutG */ … … 64 67 setLayout(m_layoutGrid); //Activation du gestionnaire principal. 65 68 69 66 70 connect(m_helpButton, SIGNAL(clicked()), this, SLOT(callConstantHelp())); 67 71 connect(m_quitButton, SIGNAL(clicked()), this, SLOT(close())); /*!< slot for the close this windows*/ … … 74 78 75 79 /*******************************************************************************************************************************************************/ 76 void ConstantWindow::toUpdate() {77 78 cout << "Pour la mise à jour!" << endl;79 }80 //void ConstantWindow::toUpdate() { 81 82 // cout << "Pour la mise à jour!" << endl; 83 //} 80 84 81 85 /*******************************************************************************************************************************************************/ … … 85 89 QTableWidgetItem *cell2 = new QTableWidgetItem; 86 90 87 for (int i = 0; i < m_tableView->rowCount() ; i++) {88 89 cell1 = m_tableView->item(i, 0);90 cell2 = m_tableView->item(i, 1);91 92 }91 //for (int i = 0; i < m_tableView->rowCount() ; i++) { 92 93 // cell1 = m_tableView->item(i, 0); 94 // cell2 = m_tableView->item(i, 1); 95 96 //} 93 97 94 98 m_quitButton->setEnabled(true); … … 105 109 106 110 //int last; 111 112 //index 107 113 108 114 for(int i1 = 0; i1 < Nom.size(); i1++) { … … 140 146 else { 141 147 if (!(m_ligneNom->text().isEmpty()) || (m_ligneValeur->text().isEmpty())) { 142 148 // for (Table<Constant>::iterator it = m_localConstantTable->begin(); it != m_localConstantTable->end(); it++) 149 //if ( QString(it->getName().c_str()) != Nom) { 150 static int i = 0; 143 151 m_delButton->setEnabled(true); 144 152 Constant localConstant (Nom.toStdString(), Val.toStdString()); 145 153 m_localConstantTable->push_back(localConstant); 146 154 addRow(); // Permet de créer une nouvelle dans le tableau d'affichage. 147 148 int anInt = m_tableView->rowCount(); 149 m_tableView->setItem(anInt - 1, 0, new QTableWidgetItem(m_ligneNom->text())); 150 m_tableView->setItem(anInt -1 , 1, new QTableWidgetItem(m_ligneValeur->text())); 151 152 } 155 156 QStandardItem *item1 = new QStandardItem(m_ligneNom->text()); 157 QStandardItem *item2 = new QStandardItem(m_ligneNom->text()); 158 //modele->appendRow(item1); 159 //modele->appendColumn(item2); 160 modele->setItem(i, 0, new QStandardItem(m_ligneNom->text())); 161 modele->setItem(i, 1, new QStandardItem(m_ligneValeur->text())); 162 // int anInt = m_tableView->rowCount(); 163 // m_tableView->setItem(anInt - 1, 0, new QTableWidgetItem(m_ligneNom->text())); 164 // m_tableView->setItem(anInt -1 , 1, new QTableWidgetItem(m_ligneValeur->text())); 165 166 i++; 167 //int r = m_tableView->currentIndex().row(); 168 //QItemSelectionModel *selection = m_tableView->selectionModel(); 169 //QModelIndex index = selection->currentIndex(); 170 //QVariant element = modele->data(index, Qt::DisplayRole); 171 //QMessageBox::information(this, "Selection", element.toString()); 172 173 //cout << "emis" << endl; 174 emit rowIsAdded(); // signal emis lorsqu'une a été correctement rajoutée dans le tableau. 175 // Il sera recupéré dans le mainwidow. 176 //} 177 } 153 178 } 154 179 155 180 initialiserChamps(); 156 181 //localHatWindow->toUpdate(); 157 emit dataAdded();182 //emit dataAdded(); 158 183 } 159 184 … … 161 186 void ConstantWindow::addRow() { 162 187 163 int row = m_tableView->rowCount(); // Renvoie le nombre de ligne du tableau d'affichage. 164 m_tableView->insertRow(row); 188 //cout << "Je passe ici" << endl; 189 //cout << "m_tableView->currentRow()= " << m_tableView->currentRow() << endl; 190 //cout << "Visual Row: " << m_tableView->visualRow(m_tableView->currentRow()) << endl 191 // int row = m_tableView->rowCount(); // Renvoie le nombre de ligne du tableau d'affichage. 192 // m_tableView->insertRow(row);//Permet d'inserer une nouvelle vierge dans le tableau à une position donnée. 165 193 } 166 194 … … 175 203 void ConstantWindow::deleteRow() { 176 204 177 if (m_tableView->selectedItems().count() > 0) //Permet au bouton supprimer lorsqu'une ligne n'est pas selectionnée. 178 179 m_tableView->removeRow(m_tableView->currentRow()); 180 } 205 int c = m_tableView->currentIndex().row(); 206 QItemSelectionModel *selection = m_tableView->selectionModel(); 207 index = selection->currentIndex(); 208 int r = index.row(); 209 if ((r >= 0) && (c != -1)) 210 { 211 modele->removeRow(r); 212 m_localConstantTable->erase(m_localConstantTable->begin() + r); 213 m_tableView->resizeRowToContents(c - 1); // columnCountChanged(c , c-1); 214 //cout << "Ligne retirée: " << r << endl; 215 //cout << "Nombre de lignes: " << modele->rowCount() << endl; 216 } 217 218 219 emit rowIsDeleted(); // signal emis lorsqu'une ligne retirée du tableau. 220 //QVariant element = modele->data(index, Qt::DisplayRole); 221 222 /* if (m_tableView->selectedItems().count() > 0) //Permet au bouton supprimer lorsqu'une ligne n'est pas selectionnée. 223 224 { 225 m_tableView->removeRow(m_tableView->currentRow()); 226 cout << "Je passe ici" << endl; 227 cout << "m_tableView->currentRow()= " << m_tableView->currentRow() << endl; 228 cut << "m_tableView->selecteditem()= " << m_tableView->selectedItems().count() << endl; 229 m_localConstantTable->erase(m_localConstantTable->begin() + m_tableView->currentRow()); 230 cout << "end erase---------------" << endl; 231 }*/ 232 233 234 //m_tableView->removeRow(index.row()); 235 //cout << "RemoveRow: " << index.row() << endl; 236 } 181 237 182 238 /******************************************************** callConstantHelp() ***************************************************************************/ … … 232 288 /**************************************************************** enregDataConstant(bool tar) **********************************************************/ 233 289 /*******************************************************************************************************************************************************/ 234 /*******************************************************************************************************************************************************/ 235 236 /*******************************************************************************************************************************************************/ 237 238 239 /*******************************************************************************************************************************************************/ 240 241 242 243 244 290 //bool ConstantWindow::event(QEvent *event) { 291 292 // if (isActiveWindow()) 293 // cout << "C'est une fenêtre active!" << endl; 294 // else { 295 // activateWindow();//cout << "Ce n'est pas la fenêtre active!" << endl; 296 // this->show(); 297 // } 298 //} 299 /*******************************************************************************************************************************************************/ 300 301 /*******************************************************************************************************************************************************/ 302 303 304 /*******************************************************************************************************************************************************/ 305 306 307 308 309 -
trunk/yao/src/interface/src/FilesViewer.cpp
r258 r300 18 18 setWindowTitle(tr("Arborescence des fichiers")); 19 19 20 modeleFichiers = new QDirModel; 21 modeleFichiers->setReadOnly(false); 22 modeleFichiers->setSorting(QDir::DirsFirst | QDir::IgnoreCase | QDir::Name);20 modeleFichiers = new QDirModel;//Choix du modÚle. 21 modeleFichiers->setReadOnly(false);//AccÚs en lecture. 22 //modeleFichiers->setSorting(QDir::DirsFirst | QDir::IgnoreCase | QDir::Name); 23 23 24 vueFichiers = new QTreeView; 25 vueFichiers->setModel(modeleFichiers); 24 vueFichiers = new QTreeView;//La vue en arbre. 25 vueFichiers->setModel(modeleFichiers); //La vue prend en compte son modÚle. 26 26 vueFichiers->setRootIndex(modeleFichiers->index("projects/")); 27 27 vueFichiers->header()->setStretchLastSection(true); -
trunk/yao/src/interface/src/HatNameWindow.cpp
r297 r300 29 29 m_comboHatName->insertItem(0, ""); 30 30 31 for (Table<Constant>::iterator it = localConstantTable->begin(); it != localConstantTable->end(); it++) { 31 //QAbstractItemModel * model; 32 for (Table<Constant>::reverse_iterator it = localConstantTable->rbegin(); it != localConstantTable->rend(); it++) { 32 33 m_comboHatName->insertItem(1, QString(it->getName().c_str())); 33 34 … … 39 40 m_boutonAjouter = new QPushButton("Ajouter", this); //Déclaration du bouton "ajouter" 40 41 m_supHatName = new QPushButton("Supprimer", this) ; //Déclaration du bouton "supprimmer" 41 m_supHatName->setDisabled(true);42 //m_supHatName->setDisabled(true); 42 43 m_quitHatName = new QPushButton("Quitter", this); 43 44 m_hatnameHelpButton = new QPushButton("Aide", this); … … 113 114 } 114 115 115 /**************************************************************************************** /116 /******************************************************************************************************************************************************/ 116 117 void HatNameWindow::callHatHelp() { 117 118 … … 119 120 120 121 } 121 /**************************************************************************************** /122 /******************************************************************************************************************************************************/ 122 123 void HatNameWindow::addHatRow() { 123 124 124 125 hatFile = getNomFichierHat(); 125 compteur ++; 126 testContenu(compteur); 126 127 Constant *c; 128 //string chaine = hatFile; 129 130 c = localConstantTable->find(hatFile); 131 132 if (c != NULL) { 133 string constantValue = localConstantTable->find(hatFile)->getText(); 134 //cout << constantValue << endl; 135 /* for(unsigned int i=0; i < constantValue.size(); i++) 136 // stringLiteral of the YAO grammar: 137 // (' ' | '\t')* ( 'a'..'z' | 'A'..'Z' | '/' | '_' | '-' | '.'| '0'..'9' )+ (' ' | '\t')* 138 if(!((constantValue[i] >= 'a' && constantValue[i]<= 'z') || (constantValue[i] >= 'A' && constantValue[i] <= 'Z') || 139 (constantValue[i] >= '0' && constantValue[i] <= '9') || (constantValue[i] == '/') || 140 (constantValue[i] == '_') || (constantValue[i] == '.') || (constantValue[i] == ' ') )){ 141 */ 142 143 listeFichiers.append(hatFile.c_str()); 144 modeleFichiers->setStringList(listeFichiers); 145 hatHeaderList->push_back(hatFile); 146 initialiserChamps(); 147 148 149 150 // QMessageBox::about(this, tr("Erreur !"), 151 // tr("<p>Valeur incorrecte.")); 152 // return; 153 } 154 155 156 else { 157 127 158 128 159 for(unsigned int i=0; i < hatFile.size(); i++) { … … 145 176 { 146 177 if (hatFile.length() != 0) { 178 // string chaine = hatHeaderList.find(hatFile);//->getText(); 179 //if (chaine) 180 //{ 181 // hatHeaderList->push_back(chaine); 182 //return; 183 //} 147 184 hatFile.append(".h"); 148 185 QString fichier = hatFile.c_str(); 149 186 //listeFichiers.removeFirst(); 187 150 188 listeFichiers.append(fichier); 151 189 … … 164 202 return; 165 203 } 166 167 QString fichier = hatFile.c_str(); 168 listeFichiers.append(fichier); 169 170 modeleFichiers->setStringList(listeFichiers); 171 172 initialiserChamps(); 173 } 174 204 else { 205 if (hatFile.length() < 2) { 206 initialiserChamps(); 207 return ; 208 } 209 else 210 if (hatFile.length() > 2) 211 { 212 QString fichier = hatFile.c_str(); 213 listeFichiers.append(fichier); 214 hatHeaderList->push_back(hatFile); 215 216 modeleFichiers->setStringList(listeFichiers); 217 218 initialiserChamps(); 219 } 220 } 221 222 //QString fichier = hatFile.c_str(); 223 //listeFichiers.append(fichier); 224 225 //modeleFichiers->setStringList(listeFichiers); 226 227 //initialiserChamps(); 228 } 229 } 175 230 /****************************************************************************************/ 176 231 void HatNameWindow::deleteHatRow() { … … 182 237 listeFichiers.removeOne(elementSelectionne.toString());//Retrait de l'élément sélectionné de l'objet QStringList 183 238 modeleFichiers->setStringList(listeFichiers); //On indique au modÚle la liste des éléments à afficher. 184 239 185 240 -- compteur; 186 241 testContenu(compteur); … … 194 249 } 195 250 196 /*************************************************************************************** */251 /***************************************************************************************/ 197 252 void HatNameWindow::toUpdate() { 198 253 254 //cout << "Dans le hat" << endl; 255 //this->activateWindow(); 256 //modeleFichiers->refresh(); 257 //modeleFichiers->reset(); 258 //vueFichiers->reset(); 199 259 //~HatNameWindow(); 200 260 // if (this->isActiveWindow()) … … 204 264 //vueFichiers->setModel(modeleFichiers); 205 265 // cout << "Salut!" << endl; 206 266 // HatNameWindow(hatHeaderList, localConstantTable); 207 267 //vueFichiers->~QListView(); 208 268 //vueFichiers = new QListView; … … 286 346 } 287 347 /******************************************************************************************************************************************************/ 348 //void HatNameWindow::updateComb 349 /******************************************************************************************************************************************************/ 288 350 HatNameWindow::~HatNameWindow() { 289 351 -
trunk/yao/src/interface/src/Include/ConstantWindow.hpp
r298 r300 11 11 #include <QPushButton> 12 12 #include <QTableWidget> 13 #include <QTableView> 14 #include <QItemSelectionModel> 15 #include <QtGui> 16 //#include <QVariant> 17 //#include <QModelIndex> 13 18 #include <QLineEdit> 14 19 #include <QLabel> … … 39 44 */ 40 45 41 ConstantWindow(yao::Table<yao::Constant> *aConstantTable, HatNameWindow *aHatWindow,QWidget *parent=0); /*!< This function returns the constante's data. */46 ConstantWindow(yao::Table<yao::Constant> *aConstantTable, QWidget *parent=0); /*!< This function returns the constante's data. */ 42 47 void addRow(); 43 48 void testContenu(int anInt); 44 49 void initialiserChamps(); 45 static void toUpdate();50 //static void toUpdate(); 46 51 protected : 47 52 // void closeEvent(QCloseEvent *event); 53 //bool event(QEvent *event); 48 54 49 55 public slots : /*!< Functions called after a click. */ 50 56 void callConstantHelp(); 51 57 void addRowInTable(); 52 void deleteRow() ;58 void deleteRow() ; 53 59 void saveData(); 54 60 55 61 signals : 56 62 57 void dataAdded(); 63 //void dataAdded(); 64 void rowIsAdded(); 65 void rowIsDeleted(); 58 66 59 67 private: … … 79 87 QStringList m_savedData; 80 88 81 QTableWidget *m_tableView; 89 QStandardItemModel *modele; 90 QModelIndex index; 91 QTableView *m_tableView; 82 92 83 93 bool isSaved; -
trunk/yao/src/interface/src/Include/MainWindow.hpp
r291 r300 96 96 void createProjectDirectory(); 97 97 void openPathWindow(); 98 void setTitle(); 99 void setWindowTitle(const QString &title); 100 void hatUpdate(); 101 98 102 signals : 99 103 100 104 void newProjectIsCreated(); 105 void newProjectIsCreated(QString chaine); 106 void WindowTitleChanged(); 101 107 102 108 private : -
trunk/yao/src/interface/src/MainWindow.cpp
r296 r300 29 29 30 30 setWindowTitle(" Visual YAO "); //Donne un titre à la fenêtre principale 31 32 31 espace = new QWorkspace; //Crée un espace de travail. Ici, ça serait notre zone centrale 33 32 … … 49 48 barreEtat = statusBar(); //Affiche la barre d'état. 50 49 50 connect(m_ConstantCopy, SIGNAL(rowIsAdded()), this, SLOT(hatUpdate())); 51 connect(m_ConstantCopy, SIGNAL(rowIsDeleted()), this, SLOT(hatUpdate())); 51 52 QDockWidget *dock3 = new QDockWidget("Résultats", this);///////////////////////////////// 52 53 dock3->setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea); … … 60 61 tabWidget->addTab(page2, " Exécution "); 61 62 62 //connect(this, SIGNAL(newProjectIsCreated()), this, SLOT(quit()));63 connect(this, SIGNAL(WindowTitleChanged()), this, SLOT(setTitle())); 63 64 this->showMaximized(); // Maximise toujours la fenetre principale. 65 66 } 67 /***************************************************************************************************************************************************/ 68 void MainWindow::setTitle() { 69 70 QWidget::setWindowTitle("Projet courant: " + QString(getProjectName().c_str()) ); 71 //QWidget::setWindowTitle(title); 64 72 65 73 } … … 232 240 m_constantButton = new QPushButton(tr("Constant"), this); 233 241 m_constantButton->setToolTip("Bouton désactivé. Vous devez d'abord creer un nouveau projet ou en ouvrir un."); 234 m_ConstantCopy = new ConstantWindow(&theConstantTable, m_hatCopy); 242 243 m_ConstantCopy = new ConstantWindow(&theConstantTable); 235 244 espace->addWindow(m_ConstantCopy); 236 245 m_ConstantCopy->hide(); 237 246 connect(m_constantButton, SIGNAL(clicked()), m_ConstantCopy, SLOT(show())); 238 247 connect(m_constantButton, SIGNAL(clicked()), this, SLOT(changeColorConstantButton())); 239 //connect(espace, SIGNAL(windowActivated(m_constantButton)), espace, SLOT(setActiveWindow(m_constantButton)));240 248 //connect(m_constantButton, SIGNAL(clicked()), espace, SLOT(activeWindow())); 241 249 242 250 m_hatNameButton = new QPushButton(tr("Hatname"), this); 243 251 connect(m_hatNameButton, SIGNAL(clicked()), this, SLOT(changeColorHatButton())); … … 409 417 } 410 418 419 /*****************************************************************************************************************************************/ 420 void MainWindow::hatUpdate() { 421 422 //if(!m_hatCopy->isActiveWindow()) 423 // { 424 //m_hatCopy->setUpdatesEnabled(true); 425 //m_hatCopy->activateWindow(); 426 //espace->addWindow(m_hatCopy); 427 //delete m_hatCopy; 428 //HatNameWindow *m_hatCopy2 = new HatNameWindow; 429 //espace->addWindow(m_hatCopy2); 430 // } 431 //m_hatCopy->setUpdatesEnabled(true); 432 //HatNameWindow *m_hatCopy2 = new HatNameWindow(&theHaderList, &theConstantTable);//getProjectName());//mwc.getHatName();; 433 //espace->setActiveWindow(m_hatCopy); 434 //espace->setActiveWindow(m_ConstantCopy); 435 if (m_hatCopy != NULL) //Teste si l'objet n'est pas déjà crée. 436 { 437 438 //m_hatCopy->close(); //Ferme l'ancienne fenêtre. 439 delete m_hatCopy; 440 m_hatCopy = new HatNameWindow(&theHaderList, &theConstantTable); //Crée un autre objet. 441 espace->addWindow(m_hatCopy); 442 m_hatCopy->show(); 443 espace->setActiveWindow(m_ConstantCopy); 444 } 445 //m_hatCopy->activateWindow(); 446 //cout << "appel reçu" << endl; 447 448 449 } 411 450 /********************************************* helpMessage() *****************************************************************************/ 412 451 void MainWindow::helpMessage() { … … 470 509 /************************************ createProjectDirectory() ******************************************************/ 471 510 void MainWindow::createProjectDirectory() { 472 511 512 theConstantTable.clear(); 513 theHaderList.clear(); 514 473 515 setProjectName(m_lineDirName->text().toStdString()); //Fonction permettant d'initialiser le nom du projet. 474 516 setProjectPath(m_linePath->text().toStdString()); //Fonction permettant d'initialiser le chemin du projet. 475 517 if (!theConstantTable.empty()) { 518 519 theConstantTable.clear(); 520 //if (espace->getActiveWindow(m_ConstantCopy)) { 521 // m_ConstantCopy->close(); 522 // delete m_ConstantCopy;} 523 } 524 //this->setWindowTitle(" Visual YAO -" + getProjectName() + "-"); 476 525 //directivesManager(); 477 526 theHaderList.push_back(getProjectName() + ".h"); … … 563 612 564 613 emit newProjectIsCreated(); 614 QString nouveauTitre = "Projet courant: " ;//+ QString(getProjectName().c_str()); 615 setWindowTitle(nouveauTitre); 565 616 } 566 617 /*******************************/ 618 void MainWindow::setWindowTitle(const QString &title) { 619 620 QWidget::setWindowTitle(title); 621 emit WindowTitleChanged(); 622 } 567 623 /************************************** createFile(string data, string extension) **********************************************/ 568 624 void MainWindow::createFile(string data, string extension) {
Note: See TracChangeset
for help on using the changeset viewer.