当前位置: 首页>>代码示例>>C++>>正文


C++ Selection::addItem方法代码示例

本文整理汇总了C++中Selection::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Selection::addItem方法的具体用法?C++ Selection::addItem怎么用?C++ Selection::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Selection的用法示例。


在下文中一共展示了Selection::addItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: changeDocGrid

void Imposition::changeDocGrid()
{
	//get first copied page
	Page* src = srcDoc->Pages->at(cbFront->currentIndex());
	
	double realSrcWidth = src->width() + srcDoc->bleeds.Left + srcDoc->bleeds.Right;
	double realSrcHeight = src->height() + srcDoc->bleeds.Top + srcDoc->bleeds.Bottom;
	
	//check whether width fits
	if (isOK == true)
	{
		//count how many rows and cols will be needed
		int cols = (int)((targetDoc->pageWidth)/realSrcWidth); // how many columns do we have on page?
		int rows = (int)((targetDoc->pageHeight)/realSrcHeight); // how many rows do we have on page?
		
		//now count how many pages are needed and create them
		int countPages=0;
		countPages = (int)(boxCopies->value() / (cols * rows)) + 1;
		if ((boxCopies->value() % (cols * rows) ) == 0) countPages--;
		if (chb2Sides->checkState() == Qt::Checked) countPages = countPages * 2; //double pages!
		targetDoc->createNewDocPages(countPages);
		
		targetDoc->changeLayerName(0,srcDoc->layerName(0));
		for (int i = 1; i < srcDoc->layerCount(); i++)
		{
			targetDoc->addLayer(srcDoc->layerName(i));
		}
		
		// make guides
		for (int i = 0; i < countPages; i++)
		{
			Page* p = targetDoc->Pages->at(i);
			
			//vertical guides
			double vertDist = (p->width() - p->Margins.Left - p->Margins.Right - cols*src->width())/cols;
			
			p->guides.addVertical(p->Margins.Left + 0.5*vertDist, p->guides.Standard);
			p->guides.addVertical(p->width() - p->Margins.Right - 0.5*vertDist, p->guides.Standard);
			
			double left = p->Margins.Left + 0.5*vertDist;
			double right = p->width() - p->Margins.Right - 0.5*vertDist;
			
			for (int j = 0; j < cols; j++)
			{
				left = left + src->width() + vertDist;
				p->guides.addVertical(left, p->guides.Standard);
				
				right = right - src->width() - vertDist;
				p->guides.addVertical(right, p->guides.Standard);
			}
			
			//horizontal guides
			double horizDist = (p->height() - p->Margins.Top - p->Margins.Bottom - rows*src->height())/rows;
			
			p->guides.addHorizontal(p->Margins.Top + 0.5*horizDist, p->guides.Standard);
			p->guides.addHorizontal(p->height() - p->Margins.Bottom - 0.5*horizDist, p->guides.Standard);
			
			double top = p->Margins.Top + 0.5*horizDist;
			double bottom = p->height() - p->Margins.Bottom - 0.5*horizDist;
			
			for (int j = 0; j < rows; j++)
			{
				top = top + src->height() + horizDist;
				p->guides.addHorizontal(top, p->guides.Standard);
				
				bottom = bottom - src->height() - horizDist;
				p->guides.addHorizontal(bottom, p->guides.Standard);
			}
		}
		
		
		//copy the first page to the clipboard
		ScribusMainWindow* scMW = ScCore->primaryMainWindow();
		scMW->view->requestMode(modeNormal);
		Selection* s = new Selection(scMW);
		
		//select items to copy
		for (int i = 0; i < srcDoc->Items->count(); i++)
		{
			if (srcDoc->OnPage(srcDoc->Items->at(i)) == src->pageNr())
				s->addItem(srcDoc->Items->at(i),false);
		}
		
		//Now, as all the relevant items have been copied, move the selection to the clipboard
		
		// new version:
		std::ostringstream xmlString;
		SaxXML xmlStream(xmlString);
		Serializer::serializeObjects(*s, xmlStream);
		std::string xml(xmlString.str());
		QByteArray ba(QByteArray(xml.c_str(), xml.length()));
		
		int currow = 0;
		int curcol = 0;
		targetDoc->setCurrentPage(targetDoc->Pages->at(0));
		Page* cur = targetDoc->currentPage();
		
		//now, start placing
		for  (int j = 0; j < boxCopies->value(); j++)
		{
//.........这里部分代码省略.........
开发者ID:AlterScribus,项目名称:ece15,代码行数:101,代码来源:imposition.cpp

示例2: xmlStream

void Imposition::booklet4p(QList<int>* pages)
{
	/*
	
	4 page imposition looks like this:
	       front:                     back:
	 --------------------       --------------------
	|         |          |     |         |          |
	|         |          |     |         |          |
	|         |          |     |         |          |
	|    4    |    1     |     |    2    |    3     |
	|         |          |     |         |          |
	|         |          |     |         |          |
	|         |          |     |         |          |
         --------------------       --------------------
	
	*/
	
	//fill the pages, so that it could be divided by for
	while ( (pages->count() % 4) != 0)
	{
		pages->append(0);
	}
	
	//create pages
	int targetSheets = (int)ceil(pages->count() / 4.0); //how many sheets do we have
	int targetPages = targetSheets * 2; //how many pages do we have
	
	targetDoc->createNewDocPages(targetPages);
	
	targetDoc->changeLayerName(0,srcDoc->layerName(0));
	for (int i = 1; i < srcDoc->layerCount(); i++)
	{
		targetDoc->addLayer(srcDoc->layerName(i));
	}
	
	//make guides
	for (int i = 0; i < targetDoc->Pages->count(); i++)
	{
		Page* p = targetDoc->Pages->at(i);
		
		//count the left guide:
		double guide_x = (p->width() - 2 * srcDoc->pageWidth)/2;
		p->guides.addVertical(guide_x, p->guides.Standard);
		
		//middle guide:
		guide_x += srcDoc->pageWidth;
		p->guides.addVertical(guide_x, p->guides.Standard);
		
		//and the right one:
		guide_x += srcDoc->pageWidth;
		p->guides.addVertical(guide_x, p->guides.Standard);
		
		//now, the top guide:
		double guide_y = (p->height() - srcDoc->pageHeight)/2;
		p->guides.addHorizontal(guide_y, p->guides.Standard);
		
		//and the bottom one:
		guide_y += srcDoc->pageHeight;
		p->guides.addHorizontal(guide_y, p->guides.Standard);
	}
	
	//start copying
	ScribusMainWindow* scMW = ScCore->primaryMainWindow();
	scMW->slotSelect();
	Selection* s = new Selection(scMW);
	
	//first, do the frontsides
	for (int i = 0; i < targetDoc->Pages->count(); i = i + 2)
	{
		targetDoc->setCurrentPage(targetDoc->Pages->at(i));
		
		//copy the page to the clipboard
		//right side
		//make selections
		for (int j = 0; j < srcDoc->Items->count(); j++)
		{
			if (srcDoc->OnPage(srcDoc->Items->at(j)) == (pages->at(i)-1))
			{
				s->addItem(srcDoc->Items->at(j),false);
			}
			
		}
		
		if (s->count() > 0)
		{
			std::ostringstream xmlString;
			SaxXML xmlStream(xmlString);
			Serializer::serializeObjects(*s, xmlStream);
			std::string xml(xmlString.str());
			QByteArray ba(QByteArray(xml.c_str(), xml.length()));
			
			//paste page from clipboard
			
			Selection pastedObjects = Serializer(*targetDoc).deserializeObjects(ba);
			
			targetDoc->moveGroup(
					targetDoc->Pages->at(i)->guides.vertical(1, targetDoc->Pages->at(i)->guides.Standard),
					targetDoc->Pages->at(i)->guides.horizontal(0, targetDoc->Pages->at(i)->guides.Standard),
					false,
//.........这里部分代码省略.........
开发者ID:AlterScribus,项目名称:ece15,代码行数:101,代码来源:imposition.cpp

示例3: changeDocFold

void Imposition::changeDocFold()
{
	if (isOK == true)
	{
		//create page
		if (foldIsBackSide->checkState() == Qt::Checked)
			targetDoc->createNewDocPages(2);
		else
			targetDoc->createNewDocPages(1);
		
		//copy layers
		for (int i = 1; i < srcDoc->layerCount(); i++)
		{
			targetDoc->addLayer(srcDoc->layerName(i));
		}
		
		targetDoc->setCurrentPage(targetDoc->Pages->at(0));
		Page* p = targetDoc->currentPage();
		
		int firstPage = foldFrontPage->currentText().toInt() - 1;
		int lastPage = 0;
		if (foldFrontPage->currentIndex() < (foldFrontPage->count()-1))
		{
			lastPage = foldFrontPage->itemText(foldFrontPage->currentIndex()+1).toInt() - 2;
		}
		else
		{
			lastPage = firstPage + srcDoc->currentPageLayout;
		}
		
		//make guides
		double allWidth = srcDoc->pageWidth * (srcDoc->currentPageLayout+1);
		double allHeight = srcDoc->pageHeight;
		
		double guide_x = (p->width() - allWidth)/2; //initial (left) guide
		p->guides.addVertical(guide_x, p->guides.Standard);
		
		for (int i = firstPage; i <= lastPage; i++)
		{
			guide_x += srcDoc->Pages->at(i)->width();
			p->guides.addVertical(guide_x,p->guides.Standard);
		}
		
		double guide_y = (p->height() - allHeight)/2;
		p->guides.addHorizontal(guide_y, p->guides.Standard);
		guide_y += allHeight;
		p->guides.addHorizontal(guide_y, p->guides.Standard);
		
		//do the copying
		ScribusMainWindow* scMW = ScCore->primaryMainWindow();
		scMW->view->requestMode(modeNormal);
		Selection* s = new Selection(scMW);
		
		//select items to copy for the first page
		for (int i = 0; i < srcDoc->Items->count(); i++)
		{
			if (	(srcDoc->OnPage(srcDoc->Items->at(i)) >= firstPage) &&
				(srcDoc->OnPage(srcDoc->Items->at(i)) <= lastPage)
			   )
				s->addItem(srcDoc->Items->at(i),false);
		}
		
		if (s->count() > 0)
		{
			//move the selection to the clipboard
			std::ostringstream xmlString;
			SaxXML xmlStream(xmlString);
			Serializer::serializeObjects(*s, xmlStream);
			std::string xml(xmlString.str());
			QByteArray ba(QByteArray(xml.c_str(), xml.length()));
			
			//paste
			Selection pastedObjects = Serializer(*targetDoc).deserializeObjects(ba);
			targetDoc->moveGroup(
					p->guides.vertical(0, p->guides.Standard),
					p->guides.horizontal(0, p->guides.Standard),
					true,
					&pastedObjects
				);
		}
		
		if (foldIsBackSide->checkState() != Qt::Checked) return;
		
		//do the second page
		s->clear();
		firstPage = foldBackPage->currentText().toInt() - 1;
		if (foldBackPage->currentIndex() < (foldBackPage->count()-1))
		{
			lastPage = foldBackPage->itemText(foldBackPage->currentIndex()+1).toInt() - 2;
		}
		else
		{
			lastPage = firstPage + srcDoc->currentPageLayout;
		}
		
		targetDoc->setCurrentPage(targetDoc->Pages->at(1));
		p = targetDoc->currentPage();
		guide_x = (p->width() - allWidth)/2; //initial (left) guide
		p->guides.addVertical(guide_x, p->guides.Standard);
		
//.........这里部分代码省略.........
开发者ID:AlterScribus,项目名称:ece15,代码行数:101,代码来源:imposition.cpp


注:本文中的Selection::addItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。