PartitionComboBox::PartitionComboBox( QWidget* parent )
    : QComboBox( parent )
{
    mButton = new QToolButton( this );
    mButton->setAutoRaise( true );
    mButton->setIcon( QIcon( ":/icons/256/properties.png" ) );
    mButton->setToolTip( tr( "Add a partition" ) );
    
    QHBoxLayout* hl = new QHBoxLayout( this );
    hl->setMargin( 0 );
    hl->setSpacing( 5 );
    hl->addStretch();
    hl->addWidget( mButton );
    
    setAttribute( Qt::WA_Hover, true );
    setModel( partitionModel() );
    setModelColumn( pPartition::DevicePath );
    setItemDelegate( new PartitionDelegate( partitionModel() ) );
    
    connect( partitionModel(), SIGNAL( rowsInserted( const QModelIndex&, int, int ) ), this, SLOT( modelChanged() ) );
    connect( partitionModel(), SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ), this, SLOT( modelChanged() ) );
    connect( partitionModel(), SIGNAL( layoutChanged() ), this, SLOT( modelChanged() ) );
    connect( partitionModel(), SIGNAL( modelReset() ), this, SLOT( modelChanged() ) );
    connect( mButton, SIGNAL( clicked() ), this, SLOT( addPartition() ) );
    
    modelChanged();
}
Beispiel #2
0
void XComboBox::setDataWidgetMap(XDataWidgetMapper* m)
{
  disconnect(this, SIGNAL(editTextChanged(QString)), this, SLOT(updateMapperData()));
  disconnect(this, SIGNAL(newID(int)), this, SLOT(updateMapperData()));

  if (!_listTableName.isEmpty())
  {
    QString tableName="";
    if (_listSchemaName.length())
      tableName=_listSchemaName + ".";
    tableName+=_listTableName;
    static_cast<XSqlTableModel*>(m->model())->setRelation(static_cast<XSqlTableModel*>(m->model())->fieldIndex(_fieldName),
                                 QSqlRelation(tableName, _listIdFieldName, _listDisplayFieldName));

    QSqlTableModel *rel =static_cast<XSqlTableModel*>(m->model())->relationModel(static_cast<XSqlTableModel*>(m->model())->fieldIndex(_fieldName));
    setModel(rel);
    setModelColumn(rel->fieldIndex(_listDisplayFieldName));

    m->setItemDelegate(new QSqlRelationalDelegate(this));
    m->addMapping(this, _fieldName);
    return;
  }
  else if (_codes.count())
    m->addMapping(this, _fieldName, "code", "currentDefault");
  else
    m->addMapping(this, _fieldName, "text", "text");

  _mapper=m;
  connect(this, SIGNAL(editTextChanged(QString)), this, SLOT(updateMapperData()));
  connect(this, SIGNAL(newID(int)), this, SLOT(updateMapperData()));
}
Beispiel #3
0
void WSuggestionPopup::setModel(WAbstractItemModel *model)
{
  if (model_) {
    /* disconnect slots from previous model */
    for (unsigned i = 0; i < modelConnections_.size(); ++i)
      modelConnections_[i].disconnect();
    modelConnections_.clear();
  }

  model_ = model;

  /* connect slots to new model */
  modelConnections_.push_back(model_->rowsInserted().connect
     (this, &WSuggestionPopup::modelRowsInserted));
  modelConnections_.push_back(model_->rowsRemoved().connect
     (this, &WSuggestionPopup::modelRowsRemoved));
  modelConnections_.push_back(model_->dataChanged().connect
     (this, &WSuggestionPopup::modelDataChanged));
  modelConnections_.push_back(model_->layoutChanged().connect
     (this, &WSuggestionPopup::modelLayoutChanged));
  modelConnections_.push_back(model_->modelReset().connect
     (this, &WSuggestionPopup::modelLayoutChanged));

  setModelColumn(modelColumn_);
}
QgsLayoutItemComboBox::QgsLayoutItemComboBox( QWidget *parent, QgsLayout *layout )
  : QComboBox( parent )
{
  setCurrentLayout( layout );

  setModelColumn( QgsLayoutModel::ItemId );
  connect( this, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayoutItemComboBox::indexChanged );
}
Beispiel #5
0
QListView* makeView(QAbstractItemModel* model, int column)
{
    auto view = new QListView;
    view->setViewMode(QListView::ListMode);
    view->setModel(model);
    view->setModelColumn(column);
    return view;
}
void BookmarksComboBoxWidget::setCurrentFolder(BookmarksItem *folder)
{
	const QModelIndex index = (folder ? folder->index() : QModelIndex());

	setRootModelIndex(index.parent());
	setModelColumn(0);
	setCurrentIndex(index.row());
	setRootModelIndex(QModelIndex());
}
void BookmarksComboBoxWidget::setCurrentFolder(const QModelIndex &index)
{
	m_index = index;

	setRootModelIndex(index.parent());
	setModelColumn(0);
	setCurrentIndex(index.row());
	setRootModelIndex(QModelIndex());
}
Beispiel #8
0
	void RelationalComboBox::setModel(QAbstractItemModel *model, int column) {

		// This hack is to work around erratic behaviour of combobox when setting a model
		// Read QT api reference of setModel and setModelColumn
		// column to display must be selected after the model is set.

// 		setModelColumn(column);

		QComboBox::setModel(model);
		setModelColumn(column);
	}
