当前位置: 首页>>代码示例>>C++>>正文


C++ QStandardItem::data方法代码示例

本文整理汇总了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;
}
开发者ID:dulton,项目名称:53_hero,代码行数:21,代码来源:tCZoneModesModel.cpp

示例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();
        }

    }

}
开发者ID:KDE,项目名称:kwooty,代码行数:18,代码来源:standarditemmodel.cpp

示例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;
	}
开发者ID:SboichakovDmitriy,项目名称:leechcraft,代码行数:18,代码来源:acceptriexdialog.cpp

示例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;
}
开发者ID:technicallyerik,项目名称:WIRK,代码行数:18,代码来源:channel.cpp

示例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;
}
开发者ID:shaowei-wang,项目名称:Clementine,代码行数:44,代码来源:globalsearchview.cpp

示例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);
        }
    }
}
开发者ID:LiveFly,项目名称:liteide,代码行数:19,代码来源:modelprojectimpl.cpp

示例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();
	}
}
开发者ID:sun-friderick,项目名称:Miam-Player,代码行数:44,代码来源:playlistdialog.cpp

示例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) );
}
开发者ID:MrMattMunro,项目名称:filesearch,代码行数:20,代码来源:relatedocdialog.cpp

示例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);
}
开发者ID:Skengrobot,项目名称:Clementine,代码行数:19,代码来源:internetmodel.cpp

示例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);
		}
	}
}
开发者ID:PhiTheta,项目名称:stellarium,代码行数:19,代码来源:TelescopeDialog.cpp

示例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));
	}
开发者ID:ttldtor,项目名称:leechcraft,代码行数:19,代码来源:bookmarksmanagerdialog.cpp

示例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 ();
	}
开发者ID:ForNeVeR,项目名称:leechcraft,代码行数:19,代码来源:bookmarksmanagerdialog.cpp

示例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;
}
开发者ID:A1kmm,项目名称:opencor,代码行数:19,代码来源:fileorganiserwidget.cpp

示例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();
}
开发者ID:idaohang,项目名称:mole,代码行数:20,代码来源:models.cpp

示例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 });
	}
开发者ID:AlexWMF,项目名称:leechcraft,代码行数:42,代码来源:roomconfigwidget.cpp


注:本文中的QStandardItem::data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。