Back to index

fet  5.18.0
changemindaysselectivelyform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           changemindaysselectivelyform.cpp  -  description
00003                              -------------------
00004     begin                : July 30, 2008
00005     copyright            : (C) 2008 by Lalescu Liviu
00006     email                : Please see http://lalescu.ro/liviu/ for details about contacting Liviu Lalescu (in particular, you can find here the e-mail address)
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 
00020 #include "changemindaysselectivelyform.h"
00021 
00022 #include "fet.h"
00023 
00024 #include <QMessageBox>
00025 
00026 ChangeMinDaysSelectivelyForm::ChangeMinDaysSelectivelyForm(QWidget* parent): QDialog(parent)
00027 {
00028        setupUi(this);
00029        
00030        okPushButton->setDefault(true);
00031        
00032        connect(okPushButton, SIGNAL(clicked()), this, SLOT(ok()));
00033        connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancel()));
00034        
00035        centerWidgetOnScreen(this);
00036        restoreFETDialogGeometry(this);
00037        
00038        QSize tmp5=oldConsecutiveComboBox->minimumSizeHint();
00039        Q_UNUSED(tmp5);
00040        QSize tmp6=newConsecutiveComboBox->minimumSizeHint();
00041        Q_UNUSED(tmp6);
00042        
00043        oldConsecutiveComboBox->clear();
00044        oldConsecutiveComboBox->addItem(tr("Any"));
00045        oldConsecutiveComboBox->addItem(tr("Yes"));
00046        oldConsecutiveComboBox->addItem(tr("No"));
00047        oldConsecutiveComboBox->setCurrentIndex(0);
00048        
00049        oldDaysSpinBox->setMinimum(-1);
00050        oldDaysSpinBox->setMaximum(gt.rules.nDaysPerWeek);
00051        oldDaysSpinBox->setValue(-1);
00052 
00053        newConsecutiveComboBox->clear();
00054        newConsecutiveComboBox->addItem(tr("No change"));
00055        newConsecutiveComboBox->addItem(tr("Yes"));
00056        newConsecutiveComboBox->addItem(tr("No"));
00057        newConsecutiveComboBox->setCurrentIndex(0);
00058        
00059        newDaysSpinBox->setMinimum(-1);
00060        newDaysSpinBox->setMaximum(gt.rules.nDaysPerWeek);
00061        newDaysSpinBox->setValue(-1);
00062        
00063        oldNActsSpinBox->setMinimum(-1);
00064        oldNActsSpinBox->setMaximum(MAX_SPLIT_OF_AN_ACTIVITY);
00065        oldNActsSpinBox->setValue(-1);
00066 }
00067 
00068 ChangeMinDaysSelectivelyForm::~ChangeMinDaysSelectivelyForm()
00069 {
00070        saveFETDialogGeometry(this);
00071 
00072 }
00073 
00074 void ChangeMinDaysSelectivelyForm::ok()
00075 {
00076        enum {ANY=0, YES=1, NO=2};
00077        enum {NOCHANGE=0};
00078 
00079        oldWeight=oldDays=oldConsecutive=oldNActs=-2;
00080        newWeight=newDays=newConsecutive=-2;
00081 
00082        QString oldWeightS=oldWeightLineEdit->text();
00083        weight_sscanf(oldWeightS, "%lf", &oldWeight);
00084        if(!(oldWeight==-1 || (oldWeight>=0.0 && oldWeight<=100.0))){
00085               QMessageBox::warning(this, tr("FET warning"), tr("Old weight must be -1 or both >=0 and <=100"));
00086               return;
00087        }
00088        
00089        QString newWeightS=newWeightLineEdit->text();
00090        weight_sscanf(newWeightS, "%lf", &newWeight);
00091        if(!(newWeight==-1 || (newWeight>=0.0 && newWeight<=100.0))){
00092               QMessageBox::warning(this, tr("FET warning"), tr("New weight must be -1 or both >=0 and <=100"));
00093               return;
00094        }
00095        
00096        oldDays=oldDaysSpinBox->value();
00097        if(!(oldDays==-1 || (oldDays>=1 && oldDays<=gt.rules.nDaysPerWeek))){
00098               QMessageBox::warning(this, tr("FET warning"), tr("Old min days must be -1 or both >=1 and <=n_days_per_week"));
00099               return;
00100        }
00101        
00102        newDays=newDaysSpinBox->value();
00103        if(!(newDays==-1 || (newDays>=1 && newDays<=gt.rules.nDaysPerWeek))){
00104               QMessageBox::warning(this, tr("FET warning"), tr("New min days must be -1 or both >=1 and <=n_days_per_week"));
00105               return;
00106        }
00107        
00108        oldConsecutive=oldConsecutiveComboBox->currentIndex();
00109        assert(oldConsecutive>=0 && oldConsecutive<=2);
00110 
00111        newConsecutive=newConsecutiveComboBox->currentIndex();
00112        assert(newConsecutive>=0 && newConsecutive<=2);
00113 
00114        oldNActs=oldNActsSpinBox->value();
00115        if(!(oldNActs==-1 || oldNActs>=1)){
00116               QMessageBox::warning(this, tr("FET warning"), tr("Old n_acts must be -1 or >=1"));
00117               return;
00118        }
00119        
00120        this->accept();
00121 }
00122 
00123 void ChangeMinDaysSelectivelyForm::cancel()
00124 {
00125        this->reject();
00126 }