QTableWidget *StManagerStudyListComp::createStudyTable ()
{
  QTableWidget *table  = new QTableWidget;

  table->setSelectionBehavior( QAbstractItemView::SelectRows );
  table->setSelectionMode( QAbstractItemView::SingleSelection );
  table->setEditTriggers( QAbstractItemView::NoEditTriggers );

  QStringList labels;
  for ( int i = 0; i < ATTRIBUTE_NUMBER; i++ ) {
    labels << tr( attributeNames[i] );
  }
  
  table->setColumnCount( labels.size() + 1 );
  table->setHorizontalHeaderLabels( labels );
  table->setColumnHidden( ATTRIBUTE_NUMBER, true );

  for ( int i = 0; i < ATTRIBUTE_NUMBER; i++ ) 
  {
    if ( attributeResizes[i] ) {
      table->horizontalHeader()->setResizeMode( i, QHeaderView::ResizeToContents );
    }
  }

  connect( table, SIGNAL(itemSelectionChanged()), this, SLOT(setEnabledView()) );
  connect( table, SIGNAL(itemDoubleClicked( QTableWidgetItem * )), this, SLOT(view()) );

  return table;
}
Example #2
0
QTableWidget* StatusViewer::prepareTable(int rows, int cols) {
    QTableWidget* table = new QTableWidget(this);
    table->setColumnCount(cols);
    table->setRowCount(rows);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setAttribute(Qt::WA_MacShowFocusRect, 0);
    table->setShowGrid(false);
    table->setAlternatingRowColors(true);
    table->setSortingEnabled(false);

    for (int c = 0; c < cols; ++c) {
        table->horizontalHeader()->setSectionResizeMode(c, QHeaderView::Stretch);
    }
    
    for(int row=0; row<rows; ++row) {
        for(int col=0; col<cols; ++col){
            QTableWidgetItem* tableItem = new QTableWidgetItem();
            tableItem->setFlags(tableItem->flags() ^ Qt::ItemIsEditable);
            tableItem->setTextAlignment(Qt::AlignRight);
            tableItem->setText("--");
            table->setItem(row, col, tableItem);
        }
    }
    
    return table;
}
QTableWidget* DatabaseView::snapshotsTable()
{
	if(tables.find(SNAPSHOTS) != tables.end())
	{
		return tables[SNAPSHOTS].second;
	}

	QList<Snapshot> snapslist = Database::getInstance().getSnapshots();
	QTableWidget *table;
	const QSize previewSize = QSize(64,64);
	table = new QTableWidget(snapslist.count(), 6);
	table->setIconSize(previewSize);
	table->setHorizontalHeaderLabels(QStringList()<<"Снимок"<<"Ширина"<<"Высота"<<"Дата"<<"На сцене"<<"hidden");
	table->setSelectionBehavior(QAbstractItemView::SelectRows);
	int row = 0;
	QByteArray imageBytes;
	foreach(Snapshot snapshot,snapslist)
	{
		table->setItem(row, 0, new QTableWidgetItem(QPixmap::fromImage(snapshot.image.scaled(previewSize,Qt::KeepAspectRatio)),""));		
		table->setItem(row, 1, new QTableWidgetItem(QString("%1").arg(snapshot.width)));
		table->setItem(row, 2, new QTableWidgetItem(QString("%1").arg(snapshot.height)));
		table->setItem(row, 3, new QTableWidgetItem(snapshot.created.toString()));
		table->setItem(row, 4, new QTableWidgetItem(snapshot.in_scene ? "Да" : "Нет"));
		table->setItem(row, 5, new QTableWidgetItem(QString("%1").arg(snapshot.id)));
		table->verticalHeader()->resizeSection(row, previewSize.height());
		for(int i = 0; i < 4; i++)
			table->item(row,i)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		row++;
	}
Example #4
0
ParamCompareDialog::ParamCompareDialog(QMap<QString, UASParameter* >& paramaterList,
                                       const QString& filename, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ParamCompareDialog),
    m_currentList(&paramaterList),
    m_newList(new QMap<QString, UASParameter*>()),
    m_fileToCompare(filename)
{
    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();

    if(filename.count()>0){
        QTimer::singleShot(200, this, SLOT(loadParameterWithFile()));
    }

}
Example #5
0
void PageMemoryRights::RunAddrSize(duint addrin, duint sizein, QString pagetypein)
{
    addr = addrin;
    size = sizein;
    pagetype = pagetypein;

    QTableWidget* tableWidget = ui->pagetableWidget;
    tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    duint nr_pages = size / PAGE_SIZE;
    tableWidget->setColumnCount(2);
    tableWidget->setRowCount(nr_pages);
    tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(QString(tr("Address"))));
    tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(QString(tr("Rights"))));

    duint actual_addr;
    char rights[RIGHTS_STRING_SIZE];
    for(duint i = 0; i < nr_pages; i++)
    {
        actual_addr = addr + (i * PAGE_SIZE);
        tableWidget->setItem(i, 0, new QTableWidgetItem(ToPtrString(actual_addr)));
        if(DbgFunctions()->GetPageRights(actual_addr, rights))
            tableWidget->setItem(i, 1, new QTableWidgetItem(QString(rights)));
    }

    QModelIndex idx = (ui->pagetableWidget->model()->index(0, 0));
    ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);
    idx = (ui->pagetableWidget->model()->index(0, 1));
    ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);

    ui->radioFullaccess->setChecked(true);
    ui->chkPageguard->setCheckable(true);
    exec();
}
Example #6
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMainWindow *w = new QMainWindow();

    QTableWidget* table = new QTableWidget();
    table->setFixedSize(300,300);

    QPalette* palette = new QPalette();
    palette->setColor(QPalette::Highlight,Qt::cyan);
    table->setPalette(*palette);

    table->setRowCount(2);
    table->setColumnCount(3);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);

    //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_1"));
    table->setItem(0,1,new QTableWidgetItem("ITEM 1_2"));
    table->setItem(0,2,new QTableWidgetItem("ITEM 1_3"));

    table->setItem(1,0,new QTableWidgetItem("ITEM 2_1"));
    table->setItem(1,1,new QTableWidgetItem("ITEM 2_2"));
    table->setItem(1,2,new QTableWidgetItem("ITEM 2_3"));

    w->setCentralWidget(table);

    w->show();

    return a.exec();
}
Example #7
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;
}
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();
}
Example #9
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;
}
Example #10
0
KeyBinder::KeyBinder(QWidget * parent, const QString & helpText, const QString & defaultText, const QString & resetButtonText) : QWidget(parent)
{
    this->defaultText = defaultText;
    enableSignal = false;

    // Two-column tab layout
    QHBoxLayout * pageKeysLayout = new QHBoxLayout(this);
    pageKeysLayout->setSpacing(0);
    pageKeysLayout->setContentsMargins(0, 0, 0, 0);

    // Table for category list
    QVBoxLayout * catListContainer = new QVBoxLayout();
    catListContainer->setContentsMargins(10, 10, 10, 10);
    catList = new QListWidget();
    catList->setFixedWidth(180);
    catList->setStyleSheet("QListWidget::item { font-size: 14px; } QListWidget:hover { border-color: #F6CB1C; } QListWidget::item:selected { background: #150A61; color: yellow; }");
    catList->setFocusPolicy(Qt::NoFocus);
    connect(catList, SIGNAL(currentRowChanged(int)), this, SLOT(changeBindingsPage(int)));
    catListContainer->addWidget(catList);
    pageKeysLayout->addLayout(catListContainer);

    // Reset all binds button
    if (!resetButtonText.isEmpty())
    {
        QPushButton * btnResetAll = new QPushButton(resetButtonText);
        catListContainer->addWidget(btnResetAll);
        btnResetAll->setFixedHeight(40);
        catListContainer->setStretch(1, 0);
        catListContainer->setSpacing(10);
        connect(btnResetAll, SIGNAL(clicked()), this, SIGNAL(resetAllBinds()));
    }

    // Container for pages of key bindings
    QWidget * bindingsPagesContainer = new QWidget();
    QVBoxLayout * rightLayout = new QVBoxLayout(bindingsPagesContainer);

    // Scroll area for key bindings
    QScrollArea * scrollArea = new QScrollArea();
    scrollArea->setContentsMargins(0, 0, 0, 0);
    scrollArea->setWidget(bindingsPagesContainer);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    scrollArea->setWidgetResizable(true);
    scrollArea->setFrameShape(QFrame::NoFrame);
    scrollArea->setStyleSheet("background: #130F2A;");

    // Add key binding pages to bindings tab
    pageKeysLayout->addWidget(scrollArea);
    pageKeysLayout->setStretch(1, 1);

    // Custom help text
    QLabel * helpLabel = new QLabel();
    helpLabel->setText(helpText);
    helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;");
    helpLabel->setFixedHeight(24);
    rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter);

    // Category list and bind table row heights
    const int rowHeight = 20;
    QSize catSize, headerSize;
    catSize.setHeight(36);
    headerSize.setHeight(24);

    // Category list header
    QListWidgetItem * catListHeader = new QListWidgetItem(tr("Category"));
    catListHeader->setSizeHint(headerSize);
    catListHeader->setFlags(Qt::NoItemFlags);
    catListHeader->setForeground(QBrush(QColor("#130F2A")));
    catListHeader->setBackground(QBrush(QColor("#F6CB1C")));
    catListHeader->setTextAlignment(Qt::AlignCenter);
    catList->addItem(catListHeader);

    // Populate
    bindingsPages = new QHBoxLayout();
    bindingsPages->setContentsMargins(0, 0, 0, 0);
    rightLayout->addLayout(bindingsPages);
    QWidget * curPage = NULL;
    QVBoxLayout * curLayout = NULL;
    QTableWidget * curTable = NULL;
    bool bFirstPage = true;
    selectedBindTable = NULL;
    bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>();
    bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>();
    for (int i = 0; i < BINDS_NUMBER; i++)
    {
        if (cbinds[i].category != NULL)
        {
            // Add stretch at end of previous layout
            if (curLayout != NULL) curLayout->insertStretch(-1, 1);

            // Category list item
            QListWidgetItem * catItem = new QListWidgetItem(HWApplication::translate("binds (categories)", cbinds[i].category));
            catItem->setSizeHint(catSize);
            catList->addItem(catItem);

            // Create new page
            curPage = new QWidget();
            curLayout = new QVBoxLayout(curPage);
            curLayout->setSpacing(2);
            bindingsPages->addWidget(curPage);
            if (!bFirstPage) curPage->setVisible(false);
        }

        // Description
        if (cbinds[i].description != NULL)
        {
            QLabel * desc = new QLabel(HWApplication::translate("binds (descriptions)", cbinds[i].description));
            curLayout->addWidget(desc, 0);
            QFrame * divider = new QFrame();
            divider->setFrameShape(QFrame::HLine);
            divider->setFrameShadow(QFrame::Plain);
            curLayout->addWidget(divider, 0);
        }

        // New table
        if (cbinds[i].category != NULL || cbinds[i].description != NULL)
        {
            curTable = new QTableWidget(0, 2);
            curTable->verticalHeader()->setVisible(false);
            curTable->horizontalHeader()->setVisible(false);
            curTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
            curTable->verticalHeader()->setDefaultSectionSize(rowHeight);
            curTable->setShowGrid(false);
            curTable->setStyleSheet("QTableWidget { border: none; } ");
            curTable->setSelectionBehavior(QAbstractItemView::SelectRows);
            curTable->setSelectionMode(QAbstractItemView::SingleSelection);
            curTable->setFocusPolicy(Qt::NoFocus);
            connect(curTable, SIGNAL(itemSelectionChanged()), this, SLOT(bindSelectionChanged()));
            connect(curTable, SIGNAL(itemClicked(QTableWidgetItem *)), this, SLOT(bindCellClicked(QTableWidgetItem *)));
            curLayout->addWidget(curTable, 0);
        }

        // Hidden combo box
        QComboBox * comboBox = CBBind[i] = new QComboBox(curTable);
        comboBox->setModel((QAbstractItemModel*)DataManager::instance().bindsModel());
        comboBox->setVisible(false);
        comboBox->setFixedWidth(200);

        // Table row
        int row = curTable->rowCount();
        QTableWidgetItem * nameCell = new QTableWidgetItem(HWApplication::translate("binds", cbinds[i].name));
        nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        curTable->insertRow(row);
        curTable->setItem(row, 0, nameCell);
        QTableWidgetItem * bindCell = new QTableWidgetItem(comboBox->currentText());
        bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        curTable->setItem(row, 1, bindCell);
        curTable->resizeColumnsToContents();
        curTable->setFixedHeight(curTable->verticalHeader()->length() + 10);

        // Updates the text in the table cell
        connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(bindChanged(const QString &)));

        // Map combo box and that row's cells to each other
        bindComboBoxCellMappings->insert(comboBox, bindCell);
        bindCellComboBoxMappings->insert(nameCell, comboBox);
        bindCellComboBoxMappings->insert(bindCell, comboBox);
    }
