本文整理汇总了C++中QStandardItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::data方法的具体用法?C++ QStandardItem::data怎么用?C++ QStandardItem::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ModeStateOn
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
bool tCZoneModesModel::ModeStateOn( int modeIndex )
{
QStandardItem* pItem = item( modeIndex );
if (pItem != 0)
{
bool ok = false;
int circuitIndex = pItem->data( INDEX_ROLE ).toInt( &ok );
if ( ok )
{
tDigitalData state( tDataId( DATA_TYPE_SWITCH_STATE, circuitIndex, DATA_ENGINE_CZONE_SELECTION ) );
bool on = (state.Value() > 0) ? true : false;
return on;
}
}
return false;
}
示例2: updateProgressItem
void StandardItemModel::updateProgressItem(const QModelIndex& index, const int progressNumber) {
QStandardItem* progressItem = this->getProgressItemFromIndex(index);
int currentDownloadProgress = progressItem->data(ProgressRole).toInt();
if (currentDownloadProgress != progressNumber) {
// set progression :
progressItem->setData(progressNumber, ProgressRole);
if (this->isNzbItem(progressItem)) {
emit parentProgressItemChangedSignal();
}
}
}
示例3:
QList<RIEXItem> AcceptRIEXDialog::GetSelectedItems () const
{
QList<RIEXItem> result;
const auto itp = Core::Instance ().GetProxy ()->GetTagsManager ();
for (int i = 0, size = Model_->rowCount (); i < size; ++i)
{
QStandardItem *item = Model_->item (i);
if (item->checkState () != Qt::Checked)
continue;
auto riex = item->data ().value<RIEXItem> ();
riex.Groups_ = itp->Split (Model_->item (i, Column::Groups)->text ());
result << riex;
}
return result;
}
示例4: findUsersByPrefix
QStringList Channel::findUsersByPrefix(QString searchStr)
{
QStringList userList = QStringList();
// prevents bug when trying to tab before connected to a channel
if (this != NULL)
{
QModelIndex startIndex = users->index(0, 0);
QModelIndexList foundUsers = users->match(startIndex, User::UserDataName, searchStr, -1, Qt::MatchStartsWith);
for(QModelIndexList::Iterator iter = foundUsers.begin(); iter != foundUsers.end(); iter++) {
QStandardItem *user = users->itemFromIndex(*iter);
QString username = user->data(User::UserDataName).value<QString>();
userList.append(username);
}
}
return userList;
}
示例5: LazyLoadArt
void GlobalSearchView::LazyLoadArt(const QModelIndex& proxy_index) {
if (!proxy_index.isValid() || proxy_index.model() != front_proxy_) {
return;
}
// Already loading art for this item?
if (proxy_index.data(GlobalSearchModel::Role_LazyLoadingArt).isValid()) {
return;
}
// Should we even load art at all?
if (!app_->library_model()->use_pretty_covers()) {
return;
}
// Is this an album?
const LibraryModel::GroupBy container_type = LibraryModel::GroupBy(
proxy_index.data(LibraryModel::Role_ContainerType).toInt());
if (container_type != LibraryModel::GroupBy_Album &&
container_type != LibraryModel::GroupBy_AlbumArtist &&
container_type != LibraryModel::GroupBy_YearAlbum &&
container_type != LibraryModel::GroupBy_OriginalYearAlbum) {
return;
}
// Mark the item as loading art
const QModelIndex source_index = front_proxy_->mapToSource(proxy_index);
QStandardItem* item = front_model_->itemFromIndex(source_index);
item->setData(true, GlobalSearchModel::Role_LazyLoadingArt);
// Walk down the item's children until we find a track
while (item->rowCount()) {
item = item->child(0);
}
// Get the track's Result
const SearchProvider::Result result =
item->data(GlobalSearchModel::Role_Result)
.value<SearchProvider::Result>();
// Load the art.
int id = engine_->LoadArtAsync(result);
art_requests_[id] = source_index;
}
示例6: doubleClickedTree
void ModelProjectImpl::doubleClickedTree(QModelIndex index)
{
if (!index.isValid()) {
return;
}
QStandardItem *item = m_file->model()->itemFromIndex(index);
if (!item) {
return;
}
bool ok;
int itemType = item->data().toInt(&ok);
if (ok && ( itemType == ModelFileImpl::ItemFile ||
itemType == ModelFileImpl::ItemProFile ) ) {
QString fileName = m_file->fileNameToFullPath(item->text());
if (!fileName.isEmpty()) {
m_liteApp->fileManager()->openEditor(fileName);
}
}
}
示例7: exportSelectedPlaylist
/** Export one playlist at a time. */
void PlaylistDialog::exportSelectedPlaylist()
{
QString exportedPlaylistLocation;
SettingsPrivate *settings = SettingsPrivate::instance();
if (settings->value("locationForExportedPlaylist").isNull()) {
exportedPlaylistLocation = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
} else {
exportedPlaylistLocation = settings->value("locationForExportedPlaylist").toString();
}
auto indexes = savedPlaylists->selectionModel()->selectedIndexes();
if (indexes.isEmpty()) {
return;
}
QStandardItem *item = _savedPlaylistModel->itemFromIndex(indexes.first());
uint playlistId = item->data(PlaylistID).toUInt();
auto db = SqlDatabase::instance();
PlaylistDAO dao = db->selectPlaylist(playlistId);
QString title = this->convertNameToValidFileName(dao.title());
// Open a file dialog and ask the user to choose a location
QString newName = QFileDialog::getSaveFileName(this, tr("Export playlist"), exportedPlaylistLocation + QDir::separator() + title, tr("Playlist (*.m3u8)"));
if (QFile::exists(newName)) {
QFile removePreviousOne(newName);
if (!removePreviousOne.remove()) {
qDebug() << Q_FUNC_INFO << "Cannot remove" << newName;
}
}
if (newName.isEmpty()) {
return;
} else {
QFile f(newName);
if (f.open(QIODevice::ReadWrite | QIODevice::Text)) {
QTextStream stream(&f);
QList<TrackDAO> tracks = db->selectPlaylistTracks(playlistId);
for (TrackDAO t : tracks) {
stream << t.uri();
endl(stream);
}
}
f.close();
}
}
示例8: openRelateDoc
// 打开菜单
void RelateDocDialog::openRelateDoc()
{
QItemSelectionModel *selections = docsView->selectionModel();
QModelIndexList selected = selections->selectedIndexes();
// 选择第一个
QModelIndex index = selected.at(0);
QStandardItem* item = model->item(index.row(), 3);
QString docUuid = qvariant_cast<QString>(item->data(Qt::DisplayRole));
Doc doc = DocDao::selectDoc(docUuid);
QString filepath = doc.DOCUMENT_LOCATION;
QFileInfo fileInfo(filepath);
if(!fileInfo.exists()){
QMessageBox::warning(this, tr("Warning"), tr("Please Confirm The original file has Deleted Or Moved. "), QMessageBox::Yes);
return;
}
QDesktopServices::openUrl ( QUrl::fromLocalFile(filepath) );
}
示例9: RemoveService
void InternetModel::RemoveService(InternetService* service) {
if (!sServices->contains(service->name())) return;
// Find and remove the root item that this service created
for (int i = 0; i < invisibleRootItem()->rowCount(); ++i) {
QStandardItem* item = invisibleRootItem()->child(i);
if (!item ||
item->data(Role_Service).value<InternetService*>() == service) {
invisibleRootItem()->removeRow(i);
break;
}
}
// Remove the service from the list
sServices->remove(service->name());
// Disconnect the service
disconnect(service, 0, this, 0);
}
示例10: retranslate
void TelescopeDialog::retranslate()
{
if (dialog)
{
ui->retranslateUi(dialog);
setAboutText();
setHeaderNames();
updateWarningTexts();
//Retranslate type strings
for (int i = 0; i < telescopeListModel->rowCount(); i++)
{
QStandardItem* item = telescopeListModel->item(i, ColumnType);
QString original = item->data(Qt::UserRole).toString();
QModelIndex index = telescopeListModel->index(i, ColumnType);
telescopeListModel->setData(index, q_(original), Qt::DisplayRole);
}
}
}
示例11: on_AddButton__released
void BookmarksManagerDialog::on_AddButton__released ()
{
if (!CurrentEditor_)
{
qWarning () << Q_FUNC_INFO
<< "no editor available";
return;
}
QStandardItem *selected = GetSelectedItem ();
const QVariantMap& data = selected ?
selected->data ().toMap () :
CurrentEditor_->GetIdentifyingData ();
QStandardItem *item = new QStandardItem (data.value ("HumanReadableName").toString ());
item->setData (data);
BMModel_->appendRow (item);
Ui_.BookmarksTree_->setCurrentIndex (BMModel_->indexFromItem (item));
}
示例12: on_RemoveButton__released
void BookmarksManagerDialog::on_RemoveButton__released ()
{
QStandardItem *item = GetSelectedItem ();
if (!item)
return;
const auto& data = item->data ().toMap ();
if (QMessageBox::question (this,
"LeechCraft",
tr ("Are you sure you want to delete the bookmark %1?")
.arg (data.value ("HumanReadableName").toString ()),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
return;
BMModel_->removeRow (item->row ());
Save ();
}
示例13: ownedBy
bool FileOrganiserWidget::ownedBy(const QString &pFileName,
QStandardItem *pItem)
{
// Check whether pFileName is already owned by pItem
for (int i = 0, iMax = pItem->rowCount(); i < iMax; ++i) {
// Check whether the current item is a file with pFileName as its name
QStandardItem *crtItem = pItem->child(i);
if ( !crtItem->data(Item::Folder).toBool()
&& (crtItem->data(Item::Path).toString() == pFileName))
return true;
}
// We couldn't find a file with pFileName as its name in pItem, so...
return false;
}
示例14: saveModelToFile
// assumes model is not modified while we are writing it out
void UpdatingFileModel::saveModelToFile()
{
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QIODevice::Text)) {
qWarning() << "Cannot load model from file" << fileName;
return;
}
QTextStream out(&file);
QStandardItem* root = invisibleRootItem();
int r = root->rowCount();
for (int i = 0; i < r; ++i) {
QStandardItem* it = root->child(i);
out << it->data(Qt::DisplayRole).toString() << "\n";
}
file.close();
}
示例15: on_ModifyPerm__released
void RoomConfigWidget::on_ModifyPerm__released ()
{
QStandardItem *stdItem = GetCurrentItem ();
if (!stdItem)
return;
QStandardItem *parent = stdItem->parent ();
if (!Aff2Cat_.values ().contains (parent))
{
qWarning () << Q_FUNC_INFO
<< "bad parent"
<< parent
<< "for"
<< stdItem;
return;
}
const QXmppMucItem::Affiliation aff = Aff2Cat_.key (parent);
const QString& jid = stdItem->text ();
std::unique_ptr<AffiliationSelectorDialog> dia (new AffiliationSelectorDialog (this));
dia->SetJID (jid);
dia->SetAffiliation (aff);
dia->SetReason (stdItem->data (ItemRoles::Reason).toString ());
if (dia->exec () != QDialog::Accepted)
return;
const QString& newJid = dia->GetJID ();
if (newJid.isEmpty ())
return;
parent->removeRow (stdItem->row ());
QXmppMucItem item;
item.setJid (newJid);
item.setAffiliation (dia->GetAffiliation ());
item.setReason (dia->GetReason ());
SendItem (item);
if (item.affiliation () != QXmppMucItem::NoAffiliation)
handlePermsReceived ({ item });
}