void QgsLayoutItemComboBox::setCurrentLayout( QgsLayout *layout )
{
  const bool prevAllowEmpty = mProxyModel && mProxyModel->allowEmptyItem();
  int itemType = mProxyModel ? mProxyModel->filterType() : -1;
  mProxyModel = qgis::make_unique< QgsLayoutProxyModel >( layout, this );
  connect( mProxyModel.get(), &QAbstractItemModel::rowsInserted, this, &QgsLayoutItemComboBox::rowsChanged );
  connect( mProxyModel.get(), &QAbstractItemModel::rowsRemoved, this, &QgsLayoutItemComboBox::rowsChanged );
  setModel( mProxyModel.get() );
  setModelColumn( QgsLayoutModel::ItemId );
  mProxyModel->sort( QgsLayoutModel::ItemId, Qt::AscendingOrder );
  mProxyModel->setAllowEmptyItem( prevAllowEmpty );
  if ( itemType >= 0 )
    mProxyModel->setFilterType( static_cast< QgsLayoutItemRegistry::ItemType >( itemType ) );
}
Beispiel #10
0
void CollectionListView::attachModel()
{
    //setup model
    m_model = new CollectionListModel(this);
    setModel(m_model);
    setModelColumn(1);

    //connections
    connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
            this, SLOT(editingFinished()));

    //select last used collection
    selectCurrentCollection();
}
Beispiel #11
0
void GridCombo::setCurrentIndex(int i)
{
	int rc = model()->rowCount();
	if (rc == 0)
		return;
	int r = i % rc;
	int c = i / rc;
	if (c >= model()->columnCount())
		return;
	if (modelColumn() != c)
		setModelColumn(c);
	if (currentIndex() != r)
		QComboBox::setCurrentIndex(r);
}
Beispiel #12
0
/*!
    Constructs a new QxtCountryComboBox with \a parent.
 */
