Пример #1
0
void tst_QFormLayout::insertRow_QString_QLayout()
{
    QFormLayout layout;
    QHBoxLayout fld1, fld2, fld3;

    layout.insertRow(-5, "&Name:", &fld1);
    QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
    QVERIFY(label1 != 0);
    QVERIFY(label1->buddy() == 0);

    QCOMPARE(layout.rowCount(), 1);

    layout.insertRow(0, "&Email:", &fld2);
    QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
    QVERIFY(label2 != 0);
    QVERIFY(label2->buddy() == 0);

    QCOMPARE(layout.rowCount(), 2);

    layout.insertRow(5, "&Age:", &fld3);
    QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget());
    QVERIFY(label3 != 0);
    QVERIFY(label3->buddy() == 0);

    QCOMPARE(layout.rowCount(), 3);
}
Пример #2
0
void tst_QFormLayout::addRow()
{
    QFormLayout layout;
    QWidget w1, w2, w3;
    QHBoxLayout l1, l2, l3;
    QLabel lbl1, lbl2;

    QCOMPARE(layout.rowCount(), 0);

    layout.addRow(&lbl1, &w1);
    layout.addRow(&lbl2, &l1);
    layout.addRow("Foo:", &w2);
    layout.addRow("Bar:", &l2);
    layout.addRow(&w3);
    layout.addRow(&l3);

    QCOMPARE(layout.rowCount(), 6);

    QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
    QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
    QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:");
    QVERIFY(layout.itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:");
    QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0);
    QVERIFY(layout.itemAt(5, QFormLayout::LabelRole) == 0);

    QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &w1);
    QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &l1);
    QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &w2);
    QVERIFY(layout.itemAt(3, QFormLayout::FieldRole)->layout() == &l2);
