예제 #1
0
void MainWindow::getTagAttributes(QList<QStandardItem*> *list, QDomNode doc)
{
    //add the tag's name in the list
    QStandardItem *newItem = new QStandardItem(doc.toElement().tagName());
    newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
    list->append(newItem);

    //if the node doesn't have any children, it means there is a value inside the node, we add this value in the list here
    if((!doc.childNodes().item(0).isElement() && doc.hasChildNodes()) && !doc.childNodes().item(0).isComment())
    {
        newItem = new QStandardItem(doc.toElement().text());
        newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
        list->append(newItem);
    }
    //if the node have at least one child, there is no value inside the node so we just had an empty string to the list
    else
    {
        newItem = new QStandardItem("");
        newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
        list->append(newItem);
    }
    //add all the attributes to the list
    for(int i = 0; i < doc.attributes().length(); i++)
    {
        newItem = new QStandardItem(doc.attributes().item(i).toAttr().name() + " : " + doc.attributes().item(i).toAttr().value());
        newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
        list->append(newItem);
    }
}
예제 #2
0
bool QgsDb2TableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
  if ( !QStandardItemModel::setData( idx, value, role ) )
    return false;

  if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol )
  {
    const QgsWkbTypes::Type wkbType = static_cast< QgsWkbTypes::Type >( idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt() );

    bool ok = wkbType != QgsWkbTypes::Unknown;

    if ( ok && wkbType != QgsWkbTypes::NoGeometry )
      idx.sibling( idx.row(), DbtmSrid ).data().toInt( &ok );

    QStringList pkCols = idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
    if ( ok && pkCols.size() > 0 )
      ok = pkCols.contains( idx.sibling( idx.row(), DbtmPkCol ).data().toString() );

    for ( int i = 0; i < DbtmColumns; i++ )
    {
      QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
      if ( ok )
        item->setFlags( item->flags() | Qt::ItemIsSelectable );
      else
        item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
    }
  }

  return true;
}
예제 #3
0
QList<QStandardItem *> MainWindow::createrowinputtable(QFileInfo fileinfo)
{
    QList<QStandardItem *>listitems;
    qint64 fs;
    QString strfs;
    for(int col=0 ; col < inputmodel->columnCount() ; col++)
    {
        QStandardItem *item = new QStandardItem();
        switch(col)
        {
           case 0:item->setText(fileinfo.fileName());
                   // add logs,constellations,signals,prns
                  item->setFlags(item->flags() ^ Qt::ItemIsEditable);
                   addChildrentofile(item);
                   break;

          case 1:  fs = fileinfo.size();
                  strfs = convertintokbmbgb(fs);
                  item->setText(strfs);
                  item->setFlags(item->flags() ^ Qt::ItemIsEditable);
                  break;

          case 2: item->setFlags(item->flags() ^ Qt::ItemIsEditable); //initialize nof ascii logs
                  break;

          case 3:  item->setFlags(item->flags() ^ Qt::ItemIsEditable);// initialize no of binary logs
                    break;

          case 4: item->setFlags(item->flags() ^ Qt::ItemIsEditable);//initialize no of unkonwn logs
                  break;
        }
        listitems.append(item);
    }
    return listitems;
}
예제 #4
0
bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
  if ( !QStandardItemModel::setData( idx, value, role ) )
    return false;

  if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol )
  {
    QGis::WkbType geomType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();

    bool ok = geomType != QGis::WKBUnknown;

    if ( ok && geomType != QGis::WKBNoGeometry )
    {
      int srid = idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );
      ok &= srid != INT_MIN;
    }

    QStringList pkCols = idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
    if ( ok && pkCols.size() > 0 )
      ok = pkCols.contains( idx.sibling( idx.row(), dbtmPkCol ).data().toString() );

    for ( int i = 0; i < dbtmColumns; i++ )
    {
      QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
      if ( ok )
        item->setFlags( item->flags() | Qt::ItemIsSelectable );
      else
        item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
    }
  }

  return true;
}
예제 #5
0
void tst_QStandardItem::clone()
{
    QStandardItem item;
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));
    item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);

    QStandardItem *clone = item.clone();
    QCOMPARE(clone->text(), item.text());
    QCOMPARE(clone->toolTip(), item.toolTip());
    QCOMPARE(clone->statusTip(), item.statusTip());
    QCOMPARE(clone->whatsThis(), item.whatsThis());
    QCOMPARE(clone->sizeHint(), item.sizeHint());
    QCOMPARE(clone->font(), item.font());
    QCOMPARE(clone->textAlignment(), item.textAlignment());
    QCOMPARE(clone->background(), item.background());
    QCOMPARE(clone->foreground(), item.foreground());
    QCOMPARE(clone->checkState(), item.checkState());
    QCOMPARE(clone->accessibleText(), item.accessibleText());
    QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
    QCOMPARE(clone->flags(), item.flags());
    QVERIFY(!(*clone < item));
    delete clone;
}
void TransfersContentsWidget::addTransfer(Transfer *transfer)
{
	QList<QStandardItem*> items;
	QStandardItem *item = new QStandardItem();
	item->setData(qVariantFromValue(static_cast<void*>(transfer)), Qt::UserRole);
	item->setFlags(item->flags() | Qt::ItemNeverHasChildren);

	items.append(item);

	item = new QStandardItem(QFileInfo(transfer->getTarget()).fileName());
	item->setFlags(item->flags() | Qt::ItemNeverHasChildren);

	items.append(item);

	for (int i = 2; i < m_model->columnCount(); ++i)
	{
		item = new QStandardItem();
		item->setFlags(item->flags() | Qt::ItemNeverHasChildren);

		items.append(item);
	}

	m_model->appendRow(items);

	if (transfer->getState() == Transfer::RunningState)
	{
		m_speeds[transfer] = QQueue<qint64>();
	}

	updateTransfer(transfer);
}
예제 #7
0
void InspectorBarLine::setElement()
      {
      InspectorElementBase::setElement();
      BarLine* bl = toBarLine(inspector->element());

      // enable / disable individual type combo items according to score and selected bar line status
      bool bMultiStaff  = bl->score()->nstaves() > 1;
      BarLineType blt   = bl->barLineType();
      bool isRepeat     = blt & (BarLineType::START_REPEAT | BarLineType::END_REPEAT | BarLineType::END_START_REPEAT);

      const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(b.type->model());
      int i = 0;
      for (auto& k : BarLine::barLineTable) {
            QStandardItem* item = model->item(i);
            // if combo item is repeat type, should be disabled for multi-staff scores
            if (k.type & (BarLineType::START_REPEAT | BarLineType::END_REPEAT | BarLineType::END_START_REPEAT)) {
                  // disable / enable
                  item->setFlags(bMultiStaff ?
                        item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
                        item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
                  }
            // if combo item is NOT repeat type, should be disabled if selected bar line is a repeat
            else {
                  item->setFlags(isRepeat ?
                        item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled) :
                        item->flags() | (Qt::ItemFlags)(Qt::ItemIsSelectable|Qt::ItemIsEnabled) );
                  }
            ++i;
            }
#if 0
      blockSpanDataSignals(true);
      manageSpanData();
      blockSpanDataSignals(false);
#endif
      }
