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; }
InformationPanel::InformationPanel(QWidget *parent) : ConfiguratorPanel(false, parent) { _name = "Information"; _icon = QIcon(":/res/icons/info.png"); setHeadline("Information"); setDescription("System paths and variables"); QVBoxLayout *l = new QVBoxLayout; l->setMargin(0); setLayout(l); QTableWidget *table = new QTableWidget; table->setFrameShape(QFrame::NoFrame); table->setColumnCount(2); table->verticalHeader()->setVisible(false); table->horizontalHeader()->setStretchLastSection(true); table->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); table->setHorizontalHeaderLabels(QStringList() << "Name" << "Value"); table->setAlternatingRowColors(true); table->setSelectionMode(QAbstractItemView::NoSelection); l->addWidget(table); Seiscomp::Environment *env = Seiscomp::Environment::Instance(); addRow(table, "PATH", getenv("PATH")); addRow(table, "ROOTDIR", env->installDir().c_str()); addRow(table, "DEFAULTCONFIGDIR", env->globalConfigDir().c_str()); addRow(table, "SYSTEMCONFIGDIR", env->appConfigDir().c_str()); addRow(table, "CONFIGDIR", env->configDir().c_str()); addRow(table, "LOGDIR", env->logDir().c_str()); addRow(table, "DATADIR", env->shareDir().c_str()); table->resizeColumnsToContents(); }
ParamCompareDialog::ParamCompareDialog(QMap<QString, UASParameter* >& paramaterList, const QString& filename, QWidget *parent) : QDialog(parent), ui(new Ui::ParamCompareDialog), m_currentList(¶materList), 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())); } }
void TrainLinePanel::__initTableHeader() { int listLineCount = ui->listWidget->count(); for(int i = 0; i < listLineCount;i++) { QTableWidget *tableWidget = new QTableWidget; tableWidget->setAlternatingRowColors(true); tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); // connect(tableWidget,SIGNAL(doubleClicked(QModelIndex)),keyboard,SLOT(show(QModelIndex))); tableWidget->verticalHeader()->setHidden(true); tableWidget->setColumnCount(10); tableWidget->setColumnHidden(9,true); tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setMinimumHeight(30); tableWidget->horizontalHeader()->setMinimumSectionSize(140); QTableWidgetItem* item = new QTableWidgetItem("Station number"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(0,item); item = new QTableWidgetItem("Station id"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(1,item); item = new QTableWidgetItem("Name(EN)"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(2,item); item = new QTableWidgetItem("Name(TH)"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(3,item); item = new QTableWidgetItem("Start time"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(4,item); item = new QTableWidgetItem("Arrive time"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(5,item); item = new QTableWidgetItem("Lng"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(6,item); item = new QTableWidgetItem("Lat"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(7,item); item = new QTableWidgetItem("Sea level"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(8,item); item = new QTableWidgetItem("Rowid"); item->setTextAlignment(Qt::AlignHCenter); tableWidget->setHorizontalHeaderItem(9,item); ui->stackedWidget->addWidget(tableWidget); } // connect(tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(updateDatabase(QTableWidgetItem*))); }
void CurrentPlayDialog::setupTabs() { boost::shared_ptr<ClientGroupCenter> clientGroupCenter = g_DataCenter->createClientGroupCenter(); for(ClientGroupCenter::Iterator it = clientGroupCenter->begin(); it != clientGroupCenter->end(); ++it) { QTableWidget *currentPleyTable = new CurrentPlayTable(*it, m_GroupTab); m_GroupTab->addTab(currentPleyTable, (*it)->getName()); m_IdtoTab.insert((*it)->getId(),currentPleyTable); currentPleyTable->setAlternatingRowColors(true); QPalette pal; pal.setColor(QPalette::AlternateBase,QColor(225,255,255)); currentPleyTable->setPalette(pal); } }
void CLOAD_WORKSHEET:: CreateTable(QTabWidget * tabWidget, QString tabName, quint64 rowCount) { quint64 columnCount = 12; // Table attributes QTableWidget * tableWidget = new QTableWidget(); QHeaderView * header = tableWidget->horizontalHeader(); header->setSectionResizeMode(QHeaderView::Stretch); header->setStretchLastSection(true); tableWidget->setAlternatingRowColors(true); tableWidget->setRowCount(rowCount); tableWidget->setColumnCount(columnCount); // set table column header tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name")); tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value")); tableWidget->setHorizontalHeaderItem(2,new QTableWidgetItem("Value Range")); tableWidget->setHorizontalHeaderItem(3,new QTableWidgetItem(" Type ")); tableWidget->setHorizontalHeaderItem(4,new QTableWidgetItem("Conversion")); tableWidget->setHorizontalHeaderItem(5,new QTableWidgetItem("Byte Offset")); tableWidget->setHorizontalHeaderItem(6,new QTableWidgetItem("Bit Offset")); tableWidget->setHorizontalHeaderItem(7,new QTableWidgetItem("Bit Size")); tableWidget->setHorizontalHeaderItem(8,new QTableWidgetItem("Field Used")); tableWidget->setHorizontalHeaderItem(9,new QTableWidgetItem("Low Byte First")); tableWidget->setHorizontalHeaderItem(10,new QTableWidgetItem("Group")); tableWidget->setHorizontalHeaderItem(11,new QTableWidgetItem("Encoding Factor")); tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(6, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(7, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(8, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(9, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(10, QHeaderView::ResizeToContents); tableWidget->horizontalHeader()->setSectionResizeMode(11, QHeaderView::ResizeToContents); // add tab tabWidget->addTab(tableWidget, tabName); }
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(); }
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; }
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")); }
void InfoDialog::setupUi(const Tags &tags) { int row = 0; QVBoxLayout *layout = new QVBoxLayout; layout->setContentsMargins(0,0,0,0); setWindowTitle(tr("EXIF information")); if (!tags.fileName().isEmpty()) setWindowTitle(windowTitle() + " - " + QFileInfo(tags.fileName()).fileName()); setWindowIcon(QIcon(":images/exif_info")); if (tags.size()) { QMapIterator<int, QPair<Tag, Data> > tag(tags); QTableWidget *tableWidget = new QTableWidget(tags.size(),2,this); tableWidget->setAlternatingRowColors(true); tableWidget->verticalHeader()->setVisible(false); tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); tableWidget->setSelectionMode(QAbstractItemView::NoSelection); tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem(tr("Tag"))); tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem(tr("Value"))); tableWidget->horizontalHeader()->setStretchLastSection(true); while (tag.hasNext()) { QTableWidgetItem *item; QPair<Tag,Data> exifValue = tag.next().value(); item = new QTableWidgetItem(exifValue.first.title); item->setToolTip(exifValue.first.description.split(". ",QString::SkipEmptyParts).join("\n")); tableWidget->setItem(row,0,item); item = new QTableWidgetItem(exifValue.second.readableValue); item->setToolTip(exifValue.first.description.split(". ",QString::SkipEmptyParts).join("\n")); tableWidget->setItem(row++,1,item); } tableWidget->resizeColumnsToContents(); tableWidget->resizeRowsToContents(); layout->addWidget(tableWidget); } else { QLabel *label = new QLabel(tr("No EXIF information available"),this); label->setAlignment(Qt::AlignCenter); layout->addWidget(label); } #ifdef Q_WS_MAC QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok,Qt::Horizontal,this); connect(buttonBox,SIGNAL(accepted()),this,SLOT(close())); layout->addWidget(buttonBox); #endif setLayout(layout); resize(600,400); }
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())); }
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); }