本文整理汇总了C++中TreeModel类的典型用法代码示例。如果您正苦于以下问题:C++ TreeModel类的具体用法?C++ TreeModel怎么用?C++ TreeModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: loadModel
void TreeViewWidget::addObjects(openstudio::IddObjectType type)
{
if(type == openstudio::IddObjectType::UserCustom){
return;
}
QModelIndexList rowList;
if(mTreeView->getSelectedRows(rowList)){
mTreeView->expand(rowList.at(0));
openstudio::Handle handle = mTreeModel->modelAtIndex(rowList.at(0))->handle();
TreeModel * model = static_cast<TreeModel *>(mTreeView->model());
model->addRows(rowList,type);
loadModel();
///! TODO this is a hack to get all indexes on all tree nodes
expandAllNodes();
QModelIndex index;
QModelIndexList persistentIndexList = mTreeModel->getPersistentIndexList();
for(int i=0; i<persistentIndexList.size(); i++){
index = persistentIndexList.at(i);
if(index.isValid()){
if(mTreeModel->modelAtIndex(index)->handle() == handle){
mTreeView->setCurrentIndex(index);
break;
}
}
}
emit modelDirty();
}
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:32,代码来源:TreeViewWidget.cpp
示例2: updateActions
void ProjectsTree::setCurrent(int id)
{
if (id) {
current_project_id = id;
updateActions(); //
TreeModel *model = (TreeModel *)view->model();
TreeItem *item = model->getItem(id);
if (item) {
statusBar()->showMessage(tr("Long.name.%1").arg(item->getName()));
#if defined TRAYPROJECT
trayIcon->showMessage("Change", item->getName());
#endif
} else {
statusBar()->showMessage(tr("Bad Project: (%1)").arg(id));
}
for (int i = 0; i < recent_projects.size(); ++i) {
if (recent_projects[i] == id) {
recent_projects.removeAt(i);
}
}
recent_projects.append(id);
while (recent_projects.size() > 10) {
recent_projects.removeFirst();
}
redrawRecentMenu();
} else {
statusBar()->showMessage(tr("No Project: (%1)").arg(id));
}
}
开发者ID:gam3,项目名称:trasker,代码行数:30,代码来源:projects.cpp
示例3: moveRowDown
void MetaEditor::moveRowDown()
{
QModelIndex index = view->selectionModel()->currentIndex();
TreeModel *model = qobject_cast<TreeModel *>(view->model());
if (model->moveRowDown(index.row(), index.parent()))
updateActions();
}
开发者ID:Sigil-Ebook,项目名称:Sigil,代码行数:7,代码来源:MetaEditor.cpp
示例4: TreeView
Tomahawk::ViewPage*
ViewManager::show( const Tomahawk::collection_ptr& collection )
{
m_currentCollection = collection;
TreeView* view;
if ( !m_treeViews.contains( collection ) || m_treeViews.value( collection ).isNull() )
{
view = new TreeView();
view->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel();
view->setTreeModel( model );
if ( collection && collection->source()->isLocal() )
view->setEmptyTip( tr( "After you have scanned your music collection you will find your tracks right here." ) );
else
view->setEmptyTip( tr( "This collection is empty." ) );
model->addCollection( collection );
m_treeViews.insert( collection, view );
}
else
{
view = m_treeViews.value( collection ).data();
}
setPage( view );
return view;
}
开发者ID:,项目名称:,代码行数:30,代码来源:
示例5: TreeWidget
Tomahawk::ViewPage*
ViewManager::show( const Tomahawk::collection_ptr& collection )
{
m_currentCollection = collection;
TreeWidget* widget;
if ( !m_treeWidgets.contains( collection ) || m_treeWidgets.value( collection ).isNull() )
{
widget = new TreeWidget();
widget->view()->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel();
widget->view()->setTreeModel( model );
if ( !collection.isNull() )
widget->view()->setEmptyTip( collection->emptyText() );
model->addCollection( collection );
m_treeWidgets.insert( collection, widget );
}
else
{
widget = m_treeWidgets.value( collection ).data();
}
setPage( widget );
return widget;
}
开发者ID:twischer,项目名称:tomahawk,代码行数:28,代码来源:ViewManager.cpp
示例6: FlexibleTreeView
Tomahawk::ViewPage*
ViewManager::show( const Tomahawk::collection_ptr& collection )
{
m_currentCollection = collection;
FlexibleTreeView* view;
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
{
view = new FlexibleTreeView();
view->columnView()->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel();
view->setTreeModel( model );
model->addCollection( collection );
setPage( view );
if ( !collection.isNull() )
view->setEmptyTip( collection->emptyText() );
m_collectionViews.insert( collection, view );
}
else
{
view = m_collectionViews.value( collection ).data();
}
view->restoreViewMode();
setPage( view );
return view;
}
开发者ID:prodigeni,项目名称:tomahawk,代码行数:32,代码来源:ViewManager.cpp
示例7: QFETCH
void tst_QColumnView::moveGrip()
{
QFETCH(bool, reverse);
if (reverse)
qApp->setLayoutDirection(Qt::RightToLeft);
ColumnView view;
TreeModel model;
view.setModel(&model);
QModelIndex home = model.thirdLevel();
view.setCurrentIndex(home);
view.resize(640, 200);
view.show();
QTest::qWait(ANIMATION_DELAY);
int columnNum = view.createdColumns.count() - 2;
QVERIFY(columnNum >= 0);
QObjectList list = view.createdColumns[columnNum]->children();
QColumnViewGrip *grip = 0;
for (int i = 0; i < list.count(); ++i) {
if ((grip = qobject_cast<QColumnViewGrip *>(list[i]))) {
break;
}
}
if (!grip)
return;
QAbstractItemView *column = qobject_cast<QAbstractItemView *>(grip->parent());
int oldX = column->width();
QCOMPARE(view.columnWidths()[columnNum], oldX);
grip->moveGrip(10);
QCOMPARE(view.columnWidths()[columnNum], (oldX + (reverse ? -10 : 10)));
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:32,代码来源:tst_qcolumnview.cpp
示例8: QMainWindow
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
QStringList headers;
headers << tr("Title") << tr("Description");
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
TreeModel *model = new TreeModel(headers, file.readAll());
file.close();
view->setModel(model);
for (int column = 0; column < model->columnCount(); ++column)
view->resizeColumnToContents(column);
connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(view->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &,
const QItemSelection &)),
this, SLOT(updateActions()));
connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions()));
connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow()));
connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn()));
connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow()));
connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn()));
connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild()));
updateActions();
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:33,代码来源:mainwindow.cpp
示例9: testIteration
void tst_TreeModel::testIteration()
{
TreeModel<> m;
TreeItem *r = m.rootItem();
TreeItem *group0 = createItem("group0");
TreeItem *group1 = createItem("group1");
TreeItem *item10 = createItem("item10");
TreeItem *item11 = createItem("item11");
TreeItem *item12 = createItem("item12");
group1->appendChild(item10);
group1->appendChild(item11);
TreeItem *group2 = createItem("group2");
TreeItem *item20 = createItem("item20");
TreeItem *item21 = createItem("item21");
TreeItem *item22 = createItem("item22");
r->appendChild(group0);
r->appendChild(group1);
r->appendChild(group2);
group1->appendChild(item12);
group2->appendChild(item20);
group2->appendChild(item21);
group2->appendChild(item22);
QCOMPARE(r->childCount(), 3);
QCOMPARE(countLevelItems(r, 1), 3);
QCOMPARE(countLevelItems(r, 2), 6);
QCOMPARE(countLevelItems(r, 3), 0);
QCOMPARE(countLevelItems(group0, 1), 0);
QCOMPARE(countLevelItems(group1, 1), 3);
QCOMPARE(countLevelItems(group1, 2), 0);
QCOMPARE(countLevelItems(group2, 1), 3);
QCOMPARE(countLevelItems(group2, 2), 0);
}
开发者ID:choenig,项目名称:qt-creator,代码行数:33,代码来源:tst_treemodel.cpp
示例10: TreeModel
void
CollectionViewPage::onCollectionChanged()
{
TreeModel* model = new TreeModel();
PlayableModel* flatModel = new PlayableModel();
PlayableModel* albumModel = new PlayableModel();
setTreeModel( model );
setFlatModel( flatModel );
setAlbumModel( albumModel );
model->addCollection( m_collection );
flatModel->appendTracks( m_collection );
albumModel->appendAlbums( m_collection );
if ( m_collection && m_collection->source() && m_collection->source()->isLocal() )
{
setEmptyTip( tr( "After you have scanned your music collection you will find your tracks right here." ) );
}
else
setEmptyTip( tr( "This collection is empty." ) );
if ( m_collection.objectCast<ScriptCollection>() )
m_trackView->setEmptyTip( tr( "Cloud collections aren't supported in the flat view yet. We will have them covered soon. Switch to another view to navigate them." ) );
}
开发者ID:Alex237,项目名称:tomahawk,代码行数:25,代码来源:CollectionViewPage.cpp
示例11: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
a.setOrganizationName("CodeRush");
a.setOrganizationDomain("coderush.me");
a.setApplicationName("UEFIExtract");
if (a.arguments().length() > 32) {
std::cout << "Too many arguments" << std::endl;
return 1;
}
if (a.arguments().length() > 1) {
QString path = a.arguments().at(1);
QFileInfo fileInfo(path);
if (!fileInfo.exists())
return ERR_FILE_OPEN;
QFile inputFile;
inputFile.setFileName(path);
if (!inputFile.open(QFile::ReadOnly))
return ERR_FILE_OPEN;
QByteArray buffer = inputFile.readAll();
inputFile.close();
TreeModel model;
FfsParser ffsParser(&model);
STATUS result = ffsParser.parse(buffer);
if (result)
return result;
std::vector<std::pair<QString, QModelIndex> > messages = ffsParser.getMessages();
for (size_t i = 0; i < messages.size(); i++) {
std::cout << messages[i].first.toLatin1().constData() << std::endl;
}
FfsDumper ffsDumper(&model);
if (a.arguments().length() == 2) {
return (ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump")) != ERR_SUCCESS);
}
else {
UINT32 returned = 0;
for (int i = 2; i < a.arguments().length(); i++) {
result = ffsDumper.dump(model.index(0, 0), fileInfo.fileName().append(".dump"), a.arguments().at(i));
if (result)
returned |= (1 << (i - 1));
}
return returned;
}
}
else {
std::cout << "UEFIExtract 0.10.8" << std::endl << std::endl
<< "Usage: UEFIExtract imagefile [FileGUID_1 FileGUID_2 ... FileGUID_31]" << std::endl
<< "Return value is a bit mask where 0 at position N means that file with GUID_N was found and unpacked, 1 otherwise" << std::endl;
return 1;
}
}
开发者ID:godthem90,项目名称:Mac_Security_S4,代码行数:59,代码来源:uefiextract_main.cpp
示例12: QDialog
MetaEditor::MetaEditor(QWidget *parent)
: QDialog(parent),
m_mainWindow(qobject_cast<MainWindow *>(parent)),
m_Relator(MarcRelators::instance()),
m_RemoveRow(new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_Delete),this, 0, 0, Qt::WidgetWithChildrenShortcut))
{
setupUi(this);
m_book = m_mainWindow->GetCurrentBook();
m_version = m_book->GetConstOPF()->GetEpubVersion();
m_opfdata = m_book->GetOPF()->GetText();
QStringList headers;
headers << tr("Name") << tr("Value");
QString data = GetOPFMetadata();
TreeModel *model = new TreeModel(headers, data);
view->setModel(model);
for (int column = 0; column < model->columnCount(); ++column)
view->resizeColumnToContents(column);
if (!isVisible()) {
ReadSettings();
}
if (m_version.startsWith('3')) {
loadMetadataElements();
loadMetadataProperties();
} else {
loadE2MetadataElements();
loadE2MetadataProperties();
}
connect(view->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &,
const QItemSelection &)),
this, SLOT(updateActions()));
connect(delButton, SIGNAL(clicked()), this, SLOT(removeRow()));
connect(tbMoveUp, SIGNAL(clicked()), this, SLOT(moveRowUp()));
connect(tbMoveDown, SIGNAL(clicked()), this, SLOT(moveRowDown()));
connect(m_RemoveRow, SIGNAL(activated()), this, SLOT(removeRow()));
if (m_version.startsWith('3')) {
connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectElement()));
connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectProperty()));
} else {
connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectE2Element()));
connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectE2Property()));
}
connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveData()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
updateActions();
}
开发者ID:Sigil-Ebook,项目名称:Sigil,代码行数:57,代码来源:MetaEditor.cpp
示例13: copyObjects
void TreeViewWidget::copyObjects()
{
mModelObjectsToPaste.clear();
QModelIndexList rowList;
if(mTreeView->getSelectedRows(rowList)){
TreeModel * model = static_cast<TreeModel *>(mTreeView->model());
BOOST_FOREACH(const QModelIndex& row, rowList){
mModelObjectsToPaste.push_back(*(model->modelAtIndex(row)));
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:9,代码来源:TreeViewWidget.cpp
示例14: exposeCurrentProject
void ProjectsTree::exposeCurrentProject()
{
TreeModel *model = view->model();
const QModelIndex &item = model->getCurrentIndex();
show();
view->scrollTo(item, QAbstractItemView::PositionAtCenter);
}
开发者ID:gam3,项目名称:trasker,代码行数:10,代码来源:projects.cpp
示例15: WriteSettings
void MetaEditor::saveData()
{
WriteSettings();
TreeModel *model = qobject_cast<TreeModel *>(view->model());
QString data = model->getAllModelData();
QString newopfdata = SetNewOPFMetadata(data);
m_book->GetOPF()->SetText(newopfdata);
QDialog::accept();
}
开发者ID:Sigil-Ebook,项目名称:Sigil,代码行数:11,代码来源:MetaEditor.cpp
示例16: insert
void UEFITool::insert(const UINT8 mode)
{
QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
if (!index.isValid())
return;
TreeModel* model = ffsEngine->treeModel();
UINT8 type;
if (mode == CREATE_MODE_BEFORE || mode == CREATE_MODE_AFTER)
type = model->type(index.parent());
else
type = model->type(index);
QString path;
switch (type) {
case Types::Volume:
path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"), currentDir, "FFS files (*.ffs *.bin);;All files (*.*)");
break;
case Types::File:
case Types::Section:
path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"), currentDir, "Section files (*.sct *.bin);;All files (*.*)");
break;
default:
return;
}
if (path.trimmed().isEmpty())
return;
QFileInfo fileInfo = QFileInfo(path);
if (!fileInfo.exists()) {
ui->statusBar->showMessage(tr("Please select existing file"));
return;
}
QFile inputFile;
inputFile.setFileName(path);
if (!inputFile.open(QFile::ReadOnly)) {
QMessageBox::critical(this, tr("Insertion failed"), tr("Can't open output file for reading"), QMessageBox::Ok);
return;
}
QByteArray buffer = inputFile.readAll();
inputFile.close();
UINT8 result = ffsEngine->insert(index, buffer, mode);
if (result) {
QMessageBox::critical(this, tr("Insertion failed"), errorMessage(result), QMessageBox::Ok);
return;
}
ui->actionSaveImageFile->setEnabled(true);
}
开发者ID:Zhangqq,项目名称:UEFITool,代码行数:54,代码来源:uefitool.cpp
示例17: removeObjects
void TreeViewWidget::removeObjects()
{
QModelIndexList rowList;
if(mTreeView->getSelectedRows(rowList)){
std::vector<openstudio::Handle> handles;
TreeModel * model = static_cast<TreeModel *>(mTreeView->model());
model->removeRows(rowList,handles);
if(!handles.empty()){
loadModel();
emit modelDirty();
}
}
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:13,代码来源:TreeViewWidget.cpp
示例18: displayNone
void TestResultView::displayTestResult(const TestResult *const result)
{
if(!result)
{
displayNone();
return;
}
/* ------- the Test Status Label --------- */
resultStatus->setText(result->status() ? TestResult::displayName(result->status())
: QLatin1String("Not Applicable"));
/* --------------------------------------- */
/* ------------ the AST View ------------- */
ASTItem *astTree = result->astTree();
static_cast<TreeModel *>(astView->model())->setRoot(astTree);
/* --------------------------------------- */
/* ------- the Error code/msg View ------- */
ErrorItem *msgRoot = new ErrorItem(ErrorHandler::Message(), 0);
const ErrorHandler::Message::List msgs(result->messages());
ErrorHandler::Message::List::const_iterator it(msgs.constBegin());
const ErrorHandler::Message::List::const_iterator end(msgs.constEnd());
for(; it != end; ++it)
msgRoot->appendChild(new ErrorItem(*it, msgRoot));
TreeModel *etm = static_cast<TreeModel *>(messageOutput->model());
etm->setRoot(msgRoot);
/* --------------------------------------- */
const QPatternist::Item::List items(result->items());
/* ----- the Serialized Output View ------ */
serializedResult->setPlainText(result->asSerialized());
/* --------------------------------------- */
/* ------ the Item List Output View ------ */
XDTItemItem *itemRoot = new XDTItemItem(QPatternist::Item(), 0);
QPatternist::Item item;
QPatternist::Item::List::const_iterator itemIt(items.constBegin());
const QPatternist::Item::List::const_iterator itemsEnd(items.constEnd());
for(; itemIt != itemsEnd; ++itemIt)
itemRoot->appendChild(new XDTItemItem(*itemIt, itemRoot));
TreeModel *itm = static_cast<TreeModel *>(itemListResult->model());
itm->setRoot(itemRoot);
/* --------------------------------------- */
}
开发者ID:,项目名称:,代码行数:51,代码来源:
示例19: execSyncV
void TreeModelBase::execSyncV( FieldContainer &oFrom,
ConstFieldMaskArg whichField,
AspectOffsetStore &oOffsets,
ConstFieldMaskArg syncMode,
const UInt32 uiSyncInfo)
{
TreeModel *pThis = static_cast<TreeModel *>(this);
pThis->execSync(static_cast<TreeModel *>(&oFrom),
whichField,
oOffsets,
syncMode,
uiSyncInfo);
}
开发者ID:Langkamp,项目名称:OpenSGToolbox,代码行数:14,代码来源:OSGTreeModelBase.cpp
示例20: populateUi
void UEFITool::populateUi(const QModelIndex ¤t)
{
if (!current.isValid())
return;
TreeModel* model = ffsEngine->treeModel();
UINT8 type = model->type(current);
UINT8 subtype = model->subtype(current);
// Set info text
ui->infoEdit->setPlainText(model->info(current));
// Enable menus
ui->menuCapsuleActions->setEnabled(type == Capsule);
ui->menuImageActions->setEnabled(type == Image);
ui->menuRegionActions->setEnabled(type == Region);
ui->menuPaddingActions->setEnabled(type == Padding);
ui->menuVolumeActions->setEnabled(type == Volume);
ui->menuFileActions->setEnabled(type == File);
ui->menuSectionActions->setEnabled(type == Section);
// Enable actions
ui->actionExtract->setDisabled(model->hasEmptyHeader(current) && model->hasEmptyBody(current) && model->hasEmptyTail(current));
ui->actionRebuild->setEnabled(type == Volume || type == File || type == Section);
ui->actionExtractBody->setDisabled(model->hasEmptyHeader(current));
ui->actionRemove->setEnabled(type == Volume || type == File || type == Section);
ui->actionInsertInto->setEnabled((type == Volume && subtype != UnknownVolume) ||
(type == File && subtype != EFI_FV_FILETYPE_ALL && subtype != EFI_FV_FILETYPE_RAW && subtype != EFI_FV_FILETYPE_PAD) ||
(type == Section && (subtype == EFI_SECTION_COMPRESSION || subtype == EFI_SECTION_GUID_DEFINED || subtype == EFI_SECTION_DISPOSABLE)));
ui->actionInsertBefore->setEnabled(type == File || type == Section);
ui->actionInsertAfter->setEnabled(type == File || type == Section);
ui->actionReplace->setEnabled((type == Region && subtype != DescriptorRegion) || type == File || type == Section);
ui->actionReplaceBody->setEnabled(type == File || type == Section);
}
开发者ID:anishp55,项目名称:UEFITool,代码行数:34,代码来源:uefitool.cpp
注:本文中的TreeModel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论