当前位置: 首页>>代码示例>>C++>>正文


C++ QStandardItem::setEditable方法代码示例

本文整理汇总了C++中QStandardItem::setEditable方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setEditable方法的具体用法?C++ QStandardItem::setEditable怎么用?C++ QStandardItem::setEditable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QStandardItem的用法示例。


在下文中一共展示了QStandardItem::setEditable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: searchForComponentAndAddToList

void ComponentView::searchForComponentAndAddToList(const ModelNode &node)
{
    QList<ModelNode> nodeList;
    nodeList.append(node);
    nodeList.append(node.allSubModelNodes());


    foreach (const ModelNode &node, nodeList) {
        if (node.nodeSourceType() == ModelNode::ComponentSource) {
            if (!node.id().isEmpty()) {
                QStandardItem *item = new QStandardItem(node.id());
                item->setData(QVariant::fromValue(node), ModelNodeRole);
                item->setEditable(false);
                removeSingleNodeFromList(node); //remove node if already present
                m_standardItemModel->appendRow(item);
            } else {
                QString description;
                ModelNode parentNode = node.parentProperty().parentModelNode();
                if (parentNode.isValid())
                    if (!parentNode.id().isEmpty())
                        description = node.parentProperty().parentModelNode().id() + QLatin1Char(' ');
                    else
                        description = node.parentProperty().parentModelNode().simplifiedTypeName() + QLatin1Char(' ');
                description += node.parentProperty().name();
                QStandardItem *item = new QStandardItem(description);
                item->setData(QVariant::fromValue(node), ModelNodeRole);
                item->setEditable(false);
                removeSingleNodeFromList(node); //remove node if already present
                m_standardItemModel->appendRow(item);
            }
        }
    }
}
开发者ID:renatofilho,项目名称:QtCreator,代码行数:33,代码来源:componentview.cpp

示例2: addAuthor

void SelectAuthorsDialog::addAuthor( void )
{
	//check bounds first
	if ( authorsCombo->currentText().length() > int(database->maxAuthorNameLength()) ) {
		KMessageBox::error( this, i18ncp( "@info", "Author name cannot be longer than 1 character.", "Author name cannot be longer than %1 characters." , database->maxAuthorNameLength() ) );
		authorsCombo->lineEdit() ->selectAll();
		return ;
	}

	if ( authorsCombo->lineEdit()->text().isEmpty() )
		return;

	if ( authorsCombo->contains( authorsCombo->currentText() ) )
		authorsCombo->setCurrentItem( authorsCombo->currentText() );

	createNewAuthorIfNecessary();

	int currentItem = authorsCombo->currentIndex();
	Element currentElement = authorList.getElement( currentItem );

	QStandardItem *itemId = new QStandardItem;
	itemId->setData( QVariant(currentElement.id), Qt::EditRole );
	itemId->setEditable( false ); 
	QStandardItem *itemAuthor = new QStandardItem( currentElement.name );
	itemAuthor->setEditable( false );
	QList<QStandardItem*> items;
	items << itemId << itemAuthor;
	authorListModel->appendRow( items );

	authorsCombo->lineEdit()->clear();
}
开发者ID:KDE,项目名称:krecipes,代码行数:31,代码来源:selectauthorsdialog.cpp

示例3: create_new_download

