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


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

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:FNNDSC,项目名称:web,代码行数:101,代码来源:FileBrowser.cpp

示例2: data

boost::any WStandardItemModel::data(const WModelIndex& index, int role) const
{
  WStandardItem *item = itemFromIndex(index, false);

  return item ? item->data(role) : boost::any();
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:6,代码来源:WStandardItemModel.C


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