예제 #8
0
void FriendsWidget::onRenameFriendActionTriggered()
{
    // friendContextMenuRequested already made sure that there is only one index selected
    QModelIndex selectedIndex = friendView->selectionModel()->selectedIndexes().at(0);
    QStandardItem* selectedItem = friendModel->itemFromIndex(friendProxyModel->mapToSource(selectedIndex));
    selectedItem->setFlags(selectedItem->flags() | Qt::ItemIsEditable);
    friendView->edit(selectedIndex);
    selectedItem->setFlags(selectedItem->flags() & ~Qt::ItemIsEditable);
}
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& ) ) );
}
예제 #10
0
파일: caxarun.cpp 프로젝트: cxwangwc/Rule
void CaxaRun::doubleClicked(const QModelIndex &index)
{
	if (index.isValid())
	{
		QStandardItem *item = m_model->item(index.row(), index.column());
		if (index.column() == 1)
			item->setFlags(item->flags() | Qt::ItemIsEditable);
		else
			item->setFlags(item->flags() & ~(Qt::ItemIsEditable));
	}
}
예제 #11
0
// ensure different axes for consecutive operations
static void disableAxis(QComboBox *w, unsigned int axis) {
	const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>(w->model());
	for (unsigned int i=0; i < 3; ++i) {
		QStandardItem* item = model->item(i);
		if (i == axis) {
			item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
			if (w->currentIndex() == axis) w->setCurrentIndex((axis+1) % 3);
		} else {
			item->setFlags(item->flags() | Qt::ItemIsEnabled);
		}
	}
}
예제 #12
0
bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
  if ( !QStandardItemModel::setData( idx, value, role ) )
    return false;

  if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol )
  {
    QGis::WkbType wkbType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();

    QString tip;
    if ( wkbType == QGis::WKBUnknown )
    {
      tip = tr( "Specify a geometry type" );
    }
    else if ( wkbType != QGis::WKBNoGeometry )
    {
      bool ok;
      int srid = idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );

      if ( !ok || srid == INT_MIN )
        tip = tr( "Enter a SRID" );
    }

    QStringList pkCols = idx.sibling( idx.row(), dbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();
    if ( tip.isEmpty() && pkCols.size() > 0 )
    {
      if ( !pkCols.contains( idx.sibling( idx.row(), dbtmPkCol ).data().toString() ) )
        tip = tr( "Select a primary key" );
    }

    for ( int i = 0; i < dbtmColumns; i++ )
    {
      QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
      if ( tip.isEmpty() )
      {
        item->setFlags( item->flags() | Qt::ItemIsSelectable | Qt::ItemIsEnabled );
        item->setToolTip( "" );
      }
      else
      {
        item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
        if ( i == dbtmSchema || i == dbtmTable || i == dbtmGeomCol )
        {
          item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
          item->setToolTip( tip );
        }
      }
    }
  }

  return true;
}
예제 #13
0
bool QgsOracleTableModel::setData( const QModelIndex &idx, const QVariant &value, int role )
{
  if ( !QStandardItemModel::setData( idx, value, role ) )
    return false;

  if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol )
  {
    QgsWkbTypes::Type wkbType = ( QgsWkbTypes::Type ) idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt();

    QString tip;
    if ( wkbType == QgsWkbTypes::Unknown )
    {
      tip = tr( "Specify a geometry type" );
    }
    else if ( wkbType != QgsWkbTypes::NoGeometry )
    {
      bool ok;
      int srid = idx.sibling( idx.row(), DbtmSrid ).data().toInt( &ok );

      if ( !ok || srid == 0 )
        tip = tr( "Enter a SRID" );
    }

    if ( tip.isEmpty() && idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toBool() )
    {
      if ( !idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 2 ).toBool() )
        tip = tr( "Select a primary key" );
    }

    for ( int i = 0; i < DbtmColumns; i++ )
    {
      QStandardItem *item = itemFromIndex( idx.sibling( idx.row(), i ) );
      if ( tip.isEmpty() )
      {
        item->setFlags( item->flags() | Qt::ItemIsSelectable | Qt::ItemIsEnabled );
        item->setToolTip( "" );
      }
      else
      {
        item->setFlags( item->flags() & ~Qt::ItemIsSelectable );
        if ( i == DbtmOwner || i == DbtmTable || i == DbtmGeomCol )
        {
          item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
          item->setToolTip( tip );
        }
      }
    }
  }

  return true;
}
static  QStandardItem *createDisabledItem(const QString &text)
{
    QStandardItem *rc = new QStandardItem(text);
    Qt::ItemFlags flags = rc->flags();
    rc->setFlags(flags & ~(Qt::ItemIsEnabled|Qt::ItemIsEditable|Qt::ItemIsSelectable));
    return rc;
}
ActionComboBoxWidget::ActionComboBoxWidget(QWidget *parent) : QComboBox(parent),
	m_view(new ItemViewWidget(this)),
	m_filterLineEdit(NULL),
	m_wasPopupVisible(false)
{
	setEditable(true);
	setView(m_view);
	setItemDelegate(new ItemDelegate(this));

	m_view->setHeaderHidden(true);

	lineEdit()->hide();

	view()->viewport()->parentWidget()->installEventFilter(this);

	QStandardItemModel *model = new QStandardItemModel(this);
	const QVector<ActionDefinition> definitions = ActionsManager::getActionDefinitions();

	for (int i = 0; i < definitions.count(); ++i)
	{
		QStandardItem *item = new QStandardItem(definitions.at(i).icon, QCoreApplication::translate("actions", (definitions.at(i).description.isEmpty() ? definitions.at(i).text : definitions.at(i).description).toUtf8().constData()));
		item->setData(definitions.at(i).identifier, Qt::UserRole);
		item->setToolTip(ActionsManager::getActionName(definitions.at(i).identifier));
		item->setFlags(item->flags() | Qt::ItemNeverHasChildren);

		model->appendRow(item);
	}

	setModel(model);
	setCurrentIndex(-1);
}
예제 #16
0
// Is this item collapsable?
bool AMVerticalStackWidget::itemCollapsable(int index) const {
	if(index < 0 || index >= count())
		return false;

	QStandardItem* item = model_.item(index,0);
	return (item->flags() & Qt::ItemIsUserCheckable);
}
    static void PopulateAttributeMatrixComboBox(AbstractFilter* filter, FilterParameter* filterParameter,
                                            QComboBox* dcCombo, QComboBox* amCombo,
                                            DataContainerArrayProxy& dcaProxy)
    {
      FilterParameterType* fp = dynamic_cast<FilterParameterType*>(filterParameter);
      assert(fp != NULL);
      DataContainerArray::Pointer dca = filter->getDataContainerArray();
      if (NULL == dca.get()) { return; }

      QString dcName = dcCombo->currentText();

      // Clear the AttributeMatrix List
      bool alreadyBlocked = false;
      if(amCombo->signalsBlocked()) { alreadyBlocked = true; }
      amCombo->blockSignals(true);
      amCombo->clear();

      // Loop over the data containers until we find the proper data container
      QList<DataContainerProxy> containers = dcaProxy.dataContainers.values();
      QListIterator<DataContainerProxy> containerIter(containers);
      QVector<unsigned int> defVec = fp->getDefaultAttributeMatrixTypes();
      while(containerIter.hasNext())
      {
        DataContainerProxy dc = containerIter.next();

        if(dc.name.compare(dcName) == 0 )
        {
          // We found the proper Data Container, now populate the AttributeMatrix List
          QMap<QString, AttributeMatrixProxy> attrMats = dc.attributeMatricies;
          QMapIterator<QString, AttributeMatrixProxy> attrMatsIter(attrMats);
          while(attrMatsIter.hasNext() )
          {
            attrMatsIter.next();
            QString amName = attrMatsIter.key();
            AttributeMatrix::Pointer am = dca->getAttributeMatrix(DataArrayPath(dc.name, amName, ""));
            amCombo->addItem(amName);

            if (NULL != am.get() && defVec.isEmpty() == false && defVec.contains(am->getType()) == false)
            {
              QStandardItemModel* model = qobject_cast<QStandardItemModel*>(amCombo->model());
              if (NULL != model)
              {
                QStandardItem* item = model->item(amCombo->findText(amName));
                if (NULL != item)
                {
                  item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
                }
              }
            }
          }
        }
      }

      if(!alreadyBlocked) { // Only unblock if this function blocked the signals.
        amCombo->blockSignals(false);
      }
    }
