本文整理汇总了C++中WStandardItem::setFlags方法的典型用法代码示例。如果您正苦于以下问题:C++ WStandardItem::setFlags方法的具体用法?C++ WStandardItem::setFlags怎么用?C++ WStandardItem::setFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WStandardItem
的用法示例。
在下文中一共展示了WStandardItem::setFlags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WStandardItem
/*! \brief Create a folder item.
*
* Configures flags for drag and drop support.
*/
WStandardItem *createFolderItem(const WString& location,
const std::string& folderId = std::string())
{
WStandardItem *result = new WStandardItem(location);
if (!folderId.empty()) {
result->setData(boost::any(folderId));
result->setFlags(result->flags() | ItemIsDropEnabled);
folderNameMap_[folderId] = location;
} else
result->setFlags(result->flags().clear(ItemIsSelectable));
result->setIcon("icons/folder.gif");
return result;
}
示例2: populateFiles
/*! \brief Populate the files model.
*
* Data (and headers) is read from the CSV file data/files.csv. We
* add icons to the first column, resolve the folder id to the
* actual folder name, and configure item flags, and parse date
* values.
*/
void populateFiles() {
fileModel_->invisibleRootItem()->setRowCount(0);
std::ifstream f((appRoot() + "data/files.csv").c_str());
if (!f)
throw std::runtime_error("Could not read: data/files.csv");
readFromCsv(f, fileModel_);
for (int i = 0; i < fileModel_->rowCount(); ++i) {
WStandardItem *item = fileModel_->item(i, 0);
item->setFlags(item->flags() | ItemIsDragEnabled);
item->setIcon("icons/file.gif");
std::string folderId = item->text().toUTF8();
item->setData(boost::any(folderId), UserRole);
item->setText(folderNameMap_[folderId]);
convertToDate(fileModel_->item(i, 4));
convertToDate(fileModel_->item(i, 5));
}
}
示例3: addEntry
//.........这里部分代码省略.........
{
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;
break;
}
}
}
if (addFolder)
{
WStandardItem *newItem = new WStandardItem(folderLeafName);
newItem->setFlags(newItem->flags().clear(ItemIsSelectable));
newItem->setIcon("icons/folder.gif");
lastItem->appendRow(newItem);
lastItem = newItem;
}
}
}
}
// For root entries, add the file logs
else
{
mModel->appendRow(createEntry(baseName, index));
}
// Now add the items under the folders
if (!rootDir)
{
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();
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)
{
lastItem = item;
break;
}
}
}
}
if (lastItem != NULL)
{
lastItem->appendRow(createEntry(baseName, index));
}
}
// Add the directory to the watch list
addWatchPath(baseDir);
return true;
}