Пример #1
0
QWidget * Table::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent)
{
    QTableWidget *tablewidget = new TableWidget(this, parent);
    tablewidget->setEnabled(enabled);
    tablewidget->setVisible(visible);
    tablewidget->setStyleSheet(QString::fromStdString(style));
    size_t rowcount = rows.size(), columncount = 0;
    for(size_t i = 0; i < rowcount; i++)
        columncount = std::max(columncount, rows[i].size());
    tablewidget->setRowCount(rowcount);
    tablewidget->setColumnCount(columncount);
    tablewidget->horizontalHeader()->setVisible(show_horizontal_header);
    tablewidget->verticalHeader()->setVisible(show_vertical_header);
    tablewidget->setShowGrid(show_grid);
    QStringList qtHorizontalHeader;
    for(size_t i = 0; i < horizontalHeader.size(); i++)
        qtHorizontalHeader << QString::fromStdString(horizontalHeader[i]);
    tablewidget->setHorizontalHeaderLabels(qtHorizontalHeader);
    QStringList qtVerticalHeader;
    for(size_t i = 0; i < verticalHeader.size(); i++)
        qtVerticalHeader << QString::fromStdString(verticalHeader[i]);
    tablewidget->setVerticalHeaderLabels(qtVerticalHeader);
    if(autosize_horizontal_header)
        tablewidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    if(autosize_vertical_header)
        tablewidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    if(sortable)
        tablewidget->setSortingEnabled(true);
    for(size_t row = 0; row < rowcount; row++)
    {
        for(size_t column = 0; column < rows[row].size(); column++)
        {
            TableItem &item = rows[row][column];
            QTableWidgetItem *qtwitem = new QTableWidgetItem(QString::fromStdString(item.text));
            if(item.editable)
                qtwitem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
            else
                qtwitem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
            tablewidget->setItem(row, column, qtwitem);
        }
    }
    tablewidget->setSelectionBehavior(selectionBehavior);
    tablewidget->setSelectionMode(selectionMode);
    QObject::connect(tablewidget, &QTableWidget::cellActivated, uiproxy, &UIProxy::onCellActivate);
    QObject::connect(tablewidget, &QTableWidget::cellChanged, uiproxy, &UIProxy::onCellActivate);
    QObject::connect(tablewidget, &QTableWidget::itemSelectionChanged, uiproxy, &UIProxy::onTableSelectionChange);
    setQWidget(tablewidget);
    setEditable(editable);
    setProxy(proxy);
    return tablewidget;
}
EmployeeListDialog::EmployeeListDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::EmployeeListDialog)
{
    ui->setupUi(this);
	ui->tableWidgetEmployeeList->setGeometry(QRect(20, 10, 351, 221));
	ui->tableWidgetEmployeeList->setColumnCount(4);
	ui->tableWidgetEmployeeList->setRowCount(10);

	QStringList header;  
	header << "ID" << "Name" << "Address" << "Type";
	QTableWidget *tableWidget = this->ui->tableWidgetEmployeeList;
	tableWidget->setHorizontalHeaderLabels(header);
}
Пример #3
0
void QgsMessageLogViewer::logMessage( QString message, QString tag, int level )
{
  mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );

  if ( !isVisible() )
  {
    mButton->show();
    QToolTip::showText( mButton->mapToGlobal( QPoint( 0, 0 ) ), mButton->toolTip() );
  }

  if ( tag.isNull() )
    tag = tr( "General" );

  int i;
  for ( i = 0; i < tabWidget->count() && tabWidget->tabText( i ) != tag; i++ )
    ;

  QTableWidget *w;
  if ( i < tabWidget->count() )
  {
    w = qobject_cast<QTableWidget *>( tabWidget->widget( i ) );
    tabWidget->setCurrentIndex( i );
  }
  else
  {
    w = new QTableWidget( 0, 3, this );
    w->verticalHeader()->setDefaultSectionSize( 16 );
    w->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents );
    w->verticalHeader()->setVisible( false );
    w->setGridStyle( Qt::DotLine );
    w->setEditTriggers( QAbstractItemView::NoEditTriggers );
    w->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );
    w->setHorizontalHeaderLabels( QStringList() << tr( "Timestamp" ) << tr( "Message" ) << tr( "Level" ) );
    tabWidget->addTab( w, tag );

    tabWidget->setCurrentIndex( tabWidget->count() - 1 );
  }

  int n = w->rowCount();

  w->setRowCount( n + 1 );
  QTableWidgetItem *item = new QTableWidgetItem( QDateTime::currentDateTime().toString( Qt::ISODate ) );
  w->setItem( n, 0, item );
  w->setItem( n, 1, new QTableWidgetItem( message ) );
  w->setItem( n, 2, new QTableWidgetItem( QString::number( level ) ) );
  w->scrollToBottom();

  w->horizontalHeader()->resizeSections( QHeaderView::ResizeToContents );
}
Пример #4
0
void TableView::setHeader(QStringList value)
{
    //_header = value;
    QTableWidget* table =  getTableWidget();
    if(0!=table)
    {
       // QStringList headers = _header.split(";", QString::SkipEmptyParts);
        table->setColumnCount(value.count());
        table->setHorizontalHeaderLabels(value);
        _header = value;
      //  table->setVerticalHeaderItem();
      //  table->setVerticalHeaderLabels(_header.split(";", QString::SkipEmptyParts));
    }
  //  emit send(esp::init(new QString(value),0,""));
}
Пример #5
0
ParamCompareDialog::ParamCompareDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ParamCompareDialog),
    m_newList(new QMap<QString, UASParameter*>())
{
    ui->setupUi(this);

    QStringList headerList;
    headerList << tr("Parameter") << tr("Value") << tr("New Value") << tr("Use");

    QTableWidget* table = ui->compareTableWidget;
    table->setColumnCount(headerList.count());
    table->setHorizontalHeaderLabels(headerList);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setAlternatingRowColors(true);
    table->setColumnWidth(PCD_COLUMN_CHECKBOX, 40);

    initConnections();
}
Пример #6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),cdadPersonas(0)
{
    ui->setupUi(this);
    //ui->mainToolBar->addAction()
    PersonaController * controller = PersonaController::getInstance();

    crearDialog = new CrearPersonaDialog(this);
    editarDialog = new EditPersonaDialog(this);
    crearDialog->setWindowTitle("Crear Persona");
    setupSignalsAndSlots();
    auto f = [] (Persona*) -> bool {return true;}; // all
    QList<Persona *> all = controller->filter(f);
    int cantidadFilas = all.size();

    QTableWidget *table = ui->tableWidget;
    table->setRowCount(cantidadFilas);
    table->setColumnCount(5);

    QStringList header;
    header << "Id" << "Nombre" << "Direccion" << "Telefono" << "Email";
    table->setHorizontalHeaderLabels(header);
    table->adjustSize();
    initPersonas();
//    for (int i = 0; i < all.size(); i++) {
//        Persona *p = all.at(i);
//        int j = 0;
//        QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(p->id()));
//        table->setItem(i, j++, item);
//        item = new QTableWidgetItem(p->nombre());
//        table->setItem(i, j++, item);

//        item = new QTableWidgetItem(p->direccion());
//        table->setItem(i, j++, item);

//        item = new QTableWidgetItem(p->telefono());
//        table->setItem(i, j++, item);
//    }
//    connect(crearDialog, SIGNAL(personaCreated(Persona*)), this, SLOT(agregarPersonaATable(Persona*)));

}
Пример #7
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMainWindow *w = new QMainWindow();

    w->setWindowTitle(QString::fromUtf8("QTableWidget Set Cell Color"));
    w->resize(400, 250);

    QTableWidget* table = new QTableWidget();

    //Set table row count 1 and column count 3
    table->setRowCount(1);
    table->setColumnCount(3);

    table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //Set Header Label Texts Here
    table->setHorizontalHeaderLabels(QString("HEADER 1;HEADER 2;HEADER 3").split(";"));


    //Add Table items here
    table->setItem(0,0,new QTableWidgetItem("ITEM 1"));
    table->setItem(0,1,new QTableWidgetItem("ITEM 2"));
    table->setItem(0,2,new QTableWidgetItem("ITEM 3"));

    //Color Table Cells Here
    table->item(0,0)->setBackgroundColor(Qt::red);
    table->item(0,1)->setBackgroundColor(Qt::green);
    table->item(0,2)->setBackgroundColor(Qt::blue);

    w->setCentralWidget(table);
    w->show();

    return a.exec();
}
Пример #8
0
QTableWidget* AutoImportWindow::setupFilesTable() {
    QTableWidget* filesTable = new QTableWidget(0, 6);
    filesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    filesTable->setAttribute(Qt::WA_MacShowFocusRect, 0);

    QStringList labels;
    labels << "" << tr("Directory") << tr("Search Name") << tr("Averaged") << tr("Aligned") << tr("Raw");
    filesTable->setHorizontalHeaderLabels(labels);
    filesTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
    filesTable->verticalHeader()->hide();
    filesTable->setShowGrid(false);
    filesTable->setAlternatingRowColors(true);
    
    connect(filesTable, &QTableWidget::itemDoubleClicked, [=](QTableWidgetItem *item){
        if(item->row() != -1 && item->row() < rowToImagePaths_.size()) {
            QString path = rowToImagePaths_[item->row()];
            ProjectImage* image = projectData.projectImage(QDir(projectData.projectDir().absoluteFilePath(path)));
            if(image) emit imageToBeOpened(image);
            else QMessageBox::warning(this, "Image Open Error!", "Image: " + path + " was either not imported or not found.");
        }
    });

    return filesTable;
}
Пример #9
0
void DossierEditeur::afficherProfil()
{
    try
    {
        QDialog* window = new QDialog(this);
        QGridLayout* lay = new QGridLayout;
        QPushButton* ok = new QPushButton("Ok");
        window->setWindowTitle("Profil");
        window->setFixedSize(400, 400);

        QStringList Formation = Dossier::getInstance().ListeCursus();
        int j = 1;
        QTableWidget* valide = new QTableWidget(1,1,this);
        QTableWidget* non_valide = new QTableWidget(1,1,this);
        QLabel* valideLabel = new QLabel("Validé :",this);
        QLabel* NonvalideLabel = new QLabel("A Valider :",this);
        valide->horizontalHeader()->hide();
        non_valide->horizontalHeader()->hide();
        valide->verticalHeader()->hide();
        non_valide->verticalHeader()->hide();
        valide->setMaximumSize(50,25);
        non_valide->setMaximumSize(50,25);

        QTableWidgetItem* ItemValide = new QTableWidgetItem("");
        ItemValide->setBackground(Qt::red);
        valide->setItem(0,0,ItemValide);

        QTableWidgetItem* ItemNonValide = new QTableWidgetItem("");
        ItemNonValide ->setBackground(Qt::gray);
        non_valide->setItem(0,0,ItemNonValide);
        //Tableaus affichant le nombre de crédits obtenu par catégorie
        for(QList<QString>::iterator it1 = Formation.begin(); it1 < Formation.end(); ++it1)
        {
            QMap<QString, unsigned int> ListeProfil = Dossier::getInstance().ListeProfil(*it1);
            QStringList P = ListeProfil.keys();
            QTableWidget* tab = new QTableWidget(1,ListeProfil.size(),this);
            tab->setHorizontalHeaderLabels(P);
            tab->setSelectionBehavior(QAbstractItemView::SelectRows);
            tab->verticalHeader()->hide();


            int i = 0;
            for(QList<QString>::iterator it2 = P.begin(); it2 < P.end(); ++it2)
            {
                QString cr; cr.setNum(ListeProfil[*it2]);
                QString creditFormation; creditFormation.setNum(FormationManager::getInstance().getFormation(*it1).getProfil(*it2));
                QString credit = cr +QString("(")+creditFormation+QString(")");
                QTableWidgetItem* monItem = new QTableWidgetItem(credit);
                if(FormationManager::getInstance().isFinished(*it1,*it2,ListeProfil[*it2]))
                    monItem->setBackground(Qt::red);
                else
                    monItem->setBackground(Qt::gray);
                tab->setItem(0,i,monItem);
                i++;
            }
            QLabel* form = new QLabel(*it1,this);
            lay->addWidget(form,j,0,1,3,Qt::AlignLeft);
            lay->addWidget(tab,j,1,1,3,Qt::AlignJustify);
            j++;
        }

        lay->addWidget(valideLabel,0,0);
        lay->addWidget(valide,0,1);
        lay->addWidget(NonvalideLabel,0,2);
        lay->addWidget(non_valide,0,3);
        lay->addWidget(ok,j,1,Qt::AlignHCenter);
        window->setLayout(lay);

        connect(ok,SIGNAL(clicked()),window,SLOT(accept()));
        window->exec();

        if(window->result())
        {

        }

    }
    catch(UTProfilerException& e)
    {
        QMessageBox::warning(this, "Ajout d'inscription", e.getInfo());
    }
}
Пример #10
0
		ValidationResultDialog::ValidationResultDialog(ValidationItem* item)
		{
			//return if there's no parent
			if (item == NULL)
			{
				return;
			}

			QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok,Qt::Horizontal, this);
			QPushButton* print_button = new QPushButton("Save to File", buttons);

			QVBoxLayout* mainLayout = new QVBoxLayout();
			QGroupBox* resultGroup = new QGroupBox(tr("Validation Results"),this);
			QGridLayout* layout = new QGridLayout();
			QVBoxLayout* resultGroupLayout = new QVBoxLayout();

			int type = item->getValidationType();

			if (type < 4 || type==5)
			{
				String train_fit ="R^2";
				String pred_qual="Q^2";
				String n = item->modelItem()->getRegistryEntry()->getStatName(item->getValidationStatistic());
				
				if(n!="") 
				{
					train_fit = n+"<br>on training data";
					pred_qual = "predictive<br>"+n;			
				}
				
				QLabel* rlabel = new QLabel(train_fit.c_str(),this);
				layout->addWidget(rlabel, 0,1);
				QString tmp;
				QLabel* qlabel=NULL;
				
				if(type<3)
				{
					qlabel = new QLabel(tmp.setNum(item->k())+ " fold "+pred_qual.c_str(),this);
				}
				else if(type==3) // boostrap
				{
					qlabel = new QLabel(QString(pred_qual.c_str())+" of "+tmp.setNum(item->numOfSamples())+ "\nbootstrap samples",this);
				}
				else if(type==5)
				{
					qlabel = new QLabel(tmp.setNum(item->getNoExternalFolds())+ " fold nested "+pred_qual.c_str(),this);
				}
				
				layout->addWidget(qlabel, 0,2);

				QLabel* rvaluelabel = new QLabel(QString(((String)(item->getR2())).c_str()),this);
				layout->addWidget(rvaluelabel,1,1);
				QLabel* qvaluelabel = new QLabel(QString(((String)(item->getQ2())).c_str()),this);
				layout->addWidget(qvaluelabel,1,2);

				resultGroup->setLayout(layout);
			}	
			else if (type == 4)
			{
				QString value;
				float num;

				QStringList labels;
				labels << "# Tests" << "R^2" << "Q^2";

				QTableWidget* table = new QTableWidget(item->resultOfRandTest()->rows(), 3, this);
				table->verticalHeader()->hide();
				table->setHorizontalHeaderLabels (labels);
				table->setAlternatingRowColors(true);
				table->setDragDropMode(QAbstractItemView::NoDragDrop);
				table->setEditTriggers(QAbstractItemView::NoEditTriggers);
				table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
				table->horizontalHeader()->setResizeMode(2,QHeaderView::Stretch); 
			
				for (int i = 0; i < item->resultOfRandTest()->rows();i++)
				{
					value.setNum(i);
					QTableWidgetItem* num_of_Test = new QTableWidgetItem(value);
					table->setItem(i, 0, num_of_Test);

					num = (*(item->resultOfRandTest()))(i,item->resultOfRandTest()->cols()-2);
					value.setNum(num);
					QTableWidgetItem* r = new QTableWidgetItem(value);
					table->setItem(i, 1, r);

					num = (*(item->resultOfRandTest()))(i,item->resultOfRandTest()->cols()-1);
					value.setNum(num);
					QTableWidgetItem* q = new QTableWidgetItem(value);
					table->setItem(i, 2, q);
				}

				QScrollArea* scrollArea = new QScrollArea(this);
				scrollArea->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
				scrollArea->setVerticalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
				scrollArea->setFrameShape(QFrame::NoFrame);
				scrollArea->setWidget(table);
				scrollArea->setWidgetResizable(true);
			
				resultGroupLayout->addWidget(scrollArea);
				resultGroup->setLayout(resultGroupLayout);
			}
			mainLayout->addWidget(resultGroup);
			mainLayout->addWidget(buttons);
			mainLayout->addStretch(1);
			setLayout(mainLayout);	
			setWindowTitle("Validation Results for " + item->name());

			connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
			connect(print_button, SIGNAL(clicked()), this, SLOT(saveToFile()));
		}
