Changeset 205 for trunk


Ignore:
Timestamp:
02/18/10 17:10:23 (14 years ago)
Author:
yerima
Message:

DefvalWindow? herits from BaseWindow? in visual Yao.

Location:
trunk/yao/src/interface/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/yao/src/interface/src/BaseWindow.cpp

    r201 r205  
    44         
    55        this->setWindowTitle("Directive  .");     /*!< To set the window's title. */ 
    6         //isCalled = false; 
     6                isCalled = false; 
    77                // Instanciation des classes. 
    88                // Déclaration des boutons et champs de saisie de texte. 
    9  
    10                 //compteur                      = 0; 
     9                compteur                = 0; 
    1110                 
    1211                m_nameLabel             = new QLabel("Entrée 1: ");    /*!< QLabel for Nom de la constante . */ 
     
    4847        //index = m_tableView ->currentIndex(); 
    4948 
    50         //m_modeleListeNoms                     = new QStringListModel(m_listeNoms); 
     49        m_modeleListeNoms                       = new QStringListModel(m_listeNoms); 
    5150 
    5251        this->setLayout(m_layoutGrid); //Activation du gestionnaire principal. 
    5352 
    5453        // Gestion des connexions entre les widgets. 
    55         connect(m_quitButton , SIGNAL(clicked()), this, SLOT(close()));  /*!< slot for the close this windows*/ 
    56         //connect(m_delButton , SIGNAL(clicked()), this, SLOT(delete Row())); /*!< To delete the object selected in the view*/ 
    57         //connect(m_addButton , SIGNAL(clicked()), this, SLOT(add Row()));  /*!< This slot add the object in the view */ 
    58         //connect(m_HelpButton, SIGNAL(clicked()), this, SLOT(call Help())); /*!< This slot opens the help window */ 
    59         //connect(m_saveButton, SIGNAL(clicked()), this, SLOT(save Data())); /*!< This slot save data in structure */ 
     54        connect(m_quitButton, SIGNAL(clicked()), this, SLOT(close()));  /*!< slot for the close this windows*/ 
     55        connect(m_addButton, SIGNAL(clicked()), this, SLOT(addRowInTable()));  /*!< This slot add the object in the view */ 
     56        connect(m_delButton, SIGNAL(clicked()), this, SLOT(deleteRow())); /*!< To delete the object selected in the view*/ 
     57        connect(m_saveButton, SIGNAL(clicked()), this, SLOT(saveData())); /*!< This slot save data in structure */ 
    6058 
    6159        this->setFixedWidth(baseSize().width() + 410); 
    6260} 
    63 /****************************************** add Row() method **********************************************/ 
    64 /*void BaseWindow::add Row() { 
     61/****************************************** addRowInTable() method **********************************************/ 
     62void BaseWindow::addRowInTable() { 
    6563 
    6664        addRow();                               // Permet de créer une nouvelle dans le tableau d'affichage. 
     
    7169    static int i = 1; 
    7270    static int j = 1; 
    73         QString Nom  = m_ligneNom ->text(); 
    74         QString Val  = m_ligneValeur ->text(); 
    75  
    76  
    77         for(int i1 = 0; i1 < Nom .size(); i1++) 
    78                 if(!((Nom .at(i1) >= QChar('a')&& Nom .at(i1) <= QChar('z')) || (Nom .at(i1) >= QChar('A')&& Nom .at(i1) <= QChar('Z')) //-------- 
    79                 || (Nom .at(i1) >= QChar('0')&& Nom .at(i1) <= QChar('9')) || (Nom .at(i1) == QChar('_')))) //|| (line1.isEmpty()) 
     71        QString Nom  = m_ligneNom->text(); 
     72        QString Val  = m_ligneValeur->text(); 
     73 
     74 
     75        for(int i1 = 0; i1 < Nom.size(); i1++) 
     76                if(!((Nom .at(i1) >= QChar('a')&& Nom .at(i1) <= QChar('z')) || (Nom .at(i1) >= QChar('A')&& Nom .at(i1) <= QChar('Z')) 
     77                        || (Nom .at(i1) >= QChar('0')&& Nom .at(i1) <= QChar('9')) || (Nom .at(i1) == QChar('_')))) //|| (line1.isEmpty()) 
    8078                        { 
    8179                                QMessageBox::critical(this, "Erreur", "Veuillez entrer une valeur exacte du nom de la constante."); 
    8280                                return; // Arrêt de la méthode 
    8381                        } 
    84         for(int i2 = 0; i2 < Val .size(); i2++) 
     82        for(int i2 = 0; i2 < Val.size(); i2++) 
    8583                if(!((Val .at(i2) >= QChar('a') && Val .at(i2) <= QChar('z')) || (Val .at(i2) >= QChar('A')&& Val .at(i2) <= QChar('Z'))  
    86                 ||(Val .at(i2) >= QChar('0') && Val .at(i2) <= QChar('9')) || (Val .at(i2) == QChar('_')) || (Val .at(i2) == QChar('-')) || (Val .at(i2) == QChar('E')) || (Val .at(i2) == QChar('e')) || (Val .at(i2) == QChar('+')) || (Val .at(i2) == QChar('.')))) //|| (line1.isEmpty()) 
    87                         { 
     84                        ||(Val .at(i2) >= QChar('0') && Val .at(i2) <= QChar('9')) || (Val .at(i2) == QChar('_')) || (Val .at(i2) == QChar('-'))  
     85                        || (Val .at(i2) == QChar('E')) || (Val .at(i2) == QChar('e')) || (Val .at(i2) == QChar('+')) || (Val .at(i2) == QChar('.')))) { 
     86 
    8887                                QMessageBox::critical(this, "Erreur", "Veuillez entrer une valeur correcte pour la constante."); 
    8988                                return; // Arrêt de la méthode 
    9089                        } 
    91         if ( m_ligneNom ->text().isEmpty()) 
     90        if (m_ligneNom->text().isEmpty()) 
    9291                { 
    93                 QMessageBox::critical(this, "Erreur", "Le champ du nom de la constante est vide: entrer un nom SVP!"); 
    94                 return; // Arrêt de la méthode 
     92                        QMessageBox::critical(this, "Erreur", "Le champ du nom de la constante est vide: entrer un nom SVP!"); 
     93                        return; // Arrêt de la méthode 
    9594                } 
    9695 
     
    9897                if (isCalled) {--i ; isCalled = false; } 
    9998 
    100         addNameInTable(i, j, m_ligneNom ->text()); 
    101         m_listeNoms .append(m_ligneNom ->text() + " " + m_ligneValeur ->text()); 
    102         addValueInTable(i, j, m_ligneValeur ->text()); 
    103  
     99        addNameInTable(i, j, m_ligneNom->text()); 
     100        m_listeNoms.append(m_ligneNom->text() + " " + m_ligneValeur->text()); 
     101        addValueInTable(i, j, m_ligneValeur->text()); 
    104102        i++; 
    105103        } 
    106104 
    107105        initialiserChamps(); 
    108 }*/ 
     106} 
     107/************************************ addRow() method ****************************************************/ 
     108void BaseWindow::addRow() { 
     109 
     110        int row = m_tableView->rowCount(); 
     111        m_tableView->insertRow(row); 
     112        compteur ++; 
     113} 
     114 
    109115/************************************ delete Row() method ****************************************************/ 
    110 /*void BaseWindow::delete Row() { 
    111  
    112         m_tableView ->removeRow(m_tableView ->currentRow()); 
     116void BaseWindow::deleteRow() { 
     117 
     118        m_tableView->removeRow(m_tableView->currentRow()); 
    113119        isCalled = true; 
    114120        -- compteur; 
    115121        testContenu(compteur); 
    116 }*/ 
     122} 
    117123 
    118124/****************************************************************************************/ 
    119 /*void BaseWindow::addNameInTable(int ligne, int colonne, QString nom ) { 
     125void BaseWindow::addNameInTable(int ligne, int colonne, QString nom ) { 
    120126 
    121127        QTableWidgetItem *chaine = new QTableWidgetItem; 
    122128                chaine->setText(nom ); 
    123129 
    124         m_tableView ->setItem(ligne-1, colonne-1, new QTableWidgetItem(nom )); 
    125 }*/ 
     130        m_tableView->setItem(ligne-1, colonne-1, new QTableWidgetItem(nom )); 
     131} 
    126132 
    127133/****************************************************************************************/ 
    128 /*void BaseWindow::addValueInTable(int ligne, int colonne, QString valeur ) { 
     134void BaseWindow::addValueInTable(int ligne, int colonne, QString valeur ) { 
    129135 
    130136        QTableWidgetItem *chaine = new QTableWidgetItem; 
    131137                chaine->setText(valeur ); 
    132138 
    133         m_tableView ->setItem(ligne - 1, colonne, chaine); 
    134 }*/ 
    135  
    136 /****************************************************************************************/ 
    137 /*void BaseWindow::addRow() { 
    138  
    139         int row = m_tableView ->rowCount(); 
    140         m_tableView ->insertRow(row); 
    141         compteur ++; 
    142 }*/ 
    143 /****************************************************************************************/ 
    144 /*void BaseWindow::save Data() { 
     139        m_tableView->setItem(ligne - 1, colonne, chaine); 
     140} 
     141 
     142/*****************************************************************************************************************************************************/ 
     143void BaseWindow::saveData() { 
    145144 
    146145        QTableWidgetItem *cell1 = new QTableWidgetItem; 
    147146        QTableWidgetItem *cell2 = new QTableWidgetItem;  
    148147         
    149         for (int i = 0; i < m_tableView ->rowCount() ; i++) { 
    150                         cell1 = m_tableView ->item(i,0); 
    151                         cell2 = m_tableView ->item(i,1); 
     148        for (int i = 0; i < m_tableView->rowCount() ; i++) { 
     149 
     150                        cell1 = m_tableView->item(i, 0); 
     151                        cell2 = m_tableView->item(i, 1); 
    152152                                 
    153                          Data.push_back(cell1->text() + " " + cell2->text()); 
     153                        m_savedData.push_back(cell1->text() + " " + cell2->text()); 
    154154 
    155155        } 
    156156        //for (QStringList::iterator it =  Data.begin(); it !=  Data.end(); it++) 
    157157        //cout << "Voici les valeurs ajoutées: " << it->toStdString() <<endl; 
    158         m_quitButton ->setEnabled(true); 
    159 }*/ 
    160 /****************************************************************************************/ 
    161 //void BaseWindow::initialiserChamps() { 
    162  
    163 //      m_ligneNom ->setText(""); 
    164 //      m_ligneValeur ->setText(""); 
    165 //} 
    166  
    167 /************************************ Implémentation de la méthode callHelp  ****************************************/ 
    168 //void BaseWindow::call Help() 
    169 //{ 
    170 //      QMessageBox::about(this, tr("Aide sur la directive  ."),("<p> La directive   permet d'associer un nom symbolique à une valeur." 
    171     //                                                              "<p><u>Exemple 1</u>:   szx 12 <p><u>Exemple 2</u>:   szy \"chaine\"<p> <u>Exemple 3</u>:   szz szx" 
    172   //                                                                "<p> Pour plus d'informations sur  , <a href=\"help/ _aide.html\">cliquez ici.</a>")); 
    173 //} 
    174  
    175 /****************************************************************************************/ 
    176  
    177 /****************************************************************************************************************************/ 
    178 //QStringList BaseWindow::getData () { 
    179  
    180 //      return  Data; 
    181 //} 
     158        m_quitButton->setEnabled(true); 
     159} 
     160/*****************************************************************************************************************************************************/ 
     161void BaseWindow::initialiserChamps() { 
     162 
     163        m_ligneNom->setText(""); 
     164        m_ligneValeur->setText(""); 
     165} 
     166 
     167 
    182168 
    183169/************************************ testContenu() ***************************************************/ 
    184 /*bool BaseWindow::testContenu(int anInt) { 
     170bool BaseWindow::testContenu(int anInt) { 
    185171 
    186172        if (anInt != 0) { 
    187                 m_delButton ->setEnabled(true); 
    188                 m_save Button->setEnabled(true); 
     173                m_delButton->setEnabled(true); 
     174                m_saveButton->setEnabled(true); 
    189175        } 
    190176        else 
    191177        { 
    192                 m_delButton ->setDisabled(true); 
    193                 m_save Button->setDisabled(true); 
    194         } 
    195 }*/ 
    196  
     178                m_delButton->setDisabled(true); 
     179                m_saveButton->setDisabled(true); 
     180        } 
     181} 
     182/****************************************************************************************************************************/ 
     183QStringList BaseWindow::getData () { 
     184 
     185        return  m_savedData; 
     186} 
    197187/****************************************************************************************/ 
    198 //void BaseWindow::closeEvent(QCloseEvent *event) { 
    199          
     188void BaseWindow::closeEvent(QCloseEvent *event) { 
     189 
     190                //QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); 
     191        QMessageBox msgBox; 
     192                msgBox.setText("Le document a été modifié."); 
     193                msgBox.setInformativeText("Voulez-vous sauvegarder les modifications apportées?"); 
     194                msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); 
     195                msgBox.setDefaultButton(QMessageBox::Yes); 
     196        int ret = msgBox.exec(); 
     197 
     198        if (ret == QMessageBox::Yes) 
     199                event->accept(); 
     200        else event->ignore(); 
     201         
     202        //QMessageBox::warning(this, tr("Application"), tr("Le document a été modifié.\n Voulez-vous sauvegarder les modifications apportées?"), 
     203          //              QMessageBox::Yes | QMessageBox::Default, 
     204            //            QMessageBox::No, 
     205              //          QMessageBox::Cancel | QMessageBox::Escape); 
     206  
    200207  //    if (maybeSave()) { 
    201208            //writeSettings(); 
     
    205212          //  event->ignore(); 
    206213       
    207 //} 
     214} 
    208215/***************************************************************************************************************/ 
    209216/*bool BaseWindow::maybeSave() 
  • trunk/yao/src/interface/src/DefvalWindow.cpp

    r201 r205  
    2323DefvalWindow::DefvalWindow(BaseWindow *parent): BaseWindow(parent) {  /*!< The constructor. */ 
    2424         
    25         //this->setWindowTitle("Directive Defval.");     /*!< To set the window's title. */ 
    26         QPushButton *b = new QPushButton("Test"); 
    27         m_layoutGrid->addWidget(b , 4, 5); 
    28 //      isCalled = false; 
    29                 // Instanciation des classes. 
    30                 // Déclaration des boutons et champs de saisie de texte. 
     25        setWindowTitle("Directive Defval.");     /*!< To set the window's title. */ 
     26        m_nameLabel->setText("Constante: "); 
     27        m_valueLabel->setText("Valeur: "); 
     28        connect(m_helpButton, SIGNAL(clicked()), this, SLOT(callDefvalHelp())); 
     29 
    3130} 
     31/********************************************************************************/ 
     32//QStringList DefvalWindow::getDataDefval() { 
     33//QStringList test; 
     34//      return test;//defvalData; 
     35//} 
     36/******************************************************************************************************************************************************/ 
     37void DefvalWindow::callDefvalHelp() 
     38{ 
     39        QMessageBox::about(this, tr("Aide sur la directive defval."), 
     40                        ("<p> La directive defval permet d'associer un nom symbolique à une valeur." 
     41                         "<p><u>Exemple 1</u>: defval szx 12 <p><u>Exemple 2</u>: defval szy \"chaine\"<p> <u>Exemple 3</u>: defval szz szx" 
     42                         "<p> Pour plus d'informations sur defval, <a href=\"help/defval_aide.html\">cliquez ici.</a>")); 
     43} 
     44/******************************************************************************************************************************************************/ 
    3245/****************************************************************************************/ 
    3346/*void DefvalWindow::closeEvent(QCloseEvent *event) { 
     
    6679        return tar; 
    6780}*/ 
    68 /********************************************************************************/ 
    69 QStringList DefvalWindow::getDataDefval() { 
    70 QStringList test; 
    71         return test;//defvalData; 
    72 } 
    7381 
    74  
  • trunk/yao/src/interface/src/Include/BaseWindow.hpp

    r201 r205  
    77#include <QLineEdit> 
    88#include <QLabel> 
    9 //#include <QTextStream> 
     9#include <QTextCodec> 
    1010#include <QGridLayout> 
    1111//#include <QStandardItemModel> 
    1212//#include <QString> 
    1313//#include <QFileDialog> 
    14 //#include <QStringListModel> 
     14#include <QStringListModel> 
    1515//#include <QStringList> 
    1616//#include <QIODevice> 
    17 //#include <QMessageBox> 
    18 //#include <QCloseEvent> 
     17#include <QMessageBox> 
     18#include <QCloseEvent> 
    1919#include <iostream> 
    2020#include <QHBoxLayout> 
     
    2727        public : 
    2828                BaseWindow(QWidget *parent=0);  
     29                QStringList getData(); 
    2930 
    30                 QGridLayout *m_layoutGrid;               
    31         private:         
    32          
     31        protected slots: 
     32                void addRowInTable(); 
     33                void deleteRow(); 
     34                void saveData(); 
     35                  
     36        protected:       
     37                //The functions 
     38                void addRow(); 
     39                bool testContenu(int anInt); 
     40                void addNameInTable(int ligne, int colonne, QString nom);  
     41                void addValueInTable(int ligne, int colonne, QString valeur); 
     42                void initialiserChamps(); 
     43                void closeEvent(QCloseEvent *event); 
     44 
     45                // Variables     
    3346                QLabel  *m_nameLabel; 
    3447                QLabel  *m_valueLabel;                   
     
    4356                QPushButton *m_helpButton; 
    4457 
     58                QGridLayout *m_layoutGrid;               
    4559                QHBoxLayout *m_layoutH1; 
    4660                 
     
    5266 
    5367                //QString lstF; 
    54                 //QStringList m_listeNomsDefval; 
     68                QStringList m_listeNoms; 
    5569                //QStringList m_listeValeursDefval; 
    56                 //QStringListModel *m_modeleListeNoms; 
    57                 //QStringList defvalData; 
     70                QStringListModel *m_modeleListeNoms; 
     71                QStringList m_savedData; 
    5872 
    59                 //bool isCalled; 
     73                bool isCalled; 
    6074                 
    61                 //int compteur; 
     75                int compteur; 
     76 
     77 
    6278};       
    6379 
  • trunk/yao/src/interface/src/Include/DefvalWindow.hpp

    r201 r205  
    2626          
    2727                DefvalWindow(BaseWindow *parent=0);   /*!< This function returns the constante's data. */ 
    28                 QStringList getDataDefval();     
     28                //QStringList getDataDefval();   
    2929        protected : 
    3030//                   void closeEvent(QCloseEvent *event);                 
    3131         
    3232        public slots :        /*!< Functions called after a click. */ 
    33  
     33                void callDefvalHelp(); 
    3434}; 
    3535#endif 
  • trunk/yao/src/interface/src/MainWindow.cpp

    r201 r205  
    2323 
    2424*/ 
    25  
    2625 
    2726MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { 
     
    6665    //horizontalLayout->addWidget(tabWidget); 
    6766                tabWidget->setCurrentIndex(1); 
    68  
     67        //connect(espace, SIGNAL(windowActivated(QWidget * w)), this, SLOT(setActiveWindow(QWidget * w))); 
    6968 
    7069 
     
    481480         description << "#DEFVAL pour definir des directives  ------------------------------------------DEFVAL" << endl; 
    482481 
    483        for (QStringList::iterator it = m_defvalCopy->getDataDefval().begin(); it != m_defvalCopy->getDataDefval().end(); it++) 
     482       for (QStringList::iterator it = m_defvalCopy->getData().begin(); it != m_defvalCopy->getData().end(); it++) 
    484483            description << "defval " << it->toStdString() << endl; 
    485484            description << endl; 
Note: See TracChangeset for help on using the changeset viewer.