Esempio n. 1
0
void Imposition::changeTab(int dest)
{
	isEdited = true;
	isOK = verifyPage();
	btnGo->setEnabled(isOK);
	btnPreview->setEnabled(isOK);
}
Esempio n. 2
0
  void testPageStore(PageStore& uut)
  {
    CPPUNIT_ASSERT_EQUAL(0, uut.getPageCount());
    int pageSize = uut.getPageSize();

    boost::shared_ptr<Page> p = uut.createPage();
    CPPUNIT_ASSERT_EQUAL(pageSize, p->getDataSize());

    populatePage(p);
    verifyPage(p);

    
    _ids.push_back(p->getId());

    for (int i = 1; i < 100; i++)
    {
      CPPUNIT_ASSERT_EQUAL(i, uut.getPageCount());
      p = uut.createPage();
      populatePage(p);
      _ids.push_back(i);
    }
    CPPUNIT_ASSERT_EQUAL(100, uut.getPageCount());

    for (int i = 0; i < 100; i++)
    {
      p = uut.getPage(_ids[i]);
      verifyPage(p);
    }

    uut.save();

    for (int i = 0; i < 100; i++)
    {
      p = uut.getPage(_ids[i]);
      verifyPage(p);
    }

    uut.flush();

    for (int i = 0; i < 100; i++)
    {
      p = uut.getPage(_ids[i]);
      verifyPage(p);
    }
  }
Esempio n. 3
0
void Imposition::setPageSize(const QString &size)
{
	disconnect(pageWidthBox, SIGNAL(valueChanged(double)), this, SLOT(customizeSize()));
	disconnect(pageHeightBox, SIGNAL(valueChanged(double)), this, SLOT(customizeSize()));
	
	PageSize* ps = new PageSize( tr(size.toLocal8Bit().constData()));
	
	pageWidthBox->setValue(ps->width() * unitRatio);
	pageHeightBox->setValue(ps->height() * unitRatio);
	
	delete ps;

	isEdited = true;
	isOK = verifyPage();
	btnGo->setEnabled(isOK);
	btnPreview->setEnabled(isOK);
	
	connect(pageWidthBox, SIGNAL(valueChanged(double)), this, SLOT(customizeSize()));
	connect(pageHeightBox, SIGNAL(valueChanged(double)), this, SLOT(customizeSize()));
}
Esempio n. 4
0
  void fileTest()
  {
    if (QFile::exists("dum.dat"))
    {
      QFile::remove("dum.dat");
    }
    {
      FilePageStore uut(100, "dum.dat");

      CPPUNIT_ASSERT_EQUAL(100, uut.getPageSize());

      testPageStore(uut);
    }
    {
      FilePageStore uut(100, "dum.dat", true);

      for (int i = 0; i < 100; i++)
      {
        boost::shared_ptr<Page> p = uut.getPage(_ids[i]);
        verifyPage(p);
      }
    }
  }
Esempio n. 5
0
Imposition::Imposition(QWidget* parent, ScribusDoc* doc) : QDialog(parent)
{
	UndoManager::instance()->setUndoEnabled(false);
	setupUi(this);
	setModal(true);

	languageChange();
	
	this->parent = parent;
	this->srcDoc = doc;
	
	//get units
	unitIndex = doc->unitIndex();
	unitRatio = unitGetRatioFromIndex(unitIndex);
	unitSuffix = unitGetSuffixFromIndex(unitIndex);
		
	//set units in page settings
	pageWidthBox->setSuffix(unitSuffix);
	pageHeightBox->setSuffix(unitSuffix);

	//fill Page Size combobox
	PageSize ps( tr(doc->m_pageSize.toLocal8Bit().constData()));
	pageSizeComboBox->addItems(ps.sizeTRList());
	pageSizeComboBox->addItem( CommonStrings::trCustomPageSize);
	
	QStringList pageSizes=ps.sizeList();
	int sizeIndex=pageSizes.indexOf(ps.nameTR());
	if (sizeIndex!=-1)
		pageSizeComboBox->setCurrentIndex(sizeIndex);
	else
		pageSizeComboBox->setCurrentIndex(pageSizeComboBox->count()-1);

	pageOrientationComboBox->addItem( tr( "Portrait" ) );
	pageOrientationComboBox->addItem( tr( "Landscape" ) );

	//put page dimensions to boxes
	pageWidthBox->setValue(ps.width() * unitRatio);
	pageHeightBox->setValue(ps.height() * unitRatio);
	
	//fill grid pages boxes with pagelists
	for (int i = 1; i <= (int)(doc->Pages->count()); i++)
	{
		cbFront->addItem(QString::number(i));
		cbBack->addItem(QString::number(i));
	}
	
	//fill folds pages boxes with pagelists
	foldFrontPage->addItem(QString::number(1));
	foldBackPage->addItem(QString::number(1));
	
	for (int i = 1; i < (int)(srcDoc->Pages->count()); i++)
	{
		if (srcDoc->locationOfPage(i) == LeftPage)
		{
			foldFrontPage->addItem(QString::number(i+1));
			foldBackPage->addItem(QString::number(i+1));
		}
	}

	isEdited = true;
	isOK = verifyPage();
	btnGo->setEnabled(isOK);
	btnPreview->setEnabled(isOK);
	
	//connect slots and signals
	connect(pageSizeComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setPageSize(const QString &)));
		
	connect(pageWidthBox, SIGNAL(valueChanged(double)), this, SLOT(customizeSize()));
	connect(pageHeightBox, SIGNAL(valueChanged(double)), this, SLOT(customizeSize()));
	connect(chb2Sides, SIGNAL(stateChanged(int)), this, SLOT(change2SidesBox(int)));
	connect(foldIsBackSide, SIGNAL(stateChanged(int)), this, SLOT(changeFoldBackPage(int)));
	connect(this, SIGNAL(accepted()), this, SLOT(accepted()));
	
	//document changing slots
	connect(impositionTabWidget, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));
	connect(pageWidthBox, SIGNAL(valueChanged(double)), this, SLOT(verifyPage()));
	connect(pageHeightBox, SIGNAL(valueChanged(double)), this, SLOT(verifyPage()));

	connect(cbFront, SIGNAL(currentIndexChanged(QString)), this, SLOT(verifyPage()));
	connect(cbBack, SIGNAL(currentIndexChanged(QString)), this, SLOT(verifyPage()));
	
	connect(cbLayout, SIGNAL(currentIndexChanged(QString)), this, SLOT(verifyPage()));
}