本文整理汇总了C++中QTreeView::model方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::model方法的具体用法?C++ QTreeView::model怎么用?C++ QTreeView::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeView
的用法示例。
在下文中一共展示了QTreeView::model方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleReload
void TreeCtrl::handleReload(Root::Action & t)
{
QTreeView* tv = wnd();
ENABLED_IF( t, true );
tv->reset();
if( tv->model() )
QMetaObject::invokeMethod( tv->model(), "reload" );
}
示例2: handleCollapseAll
void TreeCtrl::handleCollapseAll(Root::Action & t)
{
QTreeView* tv = wnd();
ENABLED_IF( t, true );
const int count = tv->model()->rowCount();
for( int i = 0; i < count; i++ )
expand( tv, tv->model()->index( i, 0 ), false );
}
示例3: handleExpandAll
void TreeCtrl::handleExpandAll(Root::Action & t)
{
QTreeView* tv = wnd();
ENABLED_IF( t, true );
QApplication::setOverrideCursor( Qt::WaitCursor );
const int count = tv->model()->rowCount();
for( int i = 0; i < count; i++ )
expand( tv, tv->model()->index( i, 0 ), true );
QApplication::restoreOverrideCursor();
}
示例4: expandTreeView
void SatellitesConfigDialog::expandTreeView()
{
QTreeView *treeView = m_configWidget->treeView;
if( !treeView->model() ) {
return;
}
// expand only branches with selected items
treeView->expandAll();
for ( int i = 0; i < treeView->model()->columnCount(); ++i ) {
treeView->resizeColumnToContents( i );
}
}
示例5: QSplitter
Route::Route(QWidget *parent, Core *core) : QSplitter(parent)
{
this->core = core;
// Machine tree
QTreeView *routeTree = new QTreeView(this);
routeTree->setModel(core->gearsTree);
routeTree->model()->setHeaderData(0, Qt::Horizontal, tr("Machines"));
connect(routeTree, SIGNAL(doubleClicked(QModelIndex)), SLOT(newMachine(QModelIndex)));
// Editor
routeScene = new QGraphicsScene(this);
routeScene->setSceneRect(0, 0, 1440, 768);
routeEditor = new QGraphicsView(routeScene, this);
routeEditor->setRenderHints(QPainter::Antialiasing);
routeEditor->centerOn(0, 0);
extraline = new QGraphicsPathItem();
extraline->hide();
routeScene->addItem(extraline);
// Layout
addWidget(routeTree);
addWidget(routeEditor);
setStretchFactor(1, 1);
}
示例6: invalidateWidgetPositions
void PackagesDelegate::invalidateWidgetPositions ()
{
QTreeView *view = qobject_cast<QTreeView*> (parent ());
QAbstractItemModel *model = view->model ();
for (int i = 0, rows = model->rowCount ();
i < rows; ++i)
emit sizeHintChanged (model->index (i, 0));
}
示例7: showPlaylistsContextMenu
void MainWindow::showPlaylistsContextMenu(QPoint point)
{
QTreeView *playlists = (QTreeView*)ui->tvPlaylists;
if(playlists->indexAt(point).isValid()) {
QStandardItemModel *model = (QStandardItemModel*)playlists->model();
QStandardItem *item = model->itemFromIndex(playlists->indexAt(point));
int data = item->data(DATA_KEY_PLAYLIST).toInt();
QList<QAction *> actions;
QAction *action;
switch(data) {
case DATA_SEARCH:
break;
case DATA_EMPTY:
action = new QAction(playlists);
action->setText(tr("Add"));
connect(action, SIGNAL(triggered()), this, SLOT(addPlaylist()));
actions.append(action);
break;
case DATA_HISTORY:
break;
default:
action = new QAction(playlists);
action->setText(tr("Delete"));
connect(action, SIGNAL(triggered()), this, SLOT(deletePlaylist()));
actions.append(action);
break;
}
if(actions.count() > 0)
{
point.setX(point.x()-10);
point.setY(point.y()+30);
QMenu::exec(actions, playlists->mapToGlobal(point));
}
}
}
示例8: testGlobalSearch
void TestGlobalSearch::testGlobalSearch()
{
QString filename(QFile::decodeName(FILES_DATA_DIR "/TestGlobalSearch.kexi"));
kDebug() << filename;
NewArgs args(m_argv);
args.vals[args.count - 1] = qstrdup(QFile::encodeName(filename).constData());
KexiAboutData aboutData;
aboutData.setProgramName(ki18n(metaObject()->className()));
int result = KexiMainWindow::create(args.count, args.vals, aboutData);
QVERIFY(kapp);
QCOMPARE(result, 0);
QLineEdit *lineEdit = kexiTester().widget<QLineEdit*>("globalSearch.lineEdit");
QVERIFY(lineEdit);
QTreeView *treeView = kexiTester().widget<QTreeView*>("globalSearch.treeView");
QVERIFY(treeView);
lineEdit->setFocus();
// enter "cars", expect 4 completion items
QTest::keyClicks(lineEdit, "cars");
QVERIFY(treeView->isVisible());
int globalSearchCompletionListRows = treeView->model()->rowCount();
QCOMPARE(globalSearchCompletionListRows, 4);
// add "x", expect no completion items and hidden list
QTest::keyClicks(lineEdit, "x");
QVERIFY(!treeView->isVisible());
globalSearchCompletionListRows = treeView->model()->rowCount();
QCOMPARE(globalSearchCompletionListRows, 0);
// Escape should clear
QTest::keyClick(lineEdit, Qt::Key_Escape, Qt::NoModifier, GUI_DELAY);
QVERIFY(lineEdit->text().isEmpty());
QTest::keyClicks(lineEdit, "cars");
QVERIFY(treeView->isVisible());
treeView->setFocus();
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
QTest::keyPress(treeView, Qt::Key_Down, Qt::NoModifier, GUI_DELAY);
// 3rd row should be "cars" form
QModelIndexList selectedIndices = treeView->selectionModel()->selectedRows();
QCOMPARE(selectedIndices.count(), 1);
QCOMPARE(treeView->model()->data(selectedIndices.first(), Qt::DisplayRole).toString(), QLatin1String("cars"));
// check if proper entry of Project Navigator is selected
QTest::keyPress(treeView, Qt::Key_Enter, Qt::NoModifier, GUI_DELAY);
KexiProjectNavigator *projectNavigator = kexiTester().widget<KexiProjectNavigator*>("KexiProjectNavigator");
QVERIFY(projectNavigator);
KexiPart::Item* selectedPartItem = projectNavigator->selectedPartItem();
QVERIFY(selectedPartItem);
QCOMPARE(selectedPartItem->name(), QLatin1String("cars"));
QCOMPARE(selectedPartItem->partClass(), QLatin1String("org.kexi-project.form"));
if (m_goToEventLoop) {
result = qApp->exec();
QCOMPARE(result, 0);
}
}
示例9: helpEvent
/*
* Called every time user positions mouse over package's treeview items
*/
bool TreeViewPackagesItemDelegate::helpEvent ( QHelpEvent *event, QAbstractItemView*,
const QStyleOptionViewItem&, const QModelIndex &index )
{
if (this->parent()->objectName() == "tvPackages")
{
QTreeView* tvPackages = qobject_cast<QTreeView*>(this->parent());
QSortFilterProxyModel *sfp = qobject_cast<QSortFilterProxyModel*>(tvPackages->model());
QStandardItemModel *sim = qobject_cast<QStandardItemModel*>(sfp->sourceModel());
if (sim->rowCount() == 0) return false;
QModelIndex ind = sfp->mapToSource(index);
QStandardItem *si = sim->itemFromIndex(ind);
if (si)
{
//If the user's mouse is not positioned above the name column, let's give him a little help...
if (si->column() != ctn_PACKAGE_NAME_COLUMN)
{
QModelIndex miName = sim->index(si->row(), ctn_PACKAGE_NAME_COLUMN);
si = sim->itemFromIndex(miName);
}
QPoint p;
gPoint = tvPackages->mapToGlobal(event->pos());
QFuture<QString> f;
disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
f = QtConcurrent::run(showPackageInfo, si->text());
g_fwToolTip.setFuture(f);
connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
}
else return false;
}
else if (this->parent()->objectName() == "tvTransaction")
{
QTreeView* tvTransaction = qobject_cast<QTreeView*>(this->parent());
QStandardItemModel *sim = qobject_cast<QStandardItemModel*>(tvTransaction->model());
if (sim->rowCount() == 0) return false;
QStandardItem *si = sim->itemFromIndex(index);
if (si)
{
//If it's really a package in the Transaction treeview...
QString pkgName=si->text();
//We have to separate Repository from Package Name, first
int slash = pkgName.indexOf("/");
if (slash != -1)
{
pkgName = pkgName.mid(slash+1);
}
if (si->icon().pixmap(22, 22).toImage() ==
IconHelper::getIconInstallItem().pixmap(22, 22).toImage() ||
si->icon().pixmap(22, 22).toImage() ==
IconHelper::getIconRemoveItem().pixmap(22, 22).toImage())
{
QStandardItemModel *modelPackages = MainWindow::returnMainWindow()->getModelPackages();
QList<QStandardItem*> foundItems =
modelPackages->findItems(pkgName, Qt::MatchExactly, ctn_PACKAGE_NAME_COLUMN);
if (foundItems.count() > 0)
{
QStandardItem *siFound = foundItems.at(0);
QPoint p;
gPoint = tvTransaction->mapToGlobal(event->pos());
QFuture<QString> f;
disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
f = QtConcurrent::run(showPackageInfo, siFound->text());
g_fwToolTip.setFuture(f);
connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
}
}
else
{
QToolTip::hideText();
}
}
}
return true;
}
示例10: helpEvent
/*
* Called every time user positions mouse over package's treeview items
*/
bool TreeViewPackagesItemDelegate::helpEvent ( QHelpEvent *event, QAbstractItemView*,
const QStyleOptionViewItem&, const QModelIndex &index )
{
if (this->parent()->objectName() == "tvPackages")
{
QTreeView* tvPackages = qobject_cast<QTreeView*>(this->parent());
PackageModel* sim = qobject_cast<PackageModel*>(tvPackages->model());
if (sim == NULL || sim->getPackageCount() == 0) return false;
const PackageRepository::PackageData*const si = sim->getData(index);
if (si != NULL)
{
QPoint p;
gPoint = tvPackages->mapToGlobal(event->pos());
QFuture<QString> f;
disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
f = QtConcurrent::run(showPackageInfo, si->name);
g_fwToolTip.setFuture(f);
connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
}
else return false;
}
else if (this->parent()->objectName() == "tvTransaction")
{
QTreeView* tvTransaction = qobject_cast<QTreeView*>(this->parent());
QStandardItemModel *sim = qobject_cast<QStandardItemModel*>(tvTransaction->model());
if (sim->rowCount() == 0) return false;
QStandardItem *si = sim->itemFromIndex(index);
if (si)
{
//If it's really a package in the Transaction treeview...
QString pkgName=si->text();
//We have to separate Repository from Package Name, first
int slash = pkgName.indexOf("/");
if (slash != -1)
{
pkgName = pkgName.mid(slash+1);
}
if (si->icon().pixmap(22, 22).toImage() ==
IconHelper::getIconInstallItem().pixmap(22, 22).toImage() ||
si->icon().pixmap(22, 22).toImage() ==
IconHelper::getIconRemoveItem().pixmap(22, 22).toImage())
{
gPoint = tvTransaction->mapToGlobal(event->pos());
QFuture<QString> f;
disconnect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
f = QtConcurrent::run(showPackageInfo, pkgName);
g_fwToolTip.setFuture(f);
connect(&g_fwToolTip, SIGNAL(finished()), this, SLOT(execToolTip()));
}
else
{
QToolTip::hideText();
}
}
}
return true;
}
示例11: keyPressEvent
//.........这里部分代码省略.........
}
else if(ke->key() == Qt::Key_C && ke->modifiers() == Qt::ControlModifier)
{
copyFullPathToClipboard();
}
else if(ke->key() == Qt::Key_L && ke->modifiers() == Qt::ControlModifier)
{
m_leFilterPackage->setFocus();
m_leFilterPackage->selectAll();
}
else if(ke->key() == Qt::Key_F && ke->modifiers() == Qt::ControlModifier)
{
if (m_commandExecuting != ectn_NONE) return;
if (isPropertiesTabWidgetVisible() &&
(ui->twProperties->currentIndex() == ctn_TABINDEX_INFORMATION ||
ui->twProperties->currentIndex() == ctn_TABINDEX_OUTPUT ||
ui->twProperties->currentIndex() == ctn_TABINDEX_NEWS ||
ui->twProperties->currentIndex() == ctn_TABINDEX_HELPUSAGE))
{
QTextBrowser *tb = ui->twProperties->currentWidget()->findChild<QTextBrowser*>("textBrowser");
SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar");
if (tb && tb->toPlainText().size() > 0 && searchBar)
{
if (searchBar) searchBar->show();
}
}
else if (isPropertiesTabWidgetVisible() && ui->twProperties->currentIndex() == ctn_TABINDEX_FILES)
{
QTreeView *tb = ui->twProperties->currentWidget()->findChild<QTreeView*>("tvPkgFileList");
SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar");
if (tb && tb->model()->rowCount() > 0 && searchBar)
{
if (searchBar) searchBar->show();
}
}
}
else if(ke->key() == Qt::Key_D && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
{
//The user wants to know which packages have no description!
showPackagesWithNoDescription();
}
else if(ke->key() == Qt::Key_G && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
{
//The user wants to go to "Display All groups"
if (!isAllGroupsSelected())
{
ui->twGroups->setCurrentItem(m_AllGroupsItem);
}
}
else if(ke->key() == Qt::Key_Y && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)
&& m_hasAURTool)
{
if (m_commandExecuting != ectn_NONE) return;
//The user wants to use "AUR tool" to search for pkgs
m_actionSwitchToAURTool->trigger();
if (m_actionSwitchToAURTool->isChecked() && UnixCommand::getLinuxDistro() != ectn_KAOS)
{
m_leFilterPackage->setFocus();
}
else
{
ui->tvPackages->setFocus();
示例12: keyPressEvent
//.........这里部分代码省略.........
}
else if (ke->key() == Qt::Key_F10)
{
maximizePackagesTreeView(false);
}
else if (ke->key() == Qt::Key_F12)
{
maximizePropertiesTabWidget(false);
}
else if(ke->key() == Qt::Key_C && ke->modifiers() == Qt::ControlModifier)
{
copyFullPathToClipboard();
}
else if(ke->key() == Qt::Key_L && ke->modifiers() == Qt::ControlModifier)
{
m_leFilterPackage->setFocus();
m_leFilterPackage->selectAll();
}
else if(ke->key() == Qt::Key_F && ke->modifiers() == Qt::ControlModifier)
{
if (m_commandExecuting != ectn_NONE) return;
if (isPropertiesTabWidgetVisible() &&
(ui->twProperties->currentIndex() == ctn_TABINDEX_INFORMATION ||
ui->twProperties->currentIndex() == ctn_TABINDEX_OUTPUT ||
ui->twProperties->currentIndex() == ctn_TABINDEX_NEWS ||
ui->twProperties->currentIndex() == ctn_TABINDEX_HELPUSAGE))
{
QTextBrowser *tb = ui->twProperties->currentWidget()->findChild<QTextBrowser*>("textBrowser");
SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar");
if (tb && tb->toPlainText().size() > 0 && searchBar)
{
if (searchBar) searchBar->show();
}
}
else if (isPropertiesTabWidgetVisible() && ui->twProperties->currentIndex() == ctn_TABINDEX_FILES)
{
QTreeView *tb = ui->twProperties->currentWidget()->findChild<QTreeView*>("tvPkgFileList");
SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar");
if (tb && tb->model()->rowCount() > 0 && searchBar)
{
if (searchBar) searchBar->show();
}
}
}
else if(ke->key() == Qt::Key_D && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
{
//The user wants to know which packages have no description!
showPackagesWithNoDescription();
}
else if(ke->key() == Qt::Key_G && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
{
//The user wants to go to "Display All groups"
if (!isAllCategoriesSelected())
{
ui->twGroups->setCurrentItem(m_AllGroupsItem);
}
}
else if(ke->key() == Qt::Key_C && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
{
if (m_commandExecuting == ectn_NONE)
{
doCleanCache(); //If we are not executing any command, let's clean the cache
}
}
else if(ke->key() == Qt::Key_R && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
{
if (m_commandExecuting == ectn_NONE)
{
doRemovePacmanLockFile(); //If we are not executing any command, let's remove Pacman's lock file
}
}
else if(ke->key() == Qt::Key_T && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)
&& m_initializationCompleted)
{
if (m_commandExecuting != ectn_NONE) return;
QStringList terminals = Terminal::getListOfAvailableTerminals();
if (terminals.count() > 2)
{
int index = terminals.indexOf(SettingsManager::getTerminal());
int newIndex = selectTerminal(index);
if (index != newIndex)
{
SettingsManager::setTerminal(terminals.at(newIndex));
}
}
}
/*else if(ke->key() == Qt::Key_Z && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
{
parseXBPSProcessOutput("Updating configuration file `/etc/skel/.bashrc");
}*/
else ke->ignore();
}