int load_event(load_t *m,int event,int data) { if(m->isshowing == 0) return(0); switch(event) { case E_MOUSEMOVE: case E_MOUSEDOWN: case E_MOUSEDOWN2: if(mouseinrange(&m->info,data) == 0) return(0); button_event(&m->closebtn,event,data); button_event(&m->loadbtn,event,data); if(list_event(&m->romlist,event,data) > 0) return(1); if(list_event(&m->dirlist,event,data) > 0) return(1); edit_event(&m->edit,event,data); break; case E_MOUSEUP: if(button_event(&m->closebtn,event,data) > 0) m->isshowing = 0; button_event(&m->loadbtn,event,data); if(list_event(&m->romlist,event,data) > 0) return(1); if(list_event(&m->dirlist,event,data) > 0) return(1); edit_event(&m->edit,event,data); break; } return(0); }
/*======================================= * edit_any_record -- Edit record of any type *=====================================*/ BOOLEAN edit_any_record (RECORD rec, RFMT rfmt) { ASSERT(rec); switch (nztype(rec)) { case 'I': return edit_indi(rec, rfmt); case 'F': return edit_family(rec, rfmt); case 'S': return edit_source(rec, rfmt); case 'E': return edit_event(rec, rfmt); case 'X': return edit_other(rec, rfmt); default: ASSERT(0); return FALSE; } }
int main() { vector<string> classes; //the first line of the ics7 file contains the elements of this icalproperty_set_x_name(ical_x_class_prop, "X-CLASS"); icalcomponent* calendar = NULL; struct icaltimetype atime; struct icalperiodtype rtime; //FIXME Later versions will try to load from the default file here //If we don't have a saved calendar, make a new one if (calendar == NULL) { atime = icaltime_from_timet( time(0),0); rtime.start = icaltime_from_timet( time(0),0); rtime.end = icaltime_from_timet( time(0),0); rtime.end.hour++; calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); } //FIXME Find all non-school days by prompt? //FIXME Ask for start/end of semester //Actually manipulating the calendar while (true) { //Prompt for user action cout << "What would you like to do?\n" << "1. Add a class\n" << "2. Add an event\n" << "3. Delete an event\n" << "4. Edit an event\n" << "5. Find an event\n" << "6. View an event\n" << "7. Delete a class\n" << "8. Exit the program\n" << endl; cout << "Enter the integer corresponding to your choice" << endl; string user_choice = ""; cin >> user_choice; bool user_choice_flag = true; //Check the string is all digits for (int i = 0; i < user_choice.size(); i++) { if (!isdigit(user_choice[i])) { cout << "Invalid selection (Not all digits)" << endl; user_choice_flag = false; break; } } if (!user_choice_flag) { continue; } //Given the choice, perform the desired action switch (atoi(user_choice.c_str())) { //ADD CLASS case 1: { add_class(calendar, classes); break; } //ADD EVENT (for a class or in general) case 2: { add_event(calendar); break; } //DELETE SINGLE EVENT case 3: { delete_event(calendar); break; } //EDIT EVENT (class or general) case 4: { edit_event(calendar); break; } //FIND EVENT case 5: { icalcomponent* event = find_event(calendar); if (event == NULL) { append_action_to_closed_log("Find event", false); }else { append_action_to_closed_log("Find event", true); } break; } //VIEW EVENT case 6: { view_event(calendar); break; } //DELETE CLASS //FIXME Not implemented in this sprint case 7: { //FIXME Ask for class name //FIXME Scan through first level of components for class //FIXME Print all matches and get the one to delete //FIXME Warn that all events for that class will be deleted //FIXME Delete class after user okay cout << "This feature is not implemented in this sprint." << endl; break; } //EXIT case 8: { //Prompt for okay if (yes_no_prompt("Your calendar data will not be saved. Continue? (y/n)")) { return 0; } break; } default: { cout << "Invalid selection (Not between 1 and 8 inclusive)" << endl; break; } } } return 0; }