Пример #11
0
//Constructors:
GenericALDialog::GenericALDialog(vtkSmartPointer<vtkTable> table,int num_classes,int active_query,std::vector<int>top_feats,QWidget *parent)
: QDialog(parent)
{

	//temp_pair.first = snapshot;
		
	//QLabel *imageLabel = new QLabel(this);
	//imageLabel->setPixmap(QPixmap::fromImage(snapshot));
	//imageLabel->resize(imageLabel->pixmap()->size());
	
	

	this->setWindowTitle(tr("Active Learning Window: Specify Class"));
	this->setModal(false);


	finish = true;

	//Master Layout
	QGridLayout * layout = new QGridLayout;
	
	//// textbox
	//lineEdit = new QLineEdit();
	//lineEdit->setMaxLength(15);

	//Top-row of the window 
	QHBoxLayout *topRow = new QHBoxLayout;
	//topRow->addWidget(imageLabel,1,0);
	
	//Done Button
	doneButton = new QPushButton("Done");

	connect(doneButton, SIGNAL(clicked()), this, SLOT(finished()));
	doneButton->setDisabled(true);
	doneButton->setDefault(false);
	doneButton->setAutoDefault(false);

	nextButton = new QPushButton("Next");

	connect(nextButton, SIGNAL(clicked()), this, SLOT(accept()));
	nextButton->setDisabled(true);
	nextButton->setDefault(false);
	nextButton->setAutoDefault(true);
	
	QLabel *enterClassLabel = new QLabel("Select Class: ", this);
	topRow->addWidget(enterClassLabel,0,0);
	


	// radiobutons for each class
	for(int i =1 ; i<= num_classes ; ++i)
	{
		QRadioButton *class_button = new QRadioButton(QString::number(i), this);
		topRow->addWidget(class_button,0,0);
		button_vector.push_back(class_button);
		connect(class_button, SIGNAL(clicked()),this,SLOT(Set_Class()));
		// Class 1 is always the default selection
	}
		
		QRadioButton *class_button = new QRadioButton("I am not sure" , this);
		connect(class_button, SIGNAL(clicked()),this,SLOT(Set_Class()));
		button_vector.push_back(class_button);
		topRow->addWidget(class_button,0,0);
		topRow->addWidget(nextButton,0,0);
		topRow->addWidget(doneButton,0,0);
		topRow->addStretch(20);


	QLabel *channelLabel = new QLabel("Please ensure all the relevant channels which might affect classification are ON ", this);


	//Remove the train column 
	table->RemoveColumnByName("train");
	int numb_cols = MIN(5,table->GetNumberOfColumns());


	QStringList sl;

	for(int i=0;i<numb_cols;++i)
	{
		sl<<QString(table->GetColumnName(top_feats[i]));
	}
	
	// Table displaying 10 top features
	QTableWidget *tableWidget = new QTableWidget(1, numb_cols, this);
	tableWidget->setHorizontalHeaderLabels(sl);


	for(int i=0;i<numb_cols;++i)
	{
	  QTableWidgetItem *newItem = new QTableWidgetItem(QString::number(table->GetValue(active_query,top_feats[i]).ToDouble()));
	  newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
	  tableWidget->setItem(0, i, newItem);
	}
	
	class_selected = -1; // Used to check if no radiobutton was selected
	
	//Bottom-row of the window 
	QVBoxLayout *botRow = new QVBoxLayout;
	botRow->addWidget(tableWidget,1,0);
	botRow->addWidget(channelLabel,1,0);
	
	layout->addLayout(topRow,0,0,0);
	layout->addLayout(botRow,1,0,0);

	this->setLayout(layout);
}
Пример #12
0
void FenPrincipale::calcul_general() {
	QString html = "<table>\n\t<thead>\n\t\t<tr>\n\t\t\t";
	html += "<td>"+tr("Position")+"</td>";
	html += "<td>"+tr("Équipage")+"</td>";
	html += "<td>"+tr("Points")+"</td>";
	for (int j = 0; j < this->nbManches; ++j) {
		html += "<td>"+tr("M")+QString::number(j+1)+"</td>";
	}
	html += "\n\t\t</tr>\n\t</thead>\n\t<tboby>";
	QTableWidget *table = new QTableWidget();
	table->verticalHeader()->hide();
	table->setSelectionMode(QAbstractItemView::NoSelection);
	table->setColumnCount(3+this->nbManches);
	table->setRowCount(this->nbEquipages);
	table->setColumnWidth(0, 80);
	table->setColumnWidth(1, 200);
	table->setColumnWidth(2, 60);
	int size = 80 + 200 + 60;
	QList<QString> labels;
	labels << tr("Position") << tr("Équipage") << tr("Points");
	for (int j = 0; j < this->nbManches; ++j) {
		labels << tr("M")+QString::number(j+1);
		size += 50;
		table->setColumnWidth(3+j, 50);
	}
	table->setMinimumWidth(size + 20);
	table->setMaximumWidth(size + 20);
	table->setHorizontalHeaderLabels(labels);
	ui->resultatsLayout->insertWidget(0, table);
	for (int i = 0; i < this->nbEquipages; ++i) {
		QList<int> ids;
		Equipage e1;
		for (int k = 0; k < this->nbEquipages; ++k) {
			Equipage e2 = this->equipages[k];
			if (e2.points <= 0) {
				// cet équipage a déjà été affiché
				continue;
			}
			if (ids.isEmpty() || e2.points < e1.points) {
				ids.clear();
				ids.append(k);
				e1 = e2;
			}
			else if (e2.points == e1.points) {
				// égalité de points
				// pour départager les équipages, on confronte leurs meilleures
				// manches (sans celles retirées)
				for (int j = 0; j < e1.pointsTries.size(); ++j) {
					if (e2.pointsTries[j] < e1.pointsTries[j]) {
						ids.clear();
						ids.append(k);
						e1 = e2;
						break;
					}
					else if (e2.pointsTries[j] > e1.pointsTries[j]) {
						break;
					}
					else if (j == e1.pointsTries.size()-1) {
						// égalité des manches
						// pour départager les équipages, on confronte toutes
						// leur manches dans l'ordre en partant de la dernière
						for (int l = 0; l < e1.pointsOrdonnes.size(); ++l) {
							if (e2.pointsOrdonnes[l] < e1.pointsOrdonnes[l]) {
								ids.clear();
								ids.append(k);
								e1 = e2;
								break;
							}
							else if (e2.pointsOrdonnes[l] > e1.pointsOrdonnes[l]) {
								break;
							}
							else if (l == e1.pointsOrdonnes.size()-1) {
								// égalité parfaite
								ids.append(k);
							}
						}
					}
				}
			}
		}
		for (int k = 0; k < ids.size(); ++k) {
			Equipage e = this->equipages[ids[k]];
			// on ajoute le début de la table html
			// on rajoute les manches en parallèle à causes de celles retirées
			QString nomString = "<span class=\"equipage\">"+e.nom+"</span>";
			if (this->typeClmt == CLMT_TEMPS) {
				nomString += "<span class=\"bateau\">"
					+this->bateaux.value(e.rating.toUpper()).serie
					+" ("+QString::number(e.coef)+")</span>";
			}
			html += "\n\t\t<tr>\n\t\t\t<td>"+QString::number(i+1)+"</td>"
				+"<td>"+nomString+"</td>"
				+"<td>"+QString::number(e.points)+"</td>";
			// on ajout l'équipage
			QLabel *pos = new QLabel(QString::number(i+1));
			QWidget *nomWidget = new QWidget();
			QVBoxLayout *nomLayout = new QVBoxLayout();
			QLabel *nom = new QLabel(e.nom);
			nom->setProperty("label", "nom");
			nomLayout->addWidget(nom);
			if (this->typeClmt == CLMT_TEMPS) {
				QLabel *bateau = new QLabel();
				bateau->setText(this->bateaux.value(e.rating.toUpper()).serie
					+" ("+QString::number(e.coef)+")");
				bateau->setProperty("label", "bateau");
				nomLayout->addWidget(bateau);
				table->setRowHeight(i+k, 45);
			}
			nomLayout->setContentsMargins(0, 0, 0, 0);
			nomLayout->setSpacing(0);
			nomWidget->setLayout(nomLayout);
			QLabel *points = new QLabel(QString::number(e.points));
			table->setCellWidget(i+k, 0, pos);
			table->setCellWidget(i+k, 1, nomWidget);
			table->setCellWidget(i+k, 2, points);
			for (int j = 0; j < this->nbManches; ++j) {
				Manche m = e.manches[j];
				QLabel *la = new QLabel();
				if (m.tpsCompense < 0) {
					la->setText(this->get_abr(m.abr));
				}
				else {
					la->setText(QString::number(m.points));
				}
				for (int l = 0; l < e.pointsRetires.size(); ++l) {
					if (e.pointsRetires[l] == m.points) {
						la->setText("("+la->text()+")");
						e.pointsRetires.removeAt(l);
						break;
					}
				}
				html += "<td>"+la->text()+"</td>";
				table->setCellWidget(i+k, j+3, la);
			}
			html += "\n\t\t</tr>";
			this->equipages[ids[k]].points = 0;
		}
		i += ids.size()-1;
	}
	html += "\n\t</tbody>\n</table>";
	this->htmls.prepend(html);
	this->progression(95);
}
std::vector<QHBoxLayout *> ActiveLearningDialog::Validation_Sample_Details(QImage snapshot, vtkSmartPointer<vtkTable> table,int classval,int PIA_query,int group,int num_classes)
{	

	QLabel *imageLabel = new QLabel(this);
	imageLabel->setPixmap(QPixmap::fromImage(snapshot));
	imageLabel->resize(imageLabel->pixmap()->size());
	
	finish = true;
	
	//Top-row of the window 
	QHBoxLayout *topRow = new QHBoxLayout;
	topRow->addWidget(imageLabel,0,0);
	
	QLabel *enterClassLabel = new QLabel("Please indicate the correct class: ", this);
	topRow->addWidget(enterClassLabel,0,0);
	
	buttongroup[group] = new QButtonGroup(this);
	buttongroup[group]->setExclusive(true);

	// radiobutons for each class
	for(int i =0 ; i< num_classes ; ++i)
	{
		QRadioButton  *class_button = new QRadioButton(QString::number(i), this);
		if(i+1==classval)
			class_button->setChecked(true);
		topRow->addWidget(class_button,0,0);
		button_vector.push_back(class_button);
		buttongroup[group]->addButton(class_button);
		connect(class_button, SIGNAL(clicked()),this,SLOT(Set_Class_Validate()));
	}
			
	//QRadioButton *class_button = new QRadioButton("I am not sure" , this);
	//connect(class_button, SIGNAL(clicked()),this,SLOT(Set_Class()));
	//button_vector.push_back(class_button);
	//buttongroup[group]->addButton(class_button);
	//topRow->addWidget(class_button,0,0);


	QStringList sl;
	for(int i=0;i<table->GetNumberOfColumns();++i)
	{
		sl<<QString(table->GetColumnName(i));
	}

	// Table displaying features of the sample
	QTableWidget *tableWidget = new QTableWidget(1, table->GetNumberOfColumns(), this);
	tableWidget->setHorizontalHeaderLabels(sl);
	tableWidget->setRowCount(1);
    tableWidget->setColumnCount(table->GetNumberOfColumns());

	for(int i=0;i<table->GetNumberOfColumns();++i)
	{
	  QTableWidgetItem *newItem = new QTableWidgetItem(QString::number(table->GetValue(PIA_query,i).ToDouble()));
	  newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
	  tableWidget->setItem(0, i, newItem);
	}

	//Bottom-row of the window 
	QHBoxLayout *botRow = new QHBoxLayout;
	botRow->addWidget(tableWidget,0,0);
	//botRow->addWidget(channelLabel,1,0);
	std::vector<QHBoxLayout *> rows;
	rows.push_back(topRow);
	rows.push_back(botRow);

	return rows;
}
Пример #14
0
void VirshGui::populateVMInfos(string vmname)
{
    VMStatus vmstatus = vmlist[vmname].getStatus();
    string strstatus = vmlist[vmname].statusToString(vmstatus);
    string memory = vmlist[vmname].getMemory();
    string vmxml = vmlist[vmname].dumpXML();
    string cpuCount = vmlist[vmname].getCPUCount();
    string ostype = vmlist[vmname].getOSType();
    string arch = vmlist[vmname].getArch();
    vector<string> bootDevs = vmlist[vmname].getBootDevs();
    vector<string> hvFeatures = vmlist[vmname].getHVFeatures();
    vector<string> cpuFeatures = vmlist[vmname].getCPUFeatures();

    string bootDevStr = join(bootDevs, ", ");
    string hvFeatureStr = join(hvFeatures, ", ");
    string cpuFeatureStr = join(cpuFeatures, ", ");

    if (vmstatus == VMStatus::shutoff) {
        ui->startStopButton->setText("VM starten");
        ui->startStopButton->setEnabled(true);
        ui->shutdownButton->setDisabled(true);
        ui->rebootButton->setDisabled(true);
        ui->virtViewerButton->setDisabled(true);
    } else if (vmstatus == VMStatus::running) {
        ui->startStopButton->setText("VM ausschalten");
        ui->startStopButton->setEnabled(true);
        ui->shutdownButton->setEnabled(true);
        ui->rebootButton->setEnabled(true);
        ui->virtViewerButton->setEnabled(true);
    } else {
        ui->startStopButton->setText("keine Aktion");
        ui->startStopButton->setDisabled(true);
        ui->shutdownButton->setDisabled(true);
        ui->rebootButton->setDisabled(true);
        ui->virtViewerButton->setDisabled(true);
    }

    while (ui->snapshotsTabLayout->count() > 0) {
        QLayoutItem *item = ui->snapshotsTabLayout->takeAt(0);
        delete item->widget();
        delete item;
    }

    int snapshotTableCount = 0;
    for (auto hdd : vmlist[vmname].getHDDImages()) {
        int row = 0;
        QGroupBox *hddGroupBox = new QGroupBox(QString::fromStdString(hdd.getPath()));
        hddGroupBox->setFlat(false);

        QVBoxLayout *hddVBox = new QVBoxLayout;
        QTableWidget *snapshotTable = new QTableWidget(0, 5, this);
        snapshotTable->setSelectionMode(QAbstractItemView::SingleSelection);
        snapshotTable->setHorizontalHeaderLabels(QStringList() << "ID" << "Tag" << "VM Size" << "Date" << "VM Clock");
        snapshotTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
        //snapshotTable->setColumnWidth(0, 45);
        snapshotTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
        snapshotTable->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
        snapshotTable->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
        snapshotTable->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
        snapshotTable->verticalHeader()->hide();
        snapshotTable->setAlternatingRowColors(true);
        //snapshotTable->setSortingEnabled(true);
        snapshotTable->setEditTriggers(QTableWidget::NoEditTriggers);
        connect(snapshotTable, &QTableWidget::cellPressed, [this, snapshotTableCount](){ clearSnapshotSelectionsExcept(snapshotTableCount); });
        snapshotTableCount++;

        for (auto snapshot : hdd.getSnapshots()) {
            snapshotTable->setRowCount(row + 1);
            QTableWidgetItem *id = new QTableWidgetItem(
                    QString::fromStdString(snapshot.getID()));
            QTableWidgetItem *tag = new QTableWidgetItem(
                    QString::fromStdString(snapshot.getTag()));
            QTableWidgetItem *size = new QTableWidgetItem(
                    QString::fromStdString(snapshot.getSize()));
            QTableWidgetItem *date = new QTableWidgetItem(
                    QString::fromStdString(snapshot.getDate()));
            QTableWidgetItem *clock = new QTableWidgetItem(
                    QString::fromStdString(snapshot.getClock()));

            snapshotTable->setItem(row, 0, id);
            snapshotTable->setItem(row, 1, tag);
            snapshotTable->setItem(row, 2, size);
            snapshotTable->setItem(row, 3, date);
            snapshotTable->setItem(row, 4, clock);

            row++;
        }
        hddVBox->addWidget(snapshotTable);

        QHBoxLayout *addSnapHBox = new QHBoxLayout;
        QLineEdit *addSnapNameEdit = new QLineEdit;
        QPushButton *addSnapButton = new QPushButton;
        addSnapButton->setText("Snapshot erstellen");
        addSnapButton->setEnabled(false);
        string hddPath = hdd.getPath();
        connect(addSnapNameEdit, &QLineEdit::textChanged, [this, addSnapButton, addSnapNameEdit](){ toggleAddSnapshotButton(addSnapButton, addSnapNameEdit); });
        connect(addSnapButton, &QPushButton::clicked, [this, hddPath, vmname, addSnapNameEdit](){ createSnapshot(hddPath, vmname, addSnapNameEdit->text().toStdString()); });
        addSnapHBox->addWidget(addSnapNameEdit);
        addSnapHBox->addWidget(addSnapButton);

        hddVBox->addLayout(addSnapHBox);
        hddGroupBox->setLayout(hddVBox);
        ui->snapshotsTabLayout->addWidget(hddGroupBox);
    }

    QPushButton *applySnapshotButton = new QPushButton("Snapshot Anwenden", this);
    connect(applySnapshotButton, SIGNAL(clicked(bool)), this, SLOT(applySnapshot()));
    //connect(applySnapshotButton, &QPushButton::clicked, [this](){ clearSnapshotSelectionsExcept(1); });
    ui->snapshotsTabLayout->addWidget(applySnapshotButton);

    ui->xmlDisplay->setText(QString::fromStdString(vmxml));
    ui->vmnameLabel->setText(QString::fromStdString(vmname));
    ui->statusLabel->setText(QString::fromStdString(strstatus));
    ui->memoryLabel->setText(QString::fromStdString(memory));
    ui->cpucountLabel->setText(QString::fromStdString(cpuCount));
    ui->typeLabel->setText(QString::fromStdString(ostype));
    ui->archLabel->setText(QString::fromStdString(arch));
    ui->bootdevLabel->setText(QString::fromStdString(bootDevStr));
    ui->hvFeaturesLabel->setText(QString::fromStdString(hvFeatureStr));
    ui->hvFeaturesLabel->setWordWrap(true);
    ui->cpuFeaturesLabel->setText(QString::fromStdString(cpuFeatureStr));
    ui->cpuFeaturesLabel->setWordWrap(true);
}
Пример #15
0
void model_import_dlg::create_mesh_tab(QTabWidget * parent, size_t index, render::lod lod)
{
	QWidget * tab = new QWidget(parent);
	tab->setObjectName("meshTab");

	auto & geometry = conv.get(index).geometry.at(lod);
	auto & material = conv.get(index).materials.at(lod);

	QGroupBox * geometry_box = new QGroupBox(tab);
	geometry_box->setGeometry(10, 10, 561, 115);
	geometry_box->setTitle("Geometry");

	QLabel * vertices = new QLabel(geometry_box);
	vertices->setGeometry(20, 20, 200, 20);
	vertices->setText("Vertices: " + QString::number(geometry.vertex_count));

	QLabel * faces = new QLabel(geometry_box);
	faces->setGeometry(20, 40, 200, 20);
	faces->setText("Faces: " + QString::number(geometry.index_count / 3));

	QLabel * indices = new QLabel(geometry_box);
	indices->setGeometry(20, 60, 200, 20);
	indices->setText("Indices: " + QString::number(geometry.index_count));

	QLabel * layout = new QLabel(geometry_box);
	layout->setGeometry(20, 80, 200, 20);
	layout->setText("Layout: " + QString::fromStdString(render::vertex::str(geometry.vertex_type)));

	QGroupBox * material_box = new QGroupBox(tab);
	material_box->setGeometry(10, 130, 561, 400);
	material_box->setTitle("Material");

	QGroupBox * colors_box = new QGroupBox(material_box);
	colors_box->setGeometry(15, 20, 455, 134);
	colors_box->setTitle("Colors");

	QTableWidget * colorsTable = new QTableWidget(colors_box);
	colorsTable->setGeometry(15, 25, 237, 92);
	colorsTable->setObjectName("colorsTable");
	colorsTable->setRowCount(3);
	colorsTable->setColumnCount(3);
	colorsTable->setFrameShape(QFrame::NoFrame);
	colorsTable->setShowGrid(false);
	colorsTable->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
	colorsTable->setEditTriggers(QAbstractItemView::DoubleClicked);
	colorsTable->horizontalHeader()->setDefaultSectionSize(60);
	colorsTable->verticalHeader()->setDefaultSectionSize(23);
	colorsTable->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection);

	QStringList color_types;
	color_types.append("Ambient");
	color_types.append("Diffuse");
	color_types.append("Specular");

	QStringList color_channels;
	color_channels.append("R");
	color_channels.append("G");
	color_channels.append("B");

	colorsTable->setVerticalHeaderLabels(color_types);
	colorsTable->setHorizontalHeaderLabels(color_channels);

	colorsTable->setItem(0, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.x))));
	colorsTable->setItem(0, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.y))));
	colorsTable->setItem(0, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.ambient.z))));
	colorsTable->setItem(1, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.x))));
	colorsTable->setItem(1, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.y))));
	colorsTable->setItem(1, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.diffuse.z))));
	colorsTable->setItem(2, 0, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.x))));
	colorsTable->setItem(2, 1, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.y))));
	colorsTable->setItem(2, 2, new QTableWidgetItem(QString::number(rgb_to_byte(material.specular.z))));

	QPushButton * colorPick = new QPushButton(colors_box);
	colorPick->setGeometry(290, 24, 75, 23);
	colorPick->setObjectName("colorPick");
	colorPick->setText("Pick");

	for (int i = 0; i < 3; i++)
		for (int j = 0; j < 3; j++)
			colorsTable->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

	QObject::connect(colorsTable, SIGNAL(itemSelectionChanged()), this, SLOT(on_color_table_changed()));
	QObject::connect(colorPick, SIGNAL(pressed()), this, SLOT(on_color_pick()));

	QLabel * spec_power = new QLabel(colors_box);
	spec_power->setGeometry(290, 89, 80, 23);
	spec_power->setText("Specular power: ");

	QDoubleSpinBox * spec_power_box = new QDoubleSpinBox(colors_box);
	spec_power_box->setObjectName("specularSpinBox");
	spec_power_box->setDecimals(2);
	spec_power_box->setSingleStep(0.05);
	spec_power_box->setFrame(false);
	spec_power_box->setGeometry(390, 89, 50, 23);
	spec_power_box->setValue(material.specular_power);

	QGroupBox * textures_box = new QGroupBox(material_box);
	textures_box->setGeometry(15, 159, 531, 225);
	textures_box->setTitle("Textures");

	QTableWidget * texturesTable = new QTableWidget(textures_box);
	texturesTable->setObjectName("texturesTable");
	texturesTable->setGeometry(15, 25, 500, 150);
	texturesTable->setRowCount(material.textures.size());
	texturesTable->setColumnCount(2);
	texturesTable->setFrameShape(QFrame::NoFrame);
	texturesTable->setShowGrid(false);
	texturesTable->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows);
	texturesTable->setEditTriggers(QAbstractItemView::DoubleClicked);
	texturesTable->horizontalHeader()->setDefaultSectionSize(60);
	texturesTable->verticalHeader()->setDefaultSectionSize(23);
	texturesTable->verticalHeader()->setVisible(false);

	QStringList texture_headers;
	texture_headers.append("File");
	texture_headers.append("Type");
	texturesTable->setHorizontalHeaderLabels(texture_headers);

	int i = 0;
	assimp::texture_type_map texture_map;

	for (auto texture : material.textures)
	{
		texturesTable->setItem(i, 0, new QTableWidgetItem(QString::fromStdString(texture.second.texture_path.generic_string())));
		texturesTable->setItem(i, 1, new QTableWidgetItem(QString::fromStdString(texture_map.get(texture.first))));
		texturesTable->setColumnWidth(0, 350);
		texturesTable->setColumnWidth(1, 150);

		i++;
	}

	for (i = 0; i < texturesTable->rowCount(); i++)
	for (int j = 0; j < texturesTable->columnCount(); j++)
		texturesTable->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

	QPushButton * add_texture = new QPushButton(textures_box);
	add_texture->setGeometry(15, 185, 75, 23);
	add_texture->setText("Add");

	QPushButton * edit_texture = new QPushButton(textures_box);
	edit_texture->setGeometry(100, 185, 75, 23);
	edit_texture->setObjectName("textureEditButton");
	edit_texture->setText("Edit");
	edit_texture->setEnabled(false);

	QPushButton * delete_texture = new QPushButton(textures_box);
	delete_texture->setGeometry(185, 185, 75, 23);
	delete_texture->setObjectName("textureDeleteButton");
	delete_texture->setText("Delete");
	delete_texture->setEnabled(false);

	QObject::connect(texturesTable, SIGNAL(itemSelectionChanged()), this, SLOT(on_texture_table_changed()));
	QObject::connect(add_texture, SIGNAL(pressed()), this, SLOT(on_texture_add()));
	QObject::connect(edit_texture, SIGNAL(pressed()), this, SLOT(on_texture_edit()));
	QObject::connect(delete_texture, SIGNAL(pressed()), this, SLOT(on_texture_delete()));

	QString title = "Mesh " + QString::number(index);
	parent->addTab(tab, title);
}
Пример #16
0
lcQPropertiesDialog::lcQPropertiesDialog(QWidget *parent, void *data) :
	QDialog(parent),
	ui(new Ui::lcQPropertiesDialog)
{
	ui->setupUi(this);

	ui->fogDensityEdit->setValidator(new QDoubleValidator());

	connect(ui->solidColorButton, SIGNAL(clicked()), this, SLOT(colorClicked()));
	connect(ui->gradient1ColorButton, SIGNAL(clicked()), this, SLOT(colorClicked()));
	connect(ui->gradient2ColorButton, SIGNAL(clicked()), this, SLOT(colorClicked()));
	connect(ui->fogColorButton, SIGNAL(clicked()), this, SLOT(colorClicked()));
	connect(ui->ambientColorButton, SIGNAL(clicked()), this, SLOT(colorClicked()));

	options = (lcPropertiesDialogOptions*)data;

	setWindowTitle(tr("%1 Properties").arg(options->Properties.mName));

	ui->descriptionEdit->setText(options->Properties.mDescription);
	ui->authorEdit->setText(options->Properties.mAuthor);
	ui->commentsEdit->setText(options->Properties.mComments);

	if (options->Properties.mBackgroundType == LC_BACKGROUND_IMAGE)
		ui->imageRadio->setChecked(true);
	else if (options->Properties.mBackgroundType == LC_BACKGROUND_GRADIENT)
		ui->gradientRadio->setChecked(true);
	else
		ui->solidRadio->setChecked(true);

	ui->imageNameEdit->setText(options->Properties.mBackgroundImage);
	ui->imageTileCheckBox->setChecked(options->Properties.mBackgroundImageTile);
	ui->fogCheckBox->setChecked(options->Properties.mFogEnabled);
	ui->fogDensityEdit->setText(QString::number(options->Properties.mFogDensity));

	QPixmap pix(12, 12);

	pix.fill(QColor(options->Properties.mBackgroundSolidColor[0] * 255, options->Properties.mBackgroundSolidColor[1] * 255, options->Properties.mBackgroundSolidColor[2] * 255));
	ui->solidColorButton->setIcon(pix);
	pix.fill(QColor(options->Properties.mBackgroundGradientColor1[0] * 255, options->Properties.mBackgroundGradientColor1[1] * 255, options->Properties.mBackgroundGradientColor1[2] * 255));
	ui->gradient1ColorButton->setIcon(pix);
	pix.fill(QColor(options->Properties.mBackgroundGradientColor2[0] * 255, options->Properties.mBackgroundGradientColor2[1] * 255, options->Properties.mBackgroundGradientColor2[2] * 255));
	ui->gradient2ColorButton->setIcon(pix);
	pix.fill(QColor(options->Properties.mFogColor[0] * 255, options->Properties.mFogColor[1] * 255, options->Properties.mFogColor[2] * 255));
	ui->fogColorButton->setIcon(pix);
	pix.fill(QColor(options->Properties.mAmbientColor[0] * 255, options->Properties.mAmbientColor[1] * 255, options->Properties.mAmbientColor[2] * 255));
	ui->ambientColorButton->setIcon(pix);

	lcPiecesLibrary *library = lcGetPiecesLibrary();
	lcArray<lcPartsListEntry>& partsUsed = options->PartsList;
	QStringList horizontalLabels, partNames;

	bool *colorsUsed = new bool[gNumUserColors];
	memset(colorsUsed, 0, sizeof(bool) * gNumUserColors);

	int *infoRows = new int[library->mPieces.GetSize()], numInfos = 0;
	memset(infoRows, 0, sizeof(int) * library->mPieces.GetSize());

	for (int partIdx = 0; partIdx < partsUsed.GetSize(); partIdx++)
	{
		colorsUsed[partsUsed[partIdx].ColorIndex] = true;

		int infoIndex = library->mPieces.FindIndex(partsUsed[partIdx].Info);
		if (!infoRows[infoIndex])
		{
			infoRows[infoIndex] = ++numInfos;
			partNames.append(partsUsed[partIdx].Info->m_strDescription);
		}
	}

	int *colorColumns = new int[gNumUserColors];
	memset(colorColumns, 0, sizeof(int) * gNumUserColors);
	int numColors = 0;

	horizontalLabels.append(tr("Part"));

	for (int colorIdx = 0; colorIdx < gNumUserColors; colorIdx++)
	{
		if (colorsUsed[colorIdx])
		{
			colorColumns[colorIdx] = numColors++;
			horizontalLabels.append(gColorList[colorIdx].Name);
		}
	}

	horizontalLabels.append(tr("Total"));

	QTableWidget *table = ui->partsTable;
	table->setColumnCount(numColors + 2);
	table->setRowCount(numInfos + 1);
	table->setHorizontalHeaderLabels(horizontalLabels);

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
	table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
#else
	table->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);
