void Principal::on_tbw_activated(const QModelIndex &index) { r = index.row(); sel = id[r]; preencheTabelaEP(sel); }
QVariant InputMethodListModel::data(const QModelIndex &index, int /*role*/) const { InputAction *action = m_inputMethods.at(index.row()).data(); QQmlEngine::setObjectOwnership(action, QQmlEngine::CppOwnership); return qVariantFromValue<InputAction *>(action); }
void MainWindow::on_robotTable_clicked(const QModelIndex &index) { ui->rselect->setValue(index.row()+1); }
QVariant ComInterfacesModel::data( const QModelIndex& index, int role /*= Qt::DisplayRole*/ ) const { if (!index.isValid()) { return QVariant(); } else if (index.row() < 0 || index.row() >= comIfs_.size()) { return QVariant(); } if (Qt::DisplayRole == role) { switch (index.column()) { case ComInterfacesDelegate::NAME_COLUMN: { return comIfs_.at(index.row())->getName(); } case ComInterfacesDelegate::COM_DEF_COLUMN: { return comIfs_.at(index.row())->getComType().toString(":"); } case ComInterfacesDelegate::TRANSFER_TYPE_COLUMN: { return comIfs_.at(index.row())->getTransferType(); } case ComInterfacesDelegate::DIRECTION_COLUMN: { return General::direction2Str(comIfs_.at(index.row())->getDirection()); } case ComInterfacesDelegate::DESCRIPTION_COLUMN: { return comIfs_.at(index.row())->getDescription(); } default: { return QVariant(); } } } else if (ComInterfacesDelegate::TRANSFER_TYPE_OPTIONS == role) { // find the vlnv of the com interface VLNV comDefVLNV = comIfs_.at(index.row())->getComType(); // if the com def is not defined if (!comDefVLNV.isValid()) { return QStringList(); } // if the com def does not exist in the library. else if (!libHandler_->contains(comDefVLNV)) { return QStringList(); } // if the object is not a com definition else if (libHandler_->getDocumentType(comDefVLNV) != VLNV::COMDEFINITION) { return QStringList(); } // parse the com definition QSharedPointer<LibraryComponent const> libComp = libHandler_->getModelReadOnly(comDefVLNV); const QSharedPointer<ComDefinition const> comDef = libComp.staticCast<ComDefinition const>(); // and return the transfer types specified in the com definition return comDef->getTransferTypes(); } else if (Qt::ForegroundRole == role) { if (comIfs_.at(index.row())->isValid()) { return QColor("black"); } else { return QColor("red"); } } else if (Qt::BackgroundRole == role) { switch (index.column()) { case ComInterfacesDelegate::NAME_COLUMN: case ComInterfacesDelegate::DIRECTION_COLUMN: { return QColor("LemonChiffon"); } default: return QColor("white"); } } else { return QVariant(); } }
void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql ) { if ( !index.isValid() || !index.parent().isValid() ) { return; } //find out schema name and table name QModelIndex schemaSibling = index.sibling( index.row(), dbtmSchema ); QModelIndex tableSibling = index.sibling( index.row(), dbtmTable ); QModelIndex geomSibling = index.sibling( index.row(), dbtmGeomCol ); if ( !schemaSibling.isValid() || !tableSibling.isValid() || !geomSibling.isValid() ) { return; } QString schemaName = itemFromIndex( schemaSibling )->text(); QString tableName = itemFromIndex( tableSibling )->text(); QString geomName = itemFromIndex( geomSibling )->text(); QList<QStandardItem*> schemaItems = findItems( schemaName, Qt::MatchExactly, dbtmSchema ); if ( schemaItems.size() < 1 ) { return; } QStandardItem* schemaItem = schemaItems.at( dbtmSchema ); int n = schemaItem->rowCount(); for ( int i = 0; i < n; i++ ) { QModelIndex currentChildIndex = indexFromItem( schemaItem->child( i, dbtmSchema ) ); if ( !currentChildIndex.isValid() ) { continue; } QModelIndex currentTableIndex = currentChildIndex.sibling( i, dbtmTable ); if ( !currentTableIndex.isValid() ) { continue; } QModelIndex currentGeomIndex = currentChildIndex.sibling( i, dbtmGeomCol ); if ( !currentGeomIndex.isValid() ) { continue; } if ( itemFromIndex( currentTableIndex )->text() == tableName && itemFromIndex( currentGeomIndex )->text() == geomName ) { QModelIndex sqlIndex = currentChildIndex.sibling( i, dbtmSql ); if ( sqlIndex.isValid() ) { itemFromIndex( sqlIndex )->setText( sql ); break; } } } }
QVariant TransactionHistoryModel::data(const QModelIndex &index, int role) const { if (!m_transactionHistory) { return QVariant(); } if (index.row() < 0 || (unsigned)index.row() >= m_transactionHistory->count()) { return QVariant(); } TransactionInfo * tInfo = m_transactionHistory->transaction(index.row()); Q_ASSERT(tInfo); if (!tInfo) { qCritical("%s: internal error: no transaction info for index %d", __FUNCTION__, index.row()); return QVariant(); } QVariant result; switch (role) { case TransactionRole: result = QVariant::fromValue(tInfo); break; case TransactionDirectionRole: result = QVariant::fromValue(tInfo->direction()); break; case TransactionPendingRole: result = tInfo->isPending(); break; case TransactionFailedRole: result = tInfo->isFailed(); break; case TransactionAmountRole: result = tInfo->amount(); break; case TransactionDisplayAmountRole: result = tInfo->displayAmount(); break; case TransactionAtomicAmountRole: result = tInfo->atomicAmount(); break; case TransactionFeeRole: result = tInfo->fee(); break; case TransactionBlockHeightRole: // Use NULL QVariant for transactions without height. // Forces them to be displayed at top when sorted by blockHeight. if (tInfo->blockHeight() != 0) { result = tInfo->blockHeight(); } break; case TransactionSubaddrIndexRole: { QString str = QString{""}; bool first = true; for (quint32 i : tInfo->subaddrIndex()) { if (!first) str += QString{","}; first = false; str += QString::number(i); } result = str; } break; case TransactionSubaddrAccountRole: result = tInfo->subaddrAccount(); break; case TransactionLabelRole: result = tInfo->subaddrIndex().size() == 1 && *tInfo->subaddrIndex().begin() == 0 ? tr("Primary address") : tInfo->label(); break; case TransactionConfirmationsRole: result = tInfo->confirmations(); break; case TransactionConfirmationsRequiredRole: result = (tInfo->blockHeight() < tInfo->unlockTime()) ? tInfo->unlockTime() - tInfo->blockHeight() : 10; break; case TransactionHashRole: result = tInfo->hash(); break; case TransactionTimeStampRole: result = tInfo->timestamp(); break; case TransactionPaymentIdRole: result = tInfo->paymentId(); break; case TransactionIsOutRole: result = tInfo->direction() == TransactionInfo::Direction_Out; break; case TransactionDateRole: result = tInfo->date(); break; case TransactionTimeRole: result = tInfo->time(); break; case TransactionDestinationsRole: result = tInfo->destinations_formatted(); break; } return result; }
// write QSettings values bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: // core option - can be changed on-the-fly settings.setValue("fUseUPnP", value.toBool()); MapPort(value.toBool()); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; // default proxy case ProxyUse: if (settings.value("fUseProxy") != value) { settings.setValue("fUseProxy", value.toBool()); setRestartRequired(true); } break; case ProxyIP: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed IP if (!settings.contains("addrProxy") || strlIpPort.at(0) != value.toString()) { // construct new value from new IP and current port QString strNewValue = value.toString() + ":" + strlIpPort.at(1); settings.setValue("addrProxy", strNewValue); setRestartRequired(true); } } break; case ProxyPort: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed port if (!settings.contains("addrProxy") || strlIpPort.at(1) != value.toString()) { // construct new value from current IP and new port QString strNewValue = strlIpPort.at(0) + ":" + value.toString(); settings.setValue("addrProxy", strNewValue); setRestartRequired(true); } } break; #ifdef ENABLE_WALLET case SpendZeroConfChange: if (settings.value("bSpendZeroConfChange") != value) { settings.setValue("bSpendZeroConfChange", value); setRestartRequired(true); } break; #endif case DisplayUnit: setDisplayUnit(value); break; case ThirdPartyTxUrls: if (strThirdPartyTxUrls != value.toString()) { strThirdPartyTxUrls = value.toString(); settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls); setRestartRequired(true); } break; case Digits: if (settings.value("digits") != value) { settings.setValue("digits", value); setRestartRequired(true); } break; case Theme: if (settings.value("theme") != value) { settings.setValue("theme", value); setRestartRequired(true); } break; case Language: if (settings.value("language") != value) { settings.setValue("language", value); setRestartRequired(true); } break; case NitrosendRounds: nNitrosendRounds = value.toInt(); settings.setValue("nNitrosendRounds", nNitrosendRounds); emit nitrosendRoundsChanged(nNitrosendRounds); break; case AnonymizeDarkcoinAmount: nAnonymizeDarkcoinAmount = value.toInt(); settings.setValue("nAnonymizeDarkcoinAmount", nAnonymizeDarkcoinAmount); emit anonymizeDarkcoinAmountChanged(nAnonymizeDarkcoinAmount); break; case CoinControlFeatures: fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures); break; case DatabaseCache: if (settings.value("nDatabaseCache") != value) { settings.setValue("nDatabaseCache", value); setRestartRequired(true); } break; case ThreadsScriptVerif: if (settings.value("nThreadsScriptVerif") != value) { settings.setValue("nThreadsScriptVerif", value); setRestartRequired(true); } break; case Listen: if (settings.value("fListen") != value) { settings.setValue("fListen", value); setRestartRequired(true); } break; default: break; } } emit dataChanged(index, index); return successful; }
void MainWin::wanoldword(QModelIndex idx) { int row = idx.row(); emit wannaeditword(findres[row].word); }
void Principal::on_tbep_doubleClicked(const QModelIndex &index) { Abre(index.row()); }
void UtilitiesView::removeFromStatistics(QModelIndex index){ ui->statisticsTable->removeRow(index.row()); }
void DrugStorage::keyPressEvent(QKeyEvent *e) { if (!list_widget->isHidden()) { int key = e->key(); int count = list_widget->model()->rowCount(); QModelIndex currentIndex = list_widget->currentIndex(); if (Qt::Key_Down == key) { int row = currentIndex.row() + 1; if (row >= count) { row = 0; } QModelIndex index = list_widget->model()->index(row, 0); list_widget->setCurrentIndex(index); } else if (Qt::Key_Up == key) { int row = currentIndex.row() - 1; if (row < 0) { row = count - 1; } QModelIndex index = list_widget->model()->index(row, 0); list_widget->setCurrentIndex(index); } else if (Qt::Key_Escape == key) { list_widget->hide(); } else if (Qt::Key_Enter == key || Qt::Key_Return == key) { if (currentIndex.isValid()) { QString strName = list_widget->currentIndex().data().toString(); int row = ui.tableWidget->currentRow(); QSqlQuery query(*sql.db); QString strsql= "select * from sys_drugdictionary where name='"+strName+"'";//;//where AbbrName = '"+strName+"' query.exec(strsql); while(query.next()) { ui.tableWidget->setItem(row,1,new QTableWidgetItem(query.value(1).toString())); ui.tableWidget->setItem(row,2,new QTableWidgetItem(query.value(4).toString())); ui.tableWidget->setItem(row,3,new QTableWidgetItem(query.value(5).toString())); ui.tableWidget->setItem(row,5,new QTableWidgetItem(query.value(6).toString())); ui.tableWidget->setItem(row,8,new QTableWidgetItem(query.value(15).toString())); ui.tableWidget->setItem(row,9,new QTableWidgetItem(query.value(16).toString()));// ui.tableWidget->setItem(row,10,new QTableWidgetItem(query.value(10).toString()));// } QString strsql1= "select * from yk_inventory where name='"+strName+"'";//;//where AbbrName = '"+strName+"' query.exec(strsql1); if(query.next()) { ui.tableWidget->setItem(row,7,new QTableWidgetItem(query.value(7).toString())); } else { QString strTemp = QString::number(0); ui.tableWidget->setItem(row,7,new QTableWidgetItem(strTemp)); } } list_widget->hide(); } else { list_widget->hide(); //QLineEdit::keyPressEvent(e); } } else { //QLineEdit::keyPressEvent(e); } }
QVariant WeatherDataModel::data(const QModelIndex &index, int role) const { if (role == Qt::TextAlignmentRole) { return Qt::AlignCenter; } if (!index.isValid() || role != Qt::DisplayRole) { return QVariant(); } switch(index.column()) { case 0: return QString("%1/%2").arg(m_data[index.row()].month()).arg(m_data[index.row()].day()); case 1: return QString().sprintf("%02d:%02d",m_data[index.row()].hour(),m_data[index.row()].minute()); } WeatherDataPoint::WeatherDataFieldId id = static_cast<WeatherDataPoint::WeatherDataFieldId>(index.column()+4); switch(id) { case WeatherDataPoint::DryBulbTemperature: { boost::optional<double> value = m_data[index.row()].dryBulbTemperature(); if(value) { //std::cout << value.get() << std::endl; return QVariant(value.get()); } break; } case WeatherDataPoint::DewPointTemperature: { boost::optional<double> value = m_data[index.row()].dewPointTemperature(); if(value) { return value.get(); } break; } case WeatherDataPoint::RelativeHumidity: { boost::optional<double> value = m_data[index.row()].relativeHumidity(); if(value) { return value.get(); } break; } case WeatherDataPoint::AtmosphericStationPressure: { boost::optional<double> value = m_data[index.row()].atmosphericStationPressure(); if(value) { return value.get(); } break; } case WeatherDataPoint::ExtraterrestrialHorizontalRadiation: { boost::optional<double> value = m_data[index.row()].extraterrestrialHorizontalRadiation(); if(value) { return value.get(); } break; } case WeatherDataPoint::ExtraterrestrialDirectNormalRadiation: { boost::optional<double> value = m_data[index.row()].extraterrestrialDirectNormalRadiation(); if(value) { return value.get(); } break; } case WeatherDataPoint::HorizontalInfraredRadiationIntensity: { boost::optional<double> value = m_data[index.row()].horizontalInfraredRadiationIntensity(); if(value) { return value.get(); } break; } case WeatherDataPoint::GlobalHorizontalRadiation: { boost::optional<double> value = m_data[index.row()].globalHorizontalRadiation(); if(value) { return value.get(); } break; } case WeatherDataPoint::DirectNormalRadiation: { boost::optional<double> value = m_data[index.row()].directNormalRadiation(); if(value) { return value.get(); } break; } case WeatherDataPoint::DiffuseHorizontalRadiation: { boost::optional<double> value = m_data[index.row()].diffuseHorizontalRadiation(); if(value) { return value.get(); } break; } case WeatherDataPoint::GlobalHorizontalIlluminance: { boost::optional<double> value = m_data[index.row()].globalHorizontalIlluminance(); if(value) { return value.get(); } break; } case WeatherDataPoint::DirectNormalIlluminance: { boost::optional<double> value = m_data[index.row()].directNormalIlluminance(); if(value) { return value.get(); } break; } case WeatherDataPoint::DiffuseHorizontalIlluminance: { boost::optional<double> value = m_data[index.row()].diffuseHorizontalIlluminance(); if(value) { return value.get(); } break; } case WeatherDataPoint::ZenithLuminance: { boost::optional<double> value = m_data[index.row()].zenithLuminance(); if(value) { return value.get(); } break; } case WeatherDataPoint::WindDirection: { boost::optional<double> value = m_data[index.row()].windDirection(); if(value) { return value.get(); } break; } case WeatherDataPoint::WindSpeed: { boost::optional<double> value = m_data[index.row()].windSpeed(); if(value) { return value.get(); } break; } case WeatherDataPoint::TotalSkyCover: { boost::optional<double> value = m_data[index.row()].totalSkyCover(); if(value) { return value.get(); } break; } case WeatherDataPoint::OpaqueSkyCover: { boost::optional<double> value = m_data[index.row()].opaqueSkyCover(); if(value) { return value.get(); } break; } case WeatherDataPoint::Visibility: { boost::optional<double> value = m_data[index.row()].visibility(); if(value) { return value.get(); } break; } case WeatherDataPoint::CeilingHeight: { boost::optional<double> value = m_data[index.row()].ceilingHeight(); if(value) { return value.get(); } break; } case WeatherDataPoint::PresentWeatherObservation: { boost::optional<double> value = m_data[index.row()].presentWeatherObservation(); if(value) { return value.get(); } break; } case WeatherDataPoint::PresentWeatherCodes: { boost::optional<int> value = m_data[index.row()].presentWeatherCodes(); if(value) { return value.get(); } break; } case WeatherDataPoint::PrecipitableWater: { boost::optional<double> value = m_data[index.row()].precipitableWater(); if(value) { return value.get(); } break; } case WeatherDataPoint::AerosolOpticalDepth: { boost::optional<double> value = m_data[index.row()].aerosolOpticalDepth(); if(value) { return value.get(); } break; } case WeatherDataPoint::SnowDepth: { boost::optional<double> value = m_data[index.row()].snowDepth(); if(value) { return value.get(); } break; } case WeatherDataPoint::DaysSinceLastSnowfall: { boost::optional<double> value = m_data[index.row()].daysSinceLastSnowfall(); if(value) { return value.get(); } break; } case WeatherDataPoint::Albedo: { boost::optional<double> value = m_data[index.row()].albedo(); if(value) { return value.get(); } break; } case WeatherDataPoint::LiquidPrecipitationDepth: { boost::optional<double> value = m_data[index.row()].liquidPrecipitationDepth(); if(value) { return value.get(); } break; } case WeatherDataPoint::LiquidPrecipitationQuantity: { boost::optional<double> value = m_data[index.row()].liquidPrecipitationQuantity(); if(value) { return value.get(); } break; } } /* if (index.row() >= stringList.size()) return QVariant(); if (role == Qt::DisplayRole) return stringList.at(index.row()); else return QVariant(); */ return QVariant(); }
void Db_table_View::on_resultado_list_clicked(const QModelIndex &index) { int row = index.row(); QSqlRecord r = model->record(row); selected_value = r.value(selection_column).toString(); }
// performs the navigation i.e. goes from mime type view to category view to document view and back void HierarchicalDocumentLauncherView::filterNavigate(FilterNavigation navigation, QModelIndex selectedItem) { QContentFilter lastFilter; if (navigation == NavigateBackward) { if (!selectedFilters.isEmpty()) { // pop the last filter from the list lastFilter = selectedFilters.takeLast(); enterNavigationMode(); } else exitNavigationMode(); } else if (navigation == NavigateForward) { if (selectedItem.isValid()) { // push the newly selected filter to the list AbstractContentFilterPropertyListModel *model = qobject_cast<AbstractContentFilterPropertyListModel *>(icons->model()); if (model) selectedFilters.append(model->value(selectedItem.row())); } } switch (selectedFilters.count()) { case 0: // show types icons->setModel(modelTypes); selectedFilterLabel->setText(QString()); break; case 1: // show categories icons->setModel(modelCategories); selectedFilterLabel->setText(modelTypes->findPropertyName(selectedFilters.first())); break; default: // both type and category have been selected selectedFilterLabel->setText(modelTypes->findPropertyName(selectedFilters.first()) + " / " + modelCategories->findPropertyName(selectedFilters.at(1))); // refresh filters of contentset QContentFilter newFilter(QContent::Document); foreach (QContentFilter filter, selectedFilters) { if (!filter.isValid()) continue; newFilter &= filter; } // filter the content set contentSet->setCriteria(newFilter); // show filtered docs icons->setModel(bpModel); exitNavigationMode(); break; } setCurrentItem(lastFilter); }
//----------------------------------------------------------------------------- // Function: AbstractParameterModel::data() //----------------------------------------------------------------------------- QVariant AbstractParameterModel::data( QModelIndex const& index, int role /*= Qt::DisplayRole */ ) const { if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) { return QVariant(); } if (role == Qt::DisplayRole) { if (index.column() == valueColumn() || index.column() == bitWidthLeftColumn() || index.column() == bitWidthRightColumn() || index.column() == arrayLeftColumn() || index.column() == arrayRightColumn()) { return expressionFormatter_->formatReferringExpression(valueForIndex(index).toString()); } else if (index.column() == descriptionColumn()) { return valueForIndex(index).toString().replace(QRegularExpression("\n.*$", QRegularExpression::DotMatchesEverythingOption), "..."); } else { return valueForIndex(index); } } else if (role == Qt::EditRole) { return expressionOrValueForIndex(index); } else if (role == Qt::ToolTipRole) { if (index.column() == valueColumn() && !index.sibling(index.row(), choiceColumn()).data().toString().isEmpty()) { QString choiceText = index.sibling(index.row(), choiceColumn()).data(Qt::DisplayRole).toString(); if (!choiceText.isEmpty()) { return expressionOrValueForIndex(index); } } if (index.column() == valueColumn() || index.column() == bitWidthLeftColumn() || index.column() == bitWidthRightColumn() || index.column() == arrayLeftColumn() || index.column() == arrayRightColumn()) { return formattedValueFor(valueForIndex(index).toString()); } else { return valueForIndex(index); } } else if (Qt::BackgroundRole == role) { return backgroundColorForIndex(index); } else if (Qt::ForegroundRole == role) { return blackForValidOrRedForInvalidIndex(index); } else // if unsupported role { return QVariant(); } }
void QucsHelp::displaySelectedChapter(const QItemSelection & is) { const QModelIndex index = is.indexes()[0]; if(index.isValid()) textBrowser->setSource(QUrl(QucsHelpDir.filePath(links[index.row()]))); }
void PasswordsContentsWidget::filterPasswords(const QString &filter) { for (int i = 0; i < m_model->rowCount(); ++i) { const QModelIndex domainIndex(m_model->index(i, 0, m_model->invisibleRootItem()->index())); int foundSets(0); bool hasDomainMatch(filter.isEmpty() || domainIndex.data(Qt::DisplayRole).toString().contains(filter, Qt::CaseInsensitive)); for (int j = 0; j < m_model->rowCount(domainIndex); ++j) { const QModelIndex setIndex(m_model->index(j, 0, domainIndex)); bool hasFieldMatch(hasDomainMatch || setIndex.data(Qt::DisplayRole).toString().contains(filter, Qt::CaseInsensitive)); if (!hasFieldMatch) { for (int k = 0; k < m_model->rowCount(setIndex); ++k) { const QModelIndex fieldIndex(m_model->index(k, 0, setIndex)); if (fieldIndex.data(Qt::DisplayRole).toString().contains(filter, Qt::CaseInsensitive) || (fieldIndex.data(FieldTypeRole).toInt() != PasswordsManager::PasswordField && fieldIndex.sibling(fieldIndex.row(), 1).data(Qt::DisplayRole).toString().contains(filter, Qt::CaseInsensitive))) { hasFieldMatch = true; break; } } if (hasFieldMatch) { ++foundSets; } } m_ui->passwordsViewWidget->setRowHidden(j, domainIndex, (!filter.isEmpty() && !hasFieldMatch)); } m_ui->passwordsViewWidget->setRowHidden(i, m_model->invisibleRootItem()->index(), (foundSets == 0 && !hasDomainMatch)); } }
QVariant StringListModel::data(const QModelIndex &index, int role) const { if (!index.isValid() || index.row() >= stringList.size() || role != Qt::DisplayRole ) return QVariant(); return stringList.at(index.row()); }
// read QSettings values and return them QVariant OptionsModel::data(const QModelIndex & index, int role) const { if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: return GUIUtil::GetStartOnSystemStartup(); case MinimizeToTray: return fMinimizeToTray; case MapPortUPnP: #ifdef USE_UPNP return settings.value("fUseUPnP"); #else return false; #endif case MinimizeOnClose: return fMinimizeOnClose; // default proxy case ProxyUse: return settings.value("fUseProxy", false); case ProxyIP: { // contains IP at index 0 and port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); return strlIpPort.at(0); } case ProxyPort: { // contains IP at index 0 and port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); return strlIpPort.at(1); } #ifdef ENABLE_WALLET case SpendZeroConfChange: return settings.value("bSpendZeroConfChange"); #endif case DisplayUnit: return nDisplayUnit; case ThirdPartyTxUrls: return strThirdPartyTxUrls; case Digits: return settings.value("digits"); case Theme: return settings.value("theme"); case Language: return settings.value("language"); case CoinControlFeatures: return fCoinControlFeatures; case DatabaseCache: return settings.value("nDatabaseCache"); case ThreadsScriptVerif: return settings.value("nThreadsScriptVerif"); case NitrosendRounds: return QVariant(nNitrosendRounds); case AnonymizeDarkcoinAmount: return QVariant(nAnonymizeDarkcoinAmount); case Listen: return settings.value("fListen"); default: return QVariant(); } } return QVariant(); }
void PreferencesDialog::chooseTab(const QModelIndex &index) { mUi->listWidget->setCurrentRow(index.row()); mUi->pageContentWidget->setCurrentIndex(index.row() + 1); }
/* \a type must be either be Install or Info */ void PackageView::showDetails( const QModelIndex &item , PackageDetails::Type type ) { if( !item.isValid() || !item.parent().isValid() || !model->hasIndex(item.row(), item.column(), item.parent()) ) return; if ( type != PackageDetails::Confirm && type != PackageDetails::Info ) return; QString name = model->data( item, Qt::DisplayRole ).toString(); //package name PackageDetails::Options options; QString text; if ( type == PackageDetails::Confirm ) { options = PackageDetails::Allow; #ifndef QT_NO_SXE if( DomainInfo::hasSensitiveDomains(model->data(item,AbstractPackageController::Domains).toString()) ) { text = QLatin1String( "<font color=\"#0000FF\">"); text += tr( "The package <font color=\"#0000FF\">%1</font> <b>cannot be installed</b> as it utilizes protected resources" ).arg( name ); text += QLatin1String("</font>"); type = PackageDetails::Confirm; options = PackageDetails::Disallow; } else { text = QString("<font color=\"#000000\">") + "<center><b><u>" + tr( "Security Alert" ) + "</u></b></center><p>" + QString("%1") .arg( DomainInfo::explain( model->data( item, AbstractPackageController::Domains ).toString(), name )); } #else text = "<center><b><u>" + tr( "Confirm Install") + " </u></b></center><p>" + tr("About to install <font color=\"#0000CC\"><b> %1 </b></font>", "%1 = package name") .arg( name ); #endif if ( options == PackageDetails::Allow ) text += QString("<br>") + tr( "Confirm Install?" ); } else //must be requesting package information { text = model->data(item, Qt::WhatsThisRole).toString(); if ( tabWidget->currentIndex() == InstalledIndex ) options = PackageDetails::Uninstall; else //must be DownloadIndex { //check if package has been installed if (model->isInstalled(item)) options= PackageDetails::None; //don't allow install option to appear //as a context menu option else options = PackageDetails::Install; //let install option appear //as a context menu option } #ifndef QT_NO_SXE if( DomainInfo::hasSensitiveDomains(model->data(item,AbstractPackageController::Domains).toString()) ) options = PackageDetails::None; #endif } qLog(Package) << "show details" << ( name.isNull() ? "no valid name" : name ); PackageDetails *pd = new PackageDetails( this, name, text, type, options ); int result = QtopiaApplication::execDialog(pd);; delete pd; //see if the user wants to proceed to the next stage if ( result == PackageDetails::Proceed ) { if ( type == PackageDetails::Confirm ) model->activateItem( item ); //for a confirm dialog this means installing else if ( type == PackageDetails::Info && (options & PackageDetails::Install) ) showDetails( item, PackageDetails::Confirm ); //for an (install) info dialog this means proceeding to confirm installation else if ( type == PackageDetails::Info && (options & PackageDetails::Uninstall) ) startUninstall(); //for an (uninstall) info dialog this means starting to uninstall (which implicitly asks for confirmation) } }
QModelIndex WBHistoryCompletionModel::mapFromSource(const QModelIndex &sourceIndex) const { int row = sourceIndex.row() * 2; return index(row, sourceIndex.column()); }
void PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); Q_ASSERT( item ); QTextOption textOption( Qt::AlignVCenter | (Qt::Alignment)index.data( Qt::TextAlignmentRole ).toUInt() ); textOption.setWrapMode( QTextOption::NoWrap ); QStyleOptionViewItemV4 opt = option; prepareStyleOption( &opt, index, item ); opt.text.clear(); qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( m_view->hoveredIndex().row() == index.row() && m_view->hoveredIndex().column() == index.column() && ( index.column() == PlayableModel::Artist || index.column() == PlayableModel::Album || index.column() == PlayableModel::Track ) ) { opt.rect.setWidth( opt.rect.width() - 16 ); QRect arrowRect( opt.rect.x() + opt.rect.width(), opt.rect.y() + 1, opt.rect.height() - 2, opt.rect.height() - 2 ); QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, arrowRect.size() ); painter->drawPixmap( arrowRect, infoIcon ); } painter->save(); if ( index.column() == PlayableModel::Score ) { QColor barColor( 167, 183, 211 ); // This matches the sidebar (sourcetreeview.cpp:672) if ( opt.state & QStyle::State_Selected ) painter->setPen( opt.palette.brightText().color() ); else painter->setPen( barColor ); QRect r = opt.rect.adjusted( 3, 3, -6, -4 ); painter->drawRect( r ); QRect fillR = r; int fillerWidth = (int)( index.data().toFloat() * (float)fillR.width() ); fillR.adjust( 0, 0, -( fillR.width() - fillerWidth ), 0 ); if ( opt.state & QStyle::State_Selected ) painter->setBrush( opt.palette.brightText().color() ); else painter->setBrush( barColor ); painter->drawRect( fillR ); } else if ( item->isPlaying() ) { QRect r = opt.rect.adjusted( 3, 0, 0, 0 ); // Paint Now Playing Speaker Icon if ( m_view->header()->visualIndex( index.column() ) == 0 ) { r.adjust( 0, 0, 0, -3 ); painter->drawPixmap( r.adjusted( 3, 1, 18 - r.width(), 1 ), TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker ) ); r.adjust( 25, 0, 0, 3 ); } painter->setPen( opt.palette.text().color() ); QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, textOption ); } else { painter->setPen( opt.palette.text().color() ); QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, opt.rect.width() - 6 ); painter->drawText( opt.rect.adjusted( 3, 1, -3, 0 ), text, textOption ); } painter->restore(); }
/*! Called from the parent() test. A model that returns an index of parent X should also return X when asking for the parent of the index. This recursive function does pretty extensive testing on the whole model in an effort to catch edge cases. This function assumes that rowCount(), columnCount() and index() already work. If they have a bug it will point it out, but the above tests should have already found the basic bugs because it is easier to figure out the problem in those tests then this one. */ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) { // First just try walking back up the tree. QModelIndex p = parent; while ( p.isValid() ) p = p.parent(); // For models that are dynamically populated if ( model->canFetchMore ( parent ) ) { fetchingMore = true; model->fetchMore ( parent ); fetchingMore = false; } int rows = model->rowCount ( parent ); int columns = model->columnCount ( parent ); if ( rows > 0 ) QVERIFY( model->hasChildren ( parent ) ); // Some further testing against rows(), columns(), and hasChildren() QVERIFY( rows >= 0 ); QVERIFY( columns >= 0 ); if ( rows > 0 ) QVERIFY( model->hasChildren ( parent ) ); //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows // << "columns:" << columns << "parent column:" << parent.column(); QVERIFY( !model->hasIndex ( rows + 1, 0, parent ) ); for ( int r = 0; r < rows; ++r ) { if ( model->canFetchMore ( parent ) ) { fetchingMore = true; model->fetchMore ( parent ); fetchingMore = false; } QVERIFY( !model->hasIndex ( r, columns + 1, parent ) ); for ( int c = 0; c < columns; ++c ) { QVERIFY( model->hasIndex ( r, c, parent ) ); QModelIndex index = model->index ( r, c, parent ); // rowCount() and columnCount() said that it existed... QVERIFY( index.isValid() ); // index() should always return the same index when called twice in a row QModelIndex modifiedIndex = model->index ( r, c, parent ); QVERIFY( index == modifiedIndex ); // Make sure we get the same index if we request it twice in a row QModelIndex a = model->index ( r, c, parent ); QModelIndex b = model->index ( r, c, parent ); QVERIFY( a == b ); // Some basic checking on the index that is returned QVERIFY( index.model() == model ); QCOMPARE( index.row(), r ); QCOMPARE( index.column(), c ); // While you can technically return a QVariant usually this is a sign // of a bug in data(). Disable if this really is ok in your model. // QVERIFY( model->data ( index, Qt::DisplayRole ).isValid() ); // If the next test fails here is some somewhat useful debug you play with. if (model->parent(index) != parent) { qDebug() << r << c << currentDepth << model->data(index).toString() << model->data(parent).toString(); qDebug() << index << parent << model->parent(index); // And a view that you can even use to show the model. // QTreeView view; // view.setModel(model); // view.show(); } // Check that we can get back our real parent. QCOMPARE( model->parent ( index ), parent ); // recursively go down the children if ( model->hasChildren ( index ) && currentDepth < 10 ) { //qDebug() << r << c << "has children" << model->rowCount(index); checkChildren ( index, ++currentDepth ); }/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/ // make sure that after testing the children that the index doesn't change. QModelIndex newerIndex = model->index ( r, c, parent ); QVERIFY( index == newerIndex ); } } }
bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, int role ) { if ( !QStandardItemModel::setData( idx, value, role ) ) return false; if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol ) { QgsWkbTypes::Type wkbType = ( QgsWkbTypes::Type ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt(); QString tip; if ( wkbType == QgsWkbTypes::Unknown ) { tip = tr( "Specify a geometry type in the '%1' column" ).arg( tr( "Data Type" ) ); } else if ( wkbType != QgsWkbTypes::NoGeometry ) { bool ok; int srid = idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok ); if ( !ok || srid == INT_MIN ) tip = tr( "Enter a SRID into the '%1' column" ).arg( tr( "SRID" ) ); } QStringList pkCols = idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toStringList(); if ( tip.isEmpty() && !pkCols.isEmpty() ) { QSet<QString> s0( idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 2 ).toStringList().toSet() ); QSet<QString> s1( pkCols.toSet() ); if ( s0.intersect( s1 ).isEmpty() ) tip = tr( "Select columns in the '%1' column that uniquely identify features of this layer" ).arg( tr( "Feature id" ) ); } for ( int i = 0; i < dbtmColumns; i++ ) { QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) ); if ( tip.isEmpty() ) { if ( i == dbtmSchema ) { item->setData( QVariant(), Qt::DecorationRole ); } item->setFlags( item->flags() | Qt::ItemIsSelectable ); item->setToolTip( QLatin1String( "" ) ); } else { item->setFlags( item->flags() & ~Qt::ItemIsSelectable ); if ( i == dbtmSchema ) item->setData( QgsApplication::getThemeIcon( QStringLiteral( "/mIconWarning.svg" ) ), Qt::DecorationRole ); if ( i == dbtmSchema || i == dbtmTable || i == dbtmGeomCol ) { item->setFlags( item->flags() ); item->setToolTip( tip ); } } } } return true; }
qint64 TelegramMessagesModel::id(const QModelIndex &index) const { int row = index.row(); return p->messages.at(row); }
void ClassList::slotCurrentRowChanged(const QModelIndex ¤t, const QModelIndex &) { emit currentRowChanged(current.row()); }
//----------------------------------------------------------------------------- // Function: AbstractParameterModel::setData() //----------------------------------------------------------------------------- bool AbstractParameterModel::setData(QModelIndex const& index, const QVariant& value, int role /*= Qt::EditRole */) { if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) { return false; } if (role == Qt::EditRole) { QSharedPointer<Parameter> parameter = getParameterOnRow(index.row()); if (index.column() == nameColumn()) { parameter->setName(value.toString()); } else if (index.column() == displayNameColumn()) { parameter->setDisplayName(value.toString()); } else if (index.column() == typeColumn()) { parameter->setType(value.toString()); } else if (index.column() == bitWidthLeftColumn()) { if (!value.isValid()) { removeReferencesFromSingleExpression(parameter->getBitWidthLeft()); emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()), QAbstractTableModel::index(rowCount() - 1, usageCountColumn())); } parameter->setBitWidthLeft(value.toString()); if (value.isValid() && parameter->getBitWidthRight().isEmpty() && !value.toString().isEmpty()) { parameter->setBitWidthRight(QString::number(0)); } } else if (index.column() == bitWidthRightColumn()) { if (!value.isValid()) { removeReferencesFromSingleExpression(parameter->getBitWidthRight()); emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()), QAbstractTableModel::index(rowCount() - 1, usageCountColumn())); } parameter->setBitWidthRight(value.toString()); if (value.isValid() && parameter->getBitWidthLeft().isEmpty() && !value.toString().isEmpty()) { parameter->setBitWidthLeft(QString::number(0)); } } else if (index.column() == minimumColumn()) { parameter->setMinimumValue(value.toString()); } else if (index.column() == maximumColumn()) { parameter->setMaximumValue(value.toString()); } else if (index.column() == choiceColumn()) { parameter->setChoiceRef(value.toString()); } else if (index.column() == valueColumn()) { if (!value.isValid()) { removeReferencesFromSingleExpression(parameter->getValue()); emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()), QAbstractTableModel::index(rowCount() - 1, usageCountColumn())); } parameter->setValue(value.toString()); } else if (index.column() == resolveColumn()) { parameter->setValueResolve(value.toString()); } else if (index.column() == arrayLeftColumn()) { if (!value.isValid()) { removeReferencesFromSingleExpression(parameter->getAttribute("kactus2:arrayLeft")); emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()), QAbstractTableModel::index(rowCount() - 1, usageCountColumn())); } parameter->setAttribute("kactus2:arrayLeft", value.toString()); if (value.isValid() && parameter->getAttribute("kactus2:arrayRight").isEmpty() && !parameter->getAttribute("kactus2:arrayLeft").isEmpty()) { parameter->setAttribute("kactus2:arrayRight", QString::number(0)); } } else if (index.column() == arrayRightColumn()) { if (!value.isValid()) { removeReferencesFromSingleExpression(parameter->getAttribute("kactus2:arrayRight")); emit dataChanged(QAbstractTableModel::index(0, usageCountColumn()), QAbstractTableModel::index(rowCount() - 1, usageCountColumn())); } parameter->setAttribute("kactus2:arrayRight", value.toString()); if (value.isValid() && parameter->getAttribute("kactus2:arrayLeft").isEmpty() && !parameter->getAttribute("kactus2:arrayRight").isEmpty()) { parameter->setAttribute("kactus2:arrayLeft", QString::number(0)); } } else if (index.column() == descriptionColumn()) { parameter->setDescription(value.toString()); } else if (index.column() == idColumn()) { return false; } else { return false; } emit dataChanged(index, index); emit contentChanged(); return true; } else // is unsupported role { return false; } }
QString VLCModel::getMeta( const QModelIndex & index, int meta ) { return index.model()->index( index.row(), columnFromMeta( meta ), index.parent() ). data().toString(); }
bool MetodModel::setData(const QModelIndex &index,const QVariant &value,int role/*,bool nul*/) { //MessageHandler::showMessage(MessageHandler::Error,"1",0); if(index.column()==2) { //MessageHandler::showMessage(MessageHandler::Error,QString::number(role),0); //int temp=value.toInt(); //if(nul) int temp=value.toInt(); if(role!=Qt::DecorationRole) ++temp; else role=Qt::EditRole; // MessageHandler::showMessage(MessageHandler::Error,"temp "+QString::number(value.toInt()),0); QString res=""; QModelIndex idx; //model_events->submitAll(); int n=model_events->rowCount(); // MessageHandler::showMessage(MessageHandler::Error,"n "+QString::number(n),0); bool flag=true; for(int i=0;i<n&&flag;++i) { idx=model_events->index(i,0); // MessageHandler::showMessage(MessageHandler::Error,"idx.data "+QString::number(idx.data().toInt()),0); if(idx.data().toInt()==temp) { idx=model_events->index(i,1); res=idx.data().toString(); // MessageHandler::showMessage(MessageHandler::Error,"res "+res,0); flag=false; } } if(!flag) { idx=QStandardItemModel::index(index.row(),8); QStandardItemModel::setData(idx,temp); return QStandardItemModel::setData(index,QVariant(res),role); } else return true; } if(index.column()==5) { int temp=value.toInt(); if(role!=Qt::DecorationRole) ++temp; else role=Qt::EditRole; QString res=""; QModelIndex idx; model_report_type->submitAll(); int n=model_report_type->rowCount(); bool flag=true; for(int i=0;i<n&&flag;++i) { idx=model_report_type->index(i,0); if(idx.data().toInt()==temp) { idx=model_report_type->index(i,1); res=idx.data().toString(); flag=false; } } idx=QStandardItemModel::index(index.row(),9); QStandardItemModel::setData(idx,temp); return QStandardItemModel::setData(index,QVariant(res),role); } role=Qt::EditRole; return QStandardItemModel::setData(index,value,role); }