本文整理汇总了C++中QStandardItem::type方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::type方法的具体用法?C++ QStandardItem::type怎么用?C++ QStandardItem::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnTreeViewContextMenu
void MainWin::OnTreeViewContextMenu(const QPoint &point)
{
if (point.isNull())
return;
QStandardItem *item = connections->itemFromIndex(
ui.serversTreeView->indexAt(point)
);
QPoint currentPoint = QCursor::pos();
if (!item || currentPoint.isNull() || treeViewUILocked)
return;
int type = item->type();
if (type == RedisServerItem::TYPE) {
if (((RedisServerItem*)item)->isLocked()) {
QMessageBox::warning(ui.serversTreeView, "Warning", "Performing operations. Please Keep patience.");
return;
}
QAction * action = serverMenu->exec(currentPoint);
if (action == nullptr)
return;
if (action->text() == "Reload")
treeViewUILocked = true;
} else if (type == RedisKeyItem::TYPE) {
keyMenu->exec(currentPoint);
}
}
示例2: onItemDoubleClicked
void RepoTreeView::onItemDoubleClicked(const QModelIndex& index)
{
QStandardItem *item = getRepoItem(index);
if (!item) {
return;
}
if (item->type() == REPO_ITEM_TYPE) {
RepoItem *it = (RepoItem *)item;
const LocalRepo& local_repo = it->localRepo();
if (local_repo.isValid()) {
// open local folder for downloaded repo
QDesktopServices::openUrl(QUrl::fromLocalFile(local_repo.worktree));
} else {
// open seahub repo page for not downloaded repo
// if (seafApplet->isPro()) {
FileBrowserDialog* dialog = new FileBrowserDialog(it->repo(), this);
const QRect screen = QApplication::desktop()->screenGeometry();
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
dialog->show();
dialog->move(screen.center() - dialog->rect().center());
dialog->raise();
// } else {
// const Account& account = seafApplet->accountManager()->accounts()[0];
// if (account.isValid()) {
// QUrl url = account.getAbsoluteUrl("repo/" + it->repo().id);
// QDesktopServices::openUrl(url);
// }
// }
}
}
}
示例3: filterAcceptsRow
bool LibraryFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
if (filterAcceptsRowItself(sourceRow, sourceParent)) {
return true;
}
// Accept if any of the parents is accepted on it's own merits
QModelIndex parent = sourceParent;
while (parent.isValid()) {
if (filterAcceptsRowItself(parent.row(), parent.parent())) {
return true;
}
parent = parent.parent();
}
// Accept if any of the children is accepted on it's own merits
if (hasAcceptedChildren(sourceRow, sourceParent)) {
return true;
}
// Accept separators if any top level items and its children are accepted
QStandardItemModel *model = qobject_cast<QStandardItemModel*>(sourceModel());
QStandardItem *item = model->itemFromIndex(model->index(sourceRow, 0, sourceParent));
if (item && item->type() == Miam::IT_Separator) {
for (QModelIndex index : _topLevelItems.values(static_cast<SeparatorItem*>(item))) {
if (filterAcceptsRow(index.row(), sourceParent)) {
return true;
}
}
}
return (SettingsPrivate::instance()->librarySearchMode() == SettingsPrivate::LSM_HighlightOnly);
}
示例4: OnConnectionTreeClick
void MainWin::OnConnectionTreeClick(const QModelIndex & index)
{
if (treeViewUILocked || !index.isValid())
return;
QStandardItem * item = connections->itemFromIndex(index);
int type = item->type();
switch (type) {
case RedisServerItem::TYPE:
{
RedisServerItem * server = (RedisServerItem *)item;
server->runDatabaseLoading();
ui.serversTreeView->setExpanded(index, true);
}
break;
case RedisServerDbItem::TYPE:
{
performanceTimer.start();
RedisServerDbItem * db = (RedisServerDbItem *)item;
connections->blockSignals(true);
statusBar()->showMessage(QString("Loading keys ..."));
db->loadKeys();
ui.serversTreeView->setExpanded(index, true);
}
break;
case RedisKeyItem::TYPE:
ui.tabWidget->openKeyTab((RedisKeyItem *)item);
break;
}
}
示例5: viewportEvent
bool RepoTreeView::viewportEvent(QEvent *event)
{
if (event->type() != QEvent::ToolTip && event->type() != QEvent::WhatsThis) {
return QTreeView::viewportEvent(event);
}
QPoint global_pos = QCursor::pos();
QPoint viewport_pos = viewport()->mapFromGlobal(global_pos);
QModelIndex index = indexAt(viewport_pos);
if (!index.isValid()) {
return true;
}
QStandardItem *item = getRepoItem(index);
if (!item) {
return true;
}
QRect item_rect = visualRect(index);
if (item->type() == REPO_ITEM_TYPE) {
showRepoItemToolTip((RepoItem *)item, global_pos, item_rect);
} else {
showRepoCategoryItemToolTip((RepoCategoryItem *)item, global_pos, item_rect);
}
return true;
}
示例6: OnKeyOpenInNewTab
void MainWin::OnKeyOpenInNewTab()
{
QStandardItem * item = ui.serversTreeView->getSelectedItem();
if (item == nullptr || item->type() != RedisKeyItem::TYPE)
return;
ui.tabWidget->openKeyTab((RedisKeyItem *)item, true);
}
示例7:
bool RedisServerDbItem::operator<(const QStandardItem & other) const
{
if (other.type() == TYPE) {
const RedisServerDbItem * another = dynamic_cast<const RedisServerDbItem *>(&other);
return this->dbIndex < another->getDbIndex();
}
return this->text() < other.text();
}
示例8: collapse
void RepoTreeView::collapse(const QModelIndex& index, bool remember)
{
QTreeView::collapse(index);
if (remember) {
QStandardItem *item = getRepoItem(index);
if (item->type() == REPO_CATEGORY_TYPE) {
expanded_categroies_.remove(item->data(Qt::DisplayRole).toString());
}
}
}
示例9: OnConnectionTreeWheelClick
void MainWin::OnConnectionTreeWheelClick(const QModelIndex & index)
{
if (!index.isValid())
return;
QStandardItem * item = connections->itemFromIndex(index);
if (item->type() == RedisKeyItem::TYPE) {
ui.tabWidget->openKeyTab((RedisKeyItem *)item, true);
}
}
示例10: filterAcceptsRow
bool RepoFilterProxyModel::filterAcceptsRow(int source_row,
const QModelIndex & source_parent) const
{
RepoTreeModel *tree_model = (RepoTreeModel *)(sourceModel());
QModelIndex index = tree_model->index(source_row, 0, source_parent);
QStandardItem *item = tree_model->itemFromIndex(index);
if (item->type() == REPO_CATEGORY_TYPE) {
// RepoCategoryItem *category = (RepoCategoryItem *)item;
// We don't filter repo categories, only filter repos by name.
return true;
} else if (item->type() == REPO_ITEM_TYPE) {
// Use default filtering (filter by item DisplayRole, i.e. repo name)
bool match = QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
// if (match) {
// RepoCategoryItem *category = (RepoCategoryItem *)(item->parent());
// }
return match;
}
return false;
}
示例11: fetchMore
void LazyStandardItemModel::fetchMore(QModelIndex const &parent)
{
QStandardItemModel *m = &visualizer_->model_;
QStandardItem *item = m->itemFromIndex(parent);
if(item && item->type() == S_Leaf)
{
LeafTreeItem *tnd = static_cast<LeafTreeItem *>(item);
if(tnd->object_)
tnd->cloneChildrenFrom(tnd->object_->node_list_.front());
tnd->setExpanded(true);
}
}
示例12: filterAcceptsRow
/** Redefined from MiamSortFilterProxyModel. */
bool UniqueLibraryFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QStandardItem *item = _model->itemFromIndex(_model->index(sourceRow, 1, sourceParent));
if (!item) {
return false;
}
bool result = false;
switch (item->type()) {
case Miam::IT_Artist:
if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) {
result = true;
} else {
QSqlQuery getArtist(*SqlDatabase::instance());
getArtist.prepare("SELECT * FROM tracks WHERE title LIKE ? AND artistId = ?");
getArtist.addBindValue("%" + filterRegExp().pattern() + "%");
getArtist.addBindValue(item->data(Miam::DF_ID).toUInt());
result = getArtist.exec() && getArtist.next();
}
break;
case Miam::IT_Album:
if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) {
result = true;
} else if (filterRegExp().indexIn(item->data(Miam::DF_Artist).toString()) != -1) {
result = true;
} else {
QSqlQuery getAlbum(*SqlDatabase::instance());
getAlbum.prepare("SELECT * FROM tracks WHERE title LIKE ? AND albumId = ?");
getAlbum.addBindValue("%" + filterRegExp().pattern() + "%");
getAlbum.addBindValue(item->data(Miam::DF_ID).toUInt());
result = getAlbum.exec() && getAlbum.next();
}
break;
case Miam::IT_Track:
if (MiamSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent)) {
result = true;
} else {
result = filterRegExp().indexIn(item->data(Miam::DF_Artist).toString()) != -1 ||
filterRegExp().indexIn(item->data(Miam::DF_Album).toString()) != -1;
}
break;
case Miam::IT_Separator:
for (QModelIndex index : _topLevelItems.values(static_cast<SeparatorItem*>(item))) {
if (filterAcceptsRow(index.row(), sourceParent)) {
result = true;
}
}
break;
default:
break;
}
return result;
}
示例13: getItem
QStandardItem* RepoItemDelegate::getItem(const QModelIndex &index) const
{
if (!index.isValid()) {
return NULL;
}
const RepoTreeModel *model = (const RepoTreeModel*)index.model();
QStandardItem *item = model->itemFromIndex(index);
if (item->type() != REPO_ITEM_TYPE &&
item->type() != REPO_CATEGORY_TYPE) {
return NULL;
}
return item;
}
示例14: return
EventItem*
EventsListView::getItem(const QModelIndex &index) const
{
if (!index.isValid()) {
return NULL;
}
const EventsListModel *model = (const EventsListModel*)index.model();
QStandardItem *qitem = model->itemFromIndex(index);
if (qitem->type() == EVENT_ITEM_TYPE) {
return (EventItem *)qitem;
}
return NULL;
}
示例15: currentRowIndex
SymbolLayerItem* QgsSymbolV2PropertiesDialog::currentLayerItem()
{
int index = currentRowIndex();
if ( index < 0 )
return NULL;
QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listLayers->model() );
if ( model == NULL )
return NULL;
QStandardItem* item = model->item( index );
if ( item->type() != SymbolLayerItemType )
return NULL;
return static_cast<SymbolLayerItem*>( item );
}