#endif

	for (int rowIdx = 0; rowIdx < partNames.size(); rowIdx++)
		table->setItem(rowIdx, 0, new QTableWidgetItem(partNames[rowIdx]));

	table->setItem(partNames.size(), 0, new QTableWidgetItem(tr("Total")));

	QVector<int> infoTotals;
	QVector<int> colorTotals;
	int total = 0;

	infoTotals.resize(numInfos);
	colorTotals.resize(numColors);

	for (int partIdx = 0; partIdx < partsUsed.GetSize(); partIdx++)
	{
		int colorIndex = partsUsed[partIdx].ColorIndex;
		int infoIndex = library->mPieces.FindIndex(partsUsed[partIdx].Info);
		int count = partsUsed[partIdx].Count;

		QTableWidgetItem *item = new QTableWidgetItem(QString::number(count));
		item->setTextAlignment(Qt::AlignCenter);
		table->setItem(infoRows[infoIndex] - 1, colorColumns[colorIndex] + 1, item);

		infoTotals[infoRows[infoIndex] - 1] += count;
		colorTotals[colorColumns[colorIndex]] += count;
		total += count;
	}

	for (int infoIdx = 0; infoIdx < numInfos; infoIdx++)
	{
		QTableWidgetItem *item = new QTableWidgetItem(QString::number(infoTotals[infoIdx]));
		item->setTextAlignment(Qt::AlignCenter);
		table->setItem(infoIdx, numColors + 1, item);
	}

	for (int colorIdx = 0; colorIdx < numColors; colorIdx++)
	{
		QTableWidgetItem *item = new QTableWidgetItem(QString::number(colorTotals[colorIdx]));
		item->setTextAlignment(Qt::AlignCenter);
		table->setItem(numInfos, colorIdx + 1, item);
	}

	QTableWidgetItem *item = new QTableWidgetItem(QString::number(total));
	item->setTextAlignment(Qt::AlignCenter);
	table->setItem(numInfos, numColors + 1, item);

	delete[] colorColumns;
	delete[] colorsUsed;
	delete[] infoRows;
}
Пример #17
0
void TSController::processDataParams(){

    TSCurveBuffer *cb= new TSCurveBuffer;

    readerThread->readd();
    //TSUsb3000Reader *rdr= readerThread->getReader();
    //rdr->read();
    //rdr->initDevice(cb);
    /*rdr->read();*/
    qDebug()<<"this is result button !";
    QTableWidget *qtw = ui->resultsTable;
    qtw->setColumnCount(2);
    qtw->setRowCount(11);
    qtw->verticalHeader()->setVisible(false);
    qtw->setHorizontalHeaderLabels(QString(tr("Параметр;Значение")).split(";"));
    qtw->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    tsanalitics* ga = new tsanalitics();
    tstempanalitic* gao = new tstempanalitic();
    tstempanalitic* gai = new tstempanalitic();
    int AvgExpirationSpeed=0, MaxExpirationSpeed=0, AvgExpirationTime=0, AvgInspirationTime=0,
            AvgRoundTime=0, AvgTempIn=0, AvgTempOut=0, AvgTempInMinusAvgTempOut=0,  BreathingVolume=0, MVL=0;
    float InspirationFrequency=0;
    int i=0;
    int *vo = curveBuffer->volume();
    for(i=0;i<curveBuffer->getLenght();i++){
        ga->append(vo[i]);
    }
    ga->approximate();

    int *ti = curveBuffer->tempIn();
    for(i=0;i<curveBuffer->getLenght();i++){
        gai->append(ti[i]);
    }
    gai->findExtremums();
    gai->deleteBadExtremums();

    int *to = curveBuffer->tempOut();
    for(i=0;i<curveBuffer->getLenght();i++){
        gao->append(to[i]);
    }
    gao->findExtremums();
    gao->deleteBadExtremums();

    AvgExpirationSpeed = ga->getAvgExpiratorySpeed();
    qtw->setItem(1,0,getQTableWidgetItem(tr("Средняя скорость выдоха(л/с)")));
    qtw->setItem(1,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(AvgExpirationSpeed)))));

    MaxExpirationSpeed = ga->getMaxExpiratorySpeed();
    qtw->setItem(2,0,getQTableWidgetItem(tr("Максимальная скорость выдоха(л/с)")));
    qtw->setItem(2,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(100*MaxExpirationSpeed)))));

    AvgExpirationTime = ga->getAvgExpiratoryTime();
    qtw->setItem(3,0,getQTableWidgetItem(tr("Среднее время выдоха(с)")));
    qtw->setItem(3,1,getQTableWidgetItem((QString::number((float)AvgExpirationTime/100))));

    AvgInspirationTime = ga->getAvgInspiratoryTime();
    qtw->setItem(4,0,getQTableWidgetItem(tr("Среднее время вдоха(с)")));
    qtw->setItem(4,1,getQTableWidgetItem((QString::number((float)AvgInspirationTime/100))));

    AvgRoundTime = AvgExpirationTime+AvgInspirationTime;
    qtw->setItem(5,0,getQTableWidgetItem(tr("Средняя время цикла(с)")));
    qtw->setItem(5,1,getQTableWidgetItem((QString::number((float)AvgRoundTime/100))));

    InspirationFrequency = ga->getFrequency();
    qtw->setItem(6,0,getQTableWidgetItem(tr("Частота дыхания(ед/мин)")));
    qtw->setItem(6,1,getQTableWidgetItem((QString::number(InspirationFrequency))));

    BreathingVolume = ga->getBreathingVolume();
    qtw->setItem(7,0,getQTableWidgetItem(tr("Дыхательный объем(л)")));
    qtw->setItem(7,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(BreathingVolume)))));

    MVL = ga->getMVL();
    qtw->setItem(8,0,getQTableWidgetItem(tr("Максимальная вентиляция легких(л)")));
    qtw->setItem(8,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr(MVL)))));

    ga->clear();

    AvgTempIn = gai->getMinAvgs();
    qtw->setItem(9,0,getQTableWidgetItem(tr("Средняя температура вдоха( 'C)")));
    qtw->setItem(9,1,getQTableWidgetItem(QString::number(curveBuffer->tempInToDeg(AvgTempIn))));
    gai->clear();

    AvgTempOut = gao->getMaxAvgs();
    qtw->setItem(10,0,getQTableWidgetItem(tr("Средняя температура выдоха( 'C)")));
    qtw->setItem(10,1,getQTableWidgetItem(QString::number(curveBuffer->tempOutToDeg(AvgTempOut))));

    AvgTempInMinusAvgTempOut = AvgTempOut-AvgTempIn;
    qtw->setItem(11,0,getQTableWidgetItem(tr("Средняя Твдоха-Средняя Твыдоха( 'C)")));
    qtw->setItem(11,1,getQTableWidgetItem(curveBuffer->tempOutToDeg(AvgTempOut)-curveBuffer->tempInToDeg(AvgTempIn)));
    qtw->removeRow(0);

    qtw->show();
}
Пример #18
0
void AddEditBlog::fetchedBlogId(const QList< QMap < QString, QString > > &list)
{
    if (d->mFetchBlogIdTimer) {
        d->mFetchBlogIdTimer->deleteLater();
        d->mFetchBlogIdTimer = Q_NULLPTR;
    }
    hideWaitWidget();
    QString blogId, blogName, blogUrl, apiUrl;
    const int listCount(list.count());
    if (listCount > 1) {
        qCDebug(BLOGILO_LOG) << "User has more than ONE blog!";
        QDialog *blogsDialog = new QDialog(this);
        QTableWidget *blogsList = new QTableWidget(blogsDialog);
        blogsList->setSelectionBehavior(QAbstractItemView::SelectRows);
        QList< QMap<QString, QString> >::const_iterator it = list.constBegin();
        QList< QMap<QString, QString> >::const_iterator endIt = list.constEnd();
        int i = 0;
        blogsList->setColumnCount(4);
        QStringList headers;
        headers << i18n("Title") << i18n("URL");

        blogsList->setHorizontalHeaderLabels(headers);
        blogsList->setColumnHidden(2, true);
        blogsList->setColumnHidden(3, true);
        for (; it != endIt; ++it) {
            qCDebug(BLOGILO_LOG) << it->value(QStringLiteral("title"));
            blogsList->insertRow(i);
            blogsList->setCellWidget(i, 0, new QLabel(it->value(QStringLiteral("title"))));
            blogsList->setCellWidget(i, 1, new QLabel(it->value(QStringLiteral("url"))));
            blogsList->setCellWidget(i, 2, new QLabel(it->value(QStringLiteral("id"))));
            blogsList->setCellWidget(i, 3, new QLabel(it->value(QStringLiteral("apiUrl"))));
            ++i;
        }
        QVBoxLayout *mainLayout = new QVBoxLayout;
        blogsDialog->setLayout(mainLayout);
        mainLayout->addWidget(blogsList);
        blogsDialog->setWindowTitle(i18n("Which blog?"));
        if (blogsDialog->exec()) {
            int row = blogsList->currentRow();
            if (row == -1) {
                delete blogsDialog;
                return;
            }
            blogId = qobject_cast<QLabel *>(blogsList->cellWidget(row, 2))->text();
            blogName = qobject_cast<QLabel *>(blogsList->cellWidget(row, 0))->text();
            blogUrl = qobject_cast<QLabel *>(blogsList->cellWidget(row, 1))->text();
            apiUrl = qobject_cast<QLabel *>(blogsList->cellWidget(row, 3))->text();
        } else {
            delete blogsDialog;
            return;
        }
        delete blogsDialog;
    } else if (listCount > 0) {
        blogId = list.constBegin()->value(QStringLiteral("id"));
        blogName = list.constBegin()->value(QStringLiteral("title"));
        blogUrl = list.constBegin()->value(QStringLiteral("url"));
        apiUrl = list.constBegin()->value(QStringLiteral("apiUrl"));
    } else {
        KMessageBox::sorry(this, i18n("Sorry, No blog found with the specified account info."));
        return;
    }
    d->ui.txtId->setText(blogId);
    d->ui.txtTitle->setText(blogName);
    d->ui.txtId->setEnabled(true);
    d->ui.btnFetch->setEnabled(true);
    d->ui.btnAutoConf->setEnabled(true);

    if (!apiUrl.isEmpty()) {
        d->ui.txtUrl->setText(apiUrl);
    } else {
        apiUrl = d->ui.txtUrl->text();
    }
    if (!blogUrl.isEmpty()) {
        d->bBlog->setBlogUrl(blogUrl);
    } else {
        if (d->tmpBlogUrl.isEmpty()) {
            d->bBlog->setBlogUrl(apiUrl);
        } else {
            d->bBlog->setBlogUrl(d->tmpBlogUrl);
        }
    }

    d->bBlog->setUrl(QUrl(apiUrl));
    d->bBlog->setUsername(d->ui.txtUser->text());
    d->bBlog->setPassword(d->ui.txtPass->text());
    d->bBlog->setBlogId(blogId);
    d->bBlog->setTitle(blogName);
}
Пример #19
0
void FenPrincipale::calcul_manches() {
	for (int j = 0;  j < this->nbManches; ++j) {
			// on initialise la table html pour l'export
		QString html = "<table>\n\t<thead>\n\t\t<tr>\n\t\t\t";
		html += "<td>"+tr("Place")+"</td>";
		html += "<td>"+tr("Équipage")+"</td>";
		html += "<td>"+tr("Points")+"</td>";
		if (this->typeClmt == CLMT_TEMPS) {
			html += "<td>"+tr("Temps réel")+"</td><td>"+tr("Temps compensé")+"</td>";
		}
		html += "\n\t\t</tr>\n\t</thead>\n\t<tboby>";
			// on affiche la table qui va contenir les résultats de la manche
		QTableWidget *table = new QTableWidget();
		table->verticalHeader()->hide();
		table->setSelectionMode(QAbstractItemView::NoSelection);
		table->setProperty("table", "manches");
		QList<QString> labels;
		labels << tr("Place") << tr("Équipage") << tr("Points");
		if (this->typeClmt == CLMT_TEMPS) {
			table->setColumnCount(5);
			labels << tr("Temps réel") << tr("Temps compensé");
			table->setMaximumWidth(560 + 20);
			table->setMinimumWidth(560 + 20);
			table->setColumnWidth(3, 120);
			table->setColumnWidth(4, 120);
		}
		else {
			table->setColumnCount(3);
			table->setMaximumWidth(320 + 20);
			table->setMinimumWidth(320 + 20);
		}
		table->setColumnWidth(0, 60);
		table->setColumnWidth(1, 200);
		table->setColumnWidth(2, 60);
		table->setHorizontalHeaderLabels(labels);
		table->setRowCount(this->nbEquipages);
		ui->choisirResultat->insertItem(j+1,
			tr("Résultats de la manche %1").arg(QString::number(j+1)));
		int nbAffiches = 0; // pour savoir à quelle ligne on en est
			// on traite et affiche les équipages
		// on traite chaque manche pour attribuer les points aux équipages
		for (int i = 0; i < this->nbEquipages; ++i) {
			// on recherche tous les équipages non encore traités pour cette
			// manches qui ont un tpsCompense minimal
			int min = 0;
			QList<int> ids;
			for (int k = 0; k < this->nbEquipages; ++k) {
				Manche m = this->equipages[k].manches[j];
				if (m.tpsCompense < 0 || m.points > 0 ) {
					// cet équipage a déjà été traité ou n'a pas de place/temps
					// (DNF, DNS, OCS, ...)
					continue;
				}
				if (m.tpsCompense < min || min == 0) {
					min = m.tpsCompense;
					ids.clear();
					ids.append(k);
				}
				else if (m.tpsCompense == min) {
					ids.append(k);
				}
			}
			if (min == 0) {
				// on n'a pas trouvé d'équipage à traiter (se produit s'il y a
				// des équipages DNS, DNF, OCS, ...)
				break;
			}
			for (int l = 0; l < ids.size(); ++l) {
				double points = (ids.size()-1.0)/2.0+i+1.0;
				this->equipages[ids.at(l)].points += points;
				this->equipages[ids.at(l)].pointsOrdonnes.prepend(points);
				this->equipages[ids.at(l)].pointsTries.append(points);
				this->equipages[ids.at(l)].manches[j].points = points;
				// on affiche ces équipages
				Equipage e = this->equipages[ids.at(l)];
				Manche m = e.manches[j];
				QLabel *place = new QLabel(QString::number(i+1));
				table->setCellWidget(i+l, 0, place);
				QWidget *nomWidget = new QWidget();
				QVBoxLayout *nomLayout = new QVBoxLayout();
				QLabel *nom = new QLabel(e.nom);
				nom->setProperty("label", "nom");
				nomLayout->addWidget(nom);
				if (this->typeClmt == CLMT_TEMPS) {
					QLabel *bateau = new QLabel();
					bateau->setText(this->bateaux.value(e.rating.toUpper()).serie
						+" ("+QString::number(e.coef)+")");
					bateau->setProperty("label", "bateau");
					nomLayout->addWidget(bateau);
					table->setRowHeight(i+l, 45);
				}
				nomLayout->setContentsMargins(0, 0, 0, 0);
				nomLayout->setSpacing(0);
				nomWidget->setLayout(nomLayout);
				table->setCellWidget(i+l, 1, nomWidget);
				QLabel *pointsi = new QLabel(QString::number(m.points));
				table->setCellWidget(i+l, 2, pointsi);
				if (this->typeClmt == CLMT_TEMPS) {
					QLabel *tpsReel = new QLabel(this->formate_tps(m.tpsReel));
					table->setCellWidget(i+l, 3, tpsReel);
					QLabel *tpsCompense = new QLabel(this->formate_tps(qRound(m.tpsCompense)));
					table->setCellWidget(i+l, 4, tpsCompense);
				}
				// on ajoute l'équipage à la table html
				QString nomString = "<span class=\"equipage\">"+e.nom+"</span>";
				if (this->typeClmt == CLMT_TEMPS) {
					nomString += "<span class=\"bateau\">"
						+this->bateaux.value(e.rating.toUpper()).serie
						+" ("+QString::number(e.coef)+")</span>";
				}
				html += "\n\t\t<tr>\n\t\t\t<td>"+QString::number(i+1)+"</td>"
					+"<td>"+nomString+"</td>"
					+"<td>"+QString::number(m.points)+"</td>";
				if (this->typeClmt == CLMT_TEMPS) {
					html += "<td>"+this->formate_tps(m.tpsReel)+"</td>"
						+"<td>"+this->formate_tps(qRound(m.tpsCompense))+"</td>";
				}
				html += "\n\t\t</tr>";
				++nbAffiches;
			}
			i = i+ids.size()-1;
		}
		// on traite les équipages qui n'ont pas de place/temps
		for (int i = 0; i < this->nbEquipages; ++i) {
			if (this->equipages[i].manches[j].tpsCompense < 0) {
				double points = this->nbEquipages+1.0;
				this->equipages[i].points += points;
				this->equipages[i].pointsOrdonnes.prepend(points);
				this->equipages[i].pointsTries.append(points);
				this->equipages[i].manches[j].points = points;
				// on affiche ces équipages
				Equipage e = this->equipages[i];
				Manche m = e.manches[j];
				QString abr = this->get_abr(m.abr);
				QLabel *place = new QLabel(abr);
				table->setCellWidget(nbAffiches, 0, place);
				QWidget *nomWidget = new QWidget();
				QVBoxLayout *nomLayout = new QVBoxLayout();
				QLabel *nom = new QLabel(e.nom);
				nom->setProperty("label", "nom");
				nomLayout->addWidget(nom);
				if (this->typeClmt == CLMT_TEMPS) {
					QLabel *bateau = new QLabel();
					bateau->setText(this->bateaux.value(e.rating.toUpper()).serie
						+" ("+QString::number(e.coef)+")");
					bateau->setProperty("label", "bateau");
					nomLayout->addWidget(bateau);
					table->setRowHeight(nbAffiches, 45);
				}
				nomLayout->setContentsMargins(0, 0, 0, 0);
				nomLayout->setSpacing(0);
				nomWidget->setLayout(nomLayout);
				table->setCellWidget(nbAffiches, 1, nomWidget);
				QLabel *pointsi = new QLabel(QString::number(m.points));
				table->setCellWidget(nbAffiches, 2, pointsi);
				if (this->typeClmt == CLMT_TEMPS) {
					QLabel *tpsReel = new QLabel(abr);
					table->setCellWidget(nbAffiches, 3, tpsReel);
					QLabel *tpsCompense = new QLabel(abr);
					table->setCellWidget(nbAffiches, 4, tpsCompense);
				}
				// on ajoute l'équipage à la table html
				QString nomString = "<span class=\"equipage\">"+e.nom+"</span>";
				if (this->typeClmt == CLMT_TEMPS) {
					nomString += "<span class=\"bateau\">"
						+this->bateaux.value(e.rating.toUpper()).serie
						+" ("+QString::number(e.coef)+")</span>";
				}
				html += "\n\t\t<tr>\n\t\t\t<td>"+abr+"</td><td>"+nomString+"</td>"
					+"<td>"+QString::number(m.points)+"</td>";
				if (this->typeClmt == CLMT_TEMPS) {
					html += "<td>"+abr+"</td><td>"+abr+"</td>";
				}
				html += "\n\t\t</tr>";
				++nbAffiches;
			}
		}
		ui->resultatsLayout->addWidget(table);
		table->hide();
		html += "\n\t</tbody>\n</table>";
		this->htmls.append(html);
		this->progression(5+j*75/this->nbManches);
	}
	// on trie les liste pointsTries
	for (int i = 0; i < this->nbEquipages; ++i) {
		qSort(this->equipages[i].pointsTries);
	}
}
Пример #20
0
ladspaPortDialog::ladspaPortDialog( const ladspa_key_t & _key )
{
	ladspa2LMMS * manager = engine::getLADSPAManager();

	setWindowIcon( embed::getIconPixmap( "ports" ) );
	setWindowTitle( tr( "Ports" ) );
	setModal( true );

	QVBoxLayout * vlayout = new QVBoxLayout( this );
	vlayout->setSpacing( 0 );
	vlayout->setMargin( 0 );

	int pc = manager->getPortCount( _key );

	QTableWidget * settings = new QTableWidget( pc, 7, this );

	QStringList ports;
	ports.append( tr( "Name" ) );
	ports.append( tr( "Rate" ) );
	ports.append( tr( "Direction" ) );
	ports.append( tr( "Type" ) );
	ports.append( tr( "Min < Default < Max" ) );
	ports.append( tr( "Logarithmic" ) );
	ports.append( tr( "SR Dependent" ) );
	settings->setHorizontalHeaderLabels( ports );

	for( int row = 0; row < pc; row++ )
	{
		for( int col = 0; col < 7; ++col )
		{
			QTableWidgetItem * item = new QTableWidgetItem;
			item->setFlags( 0 );
			settings->setItem( row, col, item );
		}

		int col = 0;
		settings->item( row, col++ )->setText( manager->getPortName( _key, row ) );

		settings->item( row, col++ )->setText( manager->isPortAudio( _key, row ) ?  tr( "Audio" ) : tr( "Control" ) );

		settings->item( row, col++ )->setText( manager->isPortInput( _key, row ) ?  tr( "Input" ) : tr( "Output" ) );

		settings->item( row, col++ )->setText( manager->isPortToggled( _key, row ) ? tr( "Toggled" ) : manager->isInteger( _key, row ) ? tr( "Integer" ) : tr( "Float" ) );

		float min = manager->getLowerBound( _key, row );
		float max = manager->getUpperBound( _key, row );
		float def = manager->getDefaultSetting( _key, row );
		QString range = "";

		if( manager->areHintsSampleRateDependent( _key, row ) )
		{
			if( min != NOHINT )
			{
				min *= engine::mixer()->processingSampleRate();
			}
			if( max != NOHINT )
			{
				max *= engine::mixer()->processingSampleRate();
			}
		}

		if( min == NOHINT )
		{
			range += "-Inf < ";
		}
		else if( manager->isInteger( _key, row ) )
		{
			range += QString::number( static_cast<int>( min ) ) +
									" < ";
		}
		else
		{
			range += QString::number( min ) + " < ";
		}

		if( def == NOHINT )
		{
			range += "None < ";
		}
		else if( manager->isInteger( _key, row ) )
		{
			range += QString::number( static_cast<int>( def ) ) + 
									" < ";
		}
		else
		{
			range += QString::number( def ) + " < ";
		}

		if( max == NOHINT )
		{
			range += "Inf";
		}
		else if( manager->isInteger( _key, row ) )
		{
			range += QString::number( static_cast<int>( max ) );
		}
		else
		{
			range += QString::number( max );
		}

		if( manager->isPortOutput( _key, row ) ||
					manager->isPortToggled( _key, row ) )
		{
			range = "";
		}

		settings->item( row, col++ )->setText( range );

		if( manager->isLogarithmic( _key, row ) )
		{
			settings->item( row, col )->setText( tr( "Yes" ) );
		}
		col++;

		if( manager->areHintsSampleRateDependent( _key, row ) )
		{
			settings->item( row, col )->setText( tr( "Yes" ) );
		}
	}


	vlayout->addWidget( settings );

	show();
}
std::vector<QHBoxLayout *> ActiveLearningDialog::Sample_Details(QImage snapshot, vtkSmartPointer<vtkTable> table,int num_classes,int active_query,std::vector<int>top_feats,int group)
{

	QLabel *imageLabel = new QLabel(this);
	imageLabel->setPixmap(QPixmap::fromImage(snapshot));
	imageLabel->resize(imageLabel->pixmap()->size());
	
	finish = true;

	
	//Top-row of the window 
	QHBoxLayout *topRow = new QHBoxLayout;
	topRow->addWidget(imageLabel,0,0);
	
	QLabel *enterClassLabel = new QLabel("Select Class: ", this);
	topRow->addWidget(enterClassLabel,0,0);
	
	buttongroup[group] = new QButtonGroup(this);
	buttongroup[group]->setExclusive(true);

	// radiobutons for each class
	for(int i =0 ; i< num_classes ; ++i)
	{
		QRadioButton  *class_button = new QRadioButton(QString::number(i + 1), this);
		topRow->addWidget(class_button,0,0);
		button_vector.push_back(class_button);
		buttongroup[group]->addButton(class_button);
		connect(class_button, SIGNAL(clicked()),this,SLOT(Set_Class()));
	}
			
	QRadioButton *class_button = new QRadioButton("I am not sure" , this);
	connect(class_button, SIGNAL(clicked()),this,SLOT(Set_Class()));
	button_vector.push_back(class_button);
	buttongroup[group]->addButton(class_button);
	topRow->addWidget(class_button,0,0);

	
	//Remove the train column 
	table->RemoveColumnByName("train");
	int numb_cols = MIN(5,table->GetNumberOfColumns());
 
	QStringList sl;

	for(int i=0;i<numb_cols;++i)
	{
		sl<<QString(table->GetColumnName(top_feats[i]));
	}
	
	// Table displaying 5 top features
	QTableWidget *tableWidget = new QTableWidget(1, numb_cols, this);
	tableWidget->setHorizontalHeaderLabels(sl);
	tableWidget->setRowCount(1);
    tableWidget->setColumnCount(numb_cols);

	for(int i=0;i<numb_cols;++i)
	{
	  QTableWidgetItem *newItem = new QTableWidgetItem(QString::number(table->GetValue(active_query,top_feats[i]).ToDouble()));
	  newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
	  tableWidget->setItem(0, i, newItem);
	}

	//classes_chosen.resize(num_classes+1);

	//for(int i =0 ; i<=num_classes ; ++i)
	//{
	//	classes_chosen[i] = -1;// Used to check if no radiobutton was selected for any sample
	//}

	//Bottom-row of the window 
	QHBoxLayout *botRow = new QHBoxLayout;
	botRow->addWidget(tableWidget,0,0);
	//botRow->addWidget(channelLabel,1,0);
	std::vector<QHBoxLayout *> rows;
	rows.push_back(topRow);
	rows.push_back(botRow);

	return rows;
}
Пример #22
0
QWidget* WidgetStyle::createWidget(const QString& name)
{
    if(name == "CheckBox")
    {
        QCheckBox* box = new QCheckBox("CheckBox");
        box->setObjectName("CheckBox");
        return setLayoutWidget({ box }, { 100, 30 });
    }
    else if(name == "ComboBox")
    {
        QComboBox* box = new QComboBox;
        box->addItem("Item1");
        box->addItem("Item3");
        box->addItem("Item3");
        box->setObjectName("ComboBox");
        return setLayoutWidget({ box }, { 70, 30 });
    }
    else if(name == "DateEdit")
    {
        QDateEdit* date = new QDateEdit;
        date->setObjectName("DateEdit");
        return setLayoutWidget({ date }, { 110, 40 });
    }
    else if(name == "DateTimeEdit")
    {
        QDateTimeEdit* date = new QDateTimeEdit;
        date->setObjectName("DateTimeEdit");
        return setLayoutWidget({ date }, { 160, 30 });
    }
    else if(name == "Dialog")
    {
        QDialog* dialog = new QDialog;
        dialog->setObjectName("Dialog");
        return setLayoutWidget({ dialog }, { 160, 110 });
    }
    else if(name == "DockWidget") //?
    {
        QDockWidget* widget = new QDockWidget;
        widget->setObjectName("DockWidget");
        widget->resize(61, 22);
        return widget;
    }
    else if(name == "DoubleSpinBox")
    {
        QDoubleSpinBox* box = new QDoubleSpinBox;
        box->setObjectName("DoubleSpinBox");
        return setLayoutWidget({ box }, { 90, 40 });
    }
    else if(name == "Frame") //??
    {
        QFrame* frame = new QFrame;
        frame->setObjectName("Frame");
        frame->resize(150, 100);
        return frame;
    }
    else if(name == "GroupBox")
    {
        QGroupBox* box = new QGroupBox("GroupBox");
        box->setObjectName("GroupBox");
        return setLayoutWidget({ box }, { 160, 110 });
    }
    else if(name == "Label")
    {
        QLabel* label = new QLabel("Label");
        label->setObjectName("Label");
        return setLayoutWidget({ label }, { 40, 20});
    }
    else if(name == "LineEdit")
    {
        QLineEdit* line = new QLineEdit;
        line->setObjectName("LineEdit");
        return setLayoutWidget({ line }, { 30, 30 });
    }
    else if(name == "ListView") //??
    {
        QListView* view = new QListView;
        view->setObjectName("ListView");
        view->resize(71, 71);
        return view;
    }
    else if(name == "ListWidget")
    {
        QListWidget* list = new QListWidget;
        list->setObjectName("ListWidget");
        for(int i = 0; i < 20; i++)
            list->addItem(QString("Item %1").arg(i));
        return setLayoutWidget({ list }, { 80, 80 });
    }
    else if(name == "MainWindow")
    {
        QMainWindow* window = new QMainWindow;
        window->setObjectName("MainWindow");
        return setLayoutWidget({ window }, { 160, 110 });
    }
    else if(name == "Menu")
    {
        QMenu* parentMenu = new QMenu;
        parentMenu->setObjectName("Menu");
        parentMenu->addMenu("Menu1");
        QMenu* menu1 = parentMenu->addMenu("Menu2");
        menu1->addMenu("Menu1");
        menu1->addMenu("Menu2");
        parentMenu->addSeparator();
        parentMenu->addMenu("Menu3");
        return setLayoutWidget({ parentMenu }, { 160, 110 });
    }
    else if(name == "MenuBar")
    {
        QMenuBar* bar = new QMenuBar;
        bar->setObjectName("QMenuBar");
        QMenu* menu1 = bar->addMenu("MenuBar1");
        menu1->addMenu("Menu1");
        menu1->addSeparator();
        menu1->addMenu("Menu2");
        QMenu* menu2 = bar->addMenu("MenuBar2");
        menu2->addMenu("Menu1");
        menu2->addSeparator();
        menu2->addMenu("Menu2");
        QMenu* menu3 = bar->addMenu("MenuBar3");
        menu3->addMenu("Menu1");
        menu3->addSeparator();
        menu3->addMenu("Menu2");
        return setLayoutWidget({ bar }, { 280, 60 });
    }
    else if(name == "ProgressBar")
    {
        QProgressBar* bar = new QProgressBar;
        bar->setObjectName("ProgressBar");
        bar->setRange(0, 100);
        bar->setValue(0);

        QTimer* timer = new QTimer(bar);
        this->connect(timer, &QTimer::timeout, this, [bar]()
        {
            if(bar->value() == 100)
                bar->setValue(0);
            else
                bar->setValue(bar->value() + 1);
        });
        timer->start(100);
        return setLayoutWidget({ bar }, { 110, 30 });
    }
    else if(name == "PushButton")
    {
        QPushButton* button = new QPushButton("PushButton");
        button->setObjectName("PushButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "RadioButton")
    {
        QRadioButton* button = new QRadioButton("RadioButton");
        button->setObjectName("RadioButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "ScrollBar")
    {
        QScrollBar* barH = new QScrollBar(Qt::Horizontal);
        QScrollBar* barV = new QScrollBar(Qt::Vertical);
        barH->setObjectName("ScrollBarH");
        barV->setObjectName("ScrollBarV");
        return setLayoutWidget({ barH, barV }, { 200, 100 });
    }
    else if(name == "Slider")
    {
        QSlider* sliderH = new QSlider(Qt::Horizontal);
        QSlider* sliderV = new QSlider(Qt::Vertical);
        sliderH->setObjectName("SliderH");
        sliderV->setObjectName("SliderV");
        return setLayoutWidget({ sliderH, sliderV }, { 200, 100 });
    }
    else if(name == "SpinBox")
    {
        QSpinBox* spinBox = new QSpinBox;
        spinBox->setObjectName("SpinBox");
        return setLayoutWidget({ spinBox }, { 60, 35 });
    }
    else if(name == "Splitter")
    {
        QSplitter* splitterV = new QSplitter(Qt::Vertical);
        QSplitter* splitterH = new QSplitter(Qt::Horizontal);
        splitterV->setObjectName("SplitterV");
        splitterH->setObjectName("SplitterH");
        splitterV->addWidget(new QPushButton("PushButton1"));
        splitterV->addWidget(new QPushButton("PushButton2"));
        splitterH->addWidget(splitterV);
        splitterH->addWidget(new QPushButton("PushButton3"));
        return setLayoutWidget({ splitterH }, { 250, 110 });
    }
    else if(name == "TabWidget")
    {
        QTabWidget* tab = new QTabWidget;
        tab->addTab(new QWidget, "Widget1");
        tab->addTab(new QWidget, "Widget2");
        tab->addTab(new QWidget, "Widget3");
        tab->setObjectName("TabWidget");
        return setLayoutWidget({ tab }, { 210, 110 });
    }
    else if(name == "TableView") //?
    {
        QTableView* view = new QTableView;
        view->setObjectName("TableView");
        view->resize(200, 100);
        return view;
    }
    else if(name == "TableWidget")
    {
        const int n = 100;
        QStringList list = { "one", "two", "three" };
        QTableWidget* table = new QTableWidget(n, n);
        table->setObjectName("TableWidget");
        table->setHorizontalHeaderLabels(list);
        table->setVerticalHeaderLabels(list);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                table->setItem(i, j, new QTableWidgetItem(QString("%1, %2").arg(i).arg(j)));
        return setLayoutWidget({ table }, { 210, 110 });
    }
    else if(name == "TextEdit")
    {
        QTextEdit* text = new QTextEdit;
        text->setObjectName("TextEdit");
        return setLayoutWidget({ text }, { 80, 80 });
    }
    else if(name == "TimeEdit")
    {
        QTimeEdit* time = new QTimeEdit;
        time->setObjectName("TimeEdit");
        return setLayoutWidget({ time }, { 80, 80 });
    }
    else if(name == "ToolButton")
    {
        QToolButton* button = new QToolButton;
        button->setText("ToolButton");
        button->setObjectName("ToolButton");
        return setLayoutWidget({ button }, { 95, 25 });
    }
    else if(name == "ToolBox")
    {
        QToolBox* box = new QToolBox;
        box->addItem(new QWidget, "Widget1");
        box->addItem(new QWidget, "Widget2");
        box->addItem(new QWidget, "Widget3");
        box->setObjectName("ToolBox");
        return setLayoutWidget({ box }, { 110, 180 });
    }
    else if(name == "TreeView") //?
    {
        QTreeView* tree = new QTreeView;
        tree->setObjectName("TreeView");
        tree->resize(200, 100);
        return tree;
    }
    else if(name == "TreeWidget")
    {
        QTreeWidget* tree = new QTreeWidget;
        tree->setObjectName("TreeWidget");
        tree->setHeaderLabels({ "Folders", "Used Space" });
        QTreeWidgetItem* item = new QTreeWidgetItem(tree);
        item->setText(0, "Local Disk");
        for(int i = 1; i < 20; i++)
        {
            QTreeWidgetItem* dir = new QTreeWidgetItem(item);
            dir->setText(0, "Directory" + QString::number(i));
            dir->setText(1, QString::number(i) + "MB");
        }
        tree->setItemExpanded(item, true);
        return setLayoutWidget({ tree }, { 210, 110 });
    }
    else if(name == "Widget")
    {
        QWidget* widget = new QWidget;
        widget->setObjectName("Widget");
        return setLayoutWidget({ widget }, { 210, 110 });
    }
    return nullptr;
}
Пример #23
0
void TSController::processDataParams(){
    //    qDebug()<<"TSController::processDataParams";
    qDebug()<<"this is result button !";
    QTableWidget *qtw = ui->resultsTable;
    qtw->setColumnCount(2);
    qtw->setRowCount(12);
    qtw->verticalHeader()->setVisible(false);
    qtw->setHorizontalHeaderLabels(QString(tr("Параметр;Значение")).split(";"));
    qtw->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    /* tsanalitics* ga = new tsanalitics();
    tstempanalitic* gao = new tstempanalitic();
    tstempanalitic* gai = new tstempanalitic();*/
    float AvgExpirationSpeed=0, MaxExpirationSpeed=0, AvgExpirationTime=0, AvgInspirationTime=0,
            AvgRoundTime=0, AvgTempIn=0, AvgTempOut=0, AvgTempInMinusAvgTempOut=0,  BreathingVolume=0, MVL=0, MinuteVentilation=0;
    float InspirationFrequency=0;
    int *vo = curveBuffer->volume();
    int *ti = curveBuffer->tempIn();
    int *to = curveBuffer->tempOut();
    QVector<int> volume,temp_in,temp_out;
    for(int i=0;i<curveBuffer->getLenght();i++){
        volume.push_back(vo[i]);
        temp_in.push_back(ti[i]);
        temp_out.push_back(to[i]);
    }
    VolumeSolver* vs = new VolumeSolver(volume,temp_in,temp_out);

    AvgExpirationSpeed = vs->getAverageExpirationSpeed();
    qtw->setItem(1,0,getQTableWidgetItem(tr("Средняя скорость выдоха(л/с)")));
    qtw->setItem(1,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)AvgExpirationSpeed)))));

    MaxExpirationSpeed = vs->getMaxExpirationSpeed();
    qtw->setItem(2,0,getQTableWidgetItem(tr("Максимальная скорость выдоха(л/с)")));
    qtw->setItem(2,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)MaxExpirationSpeed)))));

    AvgExpirationTime = vs->getAverageExpirationTime();
    qtw->setItem(3,0,getQTableWidgetItem(tr("Среднее время выдоха(с)")));
    qtw->setItem(3,1,getQTableWidgetItem((QString::number((float)AvgExpirationTime))));

    AvgInspirationTime = vs->getAverageInspirationTime();
    qtw->setItem(4,0,getQTableWidgetItem(tr("Среднее время вдоха(с)")));
    qtw->setItem(4,1,getQTableWidgetItem((QString::number((float)AvgInspirationTime))));

    AvgRoundTime = vs->getAverageCycleTime();
    qtw->setItem(5,0,getQTableWidgetItem(tr("Средняя время цикла(с)")));
    qtw->setItem(5,1,getQTableWidgetItem((QString::number((float)AvgRoundTime))));

    InspirationFrequency = vs->getInspirationFrequancyInOneMinute();
    qtw->setItem(6,0,getQTableWidgetItem(tr("Частота дыхания(ед/мин)")));
    qtw->setItem(6,1,getQTableWidgetItem((QString::number(InspirationFrequency))));

    MinuteVentilation = vs->getMinuteVentilation();
    qtw->setItem(8,0,getQTableWidgetItem(tr("Минутная вентиляция легких(л)")));
    qtw->setItem(8,1,getQTableWidgetItem(QString::number(curveBuffer->volToLtr(MinuteVentilation))));

    BreathingVolume = vs->getAverageInspiratonVentilation();
    qtw->setItem(7,0,getQTableWidgetItem(tr("Дыхательный объем(л)")));
    qtw->setItem(7,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)BreathingVolume)))));

    MVL = vs->getTotalVentilation();
    qtw->setItem(9,0,getQTableWidgetItem(tr("Суммарная вентиляция легких(л)")));
    qtw->setItem(9,1,getQTableWidgetItem(QString::number(fabs(curveBuffer->volToLtr((int)MVL)))));

    //ga->clear();

    AvgTempIn = vs->getAverageInspirationTempetature();
    qtw->setItem(10,0,getQTableWidgetItem(tr("Средняя температура вдоха( 'C)")));
    qtw->setItem(10,1,getQTableWidgetItem(QString::number(curveBuffer->tempInToDeg(AvgTempIn))));
    //gai->clear();

    AvgTempOut = vs->getAverageExpirationTempetature();
    qtw->setItem(11,0,getQTableWidgetItem(tr("Средняя температура выдоха( 'C)")));
    qtw->setItem(11,1,getQTableWidgetItem(QString::number(curveBuffer->tempOutToDeg(AvgTempOut))));

    AvgTempInMinusAvgTempOut = AvgTempOut-AvgTempIn;
    qtw->setItem(12,0,getQTableWidgetItem(tr("Средняя Твдоха-Средняя Твыдоха( 'C)")));
    qtw->setItem(12,1,getQTableWidgetItem(curveBuffer->tempOutToDeg(AvgTempOut)-curveBuffer->tempInToDeg(AvgTempIn)));

    qtw->removeRow(0);
    qtw->show();
    delete vs;
}
Пример #24
0
void StatsView::on_statsTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
	if (current == 0)
		return;
	std::string data = "";
	if (current->childCount() == 0) {
		DataContainerTreeItem *treeData = (DataContainerTreeItem *)current;
		data = treeData->getData();
	}
	QTreeWidget *statsTree = this->findChild<QTreeWidget *>("statsTree");
	QLabel *modName = this->findChild<QLabel *>("modName");
	QTableWidget *modTable = this->findChild<QTableWidget *>("modTable");
	modTable->blockSignals(true);
	StatsContainer *itemStats = GenStatsReader::getContainer(allItemStats, data.c_str());
	if (itemStats != 0) {
		modName->setText(itemStats->getArg(0).c_str());
		std::map<std::string, std::string> baseData = itemStats->getBaseDataMap();
		if (itemStats->getUsing() != 0) {
			std::map<std::string, std::string> parentData = itemStats->getUsing()->getBaseDataMap();
			for (std::map<std::string, std::string>::iterator it = parentData.begin(); it != parentData.end(); ++it) {
				if (baseData.find(it->first) == baseData.end()) {
					baseData[it->first] = it->second;
				}
			}
		}
		for (int i=0; i<modTable->rowCount(); ++i) {
			for (int j=0; j<modTable->columnCount(); ++j) {
				delete modTable->item(i, j);
			}
		}
		modTable->setRowCount(0);
		int row = 0;
		if (itemStats->getContainerType() == "deltamod") {
			StatsContainer *boost = GenStatsReader::getContainer(allItemStats, itemStats->getBoostName());
			if (boost != 0) {
				std::map<std::string, std::string> boostMap = boost->getBaseDataMap();
				for (std::map<std::string, std::string>::iterator it = boostMap.begin(); it != boostMap.end(); ++it) {
					if (baseData.find(it->first) == baseData.end()) {
						baseData[it->first] = it->second;
					}
				}
			}
			for (int i=0; i<itemStats->getPrefixList().size(); ++i) {
				QTableWidgetItem *nameItem = new QTableWidgetItem();
				nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
				nameItem->setText("Prefix");
				QTableWidgetItem *valueItem = new QTableWidgetItem();
				valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
				valueItem->setText(itemStats->getPrefixList()[i].c_str());
				modTable->insertRow(row);
				modTable->setItem(row, 0, nameItem);
				modTable->setItem(row, 1, valueItem);
				++row;
			}
			for (int i=0; i<itemStats->getSuffixList().size(); ++i) {
				QTableWidgetItem *nameItem = new QTableWidgetItem();
				nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
				nameItem->setText("Suffix");
				QTableWidgetItem *valueItem = new QTableWidgetItem();
				valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
				valueItem->setText(itemStats->getSuffixList()[i].c_str());
				modTable->insertRow(row);
				modTable->setItem(row, 0, nameItem);
				modTable->setItem(row, 1, valueItem);
				++row;
			}
		}
		for (std::map<std::string, std::string>::iterator it = baseData.begin(); it != baseData.end(); ++it) {
			QTableWidgetItem *nameItem = new QTableWidgetItem();
			nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
			nameItem->setText(it->first.c_str());
			QTableWidgetItem *valueItem = new QTableWidgetItem();
			valueItem->setFlags(valueItem->flags() & ~Qt::ItemIsEditable);
			valueItem->setText(it->second.c_str());
			modTable->insertRow(row);
			modTable->setItem(row, 0, nameItem);
			modTable->setItem(row, 1, valueItem);
			++row;
		}
		
		modTable->resizeRowsToContents();
		modTable->resizeColumnsToContents();
	} else if (current->childCount() == 0) {
		bool canEdit = true;
		if (current->text(0) == "Abilities") {
			canEdit = false;
		}
		QStringList headerList;
		headerList.push_back("Name");
		if (canEdit) {
			headerList.push_back("Editable Value");
		} else {
			headerList.push_back("Value");
		}
		modTable->setHorizontalHeaderLabels(headerList);
		for (int i=0; i<modTable->rowCount(); ++i) {
			for (int j=0; j<modTable->columnCount(); ++j) {
				delete modTable->item(i, j);
			}
		}
		modTable->setRowCount(0);
		int row = 0;
		modTable->insertRow(row);
		QTableWidgetItem *nameItem = new QTableWidgetItem();
		nameItem->setText(current->text(0));
		nameItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
		modTable->setItem(row, 0, nameItem);
		QTableWidgetItem *valueItem = new QTableWidgetItem();
		if (!canEdit) {
			valueItem->setFlags(nameItem->flags() & ~Qt::ItemIsEditable);
		}
		valueItem->setText(data.c_str());
		modTable->setItem(row, 1, valueItem);
		
		modTable->resizeRowsToContents();
		modTable->resizeColumnsToContents();
	}
	modTable->blockSignals(false);
}