void QKeyValueListView::listUpdate_slot(void) { int i, n; ListMap::iterator it; QColor clCL1, clCL2; QColor clB1, clB2; int fontSize = 8; int rowHeight = 20; clCL1 = QColor(0x00, 0x00, 0xFF); clCL2 = QColor(0x00, 0x00, 0x00); clB1 = QColor(0xFF, 0xFF, 0xFF); clB2 = QColor(0xE0, 0xE0, 0xE0); m_mutex->lock(); n = m_data.size(); setRowCount(n); setColumnCount(2); for(i=0, it=m_data.begin(); it!=m_data.end(); i++, it++) { // set name cell if( this->item(i, 0) != NULL ) { this->item(i, 0)->setText(it.key()); } else { QTableWidgetItem* item = new QTableWidgetItem(); item->setText(it.key()); item->setTextColor(clCL1); if( i % 2 == 0 ) item->setBackgroundColor(clB1); else item->setBackgroundColor(clB2); item->setFont(QFont("", fontSize)); this->setItem(i, 0, item); } // set value cell if( this->item(i, 1) != NULL ) { this->item(i, 1)->setText(it.value()); } else { QTableWidgetItem* item = new QTableWidgetItem(); item->setText(it.value()); item->setTextColor(clCL2); if( i % 2 == 0 ) item->setBackgroundColor(clB1); else item->setBackgroundColor(clB2); item->setFont(QFont("", fontSize)); this->setItem(i, 1, item); } setRowHeight(i, rowHeight); } m_mutex->unlock(); }
void SearchResultWidget::currentRowColumnChanged(int currentRow, int /*currentColumn*/, int previousRow, int /*previousColumn*/) { if (currentRow == previousRow) { return; } for (int col = 0; col < 3; ++col) { QTableWidgetItem* previousRowItem = searchTable->item(previousRow, col); QTableWidgetItem* currentRowItem = searchTable->item(currentRow, col); if (previousRowItem && col != 0) { QColor color = previousRowItem->data(Qt::UserRole + 15).value<QColor>(); if (color.isValid()) { previousRowItem->setBackgroundColor(color); } } if (currentRowItem) { QString text = currentRowItem->text(); if (col == 2 && !viewedItems.contains(text)) { viewedItems << text; } currentRowItem->setData(Qt::UserRole + 15, currentRowItem->backgroundColor()); currentRowItem->setBackgroundColor(QColor(Qt::green).lighter(170)); } } }
//刷新表格 void PlayList::tableUpdate() { //这里不能调用此类中任何一个操作元素的函数 //否则将造成循环递归 ui->playListTable->clear(); ui->playListTable->setRowCount(getLength());//删除项目后,更改表格总行数,防止出现空白行。 int count = fileList.size();//循环效率优化 //重新生成表格项目 for (int i = 0; i < count; i++) { QString fileName = fileList[i]; QFileInfo fileInfo(fileName); QTableWidgetItem *item = new QTableWidgetItem(fileInfo.fileName()); QTableWidgetItem *timeItem = new QTableWidgetItem(timeList[i]); if (i == curIndex) { item->setBackgroundColor(QColor(128, 255, 0, 128)); timeItem->setBackgroundColor(QColor(128, 255, 0, 128)); } ui->playListTable->setItem(i, 0, item); ui->playListTable->setItem(i, 1, timeItem); } }
void DetailsViewer::setStatus(const DNSData *data) { QString recordType = data->recordType(); QColor color = m_node->getColorForStatus(data->DNSSECStatus()).lighter(175); QTableWidgetItem *item = m_rows[recordType]->status; item->setBackgroundColor(color); item->setText(data->DNSSECStringStatuses().join(", ")); item = m_rows[recordType]->data; item->setBackgroundColor(color); item->setText(QStringList(data->data()).join(",\n")); m_rows[recordType]->label->setBackgroundColor(color); }
void StochasticProcessWidget::updateColors() { int distCount = process->getNumStates(); QColor weakestDistColor; QColor weakDistColor; QColor avgDistColor; QColor strongDistColor; for (int i = 0; i < distCount; i++) { int hueValue = (int)round(255.0 / ((double)distCount / (double)i)); weakDistColor.setHsv(hueValue, 40, 245); weakestDistColor.setHsv(hueValue, 15, 245); avgDistColor.setHsv(hueValue, 100, 255); strongDistColor.setHsv(hueValue, 150, 255); QPen curvePen(QBrush(strongDistColor), 3.0, Qt::SolidLine); infCurves[i]->setPen(curvePen); supCurves[i]->setPen(curvePen); QPen avgPen(QBrush(avgDistColor), 3.0, Qt::DashLine); avgMarkers[i]->setLinePen(avgPen); QPen stdDevPen(QBrush(avgDistColor), 3.0, Qt::DotLine); stdDevMarkers[i].first->setLinePen(stdDevPen); stdDevMarkers[i].second->setLinePen(stdDevPen); for (int j = 0; j <= 4; j++) { distGraphTable->item(j, i)->setBackgroundColor(weakDistColor); } for (int j = 0; j < distTable->rowCount(); j++) { QTableWidgetItem *item = distTable->item(j, i); if (item) { if (item->text() == "0\n0") { item->setBackgroundColor(weakestDistColor); } else { item->setBackgroundColor(weakDistColor); } } } } distGraph->replot(); }
void VtkColorTable::addTableRow(int row, const Point & point) { mainTable->insertRow(row); QTableWidgetItem * newItem = new QTableWidgetItem(tr("%1").arg(point.scalarValue)); mainTable->setItem(row, 0, newItem); newItem = new QTableWidgetItem(tr("%1").arg(point.color.red())); mainTable->setItem(row, 1, newItem); newItem = new QTableWidgetItem(tr("%1").arg(point.color.green())); mainTable->setItem(row, 2, newItem); newItem = new QTableWidgetItem(tr("%1").arg(point.color.blue())); mainTable->setItem(row, 3, newItem); newItem = new QTableWidgetItem(); newItem->setBackgroundColor(point.color); newItem->setFlags(Qt::ItemIsEnabled); mainTable->setItem(row, 4, newItem); newItem = new QTableWidgetItem(tr("%1").arg(point.midpoint)); mainTable->setItem(row, 5, newItem); newItem = new QTableWidgetItem(tr("%1").arg(point.sharpness)); mainTable->setItem(row, 6, newItem); }
TupLayerIndex::TupLayerIndex(int sceneIndex, QWidget *parent) : QTableWidget(0, 1, parent), k(new Private) { #ifdef K_DEBUG TINIT; #endif k->sceneIndex = sceneIndex; setSelectionMode(QAbstractItemView::SingleSelection); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QTableWidgetItem *prototype = new QTableWidgetItem; prototype->setTextAlignment(Qt::AlignCenter); prototype->setBackgroundColor(palette().text().color()); prototype->setTextColor(palette().background().color()); setItemPrototype(prototype); setHorizontalHeaderLabels(QStringList() << tr("Layers")); verticalHeader()->hide(); setHorizontalHeader(new TupLayerIndexHeader(this)); setItemDelegate(new TupLayerIndexItemDelegate(this)); connect(this, SIGNAL(cellClicked(int, int)), this, SLOT(setLocalRequest(int, int))); }
void VideoWindow::highlight(int ms) { for(int r=0; r < this->eventsPositionInMiliseconds.size(); r++){ QTableWidgetItem* item = this->ui->sequence->item(r,0); if(this->eventsPositionInMiliseconds.at(r) <= ms+125){ if(this->eventsPositionInMiliseconds.at(r) >= ms-125) item->setBackgroundColor(Qt::green); else item->setBackgroundColor(QColor(153,255,255)); } else { QPalette p; if(r%2==0) item->setBackground(p.base()); else item->setBackground(p.alternateBase()); } } }
void LogEditorWindow::find() { clear(); // 0 = "Speed" // 1 = "Heart rate" // 2 = "Power" // 3 = "Cadence" // 4 = "Altitude" // 5 = "Latitude" // 6 = "Longitude" // 7 = "Temperature" const int index = _field_selection->currentIndex(); const double value = _search_value->value(); _search_result_indecies.clear(); for (int r=0; r < _table->rowCount(); ++r) { QTableWidgetItem* item = _table->item(r, index + 2); if (searchComparison(item->text().toDouble(), value)) { item->setBackgroundColor(Qt::red); _search_result_indecies.push_back(r); } } // Scroll to the first search result if (_search_result_indecies.size() > 0) { _table->verticalScrollBar()->setValue(_search_result_indecies[0]); } _search_result_index = 0; }
void ListingTracePane::updateListingTrace() { // tableWidget depends on whether we are in the OS or a program QTableWidget *tableWidget; if (Sim::trapped) { tableWidget = ui->listingPepOsTraceTableWidget; ui->listingPepOsTraceTableWidget->show(); ui->listingTraceTableWidget->hide(); } else { tableWidget = ui->listingTraceTableWidget; ui->listingPepOsTraceTableWidget->hide(); ui->listingTraceTableWidget->show(); } for (int i = highlightedItemList.size() - 1; i >= 0; i--) { highlightedItemList.at(i)->setBackgroundColor(Qt::white); highlightedItemList.at(i)->setTextColor(Qt::black); highlightedItemList.removeLast(); } if (Pep::memAddrssToAssemblerListing->contains(Sim::programCounter)) { QTableWidgetItem *highlightedItem = tableWidget->item(Pep::memAddrssToAssemblerListing->value(Sim::programCounter), 1); highlightedItem->setBackgroundColor(QColor(56, 117, 215)); highlightedItem->setTextColor(Qt::white); highlightedItemList.append(highlightedItem); tableWidget->scrollToItem(highlightedItem); } tableWidget->horizontalScrollBar()->setValue(tableWidget->horizontalScrollBar()->minimum()); }
//Method to set week days void MonthView::SetWeekDays() { //Headers int weekDay = 1; for(int i = 0 ;i < 7;i++) { //Set column width ui->tblHeader->setColumnWidth(i,60); ui->tblDates->setColumnWidth(i,60); QTableWidgetItem *item = new QTableWidgetItem(); QString name = QDate::shortDayName(weekDay++); item->setText(name); item->setTextAlignment(Qt::AlignTop | Qt::AlignHCenter); if( i >4) { item->setBackgroundColor(QColor::fromRgb(201,72,135)); item->setForeground(QBrush(QColor::fromRgb(136,36,89))); } ui->tblHeader->setItem(0,i,item); } //Add the column for weekly totals ui->tblHeader->setColumnWidth(7,120); ui->tblDates->setColumnWidth(7,120); QTableWidgetItem *item = new QTableWidgetItem(); item->setText("Weekly Totals"); item->setTextAlignment(Qt::AlignTop | Qt::AlignHCenter); ui->tblHeader->setItem(0,7,item); }
void StochasticProcessWidget::updateTransitionColors() { int distCount = distGraphTable->columnCount() - 1; QColor cellColor; int rowLb = Lb(transitionMatrix, 1); int colLb = Lb(transitionMatrix, 2); for (int i = 0; i < distCount; i++) { for (int j = 0; j < transitionTable->columnCount(); j++) { QTableWidgetItem *item = transitionTable->item(i, j); if (!item) { continue; } double value = _double(mid(transitionMatrix[rowLb + i][colLb + j])); int hueValue = (int)round(255.0 / ((double)distCount / (double)i)); cellColor.setHsv(hueValue, (int)floor(90.0 * sqrt(value)), 255); item->setBackgroundColor(cellColor); } } }
void SpectraIdentificationViewWidget::addTextItemToBottomRow_(const QString& text, Size column_index, const QColor& c) { QTableWidgetItem * item = table_widget_->itemPrototype()->clone(); item->setText(text); item->setBackgroundColor(c); table_widget_->setItem(table_widget_->rowCount() - 1, column_index, item); }
void SpectraIdentificationViewWidget::addDoubleItemToBottomRow_(const double d, Size column_index, const QColor& c) { QTableWidgetItem * item = table_widget_->itemPrototype()->clone(); item->setData(Qt::DisplayRole, d); item->setBackgroundColor(c); table_widget_->setItem(table_widget_->rowCount() - 1, column_index, item); }
void ListingTracePane::setDebuggingState(bool b) { QTableWidget *tableWidget; if (Sim::trapped) { tableWidget = ui->listingPepOsTraceTableWidget; ui->listingPepOsTraceTableWidget->show(); ui->listingTraceTableWidget->hide(); } else { tableWidget = ui->listingTraceTableWidget; ui->listingPepOsTraceTableWidget->hide(); ui->listingTraceTableWidget->show(); } for (int i = 0; i < tableWidget->rowCount(); i++) { tableWidget->item(i, 1)->setBackgroundColor(Qt::white); tableWidget->item(i, 1)->setTextColor(Qt::black); } highlightedItemList.clear(); if (b && Pep::memAddrssToAssemblerListing->contains(Sim::programCounter)) { QTableWidgetItem *highlightedItem = tableWidget->item(Pep::memAddrssToAssemblerListing->value(Sim::programCounter), 1); highlightedItem->setBackgroundColor(QColor(56, 117, 215)); highlightedItem->setTextColor(Qt::white); highlightedItemList.append(highlightedItem); tableWidget->scrollToItem(highlightedItem); } tableWidget->horizontalScrollBar()->setValue(tableWidget->horizontalScrollBar()->minimum()); // resizeDocWidth(); }
void MusicAbstractTableWidget::setRowColor(int row, const QColor &color) const { for(int col=0; col<columnCount(); col++) { QTableWidgetItem *it = item(row, col); it->setBackgroundColor(color); } }
//设置行颜色 void MusicList::setRowColor( int row, QColor color ) { for (int i = 0; i < this->columnCount(); ++i) { QTableWidgetItem *item = this->item(row, i); item->setFont(QFont("微软雅黑", 10, QFont::Bold)); item->setBackgroundColor(color); } }
void BitSplit::setSkip(int row){ syncAnimator->stop(); QTableWidgetItem * old = ui.actionsTable->itemAt(row, 1); QTableWidgetItem * current = new QTableWidgetItem(); if(row % 2 == 1) current->setBackgroundColor(QColor(225,225,225)); current->setIcon(*skip); ui.actionsTable->setItem(row, 1, current); delete(old); }
void OgreScriptEditor::PropertyChanged(int row, int column) { QTableWidgetItem *nameItem = propertyTable_->item(row, column - 2); QTableWidgetItem *typeItem = propertyTable_->item(row, column - 1); QTableWidgetItem *valueItem = propertyTable_->item(row, column); if (!nameItem || !typeItem || !valueItem) return; QString newValueString(valueItem->text()); newValueString.trimmed(); bool valid = true; ///\todo Validity check for texture names. QString type = typeItem->text(); if (type != "TEX_1D" && type != "TEX_2D" && type != "TEX_3D" && type != "TEX_CUBEMAP") { int i = 0, j = 0; while(j != -1 && valid) { j = newValueString.indexOf(' ', i); QString newValue = newValueString.mid(i, j == -1 ? j : j - i); if (!newValue.isEmpty()) newValue.toFloat(&valid); i = j + 1; } } if (valid) { valueItem->setBackgroundColor(QColor(QColor(81, 255, 81))); QMap<QString, QVariant> typeValuePair; typeValuePair[typeItem->text()] = newValueString; materialProperties_->setProperty(nameItem->text().toLatin1(), QVariant(typeValuePair)); ValidateScriptName(lineEditName_->text()); } else { valueItem->setBackgroundColor(QColor(255, 73, 73)); buttonSaveAs_->setEnabled(false); } propertyTable_->setCurrentItem(valueItem, QItemSelectionModel::Deselect); }
void info::set_memo_table_item(int x, int y, QColor color) { if (x < ui->tw_memo->rowCount() && y < ui->tw_memo->columnCount() && x >= 0 && y >= 0) { QTableWidgetItem *item = new QTableWidgetItem; item->setBackgroundColor(color); ui->tw_memo->setItem(x, y, item); } }
void SkatLiveGameRoundTable::addRound(Database::Round *round){ Q_ASSERT(round != 0); Database::Skat::SkatRound* skatround = static_cast<Database::Skat::SkatRound*>(round); Q_ASSERT(skatround != 0); this->insertRow(this->rowCount()); for(int i = 0; i<playerlist.size();i++){ QTableWidgetItem* item = new QTableWidgetItem(""); if (skatround->solist()->id() == playerlist.at(i)->id()){ item->setText(QString::number(skatround->points(playerlist.at(i))) + " (S)"); } else{ item->setText(QString::number(skatround->points(playerlist.at(i))) + " (C)"); } if (skatround->points(playerlist.at(i)) == 0){ item->setBackgroundColor(QColor("lightGray")); } if (skatround->points(playerlist.at(i)) > 0){ item->setBackgroundColor(QColor(148,0,0)); } if (skatround->points(playerlist.at(i)) > 24){ item->setBackgroundColor(QColor(188,0,0)); } if (skatround->points(playerlist.at(i)) > 36){ item->setBackgroundColor(QColor(220,0,0)); } if (skatround->points(playerlist.at(i)) > 48){ item->setBackgroundColor(QColor(255,0,0)); } item->setTextAlignment(Qt::AlignCenter); this->setItem(this->rowCount()-1,i,item); } QTableWidgetItem* item = new QTableWidgetItem(QString::number(skatround->roundPoints())); item->setTextAlignment(Qt::AlignCenter); this->setItem(this->rowCount()-1,playerlist.size(),item); QTableWidgetItem* item1 = new QTableWidgetItem(""); item1->setSizeHint(QSize(0,0)); this->setVerticalHeaderItem(this->rowCount()-1,item1); }
void PeriodicTableParser::toTableWidget(QTableWidget *tw, const bool directAsNumber) { tw->clear(); if(directAsNumber) { tw->setColumnCount(9); tw->setRowCount(1); tw->horizontalHeader()->hide(); tw->verticalHeader()->hide(); }else { tw->setColumnCount(column); tw->setRowCount(row); } tw->setEditTriggers(QAbstractItemView::NoEditTriggers); tw->setSelectionMode(QAbstractItemView::NoSelection); tw->setGridStyle(Qt::NoPen); tw->setShowGrid(true); if(directAsNumber) { int row = 0; int column = 0; foreach(Element * el, getSortToNumberListElements()) { tw->setRowCount(row+1); QTableWidgetItem *item = new QTableWidgetItem(); item->setTextAlignment(Qt::AlignCenter); item->setText(QString("%1").arg(el->name)); item->setToolTip(QString("<font size=2 align=left>%1</font>" "<p align=right>" "<b>%2</b><br>" "%3<br>" "%4<br>" "<font size=2>%5</font></p>") .arg(el->number) .arg(el->name) .arg(el->longName) .arg(el->family->name) .arg(el->mass)); item->setBackgroundColor(QColor(el->family->color)); tw->setItem(row, column, item); if(++column % tw->columnCount() == 0) { column = 0; row++; } } }else
void Debugger::setLineBackgroundColor( int row, Qt::GlobalColor color ) { for( int i = 0; i < ui->tableWidgetCode->columnCount(); ++i ) { QTableWidgetItem* pItem = ui->tableWidgetCode->item( row, i ); if( pItem != 0 ) { pItem->setBackgroundColor( QColor( color ) ); } } }
void DownloadAbstractTableWidget::setRowColor(int row, const QColor &color) const { for(int col=0; col<columnCount(); col++) { QTableWidgetItem *it = item(row, col); if(it != nullptr) { it->setBackgroundColor(color); } } }
void MainWindow::recvStatusChanged(Status s) { QString str; str.sprintf("%d %d", s.first, s.second); ui->textEdit->append(str); QTableWidgetItem *item = ui->tableWidget->item(s.second,s.first); if(item){ QColor c = item->backgroundColor(); c.setRed(min(c.red() + 1,255)); item->setBackgroundColor(c); } }
void BitSplit::showSync(){ if(frame>7) frame = 0; QTableWidgetItem * old = ui.actionsTable->itemAt(currentAction, 1); QTableWidgetItem * current = new QTableWidgetItem(); if(color) current->setBackgroundColor(QColor(225,225,225)); current->setIcon(*syncAnimation[frame]); ui.actionsTable->setItem(currentAction, 1, current); delete(old); frame++; }
void MainWnd::SetValid(int row, int column, bool valid) { QColor cvalid(255,255,255); QColor cinvalid(255,100,100); QTableWidgetItem *item = ui->tableWidget->item(row, column); if(!item) { item = new QTableWidgetItem(); ui->tableWidget->setItem(row, column, item); } item->setBackgroundColor(valid ? cvalid : cinvalid); }
void DcmtkSeriesListWidget::updateFilter(const QString & text) { QTableWidgetItem* it; int cur = filterCombo_->currentIndex(); if (text == "") { for (int r=0; r<table->rowCount(); ++r) { for (int c=0; c<table->columnCount(); ++c) { it = table->item(r,c); it->setBackgroundColor(QColor(255, 255, 255, 127)); } } } else { bool foundInRow; for (int r=0; r<table->rowCount(); ++r) { foundInRow = false; for (int c=0; c < table->columnCount(); ++c) { it = table->item(r,c); if ((c == cur) && (it->text().contains(text, Qt::CaseInsensitive))) { foundInRow = true; } it->setBackgroundColor(QColor(255, 255, 255, 127)); } if (foundInRow) { for (int c=0; c<table->columnCount(); ++c) { it = table->item(r,c); // if (it->text().contains(text, Qt::CaseInsensitive)) { if (c == cur) { it->setBackgroundColor(QColor(255, 0, 0, 127)); } else { it->setBackgroundColor(QColor(0, 0, 255, 127)); } } } } } }
void SpectraIdentificationViewWidget::addCheckboxItemToBottomRow_(bool selected, Size column_index, const QColor& c) { QTableWidgetItem * item = table_widget_->itemPrototype()->clone(); if (selected) { item->setCheckState(Qt::Checked); } else { item->setCheckState(Qt::Unchecked); } item->setBackgroundColor(c); table_widget_->setItem(table_widget_->rowCount() - 1, column_index, item); }
void OrganizeCollectionDialog::previewNextBatch() //private slot { const int batchSize = 10; QMap<Meta::TrackPtr, QString> dests = m_trackOrganizer->getDestinations( batchSize ); QMapIterator<Meta::TrackPtr, QString> it( dests ); while( it.hasNext() ) { it.next(); Meta::TrackPtr track = it.key(); QString originalPath = track->prettyUrl(); QString newPath = it.value(); int newRow = ui->previewTableWidget->rowCount(); ui->previewTableWidget->insertRow( newRow ); //new path preview in the 1st column QPalette p = ui->previewTableWidget->palette(); QTableWidgetItem *item = new QTableWidgetItem( newPath ); KColorScheme::adjustBackground( p, KColorScheme::NegativeBackground ); if( QFileInfo( newPath ).exists() ) { item->setBackgroundColor( p.color( QPalette::Base ) ); m_conflict = true; } ui->previewTableWidget->setItem( newRow, 0, item ); //original in the second column item = new QTableWidgetItem( originalPath ); ui->previewTableWidget->setItem( newRow, 1, item ); } if( m_conflict ) { if( ui->overwriteCheck->isChecked() ) ui->conflictLabel->setText( i18n( "There is a filename conflict, existing files will be overwritten." ) ); else ui->conflictLabel->setText( i18n( "There is a filename conflict, existing files will not be changed." ) ); } else ui->conflictLabel->setText(""); // we clear the text instead of hiding it to retain the layout spacing //non-blocking way of updating the preview table. if( dests.count() == batchSize ) QTimer::singleShot( 10, this, SLOT(previewNextBatch()) ); else unsetCursor(); // finished }