Esempio n. 1
0
void PublicTalks::beforePublicTalkComboBoxShown(int rownumber)
{
    // themes combobox
    cPersonComboBox *c = static_cast<cPersonComboBox *>(maintable->cellWidget(rownumber,2));
    cPersonComboBox *speakerCombo = static_cast<cPersonComboBox *>(maintable->cellWidget(rownumber,3));

    QString currentThemeText = c->currentText();
    QTableWidget *table;
    cpersons cp;
    person *speaker = cp.getPerson(speakerCombo->currentText());
    if (speaker) {
        // the speaker selected --> will be shown speaker's themes
        table = this->getSpeakerPublicTalks(0,speaker->id, currentThemeText);
    } else {
        // no speaker selected  --> all themes will be shown
        table = this->getPublicTalksbyLang(currentThemeText);
    }

    //    schoolComboBox *sc = static_cast<schoolComboBox *>(ui->tableSchoolEdit->cellWidget(row,col));
    qDebug() << QString::number(table->rowCount());
    table->setSortingEnabled(true);
    table->sortByColumn(0,Qt::AscendingOrder);
    table->verticalHeader()->hide();
    table->setColumnWidth(0,40);
    table->setColumnWidth(1,200);
    table->setColumnWidth(2,80);
    table->setMinimumWidth(340);
    c->clear();
    c->setModel(table->model());
    c->setView(table);
    c->setModelColumn(1);

    c->setCurrentIndex(c->findText(currentThemeText,Qt::MatchExactly));
}
Esempio n. 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;
}
Esempio n. 3
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;
}
Esempio n. 4
0
/**
  * @brief Updates the resolver pool display.
  */
