make it impossible to set endtime before starttime
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 29 Nov 2008 15:10:02 +0000 (15:10 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sat, 29 Nov 2008 15:10:02 +0000 (15:10 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@202 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

src/eventedit.cpp
src/eventedit.h

index 0590ba6..0397b39 100644 (file)
@@ -76,6 +76,7 @@ MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
        starttime->setDisplayFormat(tr("ddd MMMM d yyyy, h:mm ap","time format"));
        starttime->setCalendarPopup(true);
        starttime->setDateTime(QDateTime::fromTime_t(event.startTime()));
+       connect(starttime,SIGNAL(dateTimeChanged(const QDateTime&)),this,SLOT(startTimeChanged(const QDateTime&)));
        
        gl->addWidget(lab=new QLabel(tr("End Time:")),++lctr,0);
        lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
@@ -83,6 +84,7 @@ MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
        endtime->setDisplayFormat(tr("ddd MMMM d yyyy, h:mm ap","time format"));
        endtime->setCalendarPopup(true);
        endtime->setDateTime(QDateTime::fromTime_t(event.endTime()));
+       connect(endtime,SIGNAL(dateTimeChanged(const QDateTime&)),this,SLOT(endTimeChanged(const QDateTime&)));
        
        gl->addWidget(lab=new QLabel(tr("Room/Place:")),++lctr,0);
        lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
@@ -184,3 +186,15 @@ void MEventEditor::newRoom()
                room->setText(rid);
        }
 }
+
+void MEventEditor::startTimeChanged(const QDateTime&st)
+{
+       QDateTime et=endtime->dateTime();
+       if(et<st)endtime->setDateTime(st);
+}
+
+void MEventEditor::endTimeChanged(const QDateTime&et)
+{
+       QDateTime st=starttime->dateTime();
+       if(st>et)starttime->setDateTime(et);
+}
index 63a6a1b..af4e681 100644 (file)
 #include "event.h"
 
 class MWebRequest;
+class QCheckBox;
+class QDateTime;
 class QDateTimeEdit;
+class QLabel;
 class QLineEdit;
-class QTextEdit;
-class QCheckBox;
 class QSpinBox;
-class QLabel;
+class QTextEdit;
 
 class MEventEditor:public QDialog
 {
@@ -34,6 +35,9 @@ class MEventEditor:public QDialog
                void writeBack();
                void selectRoom();
                void newRoom();
+               
+               void startTimeChanged(const QDateTime&);
+               void endTimeChanged(const QDateTime&);
        private:
                MWebRequest*req;
                MEvent event;