本文整理汇总了C++中TreeModel类的典型用法代码示例。如果您正苦于以下问题:C++ TreeModel类的具体用法?C++ TreeModel怎么用?C++ TreeModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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));
}
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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)));
}
示例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();
}
示例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);
}
示例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." ) );
}
示例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;
}
}
示例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();
}
示例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)));
}
示例14: exposeCurrentProject
void ProjectsTree::exposeCurrentProject()
{
TreeModel *model = view->model();
const QModelIndex &item = model->getCurrentIndex();
show();
view->scrollTo(item, QAbstractItemView::PositionAtCenter);
}
示例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();
}