void MainWindow::writeJsonObject(QJsonObject &json, Note note) { json["DateStart"] = note.getDateStart().toString(); json["DateEnd"] = note.getDateEnd().toString(); json["TimeStart"] = note.getTimeStart().toString(); json["TimeEnd"] = note.getTimeEnd().toString(); json["Title"] = note.getTitle(); json["Text"] = note.getText(); }
void MainWindow::on_twTaskField_itemDoubleClicked(QTableWidgetItem *item) { Dialog *dialog = new Dialog(this); Note note; if(dialog->exec() == QDialog::Accepted) { note.setTitle(dialog->getTitle()); note.setText(dialog->getText()); note.setDateStart(selDate_); note.setDateEnd(selDate_); note.setTimeStart(QTime::fromString(item->text())); note.setTimeEnd(QTime::fromString(item->text())); qDebug() << note.getTitle(); qDebug() << note.getText(); qDebug() << note.getDateStart(); qDebug() << note.getDateEnd(); qDebug() << note.getTimeStart(); qDebug() << note.getTimeEnd(); ui->twTaskField->setItem(item->row(), 1, new QTableWidgetItem(dialog->getTitle() +" " +dialog->getText())); //и записываем в контейнер: if(TimeLine_.size() != 0) { QLinkedList<Note>::iterator it; int i = 0; if(isSelDatePresented()) { for(it = TimeLine_.begin(); it != TimeLine_.end(); ++it) { if(it->getDateStart() == note.getDateStart()) { TimeLine_.insert(it, note); break; } i++; } } else TimeLine_.push_back(note); } else TimeLine_.append(note); } saveFileJson(); //<--- temp }
//----- собственно, работа с json: ----- void MainWindow::readJsonObject(const QJsonObject json, Note ¬e) { note.setDateStart(QDate::fromString(json["DateStart"].toString())); note.setDateEnd(QDate::fromString(json["DateEnd"].toString())); note.setTimeStart(QTime::fromString(json["TimeStart"].toString())); note.setTimeEnd(QTime::fromString(json["TimeEnd"].toString())); note.setTitle(json["Title"].toString()); note.setText(json["Text"].toString()); // item.Priority // item.Reminder // item.Color // item.Mask qDebug() << note.getTitle(); qDebug() << note.getText(); qDebug() << note.getDateStart(); qDebug() << note.getDateEnd(); qDebug() << note.getTimeStart(); qDebug() << note.getTimeEnd(); }