Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Serein207 committed Dec 11, 2023
1 parent 4379091 commit ca20408
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion qml/page/T_Calendar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ FluScrollablePage {
function onResult(data) {
if (data.enterPage) {
pushPage()
showInfo("注意:活动地点和类型需要重新编辑", 5000)
showInfo("注意:活动地点需要重新编辑", 4000)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions qml/page/T_EventInfo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ FluScrollablePage {
Layout.topMargin: 15
implicitWidth: parent.width
checked: EventoInfoController.isRegistrated
disabled: EventoHelper.state >= 2 || loading
disabled: EventoHelper.state != 2 || loading
contentItem: Row{
spacing: 6
FluText {
Expand Down Expand Up @@ -308,7 +308,7 @@ FluScrollablePage {
implicitWidth: parent.width
Layout.topMargin: 15
checked: EventoInfoController.isSubscribed
disabled: EventoHelper.state >= 2 || loading
disabled: EventoHelper.state > 2 || loading
contentItem: Row{
spacing: 6
FluText {
Expand Down
1 change: 1 addition & 0 deletions qml/page/T_EventoEdit.qml
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ FluScrollablePage {
}
model: TypeModel
textRole: "name"
currentIndex: EventoEditController.isEditMode ? EventoEditController.index : -1
}

FluText {
Expand Down
20 changes: 4 additions & 16 deletions src/controller/evento_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void EventoService::load_RegisteredSchedule() {
auto has_feedback = getRepo()->hasFeedbacked(evento.id).takeResult();
if (participation &&
(has_feedback || has_feedback.code() == EventoExceptionCode::FalseValue)) {
if (evento.gmtEventStart == evento.gmtEventEnd)
if (evento.gmtEventStart.date() == evento.gmtEventEnd.date())
singleDayEvents.emplace_back(evento, participation.take(), has_feedback);
else
multiDayEvents.emplace_back(evento, participation.take(), has_feedback);
Expand All @@ -105,13 +105,7 @@ void EventoService::load_RegisteredSchedule() {
stored[evento.id] = std::move(evento);
}
}
std::sort(singleDayEvents.begin(), singleDayEvents.end(),
[](const Schedule& e1, const Schedule& e2) {
auto date1 = QDate::fromString(e1.date, "MM.dd");
auto date2 = QDate::fromString(e2.date, "MM.dd");
return date1 > date2;
});
std::vector<Schedule> model(multiDayEvents.begin(), multiDayEvents.end());
std::vector<Schedule> model = std::move(multiDayEvents);
model.insert(model.end(), singleDayEvents.begin(), singleDayEvents.end());
std::set<QString> dateSet;
int width = 110;
Expand Down Expand Up @@ -148,7 +142,7 @@ void EventoService::load_SubscribedSchedule() {
auto has_feedback = getRepo()->hasFeedbacked(evento.id).takeResult();
if (participation &&
(has_feedback || has_feedback.code() == EventoExceptionCode::FalseValue)) {
if (evento.gmtEventStart == evento.gmtEventEnd)
if (evento.gmtEventStart.date() == evento.gmtEventEnd.date())
singleDayEvents.emplace_back(evento, participation.take(), has_feedback);
else
multiDayEvents.emplace_back(evento, participation.take(), has_feedback);
Expand All @@ -159,13 +153,7 @@ void EventoService::load_SubscribedSchedule() {
stored[evento.id] = std::move(evento);
}
}
std::sort(singleDayEvents.begin(), singleDayEvents.end(),
[](const Schedule& e1, const Schedule& e2) {
auto date1 = QDate::fromString(e1.date, "MM.dd");
auto date2 = QDate::fromString(e2.date, "MM.dd");
return date1 > date2;
});
std::vector<Schedule> model(multiDayEvents.begin(), multiDayEvents.end());
std::vector<Schedule> model = std::move(multiDayEvents);
model.insert(model.end(), singleDayEvents.begin(), singleDayEvents.end());
std::set<QString> dateSet;
int width = 110;
Expand Down
10 changes: 5 additions & 5 deletions src/controller/ui/evento_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ void EventoEditController::preload() {
InformationService::getInstance().load_EditInfo();
}

void EventoEditController::createEvento(const QString& title, const QString& description,
const QString& eventStart, const QString& eventEnd,
const QString& registerStart, const QString& registerEnd,
int index, int locationId,
const QVariantList& departmentIds, const QString& tag) {
void EventoEditController::createEvento(QString title, QString description, QString eventStart,
QString eventEnd, QString registerStart,
QString registerEnd, int index, int locationId,
QVariantList departmentIds, QString tag) {
auto typeId = TypeModel::getInstance()->getID(index);
if (property("isEditMode").toBool()) {
EventoService::getInstance().edit(EventoHelper::getInstance()->property("id").toInt(),
Expand All @@ -42,6 +41,7 @@ void EventoEditController::update(const DTO_Evento& event) {
}
*(departmentIds.end() - 1) = u']';

setProperty("index", TypeModel::getInstance()->getIndex(event.type.id));
setProperty("eventStart", event.gmtEventStart.toString("yyyy-MM-ddThh:mm:ss"));
setProperty("eventEnd", event.gmtEventEnd.toString("yyyy-MM-ddThh:mm:ss"));
setProperty("registerStart", event.gmtRegistrationStart.toString("yyyy-MM-ddThh:mm:ss"));
Expand Down
9 changes: 4 additions & 5 deletions src/controller/ui/evento_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ class EventoEditController : public QObject {

public:
Q_INVOKABLE void loadEditInfo();
Q_INVOKABLE void createEvento(const QString& title, const QString& description,
const QString& eventStart, const QString& eventEnd,
const QString& registerStart, const QString& registerEnd,
int index, int locationId, const QVariantList& departmentIds,
const QString& tag);
Q_INVOKABLE void createEvento(QString title, QString description, QString eventStart,
QString eventEnd, QString registerStart, QString registerEnd,
int index, int locationId, QVariantList departmentIds,
QString tag);

private:
bool m_isEditMode; // true: 编辑模式 false: 创建模式
Expand Down
6 changes: 6 additions & 0 deletions src/domain/model/type_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class TypeModel : public QAbstractListModel {
return m_data[index].id;
}

inline int getIndex(int id) {
return std::distance(m_data.begin(), std::find_if(m_data.begin(), m_data.end(), [=](const EventType& type) {
return type.id == id;
}));
}

private:
TypeModel() = default;

Expand Down
1 change: 1 addition & 0 deletions src/lang/En.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ En::En(QObject* parent) : Lang{parent} {
// event info
lang_undertaking("Ongoing");
lang_not_started("Not Started");
lang_registering("Registering");
lang_over("Over");
lang_cancelled("Cancelled");
lang_checked_in("Checked");
Expand Down
1 change: 1 addition & 0 deletions src/lang/Zh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Zh::Zh(QObject* parent) : Lang{parent} {

// event info
lang_undertaking("进行中");
lang_registering("报名中");
lang_not_started("未开始");
lang_over("已结束");
lang_cancelled("已取消");
Expand Down

0 comments on commit ca20408

Please sign in to comment.