#include "Event.h" Event::Event(QString str0,int begin0,int end0,int weekday0,int type0,int subtype0,QWidget* parent0,QString describe0) { str=str0; begin=begin0; end=end0; weekday=weekday0; type=type0; subtype=subtype0; describe=describe0; Interface_operation(parent0); index_mark=0; } Event::Event(EventData* ed,QWidget* parent0) { str=ed->str; begin=ed->begin; end=ed->end; weekday=ed->weekday; type=ed->type; subtype=ed->subtype; describe=ed->describe; Interface_operation(parent0); index_mark=0; } Event::Event(QWidget* parent0) { str=""; begin=0; end=0; weekday=0; type=0; subtype=0; describe=""; Interface_operation(parent0); index_mark=0; } void Event::Interface_operation(QWidget* parent0) { parent=parent0; button=new QPushButton(parent); button->setText(str); button->hide(); connect(button,SIGNAL(clicked(bool)),this,SLOT(theSlot())); } Event::~Event() { this->button->deleteLater(); this->parent=nullptr; } void Event::setPlace(int date_begin,int date_end,int up,int down,int height,int offset) { int diff1=begin-date_begin; int diff2=date_end-date_begin; int diff3=end-date_begin; double prop1=double(diff1)/diff2; double prop2=double(diff3)/diff2; int button_up=up+prop1*height-offset; int button_down=up+prop2*height-offset; button->setFixedSize(123,button_down-button_up); button->move(30+weekday*120,button_up); if(button_up>=up&&button_down<=down) button->show(); else button->hide(); } int Event::getDuration() { return end-begin; } void Event::theSlot() { emit theSignal(this); } void Event::change(QString str0,int begin0,int end0,int weekday0,int type0,int subtype0,QString describe0) { str=str0; begin=begin0; end=end0; weekday=weekday0; type=type0; subtype=subtype0; describe=describe0; button->setText(str); } using namespace std; void Event::save(ofstream& fout) { fout<setText(str); return; } else str="Error!"; } EventData Event::toEventData() { return EventData(str,describe,begin,end,weekday,type,subtype); } bool operator < (EventData a,EventData b) { if(a.weekday*1440+a.begin