void OpenNIC::updateResolverPool(QStringList resolverPool)
{
	/* @brief <status>;<score>;<kind>;<hostAddress>; */

	QTableWidget* table = ui->resolverPoolTable;
	double minScore,maxScore;
	scoreMinMax(resolverPool, minScore, maxScore);
	table->setRowCount(resolverPool.count());
	for(int row=0; row < resolverPool.count(); row++ )
	{
		QStringList elements = resolverPool.at(row).split(";");
		QString ip		= elements.at(3);
		QString kind	= elements.at(2);
		QString score	= elements.at(1);
		QString status	= elements.at(0);
		QString statusIcon;
		if (status == "R")
		{
			status = tr("FAIL");
			statusIcon = ":/images/status-red.png";
		}
		else if (status == "G")
		{
			status = tr("OK");
			statusIcon = ":/images/status-green.png";
		}
		else if (status == "Y")
		{
			status = tr("WARN");
			statusIcon = ":/images/status-yellow.png";
		}
		table->setItem(row,3,new QTableWidgetItem(ip));
		table->setItem(row,2,new QTableWidgetItem(kind));
#if 0
		table->setItem(row,1,new QTableWidgetItem(score));
#else
		QProgressBar* bar = new QProgressBar();
		bar->setRange((int)(minScore*1000.0),(int)(maxScore*1000.0));
		bar->setValue((int)(score.toDouble()*1000.0));
		table->setCellWidget(row,1,bar);
#endif
		table->setItem(row,0,new QTableWidgetItem(QIcon(statusIcon),status));
	}
	table->resizeColumnsToContents();
	table->resizeRowsToContents();
	table->setSortingEnabled(true);
	table->sortByColumn(1,Qt::DescendingOrder);
}
Esempio n. 5
0
QTableWidget *PublicTalks::getPersons(int type)
{
    std::vector<sql_item> vt;
//    QString str = "SELECT yleisokokous.pvm, henkilot.nimi, henkilot.id, henkilot.etunimi "
//                  "FROM henkilot LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.puheenjohtaja_id "
//                  "WHERE ohjelmatyypit & " + QString::number(type) + " GROUP BY henkilot.id";
    QString str = "SELECT yleisokokous.pvm, henkilot.nimi, henkilot.id, henkilot.etunimi "
                  "FROM henkilot LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.";
    if(type == person::chairman) {
        str.append("puheenjohtaja_id");
    } else {
        str.append("vt_lukija_id");
    }
    str.append(" WHERE ohjelmatyypit & " + QString::number(type) + " GROUP BY henkilot.id");

    vt = sql.selectSql(str);

    QTableWidget *vttable = new QTableWidget();
    vttable->horizontalHeader()->show();
    vttable->verticalHeader()->setVisible(false);
    vttable->setColumnCount(3);
    vttable->setColumnHidden(0,true);
    vttable->setColumnWidth(1,150);
    vttable->setColumnWidth(2,100);
    vttable->setMinimumWidth(270);
    vttable->setSortingEnabled(true);

    vttable->setHorizontalHeaderItem(1,new QTableWidgetItem(QObject::tr("Name")));
    vttable->setHorizontalHeaderItem(2,new QTableWidgetItem(QObject::tr("Last")));

    vttable->setRowCount(vt.size()+1);
    vttable->setItem(0,0,new QTableWidgetItem(""));
    for(unsigned int i = 0; i < vt.size(); i++) {
        vttable->setItem(i+1,0,new QTableWidgetItem(vt[i].getValue("id")));
        vttable->setItem(i+1,1,new QTableWidgetItem(vt[i].getValue("nimi") + " " + vt[i].getValue("etunimi")));
        vttable->setItem(i+1,2,new QTableWidgetItem(vt[i].getValue("pvm")));
    }
    return vttable;
}
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"));

}
Esempio n. 7
0
void PublicTalks::beforeSpeakerShown(QString name, cPersonComboBox *c)
{
    //cPersonComboBox *c = combo;

    // get speakers for comboBox
    //cPersonComboBox *combo = static_cast<cPersonComboBox *>(maintable->cellWidget(combo->property("currentrow").toInt(),3));
    cPersonComboBox *themeCombo = static_cast<cPersonComboBox *>(maintable->cellWidget(c->property("currentrow").toInt(),2));
    qDebug() << "currentRow1:" << c->currentText() << "rownumber:" << c->property("currentrow") << name;
    if (c) {
        qDebug() << "combo ok";
    } else {
        qDebug() << "combo false";
    }

    QTableWidget *table = new QTableWidget(0,4);
    table->setColumnHidden(0,true);
    table->setColumnWidth(3,0);
    std::vector<sql_item> speakers;
    if(themeCombo->currentText() == "") {
        // ei teemaa valittu
        speakers = sql.selectSql("SELECT henkilot.*,yleisokokous.pvm "
                                 "FROM henkilot "
                                 "LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.puhuja_id "
                                 "WHERE henkilot.ohjelmatyypit & 512 GROUP BY henkilot.id ORDER BY nimi");
    } else {
        // teema valittu --> haetaan teeman sopivat puhujat
        speakers = sql.selectSql("SELECT henkilot.*,P_Esitelmat.aihe_id,yleisokokous.pvm "
                                 "FROM henkilot "
                                 "LEFT JOIN P_Esitelmat ON henkilot.id = P_Esitelmat.puhuja_id "
                                 "LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.puhuja_id "
                                 " WHERE P_Esitelmat.aihe_id = '" +
                                 QString::number(getThemeId(themeCombo->currentText())) +
                                 "' AND henkilot.ohjelmatyypit & 512 GROUP BY henkilot.id ORDER BY nimi, etunimi");
    }
    table->setRowCount(speakers.size()+1);
    int currentRow = 0;
    for(unsigned int i = 0; i < speakers.size(); i++) {
        table->setItem(i+1,0,new QTableWidgetItem( speakers[i].getValue("id") ));
        table->setItem(i+1,1,new QTableWidgetItem( speakers[i].getValue("nimi") + ", " + speakers[i].getValue("etunimi")) );
        table->setItem(i+1,2,new QTableWidgetItem( speakers[i].getValue("pvm")) );
        table->setItem(i+1,3,new QTableWidgetItem( speakers[i].getValue("etunimi") + " " + speakers[i].getValue("nimi")) );

        if(c->currentText() == table->item(i+1,3)->text()) {
            QFont boldfont(table->item(i+1,1)->font().family(),
                           table->item(i+1,1)->font().pointSize(),
                           QFont::Bold);
            table->item(i+1,1)->setFont(boldfont);
            currentRow = i+1;
        }
    }
    table->verticalHeader()->hide();
    table->setColumnWidth(1,150);
    table->setColumnWidth(2,100);
    table->setMinimumWidth(280);

    c->clear();
    c->setModel(table->model());
    c->setView(table);
    c->setModelColumn(1);
    c->setCurrentIndex(currentRow);
    table->setSortingEnabled(true);
    table->sortByColumn(1,Qt::AscendingOrder);
}