Example #11
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());
    }
}
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);
}
DocumentMetaConfigurationPage::DocumentMetaConfigurationPage(RosegardenDocument *doc,
        QWidget *parent) :
    TabbedConfigurationPage(doc, parent)
{
    m_headersPage = new HeadersConfigurationPage(this, doc);
    addTab(m_headersPage, tr("Headers"));

    Composition &comp = doc->getComposition();
    std::set
    <TrackId> usedTracks;

    int audioSegments = 0, internalSegments = 0;
    for (Composition::iterator ci = comp.begin();
            ci != comp.end(); ++ci) {
        usedTracks.insert((*ci)->getTrack());
        if ((*ci)->getType() == Segment::Audio)
            ++audioSegments;
        else
            ++internalSegments;
    }

    QFrame *frame = new QFrame(m_tabWidget);
    frame->setContentsMargins(10, 10, 10, 10);
    QGridLayout *layout = new QGridLayout(frame);
    layout->setSpacing(5);

    layout->addWidget(new QLabel(tr("Filename:"), frame), 0, 0);
    layout->addWidget(new QLabel(doc->getTitle(), frame), 0, 1);

    layout->addWidget(new QLabel(tr("Formal duration (to end marker):"), frame), 1, 0);
    timeT d = comp.getEndMarker();
    RealTime rtd = comp.getElapsedRealTime(d);
    layout->addWidget(new QLabel(durationToString(comp, 0, d, rtd), frame), 1, 1);

    layout->addWidget(new QLabel(tr("Playing duration:"), frame), 2, 0);
    d = comp.getDuration();
    rtd = comp.getElapsedRealTime(d);
    layout->addWidget(new QLabel(durationToString(comp, 0, d, rtd), frame), 2, 1);

    layout->addWidget(new QLabel(tr("Tracks:"), frame), 3, 0);
    layout->addWidget(new QLabel(tr("%1 used, %2 total")
                                 .arg(usedTracks.size())
                                 .arg(comp.getNbTracks()),
                                 frame), 3, 1);

    layout->addWidget(new QLabel(tr("Segments:"), frame), 4, 0);
    layout->addWidget(new QLabel(tr("%1 MIDI, %2 audio, %3 total")
                                 .arg(internalSegments)
                                 .arg(audioSegments)
                                 .arg(internalSegments + audioSegments),
                                 frame), 4, 1);

    layout->setRowStretch(5, 2);

    addTab(frame, tr("Statistics"));

    frame = new QFrame(m_tabWidget);
    frame->setContentsMargins(10, 10, 10, 10);
    layout = new QGridLayout(frame);
    layout->setSpacing(5);

    QTableWidget *table = new QTableWidget(1, 11, frame); // , "Segment Table"
    table->setObjectName("StyledTable");
    table->setAlternatingRowColors(true);
    //table->setSelectionMode(QTableWidget::NoSelection);
    table->setSelectionBehavior( QAbstractItemView::SelectRows );
    table->setSelectionMode( QAbstractItemView::SingleSelection );
    table->setSortingEnabled(true);

    table->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr("Type")));    // p1=column
    table->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr("Track")));
    table->setHorizontalHeaderItem( 2, new QTableWidgetItem( tr("Label")));
    table->setHorizontalHeaderItem( 3, new QTableWidgetItem( tr("Time")));
    table->setHorizontalHeaderItem( 4, new QTableWidgetItem( tr("Duration")));
    table->setHorizontalHeaderItem( 5, new QTableWidgetItem( tr("Events")));
    table->setHorizontalHeaderItem( 6, new QTableWidgetItem( tr("Polyphony")));
    table->setHorizontalHeaderItem( 7, new QTableWidgetItem( tr("Repeat")));
    table->setHorizontalHeaderItem( 8, new QTableWidgetItem( tr("Quantize")));
    table->setHorizontalHeaderItem( 9, new QTableWidgetItem( tr("Transpose")));
    table->setHorizontalHeaderItem( 10, new QTableWidgetItem( tr("Delay")));

    //table->setNumRows(audioSegments + internalSegments);
    table->setRowCount(audioSegments + internalSegments);

    table->setColumnWidth(0, 50);
    table->setColumnWidth(1, 50);
    table->setColumnWidth(2, 150);
    table->setColumnWidth(3, 80);
    table->setColumnWidth(4, 80);
    table->setColumnWidth(5, 80);
    table->setColumnWidth(6, 80);
    table->setColumnWidth(7, 80);
    table->setColumnWidth(8, 80);
    table->setColumnWidth(9, 80);
    table->setColumnWidth(10, 80);

    int i = 0;

    for (Composition::iterator ci = comp.begin();
            ci != comp.end(); ++ci) {

        Segment *s = *ci;

        table->setItem(i, 0, new SegmentDataItem
                       (table,
                        s->getType() == Segment::Audio ?
                        tr("Audio") : tr("MIDI")));

        table->setItem(i, 1, new SegmentDataItem
                       (table,
                        QString("%1").arg(s->getTrack() + 1)));

        QPixmap colourPixmap(16, 16);
        Colour colour =
            comp.getSegmentColourMap().getColourByIndex(s->getColourIndex());
        colourPixmap.fill(GUIPalette::convertColour(colour));

        table->setItem(i, 2,
                       new QTableWidgetItem( colourPixmap, strtoqstr(s->getLabel())) );
//        new QTableWidgetItem(table, QTableWidgetItem::Never,
        //                         strtoqstr(s->getLabel()),
        //                               colourPixmap));

        table->setItem(i, 3, new SegmentDataItem
                       (table,
                        QString("%1").arg(s->getStartTime())));

        table->setItem(i, 4, new SegmentDataItem
                       (table,
                        QString("%1").arg(s->getEndMarkerTime() -
                                          s->getStartTime())));

        std::set<long> notesOn;
        std::multimap<timeT, long> noteOffs;
        int events = 0, notes = 0, poly = 0, maxPoly = 0;

        for (Segment::iterator si = s->begin();
                s->isBeforeEndMarker(si); ++si) {
            ++events;
            if ((*si)->isa(Note::EventType)) {
                ++notes;
                timeT startTime = (*si)->getAbsoluteTime();
                timeT endTime = startTime + (*si)->getDuration();
                if (endTime == startTime) continue;
                while (!noteOffs.empty() &&
                        (startTime >= noteOffs.begin()->first)) {
                    notesOn.erase(noteOffs.begin()->second);
                    noteOffs.erase(noteOffs.begin());
                }
                long pitch = 0;
                (*si)->get<Int>(BaseProperties::PITCH, pitch);
                notesOn.insert(pitch);
                noteOffs.insert(std::multimap<timeT, long>::value_type(endTime, pitch));
                poly = notesOn.size();
                if (poly > maxPoly) maxPoly = poly;
            }
        }

        table->setItem(i, 5, new SegmentDataItem
                       (table,
                        QString("%1").arg(events)));

        table->setItem(i, 6, new SegmentDataItem
                       (table,
                        QString("%1").arg(maxPoly)));

        table->setItem(i, 7, new SegmentDataItem
                       (table,
                        s->isRepeating() ? tr("Yes") : tr("No")));

        timeT discard;

        if (s->getQuantizer() && s->hasQuantization()) {
            timeT unit = s->getQuantizer()->getUnit();
            table->setItem(i, 8, new SegmentDataItem
                           (table,
                            NotationStrings::makeNoteMenuLabel
                            (unit, true, discard, false)));
        } else {
            table->setItem(i, 8, new SegmentDataItem
                           (table,
                            tr("Off")));
        }

        table->setItem(i, 9, new SegmentDataItem
                       (table,
                        QString("%1").arg(s->getTranspose())));

        if (s->getDelay() != 0) {
            if (s->getRealTimeDelay() != RealTime::zeroTime) {
                table->setItem(i, 10, new SegmentDataItem
                               (table,
                                QString("%1 + %2 ms")
                                .arg(NotationStrings::makeNoteMenuLabel
                                     (s->getDelay(), true, discard, false))
                                .arg(s->getRealTimeDelay().sec * 1000 +
                                     s->getRealTimeDelay().msec())));
            } else {
                table->setItem(i, 10, new SegmentDataItem
                               (table,
                                NotationStrings::makeNoteMenuLabel
                                (s->getDelay(), true, discard, false)));
            }
        } else if (s->getRealTimeDelay() != RealTime::zeroTime) {
            table->setItem(i, 10, new SegmentDataItem
                           (table,
                            QString("%2 ms")
                            .arg(s->getRealTimeDelay().sec * 1000 +
                                 s->getRealTimeDelay().msec())));
        } else {
            table->setItem(i, 10, new SegmentDataItem
                           (table,
                            tr("None")));
        }

        ++i;
    }

    layout->addWidget(table, 0, 0);

    addTab(frame, tr("Segment Summary"));

}
Example #14
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);
}