//  ### should have a third role, FullRowRole?
//    QVERIFY(layout.itemAt(4, QFormLayout::FieldRole) == 0);
//    QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0);
}
Пример #3
0
void tst_QFormLayout::insertRow_QWidget_QLayout()
{
    QFormLayout layout;
    QLabel lbl1, lbl2, lbl3, lbl4;
    QHBoxLayout fld1, fld2, fld3, fld4;

    layout.insertRow(0, &lbl1, &fld1);
    QCOMPARE(layout.rowCount(), 1);

    {
        int row = -1;
        QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
        layout.getWidgetPosition(&lbl1, &row, &role);
        QCOMPARE(row, 0);
        QCOMPARE(int(role), int(QFormLayout::LabelRole));
    }

    {
        int row = -1;
        QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
        layout.getLayoutPosition(&fld1, &row, &role);
        QCOMPARE(row, 0);
        QCOMPARE(int(role), int(QFormLayout::FieldRole));
    }

    // check that negative values append
    layout.insertRow(-2, &lbl2, &fld2);
    QCOMPARE(layout.rowCount(), 2);

    QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
    QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);

    // check that too large values append
    layout.insertRow(100, &lbl3, &fld3);
    QCOMPARE(layout.rowCount(), 3);

    QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
    QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
    QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3);

    QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->layout() == &fld1);
    QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &fld2);
    QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->layout() == &fld3);
}
QmitkFileReaderWriterOptionsWidget::Options QmitkFileReaderWriterOptionsWidget::GetOptions() const
{
  Options options;

  QFormLayout* layout = qobject_cast<QFormLayout*>(this->layout());
  const int rows = layout->rowCount();
  for(int i = 0; i < rows; ++i)
  {
    QmitkAnyAdapter* anyAdapter = dynamic_cast<QmitkAnyAdapter*>(layout->itemAt(i, QFormLayout::FieldRole)->widget());
    if (anyAdapter)
    {
      options.insert(std::make_pair(anyAdapter->GetName(), anyAdapter->GetAny()));
    }
  }
  return options;
}
Пример #5
0
void tst_QFormLayout::itemAt()
{
    QFormLayout layout;

    QWidget w1;
    QWidget w2;
    QWidget w3;
    QWidget w4;
    QWidget w5;
    QHBoxLayout l6;

    layout.setWidget(5, QFormLayout::LabelRole, &w1);
    layout.setWidget(3, QFormLayout::FieldRole, &w2);
    layout.setWidget(3, QFormLayout::LabelRole, &w3);
    layout.addRow(&w4, &w5);
    layout.addRow("Foo:", &l6);

    QCOMPARE(layout.count(), 7);

    QBitArray scoreBoard(7);
    for (int i = 0; i < 7; ++i) {
        QLayoutItem *item = layout.itemAt(i);
        QVERIFY(item != 0);

        if (item->widget() == &w1) {
            scoreBoard[0] = true;
        } else if (item->widget() == &w2) {
            scoreBoard[1] = true;
        } else if (item->widget() == &w3) {
            scoreBoard[2] = true;
        } else if (item->widget() == &w4) {
            scoreBoard[3] = true;
        } else if (item->widget() == &w5) {
            scoreBoard[4] = true;
        } else if (item->layout() == &l6) {
            scoreBoard[5] = true;
        } else if (qobject_cast<QLabel *>(item->widget())) {
            scoreBoard[6] = true;
        }
    }
    QCOMPARE(scoreBoard.count(false), 0);
}
Пример #6
0
void DonationWizard::previewImport() {
	tableWidget->clear();
	if (tableWidget->columnCount() < 5) {
		tableWidget->setColumnCount(5);
	}
	tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem());
	tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem());
	tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem());
	tableWidget->setHorizontalHeaderItem(3, new QTableWidgetItem());
	tableWidget->setHorizontalHeaderItem(4, new QTableWidgetItem());
	tableWidget->horizontalHeaderItem(0)->setText(QApplication::translate("DonationImportForm", "Member", 0, QApplication::UnicodeUTF8));
	tableWidget->horizontalHeaderItem(1)->setText(QApplication::translate("DonationImportForm", "Name, Surname", 0, QApplication::UnicodeUTF8));
	tableWidget->horizontalHeaderItem(2)->setText(QApplication::translate("DonationImportForm", "UID", 0, QApplication::UnicodeUTF8));
	tableWidget->horizontalHeaderItem(3)->setText(QApplication::translate("DonationImportForm", "Amount", 0, QApplication::UnicodeUTF8));
	tableWidget->horizontalHeaderItem(4)->setText(QApplication::translate("DonationImportForm", "Section", 0, QApplication::UnicodeUTF8));
	
	QLocale locale;
	QHash<QString, QString> sectionMapping;
	qint32 pos = 0;
	QFormLayout *layout = (QFormLayout *) importMapSections->layout();
	QLabel *label;
	QComboBox *box;
	while (pos < layout->rowCount()) {
		label = (QLabel *) layout->itemAt(pos, QFormLayout::LabelRole)->widget();
		box = (QComboBox *) layout->itemAt(pos, QFormLayout::FieldRole)->widget();
		sectionMapping.insert(label->text(), box->itemData(box->currentIndex()).toString());
		pos++;
	}
	
	PPSPerson person;
	qint32 sectionColum = importSectionColumn->value() - 1;
	qint32 column = importColumnMaster->value() - 1;
	qint32 amountColum = importAmountColumn->value() - 1;
	qint32 dbField = importColumnMemberfields->currentIndex();
	QString uid, amount, section;
	
	for (int row = 0; row < tablePreviewImport->rowCount(); row++) {
		uid = tablePreviewImport->item(row, column)->text();
		amount = tablePreviewImport->item(row, amountColum)->text();
		section = tablePreviewImport->item(row, sectionColum)->text();
		bool found(false);
		
		switch (dbField) {
			case 1:
				found = person.loadByPersonsFields(uid);
				break;
			case 2:
				found = person.loadByTelephone(uid);
				break;
			case 3:
				found = person.loadByEmail(uid);
				break;
			default:
				found = person.loadByAnyField(uid);
		}
		
		tableWidget->insertRow(row);
		if (found) {
			tableWidget->setItem(row, 0, new QTableWidgetItem(person.uid()));
			tableWidget->setItem(row, 1, new QTableWidgetItem(person.givenName() + " " + person.familyName()));
		} else {
			tableWidget->setItem(row, 0, new QTableWidgetItem(""));
			tableWidget->setItem(row, 1, new QTableWidgetItem(""));
		}
		tableWidget->setItem(row, 2, new QTableWidgetItem(uid));
		tableWidget->setItem(row, 3, new QTableWidgetItem(locale.toString(amount.toFloat())));
		tableWidget->setItem(row, 4, new QTableWidgetItem(sectionMapping.value(section)));
	}
}
Пример #7
0
QWidget* AutoImportWindow::setupStatusContinaer() {

    safeIntervalBox->setValue(ProjectPreferences().importSafeInterval());
    connect(safeIntervalBox, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=] (int i){
        ProjectPreferences().setImportSafeInterval(i);
        
    });
    
    QHBoxLayout* buttonLayout = new QHBoxLayout();
    buttonLayout->addStretch(0);
    buttonLayout->addWidget(importButton_, 0);
    buttonLayout->addWidget(refreshButton_, 0);
    buttonLayout->addStretch(1);
    
    QVBoxLayout* statusLayout = new QVBoxLayout;
    statusLayout->addWidget(statusLabel_, 0);
    statusLayout->addLayout(buttonLayout, 0);
    statusLayout->addWidget(deleteLabel_, 0);
    
    GroupContainer* statusContainer = new GroupContainer;
    statusContainer->setTitle("Current Status");
    statusContainer->setContainerLayout(statusLayout);
    
    filePatternLabel_->setText(FileNameParserDialog::expectedFileNamePattern());
    filePatternLabel_->setWordWrap(true);
    
    QPushButton* changeButton = new QPushButton("Change Pattern");
    connect(changeButton, &QPushButton::clicked, [=]{
        if(fileNameParser_->exec()) {
            filePatternLabel_->setText(FileNameParserDialog::expectedFileNamePattern());
        }
    }); 
    
    QHBoxLayout* fileNameParserLayout = new QHBoxLayout();
    fileNameParserLayout->addStretch(0);
    fileNameParserLayout->addWidget(filePatternLabel_, 0);
    fileNameParserLayout->addWidget(changeButton, 0);
    fileNameParserLayout->addStretch(1);
    
    QHBoxLayout* timerLayout = new QHBoxLayout();
    timerLayout->addStretch(0);
    timerLayout->addWidget(new QLabel("Number of seconds to wait before starting import of fresh (newly created) images"), 0);
    timerLayout->addWidget(safeIntervalBox, 0);
    timerLayout->addStretch(1);
    
    QFormLayout* optionsLayout = new QFormLayout();
    optionsLayout->setRowWrapPolicy(QFormLayout::WrapAllRows);
    
    optionsLayout->addRow("Parameters to be deduced from file names: ", fileNameParserLayout);
    optionsLayout->addRow("Import delay time: ", timerLayout);
    
    //Make the labels bold
    for(int i=0; i< optionsLayout->rowCount(); ++i) {
        QLabel* label = static_cast<QLabel*>(optionsLayout->itemAt(i, QFormLayout::LabelRole)->widget());
        QFont font = label->font();
        font.setBold(true);
        label->setFont(font);
    }
    
    GroupContainer* optionsContainer = new GroupContainer;
    optionsContainer->setTitle("Import Options");
    optionsContainer->setContainerLayout(optionsLayout);
    
    QHBoxLayout* resultsLayout = new QHBoxLayout();
    resultsLayout->addWidget(resultsTable_, 1);
    
    GroupContainer* resultsContainer = new GroupContainer;
    resultsContainer->setTitle("Import Folder Details");
    resultsContainer->setContainerLayout(resultsLayout);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
    mainLayout->addWidget(statusContainer, 0);
    mainLayout->addWidget(optionsContainer, 0);
    mainLayout->addWidget(resultsContainer, 1);
    
    QWidget* mainWid = new QWidget();
    mainWid->setLayout(mainLayout);

    return mainWid;
}