Esempio n. 1
0
void libmaus2::util::Utf8String::setup()
{
	uint64_t const bitalign = 6*64;
	
	::libmaus2::rank::ImpCacheLineRank::unique_ptr_type tI(new ::libmaus2::rank::ImpCacheLineRank(((A.size()+(bitalign-1))/bitalign)*bitalign));
	I = UNIQUE_PTR_MOVE(tI);

	::libmaus2::rank::ImpCacheLineRank::WriteContext WC = I->getWriteContext();
	for ( uint64_t i = 0; i < A.size(); ++i )
		if ( (!(A[i] & 0x80)) || ((A[i] & 0xc0) != 0x80) )
			WC.writeBit(1);
		else
			WC.writeBit(0);
			
	for ( uint64_t i = A.size(); i % bitalign; ++i )
		WC.writeBit(0);
			
	WC.flush();
	
	::libmaus2::select::ImpCacheLineSelectSupport::unique_ptr_type tS(new ::libmaus2::select::ImpCacheLineSelectSupport(*I,8));
	S = UNIQUE_PTR_MOVE(tS);
	
	#if 0
	std::cerr << "A.size()=" << A.size() << std::endl;
	std::cerr << "I.byteSize()=" << I->byteSize() << std::endl;
	#endif
}
// This is the main constructor.
PropertiesDialog::PropertiesDialog(QWidget *parent, const QVector<QString> Qheader, const QString sourceInput, const QString targetInput) : QDialog(parent) {
  // We first set up the standard elements of the interface, which are only two labels and two buttons.
  sourceLabel = new QLabel(sourceInput);
  targetLabel = new QLabel(targetInput);
  saveCloseButton = new QPushButton(tr("Save and Close"));
  cancelButton = new QPushButton(tr("Cancel"));

  // We dynamically create two lists of checkboxes as well, which represent potential properties.
  // Only variables that were not already selected as source and target nodes are included as options.
  QVectorIterator<QString> it(Qheader);
  while (it.hasNext()) {
    QPointer<QCheckBox> tempBoxOne = new QCheckBox(it.peekNext(), this);
    QPointer<QCheckBox> tempBoxTwo = new QCheckBox(it.next(), this);
    if (tempBoxOne->text() != sourceInput && tempBoxOne->text() != targetInput) {
      sourceVector.push_back(tempBoxOne);
    } else {
      delete tempBoxOne;
    }
    if (tempBoxTwo->text() != targetInput && tempBoxTwo->text() != sourceInput) {
      targetVector.push_back(tempBoxTwo);
      if (sourceInput == targetInput) {
	tempBoxTwo->setEnabled(false);
      }
    } else {
      delete tempBoxTwo;
    }
  }
  
  // We then set up the signals. Basically, save and close is the only signal that will send information from the properties dialog
  // to the main dialog.
  connect(saveCloseButton, SIGNAL(clicked()), this, SLOT(saveAndClose()));
  connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); // In case the user decides not to set properties.
  
  // Then we create our layout. 
  QPointer<QVBoxLayout> mainLayout = new QVBoxLayout;
  QPointer<QHBoxLayout> mainBodyLayout = new QHBoxLayout;
  QPointer<QVBoxLayout> mainBodyLeft = new QVBoxLayout;
  QPointer<QVBoxLayout> mainBodyRight = new QVBoxLayout;

  mainBodyLeft->addWidget(sourceLabel);
  QVectorIterator<QPointer<QCheckBox> > sI(sourceVector);
  while (sI.hasNext()) {
    mainBodyLeft->addWidget(sI.next());
  }
  
  mainBodyRight->addWidget(targetLabel);
  QVectorIterator<QPointer<QCheckBox> > tI(targetVector);
  while (tI.hasNext()) {
    mainBodyRight->addWidget(tI.next());
  }
  
  mainBodyLayout->addLayout(mainBodyLeft);
  mainBodyLayout->addLayout(mainBodyRight);
  mainLayout->addLayout(mainBodyLayout);
  QPointer<QHBoxLayout> lowerLayout = new QHBoxLayout;
  lowerLayout->addWidget(saveCloseButton);
  lowerLayout->addWidget(cancelButton);
  mainLayout->addLayout(lowerLayout);

  setLayout(mainLayout);
  setWindowTitle(tr("Set Properties"));
  setFixedHeight(sizeHint().height());
  // And that finishes our constructor
}