예제 #18
0
void MainWindow::injectSuccessorInModel(QStandardItem* parent, Task& son, Project& proj) {
    QStandardItem* temp = new QStandardItem(son.getId());
    temp->setFlags(temp->flags() & ~Qt::ItemIsEditable);
    parent->appendRow(temp);
    TasksContainer successors = AssociationManager::getInstance().getTaskSuccessors(&son);
    for (TasksContainer::iterator it = successors.begin(); it!=successors.end(); ++it) {
        injectSuccessorInModel(temp,*(*it),proj);
    }
}
예제 #19
0
void MainWindow::setProjectsTreeModel() {
    QStandardItem* parent = projectsTreeModel->invisibleRootItem();
    for (Iterator<Project> itp = ProjectFactory::getInstance().getIterator(); !(itp.isDone()); itp.next()) {
        QStandardItem* tempP = new QStandardItem(itp.current().getId());  // gonna need to manage those items, and delete them at the end of the process
        tempP->setFlags(tempP->flags() & ~Qt::ItemIsEditable);
        parent->appendRow(tempP);
        TasksContainer rootTasks = itp.current().getRootTasks();
        for (TasksContainer::iterator it = rootTasks.begin(); it!=rootTasks.end() ; ++it){
            QStandardItem* temp = new QStandardItem((*it)->getId());
            temp->setFlags(temp->flags() & ~Qt::ItemIsEditable);
            tempP->appendRow(temp);
            TasksContainer successors = AssociationManager::getInstance().getTaskSuccessors(*it);
            for (TasksContainer::iterator it2 = successors.begin(); it2!=successors.end(); ++it2) {
                injectSuccessorInModel(temp,*(*it2), itp.current());
            }
        }
    }
}
예제 #20
0
QModelIndex CDialogIrcSettings::addAliasRow( const QString& alias, const QString& command )
{
	QStandardItem* aliasItem = new QStandardItem( alias );
	QStandardItem* commandItem = new QStandardItem( command );
	QStandardItem* closeItem = new QStandardItem( QPixmap( ":/Resource/Generic/Exit.png" ), QString() );
	closeItem->setFlags( closeItem->flags() & ~Qt::ItemIsEditable );
	sourceModel->appendRow( QList<QStandardItem*>() << aliasItem << commandItem << closeItem );
	return proxyModel->mapFromSource( aliasItem->index() );
}
예제 #21
0
파일: GameStyleModel.cpp 프로젝트: CaF2/hw
void GameStyleModel::loadGameStyles()
{
    beginResetModel();

    QIcon dlcIcon;
    dlcIcon.addFile(":/res/dlcMarker.png", QSize(), QIcon::Normal, QIcon::On);
    dlcIcon.addFile(":/res/dlcMarkerSelected.png", QSize(), QIcon::Selected, QIcon::On);
    QPixmap emptySpace = QPixmap(7, 15);
    emptySpace.fill(QColor(0, 0, 0, 0));
    QIcon notDlcIcon = QIcon(emptySpace);

    // empty list, so that we can (re)fill it
    QStandardItemModel::clear();

    QList<QStandardItem * > items;
    items.append(new QStandardItem(notDlcIcon, "Normal"));

    // define a separator item
    QStandardItem * separator = new QStandardItem("---");
    separator->setData(QLatin1String("separator"), Qt::AccessibleDescriptionRole);
    separator->setFlags(separator->flags() & ~( Qt::ItemIsEnabled | Qt::ItemIsSelectable ) );

    items.append(separator);


    QStringList scripts = DataManager::instance().entryList(
                             QString("Scripts/Multiplayer"),
                             QDir::Files,
                             QStringList("*.lua")
                         );

    foreach(QString script, scripts)
    {
        script = script.remove(".lua", Qt::CaseInsensitive);

        QFile scriptCfgFile(QString("physfs://Scripts/Multiplayer/%2.cfg").arg(script));

        QString name = script;
        name = name.replace("_", " ");

        QString scheme = "locked";
        QString weapons = "locked";

        if (scriptCfgFile.exists() && scriptCfgFile.open(QFile::ReadOnly))
        {
            QTextStream input(&scriptCfgFile);
            input >> scheme;
            input >> weapons;
            scriptCfgFile.close();

            if (!scheme.isEmpty())
                scheme.replace("_", " ");

            if (!weapons.isEmpty())
                weapons.replace("_", " ");
        }
예제 #22
0
void MainWindow::injectSubTaskInModel(QStandardItem* parent, Task& son) {
    QStandardItem* temp = new QStandardItem(son.getId());
    temp->setFlags(temp->flags() & ~Qt::ItemIsEditable);
    parent->appendRow(temp);
    if (son.getTaskType()==COMPOSITE) {
        for (Iterator<Task> it = dynamic_cast<CompositeTask&>(son).getIterator(); !(it.isDone()); it.next()) {
            injectSubTaskInModel(temp,it.current());
        }
    }
}
예제 #23
0
Channel* Server::addChannel(QString inChannel, Channel::ChannelType inType)
{
    QStandardItem *newMenuItem = new QStandardItem();
    Channel *newChannel = new Channel(inChannel, inType, newMenuItem, this);
    newMenuItem->setData(QVariant::fromValue<Channel*>(newChannel), Qt::UserRole);
    menuItem->appendRow(newMenuItem);
    newMenuItem->setFlags(newMenuItem->flags() & ~Qt::ItemIsEditable);
    menuItem->sortChildren(0);
    return newChannel;
}
예제 #24
0
void tst_QStandardItem::streamItem()
{
    QStandardItem item;
    
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));

    QByteArray ba;
    {
        QDataStream ds(&ba, QIODevice::WriteOnly);
        ds << item;
    }
    {
        QStandardItem streamedItem;
        QDataStream ds(&ba, QIODevice::ReadOnly);
        ds >> streamedItem;
        QCOMPARE(streamedItem.text(), item.text());
        QCOMPARE(streamedItem.toolTip(), item.toolTip());
        QCOMPARE(streamedItem.statusTip(), item.statusTip());
        QCOMPARE(streamedItem.whatsThis(), item.whatsThis());
        QCOMPARE(streamedItem.sizeHint(), item.sizeHint());
        QCOMPARE(streamedItem.font(), item.font());
        QCOMPARE(streamedItem.textAlignment(), item.textAlignment());
        QCOMPARE(streamedItem.background(), item.background());
        QCOMPARE(streamedItem.foreground(), item.foreground());
        QCOMPARE(streamedItem.checkState(), item.checkState());
        QCOMPARE(streamedItem.accessibleText(), item.accessibleText());
        QCOMPARE(streamedItem.accessibleDescription(), item.accessibleDescription());
        QCOMPARE(streamedItem.flags(), item.flags());
    }
}
예제 #25
0
void MainWindow::openDatas(QString filename)
{
    QStandardItemModel *model = new QStandardItemModel;

    QFile fichier(filename);
    QDomDocument *doc = new QDomDocument("docXml");
    QDomElement elem;
    QList<int> *currentChild = new QList<int>();
    QList<int> *nodesLength = new QList<int>();
    int height = 0;

    //open the selected file and get the xml document in doc
    fichier.open(QIODevice::ReadWrite | QIODevice::Text);

    doc->setContent(&fichier);
    currentDocument = doc;
    fichier.close();

    //get the first element of the document
    elem = doc->documentElement();
    root = elem.tagName();
    //get the height for the document and prepare the parameters to build the tree
    heightXML(elem, &height);
    for(int i = 0; i < height-1; i++)
    {
        currentChild->append(0);
        nodesLength->append(0);
    }
    QStandardItem *item = new QStandardItem(elem.tagName());
    item->setFlags(item->flags() & ~Qt::ItemIsEditable);
    //build the model and use it to be displayed using a QTreeView
    buildTree(elem, model, item, nodesLength, 0, currentChild, -1);

    //Modify the columns' headers
    setColumnLabels(model);

    this->model = model;

    this->modelIsSet = true;

    //set the to the tree
    treeView->setModel(model);
    treeView->expandAll();
    for(int i = 0; i < model->columnCount(); i++)
    {
        treeView->resizeColumnToContents(i);
    }

    //Store the filename for the menu "Recent files"
    setSettings(filename);
    updateMenuRecentFiles();
    QObject::connect(treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(showDetails(QModelIndex)));
}
예제 #26
0
QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx, QWidget *parent )
  : QWidget( parent )
  , mLayer( vl )
  , mFieldIdx( fieldIdx )
{
  setupUi( this );

  if ( fieldIdx < 0 )
    return;

  QMapIterator<QString, QgsEditorWidgetFactory *> it( QgsGui::editorWidgetRegistry()->factories() );
  QStandardItemModel *widgetTypeModel = qobject_cast<QStandardItemModel *>( mWidgetTypeComboBox->model() );
  while ( it.hasNext() )
  {
    it.next();
    mWidgetTypeComboBox->addItem( it.value()->name(), it.key() );
    QStandardItem *item = widgetTypeModel->item( mWidgetTypeComboBox->count() - 1 );
    if ( !it.value()->supportsField( vl, fieldIdx ) )
      item->setFlags( item->flags() & ~Qt::ItemIsEnabled );
  }

  connect( mWidgetTypeComboBox, static_cast< void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsAttributeTypeDialog::onCurrentWidgetChanged );

  if ( vl->fields().fieldOrigin( fieldIdx ) == QgsFields::OriginJoin ||
       vl->fields().fieldOrigin( fieldIdx ) == QgsFields::OriginExpression )
  {
    isFieldEditableCheckBox->setEnabled( false );
  }

  mExpressionWidget->registerExpressionContextGenerator( this );

  connect( mExpressionWidget, &QgsExpressionLineEdit::expressionChanged, this, &QgsAttributeTypeDialog::defaultExpressionChanged );
  connect( mUniqueCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
  {
    mCheckBoxEnforceUnique->setEnabled( checked );
    if ( !checked )
      mCheckBoxEnforceUnique->setChecked( false );
  }
         );
  connect( notNullCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
  {
    mCheckBoxEnforceNotNull->setEnabled( checked );
    if ( !checked )
      mCheckBoxEnforceNotNull->setChecked( false );
  }
         );

  QgsSettings settings;
  restoreGeometry( settings.value( QStringLiteral( "Windows/QgsAttributeTypeDialog/geometry" ) ).toByteArray() );

  constraintExpressionWidget->setLayer( vl );
}
bool TDriverStandardFeaturModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    bool ret = QStandardItemModel::setData(index, value, role);

    QStandardItem *item = itemFromIndex(index);
    if (item) {
        Qt::ItemFlags flags = item->flags();
        flags &= ~Qt::ItemIsEditable;
        item->setFlags(flags);
    }

    return ret;
}
예제 #28
0
void StartupDialog::setSession(int index)
{
	m_windowsModel->clear();

	const SessionInformation session = SessionsManager::getSession(m_ui->sessionComboBox->itemData(index).toString());
	QFont font(m_ui->windowsTreeView->font());
	font.setBold(true);

	for (int i = 0; i < session.windows.count(); ++i)
	{
		QStandardItem *windowItem = new QStandardItem(tr("Window %1").arg(i + 1));
		windowItem->setData(session.windows.at(i).geometry, Qt::UserRole);

		for (int j = 0; j < session.windows.at(i).windows.count(); ++j)
		{
			QStandardItem *tabItem = new QStandardItem(session.windows.at(i).windows.at(j).getTitle());
			tabItem->setFlags(windowItem->flags() | Qt::ItemIsUserCheckable);
			tabItem->setData(Qt::Checked, Qt::CheckStateRole);

			if (j == session.windows.at(i).index)
			{
				tabItem->setData(font, Qt::FontRole);
			}

			windowItem->appendRow(tabItem);
		}

		if (session.windows.count() > 1)
		{
			windowItem->setFlags(windowItem->flags() | Qt::ItemIsUserCheckable);
			windowItem->setData(Qt::Checked, Qt::CheckStateRole);
		}

		m_windowsModel->invisibleRootItem()->appendRow(windowItem);
	}

	m_ui->windowsTreeView->expandAll();
}
예제 #29
0
void MainWindow::setTasksInModel() {
    QStandardItem* parent = tasksModel->invisibleRootItem();
    NonPreemptiveFactory* npf = &(NonPreemptiveFactory::getInstance());
    for (Iterator<Task> it = npf->getIterator(); !(it.isDone()); it.next()) {
        QStandardItem* temp = new QStandardItem(it.current().getId());
        temp->setFlags(temp->flags() & ~Qt::ItemIsEditable);
        parent->appendRow(temp);
        if (it.current().getTaskType()==COMPOSITE) {
            for (Iterator<Task> it2 = dynamic_cast<CompositeTask&>(it.current()).getIterator(); !(it2.isDone()); it2.next()) {
                injectSubTaskInModel(temp,it2.current());
            }
        }
    }
}
예제 #30
0
void EntryDelegate::setReadOnly(const QModelIndex & index, bool readOnly)
{
    int row = index.row();
    QModelIndex parent = index.parent();
    QStandardItem* item;
    const QStandardItemModel* model = qobject_cast<const QStandardItemModel*>( index.model() );
    if ( !model )
        return;
    
    item = model->itemFromIndex( model->index( row, 0, parent ) );
    item->setFlags( readOnly ? item->flags() & ~Qt::ItemIsEditable : item->flags() | Qt::ItemIsEditable );
    
    item = model->itemFromIndex( model->index( row, 1, parent ) );
    item->setFlags( readOnly ? item->flags() & ~Qt::ItemIsEditable : item->flags() | Qt::ItemIsEditable );
    
    item = model->itemFromIndex( model->index( row, 2, parent ) );
    item->setFlags( readOnly ? item->flags() & ~Qt::ItemIsEditable : item->flags() | Qt::ItemIsEditable );
    
    item = model->itemFromIndex( model->index( row, 3, parent ) );
    item->setFlags( readOnly ? item->flags() & ~Qt::ItemIsEditable : item->flags() | Qt::ItemIsEditable );
    
    item = model->itemFromIndex( model->index( row, 4, parent ) );
    item->setFlags( readOnly ? item->flags() & ~Qt::ItemIsEditable : item->flags() | Qt::ItemIsEditable );
}