QxtCountryComboBox::QxtCountryComboBox(QWidget* parent)
        : QComboBox(parent)
{
    QXT_INIT_PRIVATE(QxtCountryComboBox);
#ifdef QXT_DESIGNER_MODE
    setEditable(false);
#else
    setModel(new QxtCountryModel(this));
    setModelColumn(0);

    setCurrentCountry(QLocale::system().country());
#endif

    connect(this, SIGNAL(currentIndexChanged(int)), &qxt_d(), SLOT(comboBoxCurrentIndexChanged(int)));
}
Beispiel #13
0
void XComboBox::setDataWidgetMap(XDataWidgetMapper* m)
{
  if (!_listTableName.isEmpty())
  {
    QString tableName="";
    if (_listSchemaName.length())
      tableName=_listSchemaName + ".";
    tableName+=_listTableName;
    static_cast<XSqlTableModel*>(m->model())->setRelation(static_cast<XSqlTableModel*>(m->model())->fieldIndex(_fieldName), 
                                 QSqlRelation(tableName, _listIdFieldName, _listDisplayFieldName));
    
    QSqlTableModel *rel =static_cast<XSqlTableModel*>(m->model())->relationModel(static_cast<XSqlTableModel*>(m->model())->fieldIndex(_fieldName));
    setModel(rel);
    setModelColumn(rel->fieldIndex(_listDisplayFieldName));
  
    m->setItemDelegate(new QSqlRelationalDelegate(this));
    m->addMapping(this, _fieldName);
  }
  else if (_codes.count())
    m->addMapping(this, _fieldName, "code", "currentDefault");
  else
    m->addMapping(this, _fieldName, "text", "text");
}
int QComboBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 24)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 24;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isEditable(); break;
        case 1: *reinterpret_cast< int*>(_v) = count(); break;
        case 2: *reinterpret_cast< QString*>(_v) = currentText(); break;
        case 3: *reinterpret_cast< int*>(_v) = currentIndex(); break;
        case 4: *reinterpret_cast< int*>(_v) = maxVisibleItems(); break;
        case 5: *reinterpret_cast< int*>(_v) = maxCount(); break;
        case 6: *reinterpret_cast< InsertPolicy*>(_v) = insertPolicy(); break;
        case 7: *reinterpret_cast< SizeAdjustPolicy*>(_v) = sizeAdjustPolicy(); break;
        case 8: *reinterpret_cast< int*>(_v) = minimumContentsLength(); break;
        case 9: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 10: *reinterpret_cast< bool*>(_v) = autoCompletion(); break;
        case 11: *reinterpret_cast< Qt::CaseSensitivity*>(_v) = autoCompletionCaseSensitivity(); break;
        case 12: *reinterpret_cast< bool*>(_v) = duplicatesEnabled(); break;
        case 13: *reinterpret_cast< bool*>(_v) = hasFrame(); break;
        case 14: *reinterpret_cast< int*>(_v) = modelColumn(); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setEditable(*reinterpret_cast< bool*>(_v)); break;
        case 3: setCurrentIndex(*reinterpret_cast< int*>(_v)); break;
        case 4: setMaxVisibleItems(*reinterpret_cast< int*>(_v)); break;
        case 5: setMaxCount(*reinterpret_cast< int*>(_v)); break;
        case 6: setInsertPolicy(*reinterpret_cast< InsertPolicy*>(_v)); break;
        case 7: setSizeAdjustPolicy(*reinterpret_cast< SizeAdjustPolicy*>(_v)); break;
        case 8: setMinimumContentsLength(*reinterpret_cast< int*>(_v)); break;
        case 9: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 10: setAutoCompletion(*reinterpret_cast< bool*>(_v)); break;
        case 11: setAutoCompletionCaseSensitivity(*reinterpret_cast< Qt::CaseSensitivity*>(_v)); break;
        case 12: setDuplicatesEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 13: setFrame(*reinterpret_cast< bool*>(_v)); break;
        case 14: setModelColumn(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 15;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
int QListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractItemView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 1)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 1;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< Movement*>(_v) = movement(); break;
        case 1: *reinterpret_cast< Flow*>(_v) = flow(); break;
        case 2: *reinterpret_cast< bool*>(_v) = isWrapping(); break;
        case 3: *reinterpret_cast< ResizeMode*>(_v) = resizeMode(); break;
        case 4: *reinterpret_cast< LayoutMode*>(_v) = layoutMode(); break;
        case 5: *reinterpret_cast< int*>(_v) = spacing(); break;
        case 6: *reinterpret_cast< QSize*>(_v) = gridSize(); break;
        case 7: *reinterpret_cast< ViewMode*>(_v) = viewMode(); break;
        case 8: *reinterpret_cast< int*>(_v) = modelColumn(); break;
        case 9: *reinterpret_cast< bool*>(_v) = uniformItemSizes(); break;
        case 10: *reinterpret_cast< int*>(_v) = batchSize(); break;
        case 11: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 12: *reinterpret_cast< bool*>(_v) = isSelectionRectVisible(); break;
        }
        _id -= 13;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setMovement(*reinterpret_cast< Movement*>(_v)); break;
        case 1: setFlow(*reinterpret_cast< Flow*>(_v)); break;
        case 2: setWrapping(*reinterpret_cast< bool*>(_v)); break;
        case 3: setResizeMode(*reinterpret_cast< ResizeMode*>(_v)); break;
        case 4: setLayoutMode(*reinterpret_cast< LayoutMode*>(_v)); break;
        case 5: setSpacing(*reinterpret_cast< int*>(_v)); break;
        case 6: setGridSize(*reinterpret_cast< QSize*>(_v)); break;
        case 7: setViewMode(*reinterpret_cast< ViewMode*>(_v)); break;
        case 8: setModelColumn(*reinterpret_cast< int*>(_v)); break;
        case 9: setUniformItemSizes(*reinterpret_cast< bool*>(_v)); break;
        case 10: setBatchSize(*reinterpret_cast< int*>(_v)); break;
        case 11: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 12: setSelectionRectVisible(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 13;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 13;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 13;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}