void QTodoList::loadNode(QTodoNode* node, unsigned int depth) { if(!node) return; for(QTodoNode::iterator it = node->begin(); it != node->end(); ++it) { if((*it)->section == true) { QTodoListViewItemSection* lists_item = new QTodoListViewItemSection(getTodoListWidget()->getListViewItem()); QTodoSectionWidget* section = new QTodoSectionWidget(vbox,lists_item); lists_item->setSection(section); section->setName((*it)->task); section->show(); continue; } QTodoItem* item = new QTodoItem(vbox); insertTodoAtBottom(item); item->setDepth(depth); item->setTask((*it)->task); item->setPriority((*it)->priority); item->setDeadline((*it)->deadline); item->setCreated((*it)->created); item->setDone((*it)->done); item->setStatus((*it)->status); item->setAgent((*it)->agent); item->show(); loadNode((*it)->sub,depth+1); } }
void QTodoExportPluginHTML::exportItem(const QTodoItem& item) { addLine("<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\" style=\"margin-bottom:5px\">"); addLine("<tr>"); addLine("<td width=\""+QString::number(30*item.getDepth())+"\"></td>"); addLine("<td>"); addLine("<table cellspacing=\"0\" width=\"100%\">"); addLine("<tr bgcolor=\"#eeeeee\">"); addLine("<td>"); addLine("<small>"); //if(item.getPriority() != PRIO_NA) addLine("<b>"+QObject::tr("Priority:")+"</b> "+QTodo::priorityToString(item.getPriority())); //if(item.getStatus() != STAT_NA) addLine("<b>"+QObject::tr("Status:")+"</b> "+QTodo::statusToString(item.getStatus())); addLine(" "); if(item.getDeadlineDateTime().isValid()) { addLine("</small>"); addLine("</td><td align=\"right\"><small>"); //addLine("<span align=\"right\">"); addLine("<b>"); addLine(QObject::tr("Deadline:")+"</b> "+item.getDeadlineLocalString()); //addLine("</span>"); } addLine("</small>"); addLine("</td>"); addLine("</tr><tr><td>"); addLine(item.getTaskRichText().replace("\n","<br>")); addLine("<br><small><i>"); addLine(QObject::tr("Created:")+" "+item.getCreatedLocalString()); if(!item.getAgent().isEmpty()) addLine(" "+QObject::tr("Assigned to:")+" "+item.getAgent()); addLine("</i></small></td></tr></table></td></tr></table>"); }
void QTodoList::cut() { preserveContentsYPos(); QTodoListIterator it(this); QCB::get()->clear(); QCB::get()->setCut(true); QTUM::get()->startRecording(); int last_depth = -1; int above = -1; QTodoItem* previous = 0; bool last_cut = false; for(;it.current();++it) { if(QTodoItem* item = dynamic_cast<QTodoItem*>(it.current())) { if(!item->isSelected()) { if(above == -1) above = it.currentIndex() - 1; if(item->getDepth() - 1 > last_depth) { QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth())); item->setDepth(last_depth+1); } if(last_cut) item->setDepth(item->getDepth()); last_depth = item->getDepth(); last_cut = false; continue; } else { last_cut = true; } if(!previous) { --it; previous = it.item(); ++it; } QCB::get()->add(item); it.take(); } } if(previous) previous->setFocusOnTask(); else jumpToFirst(); QTUM::get()->stopRecording(); QCB::get()->doExport(); restoreContentsYPos(); }
void QTodoList::pasteAtBottom() { int last_depth = -1; int base_depth = -QCB::get()->minDepth(); QTodoItem* item = 0; for(QTodoItemVector::iterator it = QCB::get()->getItems()->begin(); it != QCB::get()->getItems()->end(); ++it) { item = new QTodoItem(*(*it)); insertTodoAtBottom(item); QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth())); item->setDepth(item->getDepth() + base_depth); if(item->getDepth() > last_depth + 1) { QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth())); item->setDepth(last_depth + 1); } last_depth = item->getDepth(); } QCB::get()->clear(); jumpToLast(); fixItemSize(item); }
void QTodoExportPluginCSV::exportItem(const QTodoItem& item) { addData(QString::number(current_id)); QTodoItem* parent = item.list()->parentTodo(&item); if(parent) addData(QString::number(item.list()->itemPos(item.list()->parentTodo(&item))+1)); else addData(""); addData(QTodo::priorityToString(item.getPriority())); addData(QTodo::statusToString(item.getStatus())); addData(item.getDeadlineLocalString()); addData(item.getAgent()); addData(item.getCreatedLocalString()); addData(item.getDoneLocalString()); addData(item.getTaskPlainText()); newRow(); }
void QTodoList::addTodo(int index, int depth) { QTodoItem* item = new QTodoItem(vbox); insertTodo(item,index,depth); item->setFocusOnTask(); item->adjustSize(); ensureVisible(0,item->mapToParent(QPoint(0,item->height()/2)).y(),0,item->height()/2); QSize s = item->sizeHint(); s.setWidth(vbox->width()-vbox->margin()*2); item->resize(s); }
QTodoItemSortPtrList* QTodoListItemsSorter::getSubList(QPtrListIterator<QWidget> it) { if(!it.atFirst() && !dynamic_cast<QTodoItem*>(it.current())) return 0; QTodoItemSortPtrList* sub_list = new QTodoItemSortPtrList; QTodoItem* current = dynamic_cast<QTodoItem*>(it.current()); int depth; if(it.atFirst()) { ++it; depth = dynamic_cast<QTodoItem*>(it.current())->getDepth(); --it; } else { depth = current->getDepth()+1; } if(it.atFirst()) sub_list->top_item = 0; else sub_list->top_item = current; ++it; for(; it.current() && (current = dynamic_cast<QTodoItem*>(it.current())) && current->getDepth() >= depth; ++it) { if(current->getDepth() == depth) sub_list->append(current); } if(sub_list->count()) return sub_list; else return 0; }
void QTodoList::addTodo() { QTodoItem* item = new QTodoItem(vbox); insertTodo(item,-1); item->setDepth(0); item->setFocusOnTask(); item->adjustSize(); ensureVisible(0,item->mapToParent(QPoint(0,item->height())).y(),0,0); fixItemSize(item); }
void QTodoList::pasteTodo(QTodoItem* todo) { if(QCB::get()->isEmpty()) return; deselectAll(); todo->setSelected(true); QTodoRadioDialog radio_dialog(tr("Paste todos"),tr("You are about to paste todos")); radio_dialog.setIcon(QTP::editpaste.s(16,16)); radio_dialog.add(QTP::add_top,tr("Paste at top"),TDP_ATTOP); radio_dialog.add(QTP::add_above,tr("Paste above"),TDP_ABOVE); radio_dialog.add(QTP::add_below,tr("Paste below"),TDP_BELOW); radio_dialog.add(QTP::add_sub,tr("Paste as sub-todos"),TDP_SUB); radio_dialog.add(QTP::add_bottom,tr("Paste at bottom"),TDP_ATBOTTOM); if(radio_dialog.exec() == QDialog::Accepted) { //preserveContentsYPos(); int pos; int last_depth = todo->getDepth(); int base_depth = todo->getDepth() - QCB::get()->minDepth();//(*QCB::get()->getItems()->begin())->getDepth(); QTUM::get()->startRecording(); QTodoItem* item = 0; switch(radio_dialog.selected()) { case TDP_ATTOP: pasteAtTop(); break; case TDP_ATBOTTOM: pasteAtBottom(); break; case TDP_ABOVE: pos = findWidget(todo); for(QTodoItemVector::reverse_iterator it = QCB::get()->getItems()->rbegin(); it != QCB::get()->getItems()->rend(); ++it) { item = new QTodoItem(*(*it)); insertTodo(item,pos,(*it)->getDepth() + base_depth); ensureItemVisible(item); if(item->getDepth() > last_depth + 1) { QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth())); item->setDepth(last_depth + 1); } last_depth = item->getDepth(); } fixItemSize(item); QCB::get()->clear(); break; case TDP_BELOW: pos = findPosBelowTodoItem(todo); for(QTodoItemVector::iterator it = QCB::get()->getItems()->begin(); it != QCB::get()->getItems()->end(); ++it) { item = new QTodoItem(*(*it)); insertTodo(item,pos,(*it)->getDepth() + base_depth); ensureItemVisible(item); if(item->getDepth() > last_depth + 1) { QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth())); item->setDepth(last_depth + 1); } last_depth = item->getDepth(); pos++; } fixItemSize(item); QCB::get()->clear(); break; case TDP_SUB: pos = findWidget(todo) + 1; for(QTodoItemVector::iterator it = QCB::get()->getItems()->begin(); it != QCB::get()->getItems()->end(); ++it) { item = new QTodoItem(*(*it)); insertTodo(item,pos,(*it)->getDepth() + base_depth + 1); ensureItemVisible(item); if(item->getDepth() > last_depth + 1) { QTUM::get()->addChange(new QTodoChangeDepth(this,findWidget(item),item->getDepth())); item->setDepth(last_depth + 1); } last_depth = item->getDepth(); pos++; } fixItemSize(item); QCB::get()->clear(); break; } QTUM::get()->stopRecording(); //restoreContentsYPos(); deselectAll(); } }
int QTodoItemSortPtrList::compareItems(QPtrCollection::Item item1, QPtrCollection::Item item2) { QTodoItem* left = reinterpret_cast<QTodoItem*>(item1); QTodoItem* right = reinterpret_cast<QTodoItem*>(item2); if(!right) return 1; for(QTodoSortCriteriaMap::const_iterator it = sort_criterias->begin(); it != sort_criterias->end(); ++it) { int r; QTodoSortOrder order = (*it).second.second; switch((*it).second.first) { case SORT_PRIORITY: if((r = right->getPriority() - left->getPriority()) != 0) if(order == ORDER_ASCENDING) return -r; else return r; break; case SORT_STATUS: if((r = right->getStatus() - left->getStatus()) != 0) if(order == ORDER_ASCENDING) return -r; else return r; break; case SORT_DEADLINE: if((r = right->getDeadlineDateTime().toTime_t() - left->getDeadlineDateTime().toTime_t()) != 0) if(order == ORDER_ASCENDING) return -r; else return r; break; case SORT_ASSIGNED: if((r = right->getAgent().compare(left->getAgent())) != 0) if(order == ORDER_ASCENDING) return -r; else return r; break; case SORT_CREATED: if((r = right->getCreated().toTime_t() - left->getCreated().toTime_t()) != 0) if(order == ORDER_ASCENDING) return -r; else return r; break; case SORT_DONE: if((r = right->getDone().toTime_t() - left->getDone().toTime_t()) != 0) if(order == ORDER_ASCENDING) return -r; else return r; break; default: break; } } return 0; }