void DataMergeGui::addMergeList() { for (int i = 0; i < importTree->topLevelItemCount(); i++) { QTreeWidgetItem *topItem = importTree->topLevelItem(i); for (int i = 0; i < topItem->childCount(); i++) { QTreeWidgetItem *childItem = topItem->child(i); if (childItem->checkState(0) == Qt::Checked) { QString crtText = topItem->text(0); if (flag == 0) { RasterElement *pFisrtElement = filenameMap[crtText.toStdString()]; RasterDataDescriptor* pFirstDesc = static_cast<RasterDataDescriptor*>(pFisrtElement->getDataDescriptor()); firstType = pFirstDesc->getDataType(); firstRowCount = pFirstDesc->getRowCount(); firstColCount = pFirstDesc->getColumnCount(); } else { RasterElement *pTempElement = filenameMap[crtText.toStdString()]; RasterDataDescriptor* pTempDesc = static_cast<RasterDataDescriptor*>(pTempElement->getDataDescriptor()); EncodingType tempType = pTempDesc->getDataType(); int tempRowCount = pTempDesc->getRowCount(); int tempColCount = pTempDesc->getColumnCount(); if (firstType != tempType) { QMessageBox::critical(NULL, "Spectral Data Merge", tr("Merge RasterElement %1 type different!").arg(crtText), "OK"); return; } if (firstRowCount != tempRowCount) { QMessageBox::critical(NULL, "Spectral Data Merge", tr("Merge RasterElement %1 row different!").arg(crtText), "OK"); return; } if (firstColCount != tempColCount) { QMessageBox::critical(NULL, "Spectral Data Merge", tr("Merge RasterElement column different!").arg(crtText), "OK"); return; } } QListWidgetItem *item = new QListWidgetItem(mergeList); item->setText(crtText + "--" + childItem->text(0)); // mergeElementList.push_back(filenameMap[crtText.toStdString()]); removeButton->setEnabled(true); mergeButton->setEnabled(true); flag = 1; } } //QListWidgetItem *crtItem = importList->currentItem(); /* QList<QListWidgetItem *> selectedList = importList->selectedItems(); for (int i = 0; i < selectedList.count(); i++) { QListWidgetItem *crtItem = selectedList.at(i); QString crtText = crtItem->text(); if (flag == 0) { RasterElement *pFisrtElement = filenameMap[crtText.toStdString()]; RasterDataDescriptor* pFirstDesc = static_cast<RasterDataDescriptor*>(pFisrtElement->getDataDescriptor()); firstType = pFirstDesc->getDataType(); firstRowCount = pFirstDesc->getRowCount(); firstColCount = pFirstDesc->getColumnCount(); } else { RasterElement *pTempElement = filenameMap[crtText.toStdString()]; RasterDataDescriptor* pTempDesc = static_cast<RasterDataDescriptor*>(pTempElement->getDataDescriptor()); EncodingType tempType = pTempDesc->getDataType(); int tempRowCount = pTempDesc->getRowCount(); int tempColCount = pTempDesc->getColumnCount(); if (firstType != tempType) { QMessageBox::critical(NULL, "Spectral Data Merge", "Merge RasterElement type different!", "OK"); return; } if (firstRowCount != tempRowCount) { QMessageBox::critical(NULL, "Spectral Data Merge", "Merge RasterElement row different!", "OK"); return; } if (firstColCount != tempColCount) { QMessageBox::critical(NULL, "Spectral Data Merge", "Merge RasterElement column different!", "OK"); return; } } QListWidgetItem *item = new QListWidgetItem(mergeList); item->setText(crtText); // mergeElementList.push_back(filenameMap[crtText.toStdString()]); removeButton->setEnabled(true); mergeButton->setEnabled(true); flag = 1; } */ } }
void ItemOrderList::setCurrentItemLabel(const QString &label) { QListWidgetItem *current = ui->listWidgetItems->currentItem(); if(current != nullptr) current->setText(label); }
void BearerEx::configurationRemoved(const QNetworkConfiguration& config) { QListWidgetItem* listItem = new QListWidgetItem(); listItem->setText(QString("Removed: ")+config.name()); eventListWidget->addItem(listItem); }
bool DialogStartup::populateListWidget(QListWidget* lw,QString configPath) { QFile xmlFile(configPath); if (!xmlFile.exists() || (xmlFile.error() != QFile::NoError)) { qDebug() << "ERROR: Unable to open config file " << configPath; return false; } xmlFile.open(QIODevice::ReadOnly); QXmlStreamReader reader(&xmlFile); while (!reader.atEnd()) { reader.readNext(); if (reader.isStartElement()) { if (reader.name() == "demos") while (!reader.atEnd()) { reader.readNext(); if (reader.isStartElement() && reader.name() == "example") { QXmlStreamAttributes attrs = reader.attributes(); QStringRef filename = attrs.value("filename"); if (!filename.isEmpty()) { QStringRef name = attrs.value("name"); QStringRef image = attrs.value("image"); QStringRef args = attrs.value("args"); QStringRef idpocket = attrs.value("idpocket"); QStringRef desc = attrs.value("desc"); QStringRef _connectortype = attrs.value("connectortype"); QStringRef _conngender = attrs.value("conngender"); QListWidgetItem *newItem = new QListWidgetItem; newItem->setText(name.toString()); newItem->setIcon(QIcon(image.toString())); newItem->setData(Qt::UserRole,idpocket.toString()); if (!idpocket.startsWith("#")) lw->addItem( newItem); // filter on connectors type and gender // if (!connType.isEmpty() && (_connectortype.indexOf(connType)==-1)) continue; // qWarning()<<connType<<" found:"<<_connectortype; // if (!connGender.isEmpty() && (_conngender.indexOf(connGender)==-1)) continue; // qWarning()<<"included"; } } else if(reader.isEndElement() && reader.name() == "demos") { return true; } } } } if (reader.hasError()) { qDebug() << QString("Error parsing %1 on line %2 column %3: \n%4") .arg(configPath) .arg(reader.lineNumber()) .arg(reader.columnNumber()) .arg(reader.errorString()); } return true; }
void QServer::readSMS(QString sms) { //Just display the message on GUI QListWidgetItem * item = new QListWidgetItem(ui.listWidget); item->setText(sms); }
void Devices::addDeviceToUsedDevList(QDomDocument &doc) { QDomNodeList list = doc.firstChildElement("device").childNodes(); if ( list.length()==0 ) return; QString device, desc, name; device = list.item(0).nodeName(); if ( device=="disk" ) { // Hard drives, floppy disks, CDROMs if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Disk %1").arg(desc.toUpper())); } else if ( device=="interface" ) { // Network Interface if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Network %1").arg(desc.toUpper())); } else if ( device=="serial" ) { // Serial port if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Serial Port %1").arg(desc.toUpper())); } else if ( device=="parallel" ) { // Parallel port if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Parallel Port %1").arg(desc.toUpper())); } else if ( device=="console" ) { // Console if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Console %1").arg(desc.toUpper())); } else if ( device=="channel" ) { // Channel if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Channel %1").arg(desc.toUpper())); } else if ( device=="smartcard" ) { // SmartCard name.append(QString("SmartCard %1").arg(desc.toUpper())); } else if ( device=="input" ) { // Input if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Input %1").arg(desc.toUpper())); } else if ( device=="hub" ) { // Hub if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Hub %1").arg(desc.toUpper())); } else if ( device=="video" ) { // Video if (list.item(0).firstChildElement("model").attributes().contains("type")) desc = list.item(0).firstChildElement("model").attributes().namedItem("type").nodeValue(); name.append(QString("Video %1").arg(desc.toUpper())); } else if ( device=="sound" ) { // Sound if (list.item(0).attributes().contains("model")) desc = list.item(0).attributes().namedItem("model").nodeValue(); name.append(QString("Sound %1").arg(desc.toUpper())); } else if ( device=="hostdev" ) { // HostDevice if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Host Device %1").arg(desc.toUpper())); } else if ( device=="graphics" ) { // Graphics if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Display %1").arg(desc.toUpper())); } else if ( device=="redirdev" ) { // Redirected devices if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("USB Redirector %1").arg(desc.toUpper())); } else if ( device=="filesystem" ) { // Filesystems if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Filesystem %1").arg(desc.toUpper())); } else if ( device=="controller" ) { // Controller if (list.item(0).attributes().contains("type")) desc = list.item(0).attributes().namedItem("type").nodeValue(); name.append(QString("Controller %1").arg(desc.toUpper())); } else if ( device=="emulator" ) { // Emulator name.append(QString("Emulator")); } else if ( device=="watchdog" ) { // WatchDog if (list.item(0).attributes().contains("model")) desc = list.item(0).attributes().namedItem("model").nodeValue(); name.append(QString("WatchDog %1").arg(desc.toUpper())); } else if ( device=="memballoon" ) { // MemBalloon if (list.item(0).attributes().contains("model")) desc = list.item(0).attributes().namedItem("model").nodeValue(); name.append(QString("MemBalloon %1").arg(desc.toUpper())); } else if ( device=="rng" ) { // Random if (list.item(0).attributes().contains("model")) desc = list.item(0).attributes().namedItem("model").nodeValue(); name.append(QString("RNG %1").arg(desc.toUpper())); } else if ( device=="tpm" ) { // TPM if (list.item(0).attributes().contains("model")) desc = list.item(0).attributes().namedItem("model").nodeValue(); name.append(QString("TPM %1").arg(desc.toUpper())); } else if ( device=="nvram" ) { // NVRAM name.append(QString("NVRAM")); } else if ( device=="panic" ) { // Panic name.append(QString("Panic")); } else return; // find DeviceName in Order int i = -1; foreach (QString _name, devNameOrder) { if ( name.startsWith(_name) ) { i = devNameOrder.indexOf(_name); break; }; }; // impossible case, but... if (i<0) return; // insert item by Device Name Order bool inserted = false; do { int row = 0; QList<QListWidgetItem*> _family = usedDeviceList->findItems( devNameOrder.at(i), Qt::MatchCaseSensitive | Qt::MatchStartsWith); if ( _family.isEmpty() ) { if ( i>0) { --i; continue; }; } else { QListWidgetItem *lastItem = _family.last(); row = usedDeviceList->row( lastItem ) + 1; }; QListWidgetItem *item = new QListWidgetItem(); item->setText(name); item->setData(Qt::UserRole, doc.toString()); usedDeviceList->insertItem(row, item); //usedDeviceList->insertItem(row, name); //usedDeviceList->item(row)->setData(Qt::UserRole, doc.toString()); showDevice(item, NULL); inserted = true; } while ( !inserted ); //qDebug()<<"added New Device:"<<name; initBootDevices(); }
bool QgsManageConnectionsDialog::populateConnections() { // Export mode. Populate connections list from settings if ( mDialogMode == Export ) { QSettings settings; switch ( mConnectionType ) { case WMS: settings.beginGroup( "/Qgis/connections-wms" ); break; case WFS: settings.beginGroup( "/Qgis/connections-wfs" ); break; case PostGIS: settings.beginGroup( "/PostgreSQL/connections" ); break; } QStringList keys = settings.childGroups(); QStringList::Iterator it = keys.begin(); while ( it != keys.end() ) { QListWidgetItem *item = new QListWidgetItem(); item->setText( *it ); listConnections->addItem( item ); ++it; } settings.endGroup(); } // Import mode. Populate connections list from file else { QFile file( mFileName ); if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { QMessageBox::warning( this, tr( "Loading connections" ), tr( "Cannot read file %1:\n%2." ) .arg( mFileName ) .arg( file.errorString() ) ); return false; } QDomDocument doc; QString errorStr; int errorLine; int errorColumn; if ( !doc.setContent( &file, true, &errorStr, &errorLine, &errorColumn ) ) { QMessageBox::warning( this, tr( "Loading connections" ), tr( "Parse error at line %1, column %2:\n%3" ) .arg( errorLine ) .arg( errorColumn ) .arg( errorStr ) ); return false; } QDomElement root = doc.documentElement(); switch ( mConnectionType ) { case WMS: if ( root.tagName() != "qgsWMSConnections" ) { QMessageBox::information( this, tr( "Loading connections" ), tr( "The file is not an WMS connections exchange file." ) ); return false; } break; case WFS: if ( root.tagName() != "qgsWFSConnections" ) { QMessageBox::information( this, tr( "Loading connections" ), tr( "The file is not an WFS connections exchange file." ) ); return false; } break; case PostGIS: if ( root.tagName() != "qgsPgConnections" ) { QMessageBox::information( this, tr( "Loading connections" ), tr( "The file is not an PostGIS connections exchange file." ) ); return false; } break; } QDomElement child = root.firstChildElement(); while ( !child.isNull() ) { QListWidgetItem *item = new QListWidgetItem(); item->setText( child.attribute( "name" ) ); listConnections->addItem( item ); child = child.nextSiblingElement(); } } return true; }
void TaskDatumParameters::updateListOfModes(eMapMode curMode) { //first up, remember currently selected mode. if (curMode == mmDeactivated){ auto sel = ui->listOfModes->selectedItems(); if (sel.count() > 0) curMode = modesInList[ui->listOfModes->row(sel[0])]; } //obtain list of available modes: Part::Datum* pcDatum = static_cast<Part::Datum*>(DatumView->getObject()); this->lastSuggestResult.bestFitMode = mmDeactivated; size_t lastValidModeItemIndex = mmDummy_NumberOfModes; if (pcDatum->Support.getSize() > 0){ pcDatum->attacher().suggestMapModes(this->lastSuggestResult); modesInList = this->lastSuggestResult.allApplicableModes; //add reachable modes to the list, too, but gray them out (using lastValidModeItemIndex, later) lastValidModeItemIndex = modesInList.size()-1; for(std::pair<const eMapMode, refTypeStringList> &rm: this->lastSuggestResult.reachableModes){ modesInList.push_back(rm.first); } } else { //no references - display all modes modesInList.clear(); for( int mmode = 0 ; mmode < mmDummy_NumberOfModes ; mmode++){ if (pcDatum->attacher().modeEnabled[mmode]) modesInList.push_back(eMapMode(mmode)); } } //populate list ui->listOfModes->blockSignals(true); ui->listOfModes->clear(); QListWidgetItem* iSelect = 0; if (modesInList.size()>0) { for (size_t i = 0 ; i < modesInList.size() ; ++i){ eMapMode mmode = modesInList[i]; std::vector<QString> mstr = AttacherGui::getUIStrings(pcDatum->attacher().getTypeId(),mmode); ui->listOfModes->addItem(mstr[0]); QListWidgetItem* item = ui->listOfModes->item(i); item->setToolTip(mstr[1] + QString::fromLatin1("\n\n") + tr("Reference combinations:\n") + AttacherGui::getRefListForMode(pcDatum->attacher(),mmode).join(QString::fromLatin1("\n"))); if (mmode == curMode) iSelect = ui->listOfModes->item(i); if (i > lastValidModeItemIndex){ //potential mode - can be reached by selecting more stuff item->setFlags(item->flags() & ~(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable)); refTypeStringList &extraRefs = this->lastSuggestResult.reachableModes[mmode]; if (extraRefs.size() == 1){ QStringList buf; for(eRefType rt : extraRefs[0]){ buf.append(AttacherGui::getShapeTypeText(rt)); } item->setText(tr("%1 (add %2)").arg( item->text(), buf.join(QString::fromLatin1("+")) )); } else { item->setText(tr("%1 (add more references)").arg(item->text())); } } else if (mmode == this->lastSuggestResult.bestFitMode){ //suggested mode - make bold assert (item); QFont fnt = item->font(); fnt.setBold(true); item->setFont(fnt); } } } //restore selection ui->listOfModes->selectedItems().clear(); if (iSelect) iSelect->setSelected(true); ui->listOfModes->blockSignals(false); }
QWidget* EditCallDialog::getManipulator(const FunctionCall::Argument *arg) { QWidget *w; switch(arg->iType) { case DBG_TYPE_CHAR: w = new QSpinBox(this); ((QSpinBox*)w)->setRange(CHAR_MIN, CHAR_MAX); ((QSpinBox*)w)->setValue(*(char*)arg->pData); break; case DBG_TYPE_UNSIGNED_CHAR: w = new QSpinBox(this); ((QSpinBox*)w)->setRange(0, UCHAR_MAX); ((QSpinBox*)w)->setValue(*(unsigned char*)arg->pData); break; case DBG_TYPE_SHORT_INT: w = new QSpinBox(this); ((QSpinBox*)w)->setRange(SHRT_MIN, SHRT_MAX); ((QSpinBox*)w)->setValue(*(short*)arg->pData); break; case DBG_TYPE_UNSIGNED_SHORT_INT: w = new QSpinBox(this); ((QSpinBox*)w)->setRange(0, USHRT_MAX); ((QSpinBox*)w)->setValue(*(unsigned short*)arg->pData); break; case DBG_TYPE_INT: w = new QSpinBox(this); ((QSpinBox*)w)->setRange(INT_MIN, INT_MAX); ((QSpinBox*)w)->setValue(*(int*)arg->pData); break; case DBG_TYPE_UNSIGNED_INT: w = new QSpinBox(this); //((QSpinBox*)w)->setRange(0, UINT_MAX); ((QSpinBox*)w)->setRange(0, INT_MAX); ((QSpinBox*)w)->setValue(*(unsigned int*)arg->pData); break; case DBG_TYPE_LONG_INT: w = new QSpinBox(this); //((QSpinBox*)w)->setRange(LONG_MIN, LONG_MAX); ((QSpinBox*)w)->setRange(INT_MIN, INT_MAX); ((QSpinBox*)w)->setValue(*(long*)arg->pData); break; case DBG_TYPE_UNSIGNED_LONG_INT: w = new QSpinBox(this); //((QSpinBox*)w)->setRange(0, ULONG_MAX); ((QSpinBox*)w)->setRange(0, INT_MAX); ((QSpinBox*)w)->setValue(*(unsigned long*)arg->pData); break; case DBG_TYPE_LONG_LONG_INT: w = new QSpinBox(this); //((QSpinBox*)w)->setRange(LLONG_MIN, LLONG_MAX); ((QSpinBox*)w)->setRange(INT_MIN, INT_MAX); ((QSpinBox*)w)->setValue(*(long long*)arg->pData); break; case DBG_TYPE_UNSIGNED_LONG_LONG_INT: w = new QSpinBox(this); //((QSpinBox*)w)->setRange(0, ULLONG_MAX); ((QSpinBox*)w)->setRange(0, INT_MAX); ((QSpinBox*)w)->setValue(*(unsigned long long*)arg->pData); break; case DBG_TYPE_FLOAT: w = new QDoubleSpinBox(this); ((QDoubleSpinBox*)w)->setRange(-FLT_MAX, FLT_MAX); ((QDoubleSpinBox*)w)->setDecimals(6); ((QDoubleSpinBox*)w)->setValue(*(float*)arg->pData); break; case DBG_TYPE_DOUBLE: w = new QDoubleSpinBox(this); ((QDoubleSpinBox*)w)->setRange(-DBL_MAX, DBL_MAX); ((QDoubleSpinBox*)w)->setDecimals(6); ((QDoubleSpinBox*)w)->setValue(*(float*)arg->pData); break; case DBG_TYPE_POINTER: { char *s; w = new QLineEdit(this); ((QLineEdit*)w)->setEnabled(false); asprintf(&s, "%p", *(void**)arg->pData); ((QLineEdit*)w)->setText(s); break; } case DBG_TYPE_BOOLEAN: w = new QComboBox(this); ((QComboBox*)w)->addItem("false"); ((QComboBox*)w)->addItem("true"); ((QComboBox*)w)->setCurrentIndex(*(bool*)arg->pData); break; case DBG_TYPE_BITFIELD: { int i = 0; GLbitfield b = *(GLbitfield*)arg->pData; w = new QListWidget(this); ((QListWidget*)w)->setSortingEnabled(true); ((QListWidget*)w)->setSelectionMode( QAbstractItemView::MultiSelection); while (glBitfieldMap[i].string != NULL) { QListWidgetItem *item = new QListWidgetItem((QListWidget*) w); item->setText(QString(glBitfieldMap[i].string)); item->setData(Qt::UserRole, QVariant(glBitfieldMap[i].value)); if ((glBitfieldMap[i].value & b) == glBitfieldMap[i].value) { item->setSelected(true); } i++; } ((QListWidget*)w)->setMinimumSize(230, 150); break; } case DBG_TYPE_ENUM: { int i = 0; int initialized = 0; w = new QComboBox(this); GLEnumValidator *v = new GLEnumValidator(w); ((QComboBox*)w)->setEditable(true); ((QComboBox*)w)->setInsertPolicy(QComboBox::NoInsert); ((QComboBox*)w)->setMaxVisibleItems(15); ((QComboBox*)w)->setValidator(v); while (glEnumerantsMap[i].string != NULL) { ((QComboBox*)w)->addItem(glEnumerantsMap[i].string); if (*(GLenum*)arg->pData == glEnumerantsMap[i].value && !initialized) { ((QComboBox*)w)->setCurrentIndex(i); initialized = 1; } i++; } connect(w, SIGNAL(editTextChanged(QString)), this, SLOT(checkValidity())); break; } case DBG_TYPE_STRUCT: { w = new QLineEdit(this); ((QLineEdit*)w)->setEnabled(false); ((QLineEdit*)w)->setText("STRUCT"); break; } default: return NULL; } return w; }
void Almoco::CarregaAlmoco( bool bCarregarUltimoAlmoco ) { if( operacao == CARREGANDO ) return ; QSqlQuery sql( db ); QString consulta; QString sWhere; double dValorAlmoco = 0; double dValorVoce = 0; double dValorEmpresa = 0; bool bTodos = false; QString sCodigoEmpresa = ui->comboBox_restaurantesLancamento->itemData( ui->comboBox_restaurantesLancamento->currentIndex() ).toString() ; this->setEnabled( false ); if( ui->comboBox_restaurantesLancamento->currentText() == "Todos" ) bTodos = true; //consulta = "select almoco.*, restaurante.nome, restaurante.valor as valorRestaurante from almoco left join restaurante on almoco.restaurante = restaurante.codigo "; consulta = "select almoco.*, ifnull( restaurante.nome, 'Não informado') as nomerestaurante, " "case when restaurante.valor is null then almoco.valor else almoco.valor - restaurante.valor end as valorvoce," "ifnull( restaurante.valor, 0 ) as valorempresa from almoco " "left join restaurante on almoco.restaurante = restaurante.codigo "; if( bTodos ) { sWhere = " where almoco.dtcadastro between '" + ui->dateEdit_filtro->date().toString("yyyy-MM-dd") + "' and '" + ui->dateEdit_filtroAte->date().toString("yyyy-MM-dd") + "' " ; } else { if( sCodigoEmpresa.isEmpty() ) sCodigoEmpresa = "0"; sWhere = " where almoco.restaurante = " + sCodigoEmpresa + " and almoco.dtcadastro between '" + ui->dateEdit_filtro->date().toString("yyyy-MM-dd") + "' and '" + ui->dateEdit_filtroAte->date().toString("yyyy-MM-dd") + "' "; } consulta += sWhere ; if( bCarregarUltimoAlmoco and !bTodos ) { int iQtd = ui->listWidget_lista->count(); if( iQtd > 0 ) { consulta.append( " and almoco.codigo > " + ui->listWidget_lista->item( iQtd - 1 )->whatsThis() ); } } else { ui->listWidget_lista->clear(); } consulta += " order by dtcadastro desc"; if( !sql.exec( consulta ) ) { Funcoes::ErroSQL( sql, "CarregaAlmoco", this); this->setEnabled( true ); return ; } //else // Funcoes::MensagemAndroid( "Carrega almoço", sql.lastQuery(), "Aperte", this ); while( sql.next() ) { QListWidgetItem *novoItem = new QListWidgetItem( ); novoItem->setText( "Data: " + sql.record().value("dtcadastro").toDate().toString("dd-MM-yyyy") + "\nValor: " + NumeroParaMoeda( sql.record().value("valor").toString() ) + "\nRestaurante: " + sql.record().value("nomerestaurante").toString() ); novoItem->setWhatsThis( sql.record().value("codigo").toString() ); ui->listWidget_lista->addItem( novoItem ); dValorAlmoco += sql.record().value("valor").toDouble(); dValorEmpresa += sql.record().value("valorempresa").toDouble(); dValorVoce += sql.record().value("valorvoce").toDouble(); } ui->label_almoco->setText( Funcoes::NumeroParaMoeda( QString::number( dValorAlmoco ) ) ); ui->label_empresa->setText( Funcoes::NumeroParaMoeda( QString::number( dValorEmpresa ) ) ); ui->label_voce->setText( Funcoes::NumeroParaMoeda( QString::number( dValorVoce ) ) ); this->setEnabled( true ); //ui->listWidget_lista->scrollBarWidgets(); }
int QgsComposerPictureWidget::addDirectoryToPreview( const QString& path ) { //go through all files of a directory QDir directory( path ); if ( !directory.exists() || !directory.isReadable() ) { return 1; //error } QFileInfoList fileList = directory.entryInfoList( QDir::Files ); QFileInfoList::const_iterator fileIt = fileList.constBegin(); QProgressDialog progress( "Adding Icons...", "Abort", 0, fileList.size() - 1, this ); //cancel button does not seem to work properly with modal dialog //progress.setWindowModality(Qt::WindowModal); int counter = 0; for ( ; fileIt != fileList.constEnd(); ++fileIt ) { progress.setLabelText( tr( "Creating icon for file %1" ).arg( fileIt->fileName() ) ); progress.setValue( counter ); QCoreApplication::processEvents(); if ( progress.wasCanceled() ) { break; } QString filePath = fileIt->absoluteFilePath(); //test if file is svg or pixel format bool fileIsPixel = false; bool fileIsSvg = testSvgFile( filePath ); if ( !fileIsSvg ) { fileIsPixel = testImageFile( filePath ); } //exclude files that are not svg or image if ( !fileIsSvg && !fileIsPixel ) { ++counter; continue; } QListWidgetItem * listItem = new QListWidgetItem( mPreviewListWidget ); listItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); if ( fileIsSvg ) { QIcon icon( filePath ); listItem->setIcon( icon ); } else if ( fileIsPixel ) //for pixel formats: create icon from scaled pixmap { QPixmap iconPixmap( filePath ); if ( iconPixmap.isNull() ) { ++counter; continue; //unknown file format or other problem } //set pixmap hardcoded to 30/30, same as icon size for mPreviewListWidget QPixmap scaledPixmap( iconPixmap.scaled( QSize( 30, 30 ), Qt::KeepAspectRatio ) ); QIcon icon( scaledPixmap ); listItem->setIcon( icon ); } else { ++counter; continue; } listItem->setText( "" ); //store the absolute icon file path as user data listItem->setData( Qt::UserRole, fileIt->absoluteFilePath() ); ++counter; } return 0; }
void PrefAssociations::addItem(QString label) { QListWidgetItem* item = new QListWidgetItem(listWidget); item->setText(label); }
// Constructor AtenPrefs::AtenPrefs(AtenWindow& parent) : QDialog(&parent), parent_(parent) { ui.setupUi(this); // Add colour popups to buttons ui.ElementColourButton->setPopupWidget(new ColourPopup(parent_, ui.ElementColourButton), true); connect(ui.ElementColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(elementColourChanged())); ui.SpotlightAmbientColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightAmbientColourButton, TColourWidget::NoAlphaOption), true); connect(ui.SpotlightAmbientColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightAmbientChanged())); ui.SpotlightDiffuseColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightDiffuseColourButton, TColourWidget::NoAlphaOption), true); connect(ui.SpotlightDiffuseColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightDiffuseChanged())); ui.SpotlightSpecularColourButton->setPopupWidget(new ColourPopup(parent_, ui.SpotlightSpecularColourButton, TColourWidget::NoAlphaOption), true); connect(ui.SpotlightSpecularColourButton->popupWidget(), SIGNAL(popupDone()), this, SLOT(spotlightSpecularChanged())); refreshing_ = false; // Add elements to element list and select first item QListWidgetItem* item; for (int i=0; i<ElementMap::nElements(); ++i) { item = new QListWidgetItem(ui.ElementList); item->setText(ElementMap::name(i)); } refreshing_ = true; // Select the first element in the elements list ui.ElementList->setCurrentRow(0); // Set Controls // View Page - Style Tab ui.StickRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::LineStyle)); ui.TubeRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::TubeStyle)); ui.SphereRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::SphereStyle)); ui.ScaledRadiusSpin->setValue(prefs.atomStyleRadius(Prefs::ScaledStyle)); ui.StickBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::LineStyle)); ui.TubeBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::TubeStyle)); ui.SphereBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::SphereStyle)); ui.ScaledBondRadiusSpin->setValue(prefs.bondStyleRadius(Prefs::ScaledStyle)); ui.SelectionScaleSpin->setValue(prefs.selectionScale()); ui.AngleLabelFormatEdit->setText(prefs.angleLabelFormat()); ui.DistanceLabelFormatEdit->setText(prefs.distanceLabelFormat()); ui.ChargeLabelFormatEdit->setText(prefs.chargeLabelFormat()); ui.LabelSizeSpin->setValue(prefs.labelSize()); ui.RenderDashedAromaticsCheck->setChecked(prefs.renderDashedAromatics()); ui.DrawHydrogenBondsCheck->setChecked(prefs.drawHydrogenBonds()); ui.HydrogenBondDotRadiusSpin->setValue(prefs.hydrogenBondDotRadius()); ui.StickLineNormalWidthSpin->setValue(prefs.stickLineNormalWidth()); ui.StickLineSelectedWidthSpin->setValue(prefs.stickLineSelectedWidth()); // View Page - Colours Tab ui.ColoursTable->setRowCount(Prefs::nObjectColours); QColor qcol; for (int n = 0; n < Prefs::nObjectColours; ++n) { QTableWidgetItem *item = new QTableWidgetItem(Prefs::objectColourName( (Prefs::ObjectColour) n )); ui.ColoursTable->setItem(n, 0, item); item = new QTableWidgetItem(); double* colour = prefs.colour( (Prefs::ObjectColour) n ); qcol.setRgbF( colour[0], colour[1], colour[2], colour[3] ); item->setBackgroundColor(qcol); ui.ColoursTable->setItem(n, 1, item); } // View Page - Rendering / Quality tab ReturnValue rv; rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::AmbientComponent), 4); ui.SpotlightAmbientColourButton->callPopupMethod("setCurrentColour", rv); rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::DiffuseComponent), 4); ui.SpotlightDiffuseColourButton->callPopupMethod("setCurrentColour", rv); rv.setArray(VTypes::DoubleData, prefs.spotlightColour(Prefs::SpecularComponent), 4); ui.SpotlightSpecularColourButton->callPopupMethod("setCurrentColour", rv); double* pos = prefs.spotlightPosition(); ui.SpotlightPositionXSpin->setValue(pos[0]); ui.SpotlightPositionYSpin->setValue(pos[1]); ui.SpotlightPositionZSpin->setValue(pos[2]); ui.ShininessSpin->setValue(prefs.shininess()); ui.PrimitiveQualitySpin->setValue(prefs.primitiveQuality()); ui.ImagePrimitiveQualitySpin->setValue(prefs.imagePrimitiveQuality()); ui.ImagePrimitivesGroup->setChecked(!prefs.reusePrimitiveQuality()); ui.LineAliasingCheck->setChecked(prefs.lineAliasing()); ui.PolygonAliasingCheck->setChecked(prefs.polygonAliasing()); ui.MultiSamplingCheck->setChecked(prefs.multiSampling()); ui.NearClipSpin->setValue(prefs.clipNear()); ui.FarClipSpin->setValue(prefs.clipFar()); ui.NearDepthSpin->setValue(prefs.depthNear()); ui.FarDepthSpin->setValue(prefs.depthFar()); // View Page - Fonts tab ui.ViewerFontEdit->setText(prefs.viewerFontFileName()); ui.MessagesSizeSpin->setValue(prefs.messagesFont().pixelSize()); // Set controls in interaction page ui.LeftMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::LeftButton)); ui.MiddleMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::MiddleButton)); ui.RightMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::RightButton)); ui.WheelMouseCombo->setCurrentIndex(prefs.mouseAction(Prefs::WheelButton)); ui.ShiftButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::ShiftKey)); ui.CtrlButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::CtrlKey)); ui.AltButtonCombo->setCurrentIndex(prefs.keyAction(Prefs::AltKey)); ui.ViewLockCombo->setCurrentIndex(prefs.viewLock()); ui.ZoomThrottleSpin->setValue(prefs.zoomThrottle()); ui.MouseMoveFilterSpin->setValue(prefs.mouseMoveFilter()); // Set controls in Program page ui.DensityUnitCombo->setCurrentIndex(prefs.densityUnit()); ui.EnergyUnitCombo->setCurrentIndex(prefs.energyUnit()); ui.HAddDistanceSpin->setValue(prefs.hydrogenDistance()); ui.MaxCuboidsSpin->setValue(prefs.maxCuboids()); ui.MaxRingsSpin->setValue(prefs.maxRings()); ui.MaxRingSizeSpin->setValue(prefs.maxRingSize()); ui.MaxUndoLevelsSpin->setValue(prefs.maxUndoLevels()); // Set pen colours and colourscale names and checks for (int n=0; n<10; n++) { QListWidgetItem* item = new QListWidgetItem(QString::number(n+1) + ". " + prefs.colourScale[n].name()); item->setCheckState( prefs.colourScale[n].visible() ? Qt::Checked : Qt::Unchecked); ui.ScaleList->addItem(item); } ui.ScaleList->setCurrentRow(0); ui.ScaleEditor->setColourScale(prefs.colourScale[0]); connect(ui.ScaleEditor, SIGNAL(colourScaleChanged()), this, SLOT(colourScaleChanged())); // Set controls in Energy/FF page ui.CalculateIntraCheck->setChecked(prefs.calculateIntra()); ui.CalculateVdwCheck->setChecked(prefs.calculateVdw()); ui.ElectrostaticMethodCombo->setCurrentIndex(prefs.electrostaticsMethod()); ui.VdwCutoffSpin->setValue(prefs.vdwCutoff()); ui.ElecCutoffSpin->setValue(prefs.elecCutoff()); ui.EwaldPrecisionMantissaSpin->setValue(prefs.ewaldPrecision().mantissa()); ui.EwaldPrecisionExponentSpin->setValue(prefs.ewaldPrecision().exponent()); ui.EwaldManualAlphaSpin->setValue(prefs.ewaldAlpha()); ui.EwaldManualKXSpin->setValue(prefs.ewaldKMax().x); ui.EwaldManualKYSpin->setValue(prefs.ewaldKMax().y); ui.EwaldManualKZSpin->setValue(prefs.ewaldKMax().z); ui.FunctionalFormList->clear(); QListWidgetItem* listitem; for (int n=0; n<VdwFunctions::nVdwFunctions; ++n) { listitem = new QListWidgetItem(ui.FunctionalFormList); listitem->setText(VdwFunctions::functionData[n].name); } ui.FunctionalFormList->setCurrentRow(0); // External Programs ui.TemporaryDirEdit->setText(prefs.tempDir().path()); ui.MopacExecutableEdit->setText(prefs.mopacExe()); // Store current values in the Prefs structure... prefsBackup_ = prefs; ElementMap::backupData(); refreshing_ = false; }
void Rec::nuevoCliente(int cliente) { QListWidgetItem *item = new QListWidgetItem; item->setText(QString::number(cliente)); conectados->addItem(item); }
CEphList::CEphList(QWidget *parent, mapView_t *view) : QDialog(parent), ui(new Ui::CEphList) { ui->setupUi(this); cELColumn[0] = tr("JD"); cELColumn[1] = tr("Date"); cELColumn[2] = tr("Time"); cELColumn[3] = tr("Magnitude"); cELColumn[4] = tr("Phase"); cELColumn[5] = tr("Position angle"); cELColumn[6] = tr("Size X"); cELColumn[7] = tr("Size Y"); cELColumn[8] = tr("Local R.A."); cELColumn[9] = tr("Local Dec."); cELColumn[10] = tr("Local R.A. (J2000.0)"); cELColumn[11] = tr("Local Dec. (J2000.0)"); cELColumn[12] = tr("Geo. R.A."); cELColumn[13] = tr("Geo. Dec."); cELColumn[14] = tr("Azimuth"); cELColumn[15] = tr("Altitude"); cELColumn[16] = tr("Dist. to Earth (R)"); cELColumn[17] = tr("Helio. dist. (r)"); cELColumn[18] = tr("Elongation"); cELColumn[19] = tr("Helio. longitude"); cELColumn[20] = tr("Helio. latitude"); cELColumn[21] = tr("Helio. rect. X"); cELColumn[22] = tr("Helio. rect. Y"); cELColumn[23] = tr("Helio. rect. Z"); cELColumn[24] = tr("Light time"); if (firstTime) { for (int i = 0; i < EL_COLUMN_COUNT; i++) { bChecked[i] = Qt::Checked; columnOrder[i] = i; } } m_view = *view; ui->comboBox->addItem(tr("Minute(s)")); ui->comboBox->addItem(tr("Hour(s)")); ui->comboBox->addItem(tr("Day(s)")); for (int i = 0; i < EL_COLUMN_COUNT; i++) { QListWidgetItem *item = new QListWidgetItem; item->setText(cELColumn[columnOrder[i]]); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item->setCheckState(bChecked[columnOrder[i]]); item->setData(Qt::UserRole + 1, columnOrder[i]); ui->listWidget_2->addItem(item); } for (int i = 0; i < PT_PLANET_COUNT; i++) { QListWidgetItem *item = new QListWidgetItem; item->setText(cAstro.getName(i)); ui->listWidget->addItem(item); } for (int i = 0; i < tComets.count(); i++) { if (tComets[i].selected) { QListWidgetItem *item = new QListWidgetItem; item->setText(tComets[i].name); item->setData(Qt::UserRole + 1, i); ui->listWidget_3->addItem(item); } } for (int i = 0; i < tAsteroids.count(); i++) { if (tAsteroids[i].selected) { QListWidgetItem *item = new QListWidgetItem; item->setText(tAsteroids[i].name); item->setData(Qt::UserRole + 1, i); ui->listWidget_4->addItem(item); } } ui->checkBox->setChecked(isUTC); ui->comboBox->setCurrentIndex(nCombo); ui->spinBox->setValue(nStep); if (firstTime) { QDateTime t; jdConvertJDTo_DateTime(m_view.jd, &t); ui->dateTimeEdit->setDate(t.date()); ui->dateTimeEdit->setTime(QTime(12, 0, 0)); t = t.addMonths(1); ui->dateTimeEdit_2->setDate(t.date()); ui->dateTimeEdit_2->setTime(QTime(12, 0, 0)); firstTime = false; } else { ui->dateTimeEdit->setDateTime(timeFrom); ui->dateTimeEdit_2->setDateTime(timeTo); } }
void KindleMainWindow::updateMatchResults( bool finished ) { WordFinder::SearchResults const & results = wordFinder.getResults(); wordList->setUpdatesEnabled( false ); qDebug() << "match results:" << results.size(); for( unsigned x = 0; x < results.size(); ++x ) { QListWidgetItem * i = wordList->item( x ); if ( !i ) { i = new QListWidgetItem( results[ x ].first, wordList ); if ( results[ x ].second ) { QFont f = i->font(); f.setItalic( true ); i->setFont( f ); } wordList->addItem( i ); } else { if ( i->text() != results[ x ].first ) i->setText( results[ x ].first ); QFont f = i->font(); if ( f.italic() != results[ x ].second ) { f.setItalic( results[ x ].second ); i->setFont( f ); } } if (i->text().at(0).direction() == QChar::DirR) i->setTextAlignment(Qt::AlignRight); if (i->text().at(0).direction() == QChar::DirL) i->setTextAlignment(Qt::AlignLeft); } while ( wordList->count() > (int) results.size() ) { // Chop off any extra items that were there QListWidgetItem * i = wordList->takeItem( wordList->count() - 1 ); if ( i ) delete i; else break; } if ( wordList->count() ) { qDebug() << "scroll to item"; wordList->scrollToItem( wordList->item( 0 ), QAbstractItemView::PositionAtTop ); wordList->setCurrentItem( 0, QItemSelectionModel::Clear ); } wordList->setUpdatesEnabled( true ); if ( finished ) { wordList->unsetCursor(); // Visually mark the input line to mark if there's no results bool setMark = results.empty() && !wordFinder.wasSearchUncertain(); if ( ui->translateLine->property( "noResults" ).toBool() != setMark ) { ui->translateLine->setProperty( "noResults", setMark ); setStyleSheet( styleSheet() ); } } }
void SubChooserDialog::addFile(QString filename) { QListWidgetItem* item = new QListWidgetItem(listWidget); item->setText(filename); item->setCheckState(Qt::Unchecked); }
void InstallDialog::httpRequestFinished(QNetworkReply *reply) { //TRACE_OBJ const QString targetFile = reply->property(targetFileProperty).toString(); if (targetFile == QLatin1String(docInfoTargetFileId)) { m_ui.progressBar->hide(); if (reply->error() != QNetworkReply::NoError) { QMessageBox::information(this, m_windowTitle, tr("Download failed: %1.") .arg(m_networkReply->errorString())); return; } if (!m_httpAborted) { while (reply->canReadLine()) { QByteArray ba = reply->readLine(); const QStringList lst = QString::fromLatin1(ba.constData()).split(QLatin1Char('|')); if (lst.count() != 4) { QMessageBox::information(this, m_windowTitle, tr("Documentation info file is corrupt!")); } else { QListWidgetItem *item = new QListWidgetItem(m_ui.listWidget); item->setText(lst.at(2).trimmed()); item->setData(QCH_FILENAME, lst.first()); item->setData(QCH_NAMESPACE, lst.at(1)); item->setData(QCH_CHECKSUM, lst.last().trimmed()); } } updateDocItemList(); } m_ui.statusLabel->setText(tr("Done.")); m_ui.cancelButton->setEnabled(false); m_ui.closeButton->setEnabled(true); updateInstallButton(); return; } // Download of file if (reply->error() != QNetworkReply::NoError) { QMessageBox::warning(this, m_windowTitle, tr("Download failed: %1.") .arg(reply->errorString())); downloadNextFile(); return; } if (m_httpAborted) { downloadNextFile(); return; } QFile file(targetFile); if (!file.open(QIODevice::WriteOnly|QIODevice::Truncate)) { QMessageBox::information(this, m_windowTitle, tr("Unable to save the file %1: %2.") .arg(targetFile).arg(file.errorString())); downloadNextFile(); return; } const QByteArray data = reply->readAll(); file.write(data); file.close(); const QByteArray digest = QCryptographicHash::hash(data, QCryptographicHash::Md5); const QString checkSum = QString::fromLatin1(digest.toHex()); if (checkSum.isEmpty() || m_currentCheckSum != checkSum) { file.remove(); QMessageBox::warning(this, m_windowTitle, tr("Download failed: Downloaded file is corrupted.")); downloadNextFile(); return; } m_ui.statusLabel->setText(tr("Installing documentation %1...") .arg(QFileInfo(targetFile).fileName())); m_ui.progressBar->setMaximum(0); m_ui.statusLabel->setText(tr("Done.")); installFile(targetFile); downloadNextFile(); }
/************************************************ * Widget Listing: * Creation of the list of drawed lovely buttons ************************************************/ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) : QListWidget( _parent ) { /* We need the parent to know the options checked */ parent = qobject_cast<ToolbarEditDialog *>(_parent); assert( parent ); /* Normal options */ setViewMode( QListView::ListMode ); setTextElideMode( Qt::ElideNone ); setDragEnabled( true ); setIconSize( QSize( 64, 32 ) ); /* All the buttons do not need a special rendering */ for( int i = 0; i < BUTTON_MAX; i++ ) { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr( nameL[i] ) ); widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); QPixmap pix( iconL[i] ); widgetItem->setIcon( pix.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); widgetItem->setToolTip( widgetItem->text() ); addItem( widgetItem ); } /* Spacers are yet again a different thing */ QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER ); widgetItem->setToolTip( widgetItem->text() ); widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); addItem( widgetItem ); widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Expanding Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND ); widgetItem->setToolTip( widgetItem->text() ); widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); addItem( widgetItem ); /** * For all other widgets, we create then, do a pseudo rendering in * a pixmaps for the view, and delete the object * * A lot of code is retaken from the Abstract, but not exactly... * So, rewrite. * They are better ways to deal with this, but I doubt that this is * necessary. If you feel like you have the time, be my guest. * -- * jb **/ for( int i = SPLITTER; i < SPECIAL_MAX; i++ ) { QWidget *widget = NULL; QListWidgetItem *widgetItem = new QListWidgetItem; widgetItem->setSizeHint( QSize( widgetItem->sizeHint().width(), 32 ) ); switch( i ) { case SPLITTER: { QFrame *line = new QFrame( this ); line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } widgetItem->setText( qtr("Splitter") ); break; case INPUT_SLIDER: { SeekSlider *slider = new SeekSlider( Qt::Horizontal, this ); widget = slider; } widgetItem->setText( qtr("Time Slider") ); break; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, parent->getOptions() & WIDGET_SHINY ); widget = snd; } widgetItem->setText( qtr("Volume") ); break; case VOLUME_SPECIAL: { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr("Small Volume") ); widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } continue; case TIME_LABEL: { QLabel *timeLabel = new QLabel( "12:42/2:12:42", this ); widget = timeLabel; } widgetItem->setText( qtr("Time") ); break; case MENU_BUTTONS: { QWidget *discFrame = new QWidget( this ); //discFrame->setLineWidth( 1 ); QHBoxLayout *discLayout = new QHBoxLayout( discFrame ); discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); QToolButton *prevSectionButton = new QToolButton( discFrame ); prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) ); prevSectionButton->setToolTip( qtr("Previous chapter") ); discLayout->addWidget( prevSectionButton ); QToolButton *menuButton = new QToolButton( discFrame ); menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) ); menuButton->setToolTip( qtr("Go to the DVD menu") ); discLayout->addWidget( menuButton ); QToolButton *nextButton = new QToolButton( discFrame ); nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) ); nextButton->setToolTip( qtr("Next chapter") ); discLayout->addWidget( nextButton ); widget = discFrame; } widgetItem->setText( qtr("DVD menus") ); break; case TELETEXT_BUTTONS: { QWidget *telexFrame = new QWidget( this ); QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame ); telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); QToolButton *telexOn = new QToolButton( telexFrame ); telexOn->setIcon( QIcon( ":/toolbar/tv" ) ); telexLayout->addWidget( telexOn ); QToolButton *telexTransparent = new QToolButton; telexTransparent->setIcon( QIcon( ":/toolbar/tvtelx" ) ); telexTransparent->setToolTip( qtr("Teletext transparency") ); telexLayout->addWidget( telexTransparent ); QSpinBox *telexPage = new QSpinBox; telexLayout->addWidget( telexPage ); widget = telexFrame; } widgetItem->setText( qtr("Teletext") ); break; case ADVANCED_CONTROLLER: { AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } widgetItem->setText( qtr("Advanced Buttons") ); break; case PLAYBACK_BUTTONS: { widget = new QWidget; DeckButtonsLayout *layout = new DeckButtonsLayout( widget ); BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward ); BrowseButton *next = new BrowseButton( widget ); RoundButton *play = new RoundButton( widget ); layout->setBackwardButton( prev ); layout->setForwardButton( next ); layout->setRoundButton( play ); } widgetItem->setText( qtr("Playback Buttons") ); break; case ASPECT_RATIO_COMBOBOX: widget = new AspectRatioComboBox( p_intf ); widgetItem->setText( qtr("Aspect ratio selector") ); break; case SPEED_LABEL: widget = new SpeedLabel( p_intf, this ); widgetItem->setText( qtr("Speed selector") ); break; case TIME_LABEL_ELAPSED: widget = new QLabel( "2:42", this ); widgetItem->setText( qtr("Elapsed time") ); break; case TIME_LABEL_REMAINING: widget = new QLabel( "-2:42", this ); widgetItem->setText( qtr("Total/Remaining time") ); break; default: msg_Warn( p_intf, "This should not happen %i", i ); break; } if( widget == NULL ) continue; #if HAS_QT5 widgetItem->setIcon( QIcon( widget->grab() ) ); #else widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) ); #endif widgetItem->setToolTip( widgetItem->text() ); widget->hide(); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); delete widget; } }
void radeon_profile::on_list_variables_itemClicked(QListWidgetItem *item) { ui->list_vaules->clear(); if (item->text().contains("----")) // the separator return; if (envVars.isEmpty()) return; // read variable possible values from file QStringList values = envVars.filter(ui->list_variables->currentItem()->text())[0].remove(ui->list_variables->currentItem()->text()+"|").split("#",QString::SkipEmptyParts); // if value for this variable is 'user_input' display a window for input if (values[0] == "user_input") { bool ok; QString input = QInputDialog::getText(this, tr("Enter value"), tr("Enter valid value for ") + ui->list_variables->currentItem()->text(), QLineEdit::Normal,"",&ok); // look for this variable in list int varIndex = selectedVariableVaules.indexOf(QRegExp(ui->list_variables->currentItem()->text()+".+",Qt::CaseInsensitive),0); if (!input.isEmpty() && ok) { // if value was ok if (varIndex == -1) // add it to list selectedVariableVaules.append(ui->list_variables->currentItem()->text()+"="+input); else // replace if already exists selectedVariableVaules[varIndex] = ui->list_variables->currentItem()->text()+"=\""+input+"\""; } else { // hehe, looks weird but check ok status is for, when input was empty, and whether user click ok or cancel, dispaly quesion if ((varIndex != -1) || ok) { if (QMessageBox::question(this, tr("Question"), tr("Remove this item?"), QMessageBox::Yes | QMessageBox::No,QMessageBox::Yes) == QMessageBox::Yes) selectedVariableVaules.removeAt(varIndex); } } ui->txt_summary->setText(selectedVariableVaules.join(" ")); return; } // go through list from file and check if it is selected (exists in summary) for (int i= 0 ; i< values.count(); i++ ) { // look for selected variable in list with variables and its values int varIndex = selectedVariableVaules.indexOf(QRegExp(ui->list_variables->currentItem()->text()+".+",Qt::CaseInsensitive),0); QListWidgetItem *valItem = new QListWidgetItem(); valItem->setText(values[i]); // if not, add to list where from user can choose, add unchecked if (varIndex == -1) { valItem->setFlags(item->flags() | Qt::ItemIsUserCheckable); valItem->setCheckState(Qt::Unchecked); } else { // if it is on list, add checked if (selectedVariableVaules[varIndex].contains(valItem->text())) valItem->setCheckState(Qt::Checked); else { // other, unchecked valItem->setFlags(item->flags() | Qt::ItemIsUserCheckable); valItem->setCheckState(Qt::Unchecked); } } ui->list_vaules->addItem(valItem); } }
QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *parent, Qt::WFlags fl ) : QDialog( parent, fl ) , mMapCanvas( mapCanvas ) { setupUi( this ); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) ); connect( projectionSelector, SIGNAL( sridSelected( QString ) ), this, SLOT( setMapUnitsToCurrentProjection() ) ); /////////////////////////////////////////////////////////// // Properties stored in map canvas's QgsMapRenderer // these ones are propagated to QgsProject by a signal QgsMapRenderer* myRenderer = mMapCanvas->mapRenderer(); QGis::UnitType myUnit = myRenderer->mapUnits(); setMapUnits( myUnit ); //see if the user wants on the fly projection enabled bool myProjectionEnabled = myRenderer->hasCrsTransformEnabled(); cbxProjectionEnabled->setChecked( myProjectionEnabled ); mProjectSrsId = myRenderer->destinationCrs().srsid(); QgsDebugMsg( "Read project CRSID: " + QString::number( mProjectSrsId ) ); projectionSelector->setSelectedCrsId( mProjectSrsId ); projectionSelector->setEnabled( myProjectionEnabled ); /////////////////////////////////////////////////////////// // Properties stored in QgsProject title( QgsProject::instance()->title() ); // get the manner in which the number of decimal places in the mouse // position display is set (manual or automatic) bool automaticPrecision = QgsProject::instance()->readBoolEntry( "PositionPrecision", "/Automatic" ); if ( automaticPrecision ) { radAutomatic->setChecked( true ); spinBoxDP->setDisabled( true ); labelDP->setDisabled( true ); } else { radManual->setChecked( true ); } cbxAbsolutePath->setCurrentIndex( QgsProject::instance()->readBoolEntry( "Paths", "/Absolute", true ) ? 0 : 1 ); int dp = QgsProject::instance()->readNumEntry( "PositionPrecision", "/DecimalPlaces" ); spinBoxDP->setValue( dp ); QString format = QgsProject::instance()->readEntry( "PositionPrecision", "/DegreeFormat", "D" ); if ( format == "DM" ) radDM->setChecked( true ); else if ( format == "DMS" ) radDMS->setChecked( true ); else radD->setChecked( true ); //get the color selections and set the button color accordingly int myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorRedPart", 255 ); int myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorGreenPart", 255 ); int myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorBluePart", 0 ); int myAlphaInt = QgsProject::instance()->readNumEntry( "Gui", "/SelectionColorAlphaPart", 255 ); QColor myColor = QColor( myRedInt, myGreenInt, myBlueInt, myAlphaInt ); pbnSelectionColor->setColor( myColor ); //get the color for map canvas background and set button color accordingly (default white) myRedInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorRedPart", 255 ); myGreenInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorGreenPart", 255 ); myBlueInt = QgsProject::instance()->readNumEntry( "Gui", "/CanvasColorBluePart", 255 ); myColor = QColor( myRedInt, myGreenInt, myBlueInt ); pbnCanvasColor->setColor( myColor ); //get project scales QStringList myScales = QgsProject::instance()->readListEntry( "Scales", "/ScalesList" ); if ( !myScales.isEmpty() ) { QStringList::const_iterator scaleIt = myScales.constBegin(); for ( ; scaleIt != myScales.constEnd(); ++scaleIt ) { QListWidgetItem* newItem = new QListWidgetItem( lstScales ); newItem->setText( *scaleIt ); newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); lstScales->addItem( newItem ); } } grpProjectScales->setChecked( QgsProject::instance()->readBoolEntry( "Scales", "/useProjectScales" ) ); QgsMapLayer* currentLayer = 0; QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); const QMap<QString, QgsMapLayer*> &mapLayers = QgsMapLayerRegistry::instance()->mapLayers(); if ( mMapCanvas->currentLayer() ) { mLayerSrsId = mMapCanvas->currentLayer()->crs().srsid(); } else if ( mapLayers.size() > 0 ) { mLayerSrsId = mapLayers.begin().value()->crs().srsid(); } else { mLayerSrsId = mProjectSrsId; } twIdentifyLayers->setColumnCount( 3 ); twIdentifyLayers->horizontalHeader()->setVisible( true ); twIdentifyLayers->setHorizontalHeaderItem( 0, new QTableWidgetItem( tr( "Layer" ) ) ); twIdentifyLayers->setHorizontalHeaderItem( 1, new QTableWidgetItem( tr( "Type" ) ) ); twIdentifyLayers->setHorizontalHeaderItem( 2, new QTableWidgetItem( tr( "Identifiable" ) ) ); twIdentifyLayers->setRowCount( mapLayers.size() ); twIdentifyLayers->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents ); int i = 0; for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ ) { currentLayer = it.value(); QTableWidgetItem *twi = new QTableWidgetItem( QString::number( i ) ); twIdentifyLayers->setVerticalHeaderItem( i, twi ); twi = new QTableWidgetItem( currentLayer->name() ); twi->setData( Qt::UserRole, it.key() ); twi->setFlags( twi->flags() & ~Qt::ItemIsEditable ); twIdentifyLayers->setItem( i, 0, twi ); QString type; if ( currentLayer->type() == QgsMapLayer::VectorLayer ) { type = tr( "Vector" ); } else if ( currentLayer->type() == QgsMapLayer::RasterLayer ) { QgsRasterLayer *rl = qobject_cast<QgsRasterLayer *>( currentLayer ); if ( rl && rl->providerType() == "wms" ) { type = tr( "WMS" ); } else { type = tr( "Raster" ); } } twi = new QTableWidgetItem( type ); twi->setFlags( twi->flags() & ~Qt::ItemIsEditable ); twIdentifyLayers->setItem( i, 1, twi ); QCheckBox *cb = new QCheckBox(); cb->setChecked( !noIdentifyLayerIdList.contains( currentLayer->id() ) ); twIdentifyLayers->setCellWidget( i, 2, cb ); } grpOWSServiceCapabilities->setChecked( QgsProject::instance()->readBoolEntry( "WMSServiceCapabilities", "/", false ) ); mWMSTitle->setText( QgsProject::instance()->readEntry( "WMSServiceTitle", "/" ) ); mWMSContactOrganization->setText( QgsProject::instance()->readEntry( "WMSContactOrganization", "/", "" ) ); mWMSContactPerson->setText( QgsProject::instance()->readEntry( "WMSContactPerson", "/", "" ) ); mWMSContactMail->setText( QgsProject::instance()->readEntry( "WMSContactMail", "/", "" ) ); mWMSContactPhone->setText( QgsProject::instance()->readEntry( "WMSContactPhone", "/", "" ) ); mWMSAbstract->setPlainText( QgsProject::instance()->readEntry( "WMSServiceAbstract", "/", "" ) ); mWMSOnlineResourceLineEdit->setText( QgsProject::instance()->readEntry( "WMSOnlineResource", "/", "" ) ); mWMSUrlLineEdit->setText( QgsProject::instance()->readEntry( "WMSUrl", "/", "" ) ); bool ok; QStringList values; mWMSExtMinX->setValidator( new QDoubleValidator( mWMSExtMinX ) ); mWMSExtMinY->setValidator( new QDoubleValidator( mWMSExtMinY ) ); mWMSExtMaxX->setValidator( new QDoubleValidator( mWMSExtMaxX ) ); mWMSExtMaxY->setValidator( new QDoubleValidator( mWMSExtMaxY ) ); values = QgsProject::instance()->readListEntry( "WMSExtent", "/", &ok ); grpWMSExt->setChecked( ok && values.size() == 4 ); if ( grpWMSExt->isChecked() ) { mWMSExtMinX->setText( values[0] ); mWMSExtMinY->setText( values[1] ); mWMSExtMaxX->setText( values[2] ); mWMSExtMaxY->setText( values[3] ); } values = QgsProject::instance()->readListEntry( "WMSCrsList", "/", &ok ); grpWMSList->setChecked( ok && values.size() > 0 ); if ( grpWMSList->isChecked() ) { mWMSList->addItems( values ); } else { values = QgsProject::instance()->readListEntry( "WMSEpsgList", "/", &ok ); grpWMSList->setChecked( ok && values.size() > 0 ); if ( grpWMSList->isChecked() ) { QStringList list; foreach ( QString value, values ) { list << QString( "EPSG:%1" ).arg( value ); } mWMSList->addItems( list ); }
void MythListBox::changeItem(const QString &new_text, uint row) { QListWidgetItem *widget = item(row); if (widget) widget->setText(new_text); }
/************************************************ * Widget Listing: * Creation of the list of drawed lovely buttons ************************************************/ WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent ) : QListWidget( _parent ) { /* We need the parent to know the options checked */ parent = qobject_cast<ToolbarEditDialog *>(_parent); assert( parent ); /* Normal options */ setViewMode( QListView::IconMode ); setSpacing( 20 ); setDragEnabled( true ); /* All the buttons do not need a special rendering */ for( int i = 0; i < BUTTON_MAX; i++ ) { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr( nameL[i] ) ); widgetItem->setIcon( QIcon( iconL[i] ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } /* Spacers are yet again a different thing */ QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER ); addItem( widgetItem ); widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ), qtr( "Expanding Spacer" ), this ); widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND ); addItem( widgetItem ); /** * For all other widgets, we create then, do a pseudo rendering in * a pixmaps for the view, and delete the object * * A lot of code is retaken from the Abstract, but not exactly... * So, rewrite. * They are better ways to deal with this, but I doubt that this is * necessary. If you feel like you have the time, be my guest. * -- * jb **/ for( int i = SPLITTER; i < SPECIAL_MAX; i++ ) { QWidget *widget = NULL; QListWidgetItem *widgetItem = new QListWidgetItem( this ); switch( i ) { case SPLITTER: { QFrame *line = new QFrame( this ); line->setFrameShape( QFrame::VLine ); line->setFrameShadow( QFrame::Raised ); line->setLineWidth( 0 ); line->setMidLineWidth( 1 ); widget = line; } widgetItem->setText( qtr("Splitter") ); break; case INPUT_SLIDER: { InputSlider *slider = new InputSlider( Qt::Horizontal, this ); widget = slider; } widgetItem->setText( qtr("Time Slider") ); break; case VOLUME: { SoundWidget *snd = new SoundWidget( this, p_intf, parent->getOptions() & WIDGET_SHINY ); widget = snd; } widgetItem->setText( qtr("Volume") ); break; case VOLUME_SPECIAL: { QListWidgetItem *widgetItem = new QListWidgetItem( this ); widgetItem->setText( qtr("Small Volume") ); widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) ); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); } continue; case TIME_LABEL: { QLabel *timeLabel = new QLabel( "12:42/2:12:42", this ); widget = timeLabel; } widgetItem->setText( qtr("Time") ); break; case MENU_BUTTONS: { QWidget *discFrame = new QWidget( this ); //discFrame->setLineWidth( 1 ); QHBoxLayout *discLayout = new QHBoxLayout( discFrame ); discLayout->setSpacing( 0 ); discLayout->setMargin( 0 ); QToolButton *prevSectionButton = new QToolButton( discFrame ); prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) ); discLayout->addWidget( prevSectionButton ); QToolButton *menuButton = new QToolButton( discFrame ); menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) ); discLayout->addWidget( menuButton ); QToolButton *nextButton = new QToolButton( discFrame ); nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) ); discLayout->addWidget( nextButton ); widget = discFrame; } widgetItem->setText( qtr("DVD menus") ); break; case TELETEXT_BUTTONS: { QWidget *telexFrame = new QWidget( this ); QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame ); telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 ); QToolButton *telexOn = new QToolButton( telexFrame ); telexOn->setIcon( QIcon( ":/toolbar/tv" ) ); telexLayout->addWidget( telexOn ); QToolButton *telexTransparent = new QToolButton; telexOn->setIcon( QIcon( ":/toolbar/tvtelx" ) ); telexLayout->addWidget( telexTransparent ); QSpinBox *telexPage = new QSpinBox; telexLayout->addWidget( telexPage ); widget = telexFrame; } widgetItem->setText( qtr("Teletext") ); break; case ADVANCED_CONTROLLER: { AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this ); widget = advControls; } widgetItem->setText( qtr("Advanced Buttons") ); break; default: msg_Warn( p_intf, "This should not happen %i", i ); break; } if( widget == NULL ) continue; widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) ); widget->hide(); widgetItem->setData( Qt::UserRole, QVariant( i ) ); addItem( widgetItem ); delete widget; } }
// 根据text取得ListItem QListWidgetItem* CustomToolDialog::getToolbarItemByText(const QString & text) { // 判断 if(text == "view_tree.png"){ // 分类树 QListWidgetItem *viewTreeItem = new QListWidgetItem; viewTreeItem->setIcon(Utils::getIcon("view_tree.png")); viewTreeItem->setText(tr("Show/Hide Class Tree")); viewTreeItem->setData(Qt::UserRole, "view_tree.png"); return viewTreeItem; } // 全屏 if(text == "view_fullscreen.png"){ QListWidgetItem *fullScreen = new QListWidgetItem; fullScreen->setIcon(Utils::getIcon("view_fullscreen.png")); fullScreen->setText(tr("Full Screen")); fullScreen->setData(Qt::UserRole, "view_fullscreen.png"); return fullScreen; } // 个人主页 if(text == "homepage.png"){ QListWidgetItem *homepageItem = new QListWidgetItem; homepageItem->setIcon(Utils::getIcon("homepage.png")); homepageItem->setText(tr("HomePage")); homepageItem->setData(Qt::UserRole, "homepage.png"); return homepageItem; } // 邀请朋友 if(text == "invite.png"){ QListWidgetItem *inviteItem = new QListWidgetItem; inviteItem->setIcon(Utils::getIcon("invite.png")); inviteItem->setText(tr("Invite Friends...")); inviteItem->setData(Qt::UserRole, "invite.png"); return inviteItem; } // 论坛 if(text == "forum.png"){ QListWidgetItem *forumItem = new QListWidgetItem; forumItem->setIcon(Utils::getIcon("forum.png")); forumItem->setText(tr("Forum")); forumItem->setData(Qt::UserRole, "forum.png"); return forumItem; } // 另存到移动设备 if(text == "document-savetomobi.png"){ QListWidgetItem *saveToMobiItem = new QListWidgetItem; saveToMobiItem->setIcon(Utils::getIcon("document-savetomobi.png")); saveToMobiItem->setText(tr("Save To Mobile...")); saveToMobiItem->setData(Qt::UserRole, "document-savetomobi.png"); return saveToMobiItem; } // 导入 if(text == "document-import.png"){ QListWidgetItem *importItem = new QListWidgetItem; importItem->setIcon(Utils::getIcon("document-import.png")); importItem->setText(tr("Import...")); importItem->setData(Qt::UserRole, "document-import.png"); return importItem; } // 导出 if(text == "document-export.png"){ QListWidgetItem *exportItem = new QListWidgetItem; exportItem->setIcon(Utils::getIcon("document-export.png")); exportItem->setText(tr("Export...")); exportItem->setData(Qt::UserRole, "document-export.png"); return exportItem; } // // 插件管理 // if(text == "plugin.png"){ // QListWidgetItem *pluginItem = new QListWidgetItem; // pluginItem->setIcon(Utils::getIcon("plugin.png")); // pluginItem->setText(tr("Plugins")); // pluginItem->setData(Qt::UserRole, "plugin.png"); // return pluginItem; // } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); // QListWidget QListWidget listWidget; // 一种添加项目的简便方法 new QListWidgetItem("a", &listWidget); // 添加项目的另一种方法,这样还可以进行各种设置 QListWidgetItem *listWidgetItem = new QListWidgetItem; listWidgetItem->setText("b"); listWidgetItem->setIcon(QIcon("../modelView2/yafeilinux.png")); listWidgetItem->setToolTip("this is b!"); listWidget.insertItem(1, listWidgetItem); // 设置排序为倒序 listWidget.sortItems(Qt::DescendingOrder); // 显示列表部件 listWidget.show(); // QTreeWidget QTreeWidget treeWidget; // 必须设置列数 treeWidget.setColumnCount(2); // 设置标头 QStringList headers; headers << "name" << "year"; treeWidget.setHeaderLabels(headers); // 添加项目 QTreeWidgetItem *grade1 = new QTreeWidgetItem(&treeWidget); grade1->setText(0,"Grade1"); QTreeWidgetItem *student = new QTreeWidgetItem(grade1); student->setText(0,"Tom"); student->setText(1,"1986"); QTreeWidgetItem *grade2 = new QTreeWidgetItem(&treeWidget, grade1); grade2->setText(0,"Grade2"); treeWidget.show(); // QTableWidget // 创建表格部件,同时指定行数和列数 QTableWidget tableWidget(3, 2); // 创建表格项目,并插入到指定单元 QTableWidgetItem *tableWidgetItem = new QTableWidgetItem("qt"); tableWidget.setItem(1, 1, tableWidgetItem); // 创建表格项目,并将它们作为标头 QTableWidgetItem *headerV = new QTableWidgetItem("first"); tableWidget.setVerticalHeaderItem(0,headerV); QTableWidgetItem *headerH = new QTableWidgetItem("ID"); tableWidget.setHorizontalHeaderItem(0,headerH); tableWidget.show(); // 为listWidget启用拖放 // 设置选择模式为单选 listWidget.setSelectionMode(QAbstractItemView::SingleSelection); // 启用拖动 listWidget.setDragEnabled(true); // 设置接受拖放 listWidget.viewport()->setAcceptDrops(true); // 设置显示将要被放置的位置 listWidget.setDropIndicatorShown(true); // 设置拖放模式为移动项目,如果不设置,默认为复制项目 listWidget.setDragDropMode(QAbstractItemView::InternalMove); return app.exec(); }
void Completer::loadAtocompliteData() { QStringList listData = Highlighter::getKeyWords(m_extation); if(listData.isEmpty()) return; unsigned char nCount=0; //indicate if keyword, Build Function, ... QStringList::const_iterator it; for (it = listData.constBegin(); it != listData.constEnd(); ++it) { QString line = (*it), comment; if(line == "---END BLOCK---") { ++nCount; continue; } int i = line.indexOf("//"); if(i != -1) { comment = line.mid(i+2); line.truncate(i); line = line.simplified(); } i = line.indexOf("{"); if(i != -1) { int j = line.indexOf("}"); QString prop = line.mid(i+1,j-i-1); line.truncate(i); QStringList l = prop.split(";"); if(!l.isEmpty()) { for(i=0;i<l.size();i++) { QString s = l.at(i); s = s.simplified(); if(!s.isEmpty()) m_propertiesStruct.insert(line,s); } } } QListWidgetItem *item = new QListWidgetItem(lwItems); item->setText(line); item->setToolTip(comment); switch(nCount) { case 0: item->setIcon(QIcon(":/images/keyword.png")); break; case 1: item->setIcon(QIcon(":/images/DataType.png")); break; case 2: item->setIcon(QIcon(":/images/BuiltinVar.png")); break; case 3: item->setIcon(QIcon(":/images/BuiltinFunction.png")); break; default: item->setIcon(QIcon(":/images/DataType.png")); } } lwItems->sortItems(); }
void DiscoInfoWindow::updateWindow() { IDiscoInfo dinfo = FDiscovery->discoInfo(FStreamJid,FContactJid,FNode); int row = 0; ui.twtIdentity->clearContents(); foreach(const IDiscoIdentity &identity, dinfo.identity) { ui.twtIdentity->setRowCount(row+1); ui.twtIdentity->setItem(row,0,new QTableWidgetItem(identity.category)); ui.twtIdentity->setItem(row,1,new QTableWidgetItem(identity.type)); ui.twtIdentity->setItem(row,2,new QTableWidgetItem(identity.name)); row++; } ui.twtIdentity->verticalHeader()->resizeSections(QHeaderView::ResizeToContents); qSort(dinfo.features); ui.lwtFearures->clear(); foreach(const QString &featureVar, dinfo.features) { IDiscoFeature dfeature = FDiscovery->discoFeature(featureVar); dfeature.var = featureVar; QListWidgetItem *listItem = new QListWidgetItem; listItem->setIcon(dfeature.icon); listItem->setText(dfeature.name.isEmpty() ? dfeature.var : dfeature.name); if (FDiscovery->hasFeatureHandler(featureVar)) { QFont font = ui.lwtFearures->font(); font.setBold(true); listItem->setData(Qt::FontRole,font); } listItem->setData(Qt::UserRole,dfeature.var); listItem->setData(Qt::UserRole+1,dfeature.description); ui.lwtFearures->addItem(listItem); } onCurrentFeatureChanged(ui.lwtFearures->currentItem(), NULL); if (FDataForms) { if (FFormMenu) { FFormMenu->deleteLater(); FFormMenu = NULL; } if (!dinfo.extensions.isEmpty()) { FFormMenu = new Menu(ui.pbtExtensions); for (int index=0; index<dinfo.extensions.count(); index++) { IDataForm form = FDataForms->localizeForm(dinfo.extensions.at(index)); Action *action = new Action(FFormMenu); action->setData(ADR_FORM_INDEX,index); action->setText(!form.title.isEmpty() ? form.title : FDataForms->fieldValue("FORM_TYPE",form.fields).toString()); connect(action,SIGNAL(triggered(bool)),SLOT(onShowExtensionForm(bool))); FFormMenu->addAction(action); } } ui.pbtExtensions->setMenu(FFormMenu); ui.pbtExtensions->setEnabled(FFormMenu!=NULL); } if (!dinfo.error.isNull()) { ui.lblError->setText(tr("Error: %1").arg(dinfo.error.errorMessage())); ui.twtIdentity->setEnabled(false); ui.lwtFearures->setEnabled(false); ui.lblError->setVisible(true); } else { ui.twtIdentity->setEnabled(true); ui.lwtFearures->setEnabled(true); ui.lblError->setVisible(false); } ui.twtIdentity->horizontalHeader()->setResizeMode(0,QHeaderView::ResizeToContents); ui.twtIdentity->horizontalHeader()->setResizeMode(1,QHeaderView::ResizeToContents); ui.twtIdentity->horizontalHeader()->setResizeMode(2,QHeaderView::Stretch); ui.pbtUpdate->setEnabled(true); }
void Dialog::on_mAdd_clicked() { QListWidgetItem *item = new QListWidgetItem; item->setText(ui->mSiteName->text()); ui->mListWidget->addItem(item); }
void CockpitWindow::constructLayout() { // Setup an MDI application. m_cockpitArea = new QMdiArea(this); m_fileMenu = menuBar()->addMenu(tr("&File")); m_fileMenu->addSeparator(); QAction *closeAction = new QAction(tr("&Close"), this); closeAction->setShortcut(tr("Ctrl+Q")); closeAction->setToolTip("Close the application."); connect(closeAction, SIGNAL(triggered()), this, SLOT(close())); m_fileMenu->addAction(closeAction); m_windowMenu = menuBar()->addMenu(tr("&Window")); QAction* cascadeSWAct = new QAction(tr("C&ascade"), this); cascadeSWAct->setShortcut(tr("Ctrl+F9")); cascadeSWAct->setToolTip(tr("Cascade all open monitors.")); connect(cascadeSWAct, SIGNAL(triggered()), m_cockpitArea, SLOT(cascadeSubWindows())); m_windowMenu->addAction(cascadeSWAct); QAction* tileSWAct = new QAction(tr("&Tile"), this); tileSWAct->setShortcut(tr("Ctrl+F10")); tileSWAct->setToolTip(tr("Tile all open monitors.")); connect(tileSWAct, SIGNAL(triggered()), m_cockpitArea, SLOT(tileSubWindows())); m_windowMenu->addAction(tileSWAct); m_windowMenu->addSeparator(); QAction* maxSWAction = new QAction(tr("Ma&ximize"), this); maxSWAction->setShortcut(tr("Ctrl+F11")); maxSWAction->setToolTip(tr("Maximize current monitor.")); connect(maxSWAction, SIGNAL(triggered()), SLOT(maximizeActiveSubWindow())); m_windowMenu->addAction(maxSWAction); QAction* minSWAction = new QAction(tr("M&inimize"), this); minSWAction->setShortcut(tr("Ctrl+F12")); minSWAction->setToolTip(tr("Minimize current monitor.")); connect(minSWAction, SIGNAL(triggered()), SLOT(minimizeActiveSubWindow())); m_windowMenu->addAction(minSWAction); QAction* resetSWAction = new QAction(tr("&Reset"), this); resetSWAction->setShortcut(tr("Ctrl+Shift+F12")); resetSWAction->setToolTip(tr("Reset current monitor.")); connect(resetSWAction, SIGNAL(triggered()), SLOT(resetActiveSubWindow())); m_windowMenu->addAction(resetSWAction); QAction* closeSWAction = new QAction(tr("&Close"), this); closeSWAction->setShortcut(tr("Ctrl+C")); closeSWAction->setToolTip(tr("Close current monitor.")); connect(closeSWAction, SIGNAL(triggered()), m_cockpitArea , SLOT(closeActiveSubWindow())); m_windowMenu->addAction(closeSWAction); QAction* closeAllSWAction = new QAction(tr("Close &all"), this); closeAllSWAction->setShortcut(tr("Ctrl+Shift+C")); closeAllSWAction->setToolTip(tr("Close all monitors.")); connect(closeAllSWAction, SIGNAL(triggered()), m_cockpitArea, SLOT(closeAllSubWindows())); m_windowMenu->addAction(closeAllSWAction); // Load available plugins. m_availablePlugInsList = new QListWidget(this); m_availablePlugInsList->setMaximumWidth(200); m_availablePlugInsList->setMinimumWidth(200); connect(m_availablePlugInsList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(showPlugIn(QListWidgetItem*))); // Query PlugInProvider for available plugins. vector<string> listOfAvailablePlugins = m_plugInProvider.getListOfAvailablePlugIns(); vector<string>::iterator it = listOfAvailablePlugins.begin(); while (it != listOfAvailablePlugins.end()) { QListWidgetItem *item = new QListWidgetItem(m_availablePlugInsList); item->setText((*it).c_str()); item->setToolTip(m_plugInProvider.getDescriptionForPlugin((*it)).c_str()); it++; } QDockWidget *dockWidget = new QDockWidget(tr("Plugins"), this); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); dockWidget->setWidget(m_availablePlugInsList); addDockWidget(Qt::LeftDockWidgetArea, dockWidget); setCentralWidget(m_cockpitArea); m_multiplexer->start(); }
void ListWidgetItemPrototype::setText(const QString &text) { QListWidgetItem *item = qscriptvalue_cast<QListWidgetItem*>(thisObject()); if (item) item->setText(text); }