void list_handling::create_new_download(const download &new_download, QStandardItem *pkg, int dl_line){
	string color, status_text, time_left;
	color = build_status(status_text, time_left, new_download);

	QStandardItem *dl = new QStandardItem(QIcon("img/bullet_black.png"), QString("%1").arg(new_download.id));
	dl->setEditable(false);
	pkg->setChild(dl_line, 0, dl);

	dl = new QStandardItem(QString(new_download.title.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 1, dl);

	dl = new QStandardItem(QString(new_download.url.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 2, dl);

	dl = new QStandardItem(QString(time_left.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 3, dl);

	string colorstring = "img/bullet_" + color + ".png";
	dl = new QStandardItem(QIcon(colorstring.c_str()), my_main_window->CreateQString(status_text.c_str()));
	dl->setEditable(false);
	pkg->setChild(dl_line, 4, dl);
}
开发者ID:HeBD,项目名称:DownloadDaemon,代码行数:25,代码来源:ddclient_gui_list_handling.cpp

示例4: populateTableModel

static void populateTableModel(QStandardItemModel *model)
{
    enum { ItemCount = 50 };

    const char *itemNames[] = { "potion", "ring", "amulet", "wand", "figurine" };
    const char *itemColors[] = { "black", "white", "red", "mauve", "blue", "green",
                                 "yellow", "ultramarine", "pink", "purple" };

    for (int i = 0; i < ItemCount; ++i) {
        QList<QStandardItem*> row;
        QStandardItem *item;
        item = new QStandardItem((i % 10 == 0) ? QString(itemNames[i / 10]) : QString());
        item->setEditable(false);
        row.append(item);
        item = new QStandardItem(QString("%1 %2").arg(QString(itemColors[i % 10])).
                    arg(QString(itemNames[i / 10])));
        item->setEditable(false);
        row.append(item);
        item = new QStandardItem(QString("%1 gold coins").arg(i * 10 + (i % 10) * 15 + 13));
        item->setTextAlignment(Qt::AlignCenter); // the Maemo 5 design spec recommends this.
        item->setEditable(false);
        row.append(item);
        model->appendRow(row);
    }
}
开发者ID:agamez,项目名称:qt-x11-maemo,代码行数:25,代码来源:main.cpp

示例5: AddCookie

	void CookiesEditModel::AddCookie (const QNetworkCookie& cookie)
	{
		int i = 0;
		if (Cookies_.size ())
			i = (Cookies_.end () - 1).key () + 1;
		Cookies_ [i] = cookie;
	
		QString domain = cookie.domain ();
	
		QList<QStandardItem*> foundItems = findItems (domain);
		QStandardItem *parent = 0;
		if (!foundItems.size ())
		{
			parent = new QStandardItem (domain);
			parent->setEditable (false);
			parent->setData (-1);
			invisibleRootItem ()->appendRow (parent);
		}
		else
			parent = foundItems.back ();
		QStandardItem *item = new QStandardItem (QString (Cookies_ [i].name ()));
		item->setData (i);
		item->setEditable (false);
		parent->appendRow (item);
	
		Jar_->setAllCookies (Cookies_.values ());
	}
开发者ID:Zereal,项目名称:leechcraft,代码行数:27,代码来源:cookieseditmodel.cpp

示例6: addObject

	int ObjectTableView::addObject(const SceneObject *sceneObject)
	{
		QStandardItem *itemObjectName = new QStandardItem(QString::fromStdString(sceneObject->getName()));
		itemObjectName->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemObjectName->setEditable(false);

		std::string pathFileName;
		if(sceneObject->getModel()->getMeshes())
		{
			pathFileName = sceneObject->getModel()->getMeshes()->getMeshFilename();
		}
		QStandardItem *itemMeshFile = new QStandardItem(QString::fromStdString(FileHandler::getFileName(pathFileName)));
		itemMeshFile->setToolTip(QString::fromStdString(pathFileName));
		itemMeshFile->setData(qVariantFromValue(sceneObject), Qt::UserRole + 1);
		itemMeshFile->setEditable(false);

		int nextRow = objectsListModel->rowCount();
		objectsListModel->insertRow(nextRow);
		objectsListModel->setItem(nextRow, 0, itemObjectName);
		objectsListModel->setItem(nextRow, 1, itemMeshFile);

		resizeRowsToContents();

		return nextRow;
	}
开发者ID:petitg1987,项目名称:UrchinEngine,代码行数:25,代码来源:ObjectTableView.cpp

示例7: addItem

void FileViewModel::addItem(const QString &name,
             const QString &size, const QString &type, const QString &date)
{

    QList<QStandardItem*> rowItems;

    QStandardItem *nameItem = new QStandardItem(name);
    QStandardItem *sizeItem = new QStandardItem(size);
    QStandardItem *typeItem = new QStandardItem(type);
    QStandardItem *dateItem = new QStandardItem(date);

    nameItem->setEditable(false);
    sizeItem->setEditable(false);
    typeItem->setEditable(false);
    dateItem->setEditable(false);

    rowItems.push_back(nameItem);
    rowItems.push_back(sizeItem);
    rowItems.push_back(typeItem);
    rowItems.push_back(dateItem);

    m_ItemModel->insertRow(0, rowItems);


//    m_ItemModel->setData(m_ItemModel->index(0, 0), name, Qt::DisplayRole);
//    m_ItemModel->setData(m_ItemModel->index(0, 1), size, Qt::DisplayRole);
//    m_ItemModel->setData(m_ItemModel->index(0, 2), type, Qt::DisplayRole);
//    m_ItemModel->setData(m_ItemModel->index(0, 3), date, Qt::DisplayRole);
}
开发者ID:OleksiiOzerov,项目名称:ArchiverApplication,代码行数:29,代码来源:FileViewModel.cpp

示例8: populate

void KreCategoriesListWidget::populate( QStandardItem * item, int id )
{
	int current_row = 0;

	CategoryTree categoryTree;
	m_database->loadCategories( &categoryTree, -1, 0, id, false );

	for ( CategoryTree * child_it = categoryTree.firstChild(); 
	child_it; child_it = child_it->nextSibling() ) {
		//The "Id" item.
		QStandardItem *itemId = new QStandardItem;
		itemId->setData( QVariant(child_it->category.id), Qt::EditRole );
		itemId->setEditable( false );

		//The "Category" item.
		QStandardItem *itemCategory = new QStandardItem( child_it->category.name );
		itemCategory->setEditable( true );
	
		//Insert the items as children
		item->setChild( current_row, 0, itemCategory );
		item->setChild( current_row, 1, itemId );
		populate( itemCategory, child_it->category.id );
		++current_row;
	}

}
开发者ID:eliovir,项目名称:krecipes,代码行数:26,代码来源:krecategorieslistwidget.cpp

示例9: eventFilter

bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
{
    if ((object == this) || (object == treeView->viewport())) {
        QModelIndex index = treeView->currentIndex();
        if (e->type() == QEvent::KeyPress) {
            QKeyEvent *ke = static_cast<QKeyEvent*>(e);
            if (index.isValid() && searchField->text().isEmpty()) {
                const QModelIndex &src = filterBookmarkModel->mapToSource(index);
                if (ke->key() == Qt::Key_F2) {
                    QStandardItem *item =
                        bookmarkManager->treeBookmarkModel()->itemFromIndex(src);
                    if (item) {
                        item->setEditable(true);
                        treeView->edit(index);
                        item->setEditable(false);
                    }
                } else if (ke->key() == Qt::Key_Delete) {
                    bookmarkManager->removeBookmarkItem(treeView, src);
                }
            }

            switch (ke->key()) {
                default: break;
                case Qt::Key_Up: {
                case Qt::Key_Down:
                    treeView->subclassKeyPressEvent(ke);
                }   break;

                case Qt::Key_Enter: {
                case Qt::Key_Return:
                    index = treeView->selectionModel()->currentIndex();
                    if (index.isValid()) {
                        QString data = index.data(Qt::UserRole + 10).toString();
                        if (!data.isEmpty() && data != QLatin1String("Folder"))
                            emit requestShowLink(data);
                    }
                }   break;

                case Qt::Key_Escape: {
                    emit escapePressed();
                }   break;
            }
        } else if (e->type() == QEvent::MouseButtonRelease) {
            if (index.isValid()) {
                QMouseEvent *me = static_cast<QMouseEvent*>(e);
                bool controlPressed = me->modifiers() & Qt::ControlModifier;
                if(((me->button() == Qt::LeftButton) && controlPressed)
                    || (me->button() == Qt::MidButton)) {
                        QString data = index.data(Qt::UserRole + 10).toString();
                        if (!data.isEmpty() && data != QLatin1String("Folder"))
                        {
                            //CentralWidget::instance()->setSourceInNewTab(data);
                            emit requestShowLinkInNewTab(data);
                        }
                }
            }
        }
    }
    return QWidget::eventFilter(object, e);
}
开发者ID:pasnox,项目名称:monkeystudio2,代码行数:60,代码来源:bookmarkmanager.cpp

示例10: load

void KreCategoriesListWidget::load( int limit, int offset )
{
	CategoryTree categoryTree;
	CategoryTree * pCategoryTree = &categoryTree;
	m_sourceModel->setRowCount( 0 );
	m_database->loadCachedCategories( &pCategoryTree, limit, offset, -1, true );

        for ( CategoryTree * child_it = pCategoryTree->firstChild(); child_it; child_it = child_it->nextSibling() ) {
		//The "Id" item.
		QStandardItem *itemId = new QStandardItem;
		itemId->setData( QVariant(child_it->category.id), Qt::EditRole );
		itemId->setEditable( false );

		//The "Category" item.
		QStandardItem *itemCategory = new QStandardItem( child_it->category.name );
		itemCategory->setEditable( true );

		//Insert the items in the model.
		QList<QStandardItem*> items;
		items << itemCategory << itemId;
		m_sourceModel->appendRow( items );

		//Populate the current element.
		populate( itemCategory, child_it->category.id );
        }

	emit loadFinishedPrivate();
}
开发者ID:eliovir,项目名称:krecipes,代码行数:28,代码来源:krecategorieslistwidget.cpp

示例11: LoadModels

void AELoadedResourcesTreeView::LoadModels()
{
	_modelResourcesItem->removeRows(0, _modelResourcesItem->rowCount());

	Anima::AnimaModelsManager* mgr = _document->GetEngine()->GetScenesManager()->GetScene("AnimaEditor")->GetModelsManager();
	for (int i = 0; i < mgr->GetModelsNumber(); i++)
	{
		Anima::AnimaModel* model = mgr->GetModel(i);
		
		QStandardItem *resourceNameItem = new QStandardItem(QString("%0").arg(model->GetName()));
		resourceNameItem->setData(QVariant::fromValue(model), ModelRole);
		resourceNameItem->setEditable(true);

		QStandardItem *resourceFileNameItem = new QStandardItem(QString("%0").arg(model->GetOriginFileName()));
		resourceFileNameItem->setData(QVariant::fromValue(model), ModelRole);
		resourceFileNameItem->setEditable(false);

		QList<QStandardItem*> newItem;
		newItem.append(resourceNameItem);
		newItem.append(resourceFileNameItem);

		resourceNameItem->removeRows(0, resourceNameItem->rowCount());

		LoadModelMeshes(model, resourceNameItem);
		LoadModelAnimations(model, resourceNameItem);

		_modelResourcesItem->appendRow(newItem);
	}
}
开发者ID:zillemarco,项目名称:Anima_Old,代码行数:29,代码来源:AELoadedResourcesTreeView.cpp

示例12: bookmarkModel

void OnyxMainWindow::bookmarkModel(QStandardItemModel & model,
                                   QModelIndex & selected)
{
    CRFileHistRecord * rec = view_->getDocView()->getCurrentFileHistRecord();
    if ( !rec )
        return;
    LVPtrVector<CRBookmark> & list( rec->getBookmarks() );
    model.setColumnCount(2);
    int row = 0;
    for(int i  = 0; i < list.length(); ++i)
    {
        // skip cites
        CRBookmark * bmk = list[i];
        if (!bmk || (bmk->getType() == bmkt_comment || bmk->getType() == bmkt_correction))
            continue;

        QString t =cr2qt(view_->getDocView()->getPageText(true, list[i]->getBookmarkPage()));
        t.truncate(100);
        QStandardItem *title = new QStandardItem(t);
        title->setData((int)list[i]);
        title->setEditable(false);
        model.setItem(row, 0, title);

        int pos = list[i]->getPercent();
        QString str(tr("%1"));
        str = str.arg(pos);
        QStandardItem *page = new QStandardItem(str);
        page->setTextAlignment(Qt::AlignCenter);
        page->setEditable(false);
        model.setItem(row, 1, page);

        row++;
    }
}
开发者ID:MEHDIDZ16,项目名称:boox-opensource,代码行数:34,代码来源:mainwindow.cpp

示例13: addItems

void RegistersModel::addItems(int startAddress, int noOfItems, bool valueIsEditable)
{
    int row;
    int col;
    m_startAddress = startAddress;
    m_noOfItems = noOfItems;
    m_offset = (startAddress % 10);
    m_firstRow = startAddress / 10;
    m_lastRow = (startAddress + noOfItems - 1) / 10;

    qDebug()<<  "RegistersModel : address " << startAddress << " ,noOfItems " << noOfItems
                << " ,offset " << m_offset << " ,first row " << m_firstRow << " ,last row " << m_lastRow;

    //Format Vertical - Horizontal Header
    clear();
    if (noOfItems > 1) {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]<<RegModelHeaderLabels[1]
                                                    <<RegModelHeaderLabels[2]<<RegModelHeaderLabels[3]
                                                    <<RegModelHeaderLabels[4]<<RegModelHeaderLabels[5]
                                                    <<RegModelHeaderLabels[6]<<RegModelHeaderLabels[7]
                                                    <<RegModelHeaderLabels[8]<<RegModelHeaderLabels[9]);

        QStringList vertHeader;
        for (int i = m_firstRow; i <= m_lastRow ; i++) {
            vertHeader<<QString("%1").arg(i * 10, 2, 10, QLatin1Char('0'));
        }
        model->setVerticalHeaderLabels(vertHeader);
    }
    else {
        model->setHorizontalHeaderLabels(QStringList()<<RegModelHeaderLabels[0]);
        model->setVerticalHeaderLabels(QStringList()<<QString("%1").arg(startAddress, 2, 10, QLatin1Char('0')));
    }

    //Add data to model
    if (noOfItems == 1){
        QStandardItem *valueItem = new QStandardItem("-");model->setItem(0, 0, valueItem);
        valueItem->setEditable(valueIsEditable);
    }
    else {
        for (int i = 0; i < ((m_offset + noOfItems - 1) / 10 + 1) * 10 ; i++) {
            row = i / 10;
            col = i % 10;
            //Address
            if (i >= m_offset + noOfItems || i < m_offset){//not used cells
                QStandardItem *valueItem = new QStandardItem("x");model->setItem(row, col, valueItem);
                valueItem->setEditable(false);
                valueItem->setForeground(QBrush(Qt::red));
                valueItem->setBackground(QBrush(Qt::lightGray));
            }
            else {
                QStandardItem *valueItem = new QStandardItem("-");model->setItem(row, col, valueItem);
                valueItem->setEditable(valueIsEditable);
            }
        }
    }

    emit(refreshView());

}
开发者ID:dm-urievich,项目名称:byce_tool,代码行数:59,代码来源:registersmodel.cpp

示例14: QDialog

QgsStyleV2GroupSelectionDialog::QgsStyleV2GroupSelectionDialog( QgsStyleV2 *style, QWidget *parent ) :
    QDialog( parent )
    , mStyle( style )
{
  setupUi( this );

  QStandardItemModel* model = new QStandardItemModel( groupTree );
  groupTree->setModel( model );

  QStandardItem *allSymbols = new QStandardItem( tr( "All Symbols" ) );
  allSymbols->setData( "all", Qt::UserRole + 2 );
  allSymbols->setEditable( false );
  setBold( allSymbols );
  model->appendRow( allSymbols );

  QStandardItem *group = new QStandardItem( "" ); //require empty name to get first order groups
  group->setData( "groupsheader", Qt::UserRole + 2 );
  group->setEditable( false );
  group->setFlags( group->flags() & ~Qt::ItemIsSelectable );
  buildGroupTree( group );
  group->setText( tr( "Groups" ) );//set title later
  QStandardItem *ungrouped = new QStandardItem( tr( "Ungrouped" ) );
  ungrouped->setData( 0 );
  ungrouped->setData( "group", Qt::UserRole + 2 );
  setBold( ungrouped );
  setBold( group );
  group->appendRow( ungrouped );
  model->appendRow( group );

  QStandardItem *tag = new QStandardItem( tr( "Smart Groups" ) );
  tag->setData( "smartgroupsheader" , Qt::UserRole + 2 );
  tag->setEditable( false );
  tag->setFlags( group->flags() & ~Qt::ItemIsSelectable );
  setBold( tag );
  QgsSymbolGroupMap sgMap = mStyle->smartgroupsListMap();
  QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
  while ( i != sgMap.constEnd() )
  {
    QStandardItem *item = new QStandardItem( i.value() );
    item->setEditable( false );
    item->setData( i.key() );
    item->setData( "smartgroup" , Qt::UserRole + 2 );
    tag->appendRow( item );
    ++i;
  }
  model->appendRow( tag );

  // expand things in the group tree
  int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
  for ( int i = 0; i < rows; i++ )
  {
    groupTree->setExpanded( model->indexFromItem( model->item( i ) ), true );
  }
  connect( groupTree->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( groupTreeSelectionChanged( const QItemSelection&, const QItemSelection& ) ) );
}
开发者ID:ar-jan,项目名称:QGIS,代码行数:55,代码来源:qgsstylev2groupselectiondialog.cpp

示例15: initModel

void MangaListWidget::initModel(QString mangaSelected) {
  _scansDirectory.setFilter(QDir::Dirs);
  QStringList dirsList = Utils::dirList(_scansDirectory);

  _model->removeRows(0, _model->rowCount());

  QModelIndex indexMangaSelected;

  for (const QString& mangaName: dirsList) {
    QString currDirStr = _scansDirectory.path() + "/" + mangaName;

    QStandardItem* currItem = new QStandardItem(mangaName);
    currItem->setEditable(false);
    _model->appendRow(currItem);

    QDir currDir(currDirStr);
    QStringList currDirsList = Utils::dirList(currDir, true);

    QList<bool> areChaptersRead = Utils::areChaptersRead(mangaName);
    if (!Utils::isMangaRead(areChaptersRead))
      currItem->setFont(QFont("", -1, 99));
    else
      currItem->setFont(QFont());

    if (mangaName == mangaSelected) {
      indexMangaSelected = _model->indexFromItem(currItem);
    }

    int k = 0;
    for (const QString& currChStr: currDirsList) {
      if (k >= areChaptersRead.size()) {
        QMessageBox::critical(this, "List error", "Error while tempting to edit manga read flags whithin MangaListWidget::initModel.");
        return;
      }
      bool isChapterRead = areChaptersRead.at(k);

      QStandardItem* currChItem = new QStandardItem(currChStr);
      currChItem->setEditable(false);
      setTextAccordingToRead(currChItem, isChapterRead);

      currItem->appendRow(currChItem);

      k++;
    }
  }

  if (indexMangaSelected.isValid()) {
    _view->selectionModel()->setCurrentIndex(indexMangaSelected, QItemSelectionModel::Current);
  }

  decorateMangaNames();
}
开发者ID:vmichele,项目名称:MangaReaderForLinux,代码行数:52,代码来源:MangaListWidget.cpp


注:本文中的QStandardItem::setEditable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。