Example #1
0
void TasksTab::OnBnClickedButtonEdit2()
{
	HTREEITEM hItem = m_Tree.GetSelectedItem();
	if( !hItem ) return;

	DWORD_PTR dw = m_Tree.GetItemData( hItem ); 
	Task* itemData = (Task*)dw;
	if( itemData != NULL ) {					
		UpdateData(TRUE);
		
		itemData->setName( m_NameValue );
		itemData->setDescription( m_DescriptionValue );
		itemData->setManhours( atoi( m_MHValue ) );
		itemData->clearStaff();
		for( int i=0; i < m_AssignList.GetCount(); i++ ) {
			DWORD_PTR dw = m_AssignList.GetItemData( i );
			if( dw != NULL ) {				
				Personnel* staff = (Personnel*)dw;
				itemData->addStaff( staff );				
			}
		}
		
		UpdateData( FALSE );
	}

	ReloadTaskTree();
}
Example #2
0
void ProgramMenu::editTask(int id) {
    string description, date, time;
    int priority, severity;
    Task* task = list->getTask(id);
    cout << "Edytuj zadanie" << endl << endl;
    cout << "Podaj date terminu: (" << task->getDate() << ")";
    cin >> date;
    task->setDate(date);
    cout << "Podaj godzine terminu: (" << task->getTime() << ")";
    cin >> time;
    task->setTime(time);
    cout << "Podaj opis zadania: (" << task->getDescription() << ")";
    cin.ignore();
    getline(cin, description);
    task->setDescription(description);
    cout << "Podaj priorytet (od 0 do 5): (" << task->getPriority() << ")";
    cin >> priority;
    while (priority > 5 || priority < 0) {
        cout << "Podaj cyfre od 0 do 5" << endl;
        cin >> priority;
    }
    task->setPriority(priority);
    cout << "Podaj waznosc zadania (od 0 do 5): (" << task->getSeverity() << ")";
    cin >> severity;
    while (severity > 5 || severity < 0) {
        cout << "Podaj cyfre od 0 do 5" << endl;
        cin >> severity;
    }
    task->setSeverity(severity);
    clear();
    this->list->showList();
    this->showMenu();
}
Example #3
0
void TasksTab::OnBnClickedButtonNew()
{
	Task *newTask = new Task();
	newTask->setName( "Unnamed Task" );
	newTask->setDescription( "Unnamed Task Description" );

	HTREEITEM hItem = m_Tree.GetSelectedItem();
	if( !hItem ) {
		taskContainer->push_back( newTask );
	} else {
		DWORD_PTR dw = m_Tree.GetItemData( hItem ); //get item data
		Task* ItemData = (Task*)dw;
		if( ItemData != NULL ) {
			ItemData->addTask( newTask );
		}
	}	

	ReloadTaskTree();
}
//Retrieves information of done tasks.
void Storage::retrieveDoneTasks(TaskList& listOfTasks) {
	std::string userInput = DEFAULT_EMPTY;
	std::ifstream input(_doneFileName);
	std::string temp;
	int taskHeader;

	if(input.is_open()) {
		while(!input.eof()) {
			taskHeader = START_VALUE;
			getline(input,userInput);
			if(userInput == DEFAULT_EMPTY) {
				return;
			}
			Task* newTask = new Task;
			while (userInput != SEPARATOR) {
				std::string details = Parser::removeFirstWord(userInput);
				details = Parser::trim(details);
				switch(taskHeader) {
				case HEADER_DESCRIPTION: {
					newTask->setDescription(details);
					taskHeader++;
					break;
				}
				case HEADER_START_DATE: {
					taskHeader++;
					if(details == DEFAULT_EMPTY || details == SPACE_PARAMETER) {
						break;
					} else {
						try{
							newTask->setStartDate(_parser.createDate(details));
						} catch(...) {
							delete newTask->getStartDate();
							newTask->setStartDate(NULL);
							_corrupted=true;
						}
					}
					break;
				}
				case HEADER_END_DATE: {
					taskHeader++;
					if(details == DEFAULT_EMPTY || details == SPACE_PARAMETER) {
						break;
					} else {
						try {
							newTask->setEndDate(_parser.createDate(details));
						} catch(...) {
							delete newTask->getEndDate();
							newTask->setEndDate(NULL);
							_corrupted=true;
						}					
					} break;
				}
				case HEADER_START_TIME: {
					taskHeader++;
					if(details == DEFAULT_EMPTY || details == SPACE_PARAMETER) {
						break;
					} else {
						try {
							newTask->setStartTime(_parser.createTime(details));
						} catch(...) {
							delete newTask->getStartTime();
							newTask->setStartTime(NULL);
							_corrupted=true;
						}						
					}
					break;
				}
				case HEADER_END_TIME: {
					taskHeader++;
					if(details == DEFAULT_EMPTY || details == SPACE_PARAMETER) {
						break;
					} else {
						try {
							newTask->setEndTime(_parser.createTime(details));
						} catch(...) {
							delete newTask->getEndTime();
							newTask->setEndTime(NULL);
							_corrupted=true;
						}						
					} 
					break;
				}
				case HEADER_CATEGORY: {
					taskHeader++;
					newTask->setCategory(details);
					break;
				}
				case HEADER_STATUS: {
					taskHeader++;
					TASK_STATUS status = _parser.getTaskStatus(details);
					newTask->setStatusAsDone();
					break;
				}
				default: {
					taskHeader++;
					_corrupted = true;
					break;
				}
				}
				if(taskHeader > COLUMN_OUT_OF_BOUND) {
					break;
				}
				getline(input, userInput);
			} 
			listOfTasks.addTaskToDoneList(*newTask);
		} 
	}
	input.close();
}
void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    {
        Task task;
        task.setName(index.data(Task::NameRole).toString());
        task.setDescription(index.data(Task::DescriptionRole).toString());
        task.setPriority(index.data(Task::PriorityRole).toInt());
        task.setDeadlineTime(index.data(Task::DeadlineRole).toDateTime());
        task.setCompleted(index.data(Task::CompleteStatusRole).toBool());
        task.setPrivate(index.data(Task::PrivateRole).toBool());
        task.setCreateDate(index.data(Task::CreatedRole).toDate());
        task.setRepeatType((Task::RepeatType)index.data(Task::RepeatRole).toInt());

        QImage priorityImage(task.priorityIcon());




        QColor taskTextColor;
        if (option.state & QStyle::State_Selected)
        {
            if (task.deadlineTime()<QDateTime::currentDateTime() && task.deadlineTime().isValid() && !task.completed())
            {
                QColor bgColor(255,65,204);
                QBrush brush(bgColor);



                painter->fillRect(option.rect, brush);

            } else
            QStyledItemDelegate::paint(painter, option, index);
        } else if (task.deadlineTime()<QDateTime::currentDateTime() && task.deadlineTime().isValid() && !task.completed())
        {
            QColor bgColor(255,91,91);
            QBrush brush(bgColor);

            painter->fillRect(option.rect, brush);
        }

        else {
            QBrush brush = (index.row()%2)?option.palette.base():option.palette.alternateBase();
            taskTextColor.setRgb(255-brush.color().red(),
                                 255-brush.color().green(),
                                 255-brush.color().blue());

            painter->fillRect(option.rect, brush);
            }
            painter->save();
            QFont taskFont = getTaskFont(option);
            QFont descriptionFont = getDescriptionFont(option);
            QFont dateFont = getDateFont(option);
            QFont timeFont = getTimeFont(option);

            QFontMetrics fmTaskFont(taskFont);
            QFontMetrics fmDescriptionFont(descriptionFont);
            QFontMetrics fmDateFont(dateFont);
            int dateWidth=fmDateFont.width(task.deadlineTime().date().toString(Qt::SystemLocaleShortDate));

            painter->setPen(Qt::black);

            painter->setFont(taskFont);
            QRect nameRect=option.rect.adjusted(priorityImage.width(),4, -dateWidth-10,0);
            painter->drawText(nameRect,Qt::AlignHCenter, fmTaskFont.elidedText(task.name(),Qt::ElideRight,nameRect.width()-70,0));


            QRect descriptionRect=option.rect.adjusted(priorityImage.width(),30,-dateWidth-10,0);
            painter->setFont(descriptionFont);

            painter->drawText(descriptionRect,Qt::AlignHCenter,
                              fmDescriptionFont.elidedText(task.description().replace("\n"," "),Qt::ElideRight,descriptionRect.width()));


            painter->drawImage(option.rect.adjusted(0,3,-(option.rect.width()-priorityImage.width()),-(option.rect.height()-priorityImage.height())),priorityImage);
            if (task.completed()%2==1)
            {
                QImage completeImage=QImage(":/icons/task-complete");
                painter->drawImage(option.rect.adjusted(10,10,-(option.rect.width()-priorityImage.width()+10),-(option.rect.height()-priorityImage.height())-10),completeImage);
            }
            if ((int)task.repeatType()>0)
            {
                QImage completeImage=QImage(":/icons/clock");
                painter->drawImage(option.rect.adjusted(priorityImage.width(),5,-(option.rect.width()-completeImage.width()),-(option.rect.height()-completeImage.height())),completeImage);
            }

            painter->setFont(dateFont);

            painter->drawText(option.rect.adjusted((option.rect.width()-dateWidth-10),8,0,0),Qt::AlignHCenter,task.deadlineTime().date().toString(Qt::SystemLocaleShortDate));

            painter->setFont(timeFont);
            painter->drawText(option.rect.adjusted((option.rect.width()-dateWidth-10),20,0,0),Qt::AlignHCenter,task.deadlineTime().time().toString(Qt::SystemLocaleShortDate));

            if (task.isPrivate() && !task.completed())
            {
                QImage privateImage(":/icons/private");
                painter->drawImage(option.rect.adjusted(10,10,-(option.rect.width()-priorityImage.width()+10),-(option.rect.height()-priorityImage.height())-10),privateImage);
            }
            painter->restore();

        }
}