void AddIndvAssignmentDialog::addAssignment() { QString assignName(boxOne->text()); QString pointValue(boxTwo->text()); QString earnedPoints(earnedPointsBox->text()); std::string assignNameStr(assignName.toAscii()); double pointValueDouble(pointValue.toDouble()); double earnedPointsDouble(earnedPoints.toDouble()); if(assignNameStr == "INVALID ASSIGNMENT") { QMessageBox *messageBox = new QMessageBox(this); messageBox->setText("You cannot name an assignment \"INVALID ASSIGNMENT\""); messageBox->exec(); boxOne->clear(); boxTwo->clear(); return; } Assignment newAssignment(pointValueDouble, earnedPointsDouble, assignNameStr); messageWin->setWindowTitle("Confirmation"); if(student->addAssignment(newAssignment)) { messageWin->setText("Assignment added!"); emit assignmentAdded(); } else { messageWin->setText("Assignment was not added successfully."); } messageWin->exec(); close(); }
void EditIndvAssignmentDialog::editAssignment() { // Get the current values of each input box as a QString QString assignName(boxOne->text()); QString pointValue(boxTwo->text()); QString earnedPoints(earnedPointsBox->text()); // Convert the QString values to useable data types std::string assignNameStr(assignName.toAscii()); double pointValueDouble(pointValue.toDouble()); double earnedPointsDouble(earnedPoints.toDouble()); // Guard against the name "INVALID ASSIGNMENT" for assignments(it's reserved) if(assignNameStr == "INVALID ASSIGNMENT") { QMessageBox *messageBox = new QMessageBox(this); messageBox->setText("You cannot name an assignment \"INVALID ASSIGNMENT\""); messageBox->exec(); boxOne->clear(); boxTwo->clear(); return; } // Make a copy of the new assignment as the old assignment for comparison Assignment newAssignment(pointValueDouble, earnedPointsDouble, assignNameStr); Assignment currentAssignment(student->getAssignment(assignmentName)); // Set the text on the confirmation window confirmWin->setWindowTitle("Confirm Edit"); confirmWin->setText("Are you sure you want to edit this assignment?"); confirmWin->setStandardButtons(QMessageBox::Yes|QMessageBox::No); // If the user confirms the confirmation dialog if(confirmWin->exec() == QMessageBox::Yes) { // Edit the points earned/possible student->editAssignmentGrade(currentAssignment.getName(), pointValueDouble, earnedPointsDouble); // If the name has been changed if(assignNameStr != currentAssignment.getName()) { // Get the assignment number to edit the assignment name int assignNum = student->getAssignmentNumber(currentAssignment.getName()); student->editAssignmentName(assignNum, assignNameStr); } emit assignmentEdited(); } else // If the user selects no on the confirmation dialog { return; } close(); }
bool SimObject::readObject(Stream *stream) { const char *name = stream->readSTString(true); if(name && *name) assignName(name); U32 numFields; stream->read(&numFields); for(S32 i = 0;i < numFields;i++) { const char *fieldName = stream->readSTString(); const char *data = stream->readSTString(); setDataField(fieldName, NULL, data); } return true; }