本文整理汇总了C++中WStandardItem::data方法的典型用法代码示例。如果您正苦于以下问题:C++ WStandardItem::data方法的具体用法?C++ WStandardItem::data怎么用?C++ WStandardItem::data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WStandardItem
的用法示例。
在下文中一共展示了WStandardItem::data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addEntry
///
// Add an entry to the browser
//
bool FileBrowser::addEntry(bool rootDir, int entryDepth,
const std::string &baseDir,
const std::string &baseName,
int index)
{
//
// The code below adds an entry into the tree such as follows:
//
// + tract_meta.bash
// + dicom_seriesCollect.bash
// + tract_meta-stage-2-dcm2trk.bash
// |
// + stage-1-mri_convert
// |
// + diff_unpack
//
// ...
//
// The relatively convoluted logic below is responsible for
// adding a new item to this tree structure.
// If it's not a root directory, add the unique folder names as
// root folder entries
if (!rootDir)
{
bool addEntry = true;
int modelRow;
// Iterate over all the rows in the root
for (modelRow = 0; modelRow < mModel->rowCount(); modelRow++)
{
WStandardItem *item = mModel->item(modelRow);
bool match = true;
// For the depth of the folder, attempt to match as many folders
// as possible.
for (int depth = 0; depth <= entryDepth && item != NULL; depth++)
{
path dirPath = path(baseDir);
for (int d = 0; d < (entryDepth - depth); d++)
{
dirPath = dirPath.branch_path();
}
std::string folderLeafName = path(dirPath).leaf().string();
boost::any displayData = item->data(DisplayRole);
if (!displayData.empty())
{
WString folderName = boost::any_cast<WString>(displayData);
// Folder did not match, this means we need to add it
// to the tree
if (folderName.toUTF8() != folderLeafName)
{
match = false;
break;
}
}
}
// All folders matched, we do not need a new folder
if (match)
{
addEntry = false;
}
}
// Add all of the necessary folder entries to the tree
if (addEntry)
{
WStandardItem *lastItem = mModel->invisibleRootItem();
for (int depth = 0; depth <= entryDepth; depth++)
{
path dirPath = path(baseDir);
for (int d = 0; d < (entryDepth - depth); d++)
{
dirPath = dirPath.branch_path();
}
std::string folderLeafName = path(dirPath).leaf().string();
bool addFolder = true;
for (int row = 0; row < lastItem->rowCount(); row++)
{
WStandardItem *item = lastItem->child(row);
std::string folderLeafName = path(dirPath).leaf().string();
boost::any displayData = item->data(DisplayRole);
if (!displayData.empty())
{
WString folderName = boost::any_cast<WString>(displayData);
if (folderName.toUTF8() == folderLeafName)
{
addFolder = false;
lastItem = item;
//.........这里部分代码省略.........
示例2: data
boost::any WStandardItemModel::data(const WModelIndex& index, int role) const
{
WStandardItem *item = itemFromIndex(index, false);
return item ? item->data(role) : boost::any();
}