Changeset 319


Ignore:
Timestamp:
05/12/10 16:13:11 (14 years ago)
Author:
yerima
Message:

Some controls like disabling/enabling the delete button if there are not/there are data in the structure. This functionality is implemented in DefvalWindow?. The next time, it will be implemented in HatNameWindow?. visual Yao.

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

Legend:

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

    r317 r319  
    3838                m_helpButton->setMaximumSize(35, 25); 
    3939        m_delButton             = new QPushButton("Supprimer", this);  /*!< QPushButton for Supprimer. */ 
    40                 m_delButton ->setDisabled(true);          /*!< setDisabled is true. */ 
     40                if(isLocalConstantTableEmpty()) m_delButton ->setDisabled(true);          /*!< setDisabled is true. */ 
    4141        m_quitButton                    = new QPushButton("Quitter", this);   /*!< QPushButton for Quitter. */ 
    4242 
     
    8787void ConstantWindow::addRowInTable() { 
    8888   
    89           //testContenu(compteur);  // Permet de vérifier si une ligne est présente dans le tableau d'affichage. 
    9089        QString Nom  = m_ligneNom->text(); 
    9190        QString Val  = m_ligneValeur->text(); 
     
    144143        } 
    145144 
    146         initialiserChamps(); 
     145        eraseData(); 
    147146 } 
    148147 
     148/*******************************************************************************************************************************************************/ 
    149149/******************************************************************* delete Row() method ***************************************************************/ 
    150150void ConstantWindow::deleteRow() { 
     
    160160                m_localConstantTable->erase(m_localConstantTable->begin() + r); 
    161161                 
    162              for (unsigned int i=0; i < localHeaderList->size(); i++ ) //Parcourt le vecteur en fonction de sa taille (nombre d'éléments) 
     162             for (unsigned int i=0; i < localHeaderList->size(); i++ ) //Parcourt le vecteur de HatName en fonction de sa taille (nombre d'éléments) 
    163163                { 
    164164                         
    165                         if (element.toString().toStdString() == localHeaderList->at(i)) //Teste si l'éléement à supprimer dans defval est aussi dans hat 
     165                        if (element.toString().toStdString() == localHeaderList->at(i)) //Teste si l'élément à supprimer dans defval est aussi dans hat 
    166166                                localHeaderList->erase(localHeaderList->begin() + i);//localHeaderList->begin() +i );    
    167167                } 
    168168                 
    169169                emit rowIsDeleted(element.toString()); // signal emis lorsqu'une ligne retirée du tableau.  
    170         } 
    171 } 
    172   
    173 /***************************************************** initialiserChamps() *****************************************************************************/ 
    174 void ConstantWindow::initialiserChamps() { 
     170                if(isLocalConstantTableEmpty()) m_delButton->setDisabled(true); 
     171        } 
     172         
     173} 
     174  
     175/*******************************************************************************************************************************************************/ 
     176/***************************************************** eraseData() *****************************************************************************/ 
     177void ConstantWindow::eraseData() { 
    175178 
    176179        m_ligneNom->setText(""); 
     
    178181} 
    179182/*******************************************************************************************************************************************************/ 
     183/*******************************************************************************************************************************************************/ 
    180184void ConstantWindow::saveData() { 
    181185  
     
    184188} 
    185189 
     190/*******************************************************************************************************************************************************/ 
     191bool ConstantWindow::isLocalConstantTableEmpty() { 
     192 
     193        if (m_localConstantTable->empty()) 
     194                return true; 
     195        else 
     196                return false; 
     197} 
    186198/******************************************************** callConstantHelp() ***************************************************************************/ 
    187199void ConstantWindow::callConstantHelp() { 
     
    194206} 
    195207/*******************************************************************************************************************************************************/ 
    196 void ConstantWindow::testContenu(int anInt) { 
    197  
    198         if (anInt != 0) { 
    199                 m_delButton->setEnabled(true); 
    200         } 
    201         else { 
    202  
    203                 m_delButton->setDisabled(true); 
    204         } 
    205 } 
    206208/*******************************************************************************************************************************************************/ 
    207209void ConstantWindow::closeEvent(QCloseEvent *event) { 
    208210         
    209                 emit windowIsClosed(1);          
    210         /*int ret = QMessageBox::warning(this, tr("Confirmation de fermeture"), 
    211                          tr("Voulez-vous vraiment quitter?"), 
    212                          QMessageBox::Yes | QMessageBox::Default, 
    213                          QMessageBox::Cancel | QMessageBox::Escape); 
    214              if (ret == QMessageBox::Yes) { 
    215                 event->accept(); 
    216                 //this->~ConstantWindow(); 
    217                 } 
    218               else 
    219                 event->ignore(); 
    220 */ 
    221      /* if (maybeSave()) { 
    222             //writeSettings(); 
    223             event->accept(); 
    224       }  
    225         else  
    226             event->ignore(); 
    227       */ 
    228         //this->~ConstantWindow(); 
    229 } 
    230 /*******************************************************************************************************************************************************/ 
    231 /*******************************************************************************************************************************************************/ 
    232 /*******************************************************************************************************************************************************/ 
    233  
     211        if (!(m_ligneNom->text().isEmpty()) && !(m_ligneValeur->text().isEmpty())) { //When the two QLineEdit content data, show a confirmation box.     
     212         
     213        int ret = QMessageBox::warning(this, tr("Confirmation de fermeture"), tr("Voulez-vous vraiment quitter?"), 
     214                          QMessageBox::Yes | QMessageBox::Default, QMessageBox::Cancel | QMessageBox::Escape); 
     215         
     216        if (ret == QMessageBox::Yes)  
     217                 event->accept(); 
     218               else 
     219                 event->ignore(); 
     220 
     221        } 
     222                emit windowIsClosed(1); //The signal is emitted with parameter "1" which is used for "DevalWindow".      
     223} 
     224 
     225/*******************************************************************************************************************************************************/ 
    234226/************************************************ Le destructeur ~ConstantWindow() ********************************************************************/ 
    235227ConstantWindow::~ConstantWindow() { 
     
    240232  
    241233} 
    242  
    243 /*******************************************************************************************************************************************************/ 
    244  
    245  
     234/****************************************************************************************************************************************************/ 
     235/************************************************** The end of the file. ****************************************************************************/ 
     236/****************************************************************************************************************************************************/ 
  • trunk/yao/src/interface/src/HatNameWindow.cpp

    r317 r319  
    1414using namespace yao; //! \namespace yao 
    1515 
    16 /*************************************** Implémentation du constructeur **************************************************/ 
     16/***************************************   The class constructor: HatNameWindow()  ********************************************************************/ 
    1717HatNameWindow::HatNameWindow(vector <string> *aHeaderList, Table <Constant> *aConstantTable, QWidget *parent) : QWidget(parent), modeleFichiers(NULL),  
    1818vueFichiers(NULL), modeleHatName(NULL), hatHeaderList(NULL), localConstantTable(NULL) 
     
    108108} 
    109109 
    110 /******************************************************************************************************************************************************/ 
     110/************************************* Implementation of the method callHatHelp() **********************************************************************/ 
    111111void HatNameWindow::callHatHelp() { 
    112112 
     
    114114 
    115115} 
    116 /******************************************************************************************************************************************************/ 
     116/*************************************** Implementation of the method addHatRow()  ********************************************************************/ 
    117117void HatNameWindow::addHatRow() { 
    118118 
     
    127127        modeleHatName->setItem(modeleHatName->rowCount(), new QStandardItem(QString(constantValue.c_str()))); 
    128128        hatHeaderList->push_back(hatFile); 
    129         initialiserChamps(); 
     129        eraseData(); 
    130130    }          
    131131 
     
    158158            hatHeaderList->push_back(hatFile);  
    159159            modeleHatName->setItem(modeleHatName->rowCount(), new QStandardItem(QString(hatFile.c_str())));  
    160             initialiserChamps(); 
     160            eraseData(); 
    161161        } 
    162162 
     
    171171else { 
    172172         if (hatFile.length() < 2) { 
    173                 initialiserChamps(); 
     173                eraseData(); 
    174174                return ; 
    175175        } 
     
    181181        hatHeaderList->push_back(hatFile); 
    182182          
    183         initialiserChamps(); 
     183        eraseData(); 
    184184        } 
    185185} 
    186186 
    187187        } 
    188 //cout << "Nombre de lignes: " << modeleHatName->rowCount() << endl; 
    189 } 
    190 /****************************************************************************************/ 
     188} 
     189/***********************************************  Implementation of the method deleteHatRow() ********************************************************/ 
    191190void HatNameWindow::deleteHatRow() { 
    192191 
    193     /*QItemSelectionModel *selection = vueFichiers->selectionModel(); 
    194     QModelIndex indexElementSelectionne = selection->currentIndex(); 
    195     QVariant elementSelectionne = modeleHatName->data(indexElementSelectionne, Qt::DisplayRole); 
    196  
    197      listeFichiers.removeOne(elementSelectionne.toString());//Retrait de l'élément sélectionné de l'objet QStringList 
    198      //modeleHatName->setStringList(listeFichiers); //On indique au modÚle la liste des éléments à afficher. 
    199      */ 
    200 //      -- compteur; 
    201 //      testContenu(compteur); 
    202  
    203         //int c = vueFichiers->currentIndex().row(); 
    204192         QItemSelectionModel *selection = vueFichiers->selectionModel(); //Un ensemble sur les éléments selectionnés 
    205193         index = selection->currentIndex(); //Précision de l'élément courant selectionné 
     
    208196         if (selection->hasSelection()) // Evite certains effets indésirables: suppression de la derniere ligne aprÚs clic sur le vide. 
    209197          { 
    210                  modeleHatName->removeRows(r, 1);// Le 2Úme parametre indique le nombre de ligne à supprimer 
     198                 modeleHatName->removeRows(vueFichiers->currentIndex().row(), 1);// Le 2Úme parametre indique le nombre de ligne à supprimer 
    211199                 hatHeaderList->erase(hatHeaderList->begin() + r);//On met à jour la structure de données en supprimant aussi l'élement. 
    212200                 //m_tableView->resizeRowToContents(c - 1); // columnCountChanged(c , c-1); 
    213201         } 
    214202 
    215  
    216203  } 
    217204 
    218 /****************************************************************************************/ 
    219 void HatNameWindow::initialiserChamps() { 
     205/***********************************************  *Implementation of the method************************************************************************/ 
     206void HatNameWindow::eraseData() { 
    220207 
    221208            m_comboHatName->clearEditText(); 
    222209} 
    223210 
    224 /***************************************************************************************/ 
    225 void HatNameWindow::toUpdateView(QString choix) { 
    226  
    227  
    228                 //cout << choix.toStdString() << endl; 
    229 /* 
    230         int c = vueFichiers->currentIndex().row(); 
    231          
    232         //      cout << c << endl; 
    233         QItemSelectionModel *selection = vueFichiers->selectionModel(); 
    234          index = modeleHatName->indexFromItem(new QStandardItem(choix));//currentIndex(); 
    235          QVariant element = modeleHatName->data(index, Qt::DisplayRole); 
    236                 //cout << element.toString() << endl; 
    237         //      QMessageBox::information(this, "Selection", element.toString()); 
    238         QList <QStandardItem *> list;  
    239         for (int i = 0; i <= modeleHatName->rowCount(); i++) { 
    240  
    241                 list << modeleHatName->findItems(choix); 
    242         //modeleHatName 
    243  
    244          
    245         //      if (element.toString() == choix) 
    246         } 
    247  
    248         for(QList <QStandardItem *>::iterator it = list.begin(); it != list.end(); it++ ) //int i = 0; i < list.size() ++i) 
    249 //              if(list.at(i) == choix ) return ; 
    250                         cout << "blabla" << endl;//choix << endl; 
    251  
    252         //      if (element.toString() == choix) 
    253         //      modeleHatName->removeRow(c);     
    254         //      cout << "Ligne supprimée!" << endl; 
    255 */       
    256         //QVariant element = modeleHatName->data(index, Qt::DisplayRole); 
    257          
    258         //modeleHatName; 
    259  
    260         //cout << "Dans le hat" << endl; 
    261         //this->activateWindow(); 
    262         //modeleHatName->refresh();  
    263         //modeleHatName->reset(); 
    264         //vueFichiers->reset(); 
    265         //~HatNameWindow(); 
    266 //      if (this->isActiveWindow()) 
    267 //              vueFichiers->reset();    
    268         //vueFichiers = new QListView; 
    269         //toResetWindow(); 
    270         //vueFichiers->setModel(modeleHatName); 
    271         //cout << element << endl; 
    272         //QMessageBox::information(this, "Selection", choix); 
    273  
    274 //      HatNameWindow(hatHeaderList, localConstantTable); 
    275         //vueFichiers->~QListView(); 
    276         //vueFichiers = new QListView; 
    277         //vueFichiers->setModel(modeleHatName);  
    278  
    279 } 
    280  
    281 /******************************************************/ 
    282 //void HatNameWindow::toResetWindow() { 
    283  
    284 //      vueFichiers->reset();  
    285  
    286 //} 
    287 /******************************************************/ 
     211/***************************************************Implementation of the method***********************************************************************/ 
    288212void HatNameWindow::closeEvent(QCloseEvent *event){ 
    289213 
     
    293217 
    294218} 
    295 /****************************************************************************************/ 
     219/***************************************************Implementation of the method***********************************************************************/ 
    296220void HatNameWindow::ouvrirProjetExistant() { 
    297221 
     
    301225} 
    302226 
    303 /****************************************************************************************/ 
     227/****************************************************Implementation of the method*********************************************************************/ 
    304228void HatNameWindow::testPresenceFichier() { 
    305229 
     
    309233       m_supHatName->setEnabled(true); 
    310234} 
    311 /****************************************************************************************/ 
     235/***************************************************Implementation of the method************************************************************************/ 
    312236vector<string> *HatNameWindow::getTheHeaderList() { 
    313237 
     
    316240 } 
    317241 
    318 /****************************************************************************************/ 
     242/****************************************************Implementation of the method***********************************************************************/ 
    319243void HatNameWindow::setTheHeaderList(vector<string> *theHeaderList) { 
    320244 
     
    322246} 
    323247 
    324 /****************************************************************************************/ 
     248/******************************************************Implementation of the method*********************************************************************/ 
    325249void HatNameWindow::setLocalProjectName(string name) { 
    326250 
     
    329253} 
    330254 
    331 /****************************************************************************************/ 
     255/****************************************************** Implementation of the method getLocalProjectName() *******************************************/ 
    332256string HatNameWindow::getLocalProjectName() { 
    333257 
     
    337261 
    338262 
    339 /****************************************************************************************/ 
     263/******************************************************* Implementation of the method getHatList() ****************************************************/ 
    340264QStringList HatNameWindow::getHatList() { 
    341265 
     
    343267 
    344268 } 
    345  /***************************************************************************************/ 
    346  bool HatNameWindow::testContenu(int anInt) { 
    347  
    348         if (anInt != 0) { 
    349                 m_supHatName->setEnabled(true); 
    350                 //m_enregHatName->setEnabled(true); 
    351                  
    352                 return true; 
    353         } 
    354         else 
    355         { 
    356                 m_supHatName->setDisabled(true); 
    357                 //m_enregHatName->setDisabled(true); 
    358                  
    359                 return false; 
    360         } 
    361  
    362 } 
    363269/******************************************************************************************************************************************************/ 
    364270//void HatNameWindow::updateComb 
    365 /******************************************************************************************************************************************************/ 
     271/******************************************************** Implementation of the destructor ************************************************************/ 
    366272HatNameWindow::~HatNameWindow() { 
    367273 
    368274//      delete vueFichiers; 
    369275} 
    370  
    371  
     276/****************************************************************************************************************************************************/ 
     277/************************************************** The end of the file. ****************************************************************************/ 
     278/****************************************************************************************************************************************************/ 
  • trunk/yao/src/interface/src/MainWindow.cpp

    r318 r319  
    543543                        m_hatCopy->show(); 
    544544                        espace->setActiveWindow(m_ConstantCopy); 
    545                         m_hatCopy->toUpdateView(choix); 
     545                        //m_hatCopy->toUpdateView(choix); 
    546546                } 
    547547         
  • trunk/yao/src/interface/src/include/ConstantWindow.hpp

    r317 r319  
    22 * \file    ConstantWindow.hpp 
    33 * \brief   ConstantWindow class for visual_YAO. 
    4  * \version 2009/12/26 (yyyy/mm/dd) 
    5  * \author  MAYAKI Abdouramane & MAYOMBO Alexis. 
     4 * \version 2010/05/12 (yyyy/mm/dd) 
     5 * \author  MAYAKI Abdouramane. 
    66 */ 
    77#ifndef DEFVALWINDOW_HPP 
     
    4242          
    4343                ConstantWindow(yao::Table<yao::Constant> *aConstantTable, std::vector <std::string> *aHeaderList, QWidget *parent=0);   
    44                 void testContenu(int anInt);     
    45                 void initialiserChamps(); 
     44                void eraseData(); 
     45                bool isLocalConstantTableEmpty();  
    4646                ~ConstantWindow(); 
     47 
    4748        protected : 
    4849                void closeEvent(QCloseEvent *event);                 
    49                 //bool event(QEvent *event); 
    5050         
    5151        public slots :        /*!< Functions called after a click. */ 
  • trunk/yao/src/interface/src/include/HatNameWindow.hpp

    r317 r319  
    5050                void setLocalProjectName(std::string name); 
    5151                std::string getLocalProjectName(); 
    52                 bool testContenu(int anInt); 
    53                 void toUpdateView(QString choix); 
    54         //      void toResetWindow(); 
    5552                ~HatNameWindow(); 
    5653 
     
    6764                void addHatRow();               /*!< This function is called to insert data in the model. */ 
    6865                void deleteHatRow();            /*!< This function is called to delete data from the model. */ 
    69                 void initialiserChamps();       /*!< This function is called to initialize the lineEdit. */ 
     66                void eraseData();       /*!< This function is called to initialize the lineEdit. */ 
    7067                void ouvrirProjetExistant();    /*!< This function is called to open an existing project. */ 
    7168                void appelEnregistrer();        /*!< This function is called to save the current project in the file model */ 
Note: See TracChangeset for help on using the changeset viewer.