コード例 #1
0
ファイル: qtodo_list.cpp プロジェクト: tobimensch/qtodo
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);
}
コード例 #2
0
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("&nbsp;");
	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>");
}
コード例 #3
0
ファイル: qtodo_list.cpp プロジェクト: tobimensch/qtodo
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;
}
コード例 #4
0
ファイル: qtodo_list.cpp プロジェクト: tobimensch/qtodo
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();
	}
}