Exemple #1
0
void TreeRegions::slotEnableButtons()
{
	slotEnableButtons(QItemSelection(), QItemSelection());
	/*if (m_editMode)
	{
		ui->action_Edit->setEnabled(false);
		ui->action_Delete->setEnabled(false);
		ui->action_New->setEnabled(false);
		ui->action_NewRoot->setEnabled(false);
		ui->action_Yes->setEnabled(m_model->allowSave());
		ui->action_No->setEnabled(true);
	}
	else
	{
		ui->action_New->setEnabled(true);
		ui->action_NewRoot->setEnabled(true);
		ui->action_Yes->setEnabled(false);
		ui->action_No->setEnabled(false);
		if (ui->treeView->selectionModel()->selectedRows().count() == 1)
		{
			ui->action_Delete->setEnabled(true);
			ui->action_Edit->setEnabled(true);			
		}
		else
		{
			ui->action_Delete->setEnabled(false);
			ui->action_Edit->setEnabled(false);	
			
		}
	}*/
}
void GraphicalUriArray::moveItems( int step )
{
  QModelIndexList selected = m_listView->selectionModel()->selectedRows();
  QModelIndexList::iterator it = selected.begin();
  QStringList items = m_model->stringList();
  QList<int> newSelection;

  // move the elements
  for( ; it != selected.end() ; ++it )
  {
      int row = it->row();
      int newRow = row + step;

//      if(  newRow >= 0 && newRow < items.count() )
      items.move( row, newRow );    // move the row
      newSelection.append( newRow );
  }

  m_model->setStringList(items); // set the new items

  // select items that were just moved
  QList<int>::iterator itNewSelect = newSelection.begin();
  for( ; itNewSelect != newSelection.end(); ++ itNewSelect)
    m_listView->selectionModel()->select( m_model->index(*itNewSelect), QItemSelectionModel::Select );

  // update buttons enabled states
  selectionChanged(QItemSelection(), QItemSelection());
}
void KUI_project::openFileSlot()
{
  updateActions(QItemSelection(), QItemSelection());
  
  KUrl url;
  url.setDirectory( path );
  QString modelPath = KFileDialog::getOpenFileName(url, QString("*.xui"), this, QString("Open"));
  
  if ( modelPath.isEmpty() )
    return;
  
  url.setPath( modelPath );
  
  path = url.directory();
  QDir::setCurrent( path );
  
  qDebug() << "New path: " << path;
  
  if (modelPath.isEmpty()) {
    return;
  }
  

  modelSetup( modelPath );
  
}
void QgsStyleManagerDialog::populateSymbols( const QStringList& symbolNames, bool check )
{
  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
  model->clear();

  int type = currentItemType();

  for ( int i = 0; i < symbolNames.count(); ++i )
  {
    QString name = symbolNames[i];
    QgsSymbol* symbol = mStyle->symbol( name );
    if ( symbol && symbol->type() == type )
    {
      QStandardItem* item = new QStandardItem( name );
      QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( symbol, listItems->iconSize() );
      item->setIcon( icon );
      item->setData( name ); // used to find out original name when user edited the name
      item->setCheckable( check );
      item->setToolTip( name );
      // add to model
      model->appendRow( item );
    }
    delete symbol;
  }
  selectedSymbolsChanged( QItemSelection(), QItemSelection() );
  symbolSelected( listItems->currentIndex() );
}
Exemple #5
0
QItemSelection ListExtension::itemSelection( const QModelIndex & first, const QModelIndex & last ) const
{
	if (!first.isValid() && !last.isValid())
	{
		return QItemSelection();
	}
	if (!first.isValid() && last.isValid())
	{
		return QItemSelection( last, last );
	}
	if (first.isValid() && !last.isValid())
	{
		return QItemSelection( first, first );
	}

	assert( first.column() == 0 && !first.parent().isValid() );
	assert( last.column() == 0 && !last.parent().isValid() );

	auto begin = first;
	auto end = last;

	if (begin.row() > end.row())
	{
		std::swap(begin, end);
	}

	return QItemSelection( begin, end );
}
Exemple #6
0
void QtScrollerFilter::stateChanged_QAbstractItemView(QAbstractItemView *view, QtScroller::State state)
{
    switch (state) {
    case QtScroller::Pressed:
        if (view->selectionModel()) {
            oldSelection = view->selectionModel()->selection();
            oldCurrent = view->selectionModel()->currentIndex();
        } else {
            oldSelection = QItemSelection();
            oldCurrent = QModelIndex();
        }
        break;

    case QtScroller::Dragging:
        // restore the old selection if we really start scrolling
        if (view->selectionModel()) {
            view->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
            view->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
        }
        // fall through

    default:
        oldSelection = QItemSelection();
        oldCurrent = QModelIndex();
        break;
    }
}
void tst_QAbstractProxyModel::mapSelectionToSource_data()
{
    QTest::addColumn<QItemSelection>("selection");
    QTest::addColumn<QItemSelection>("mapSelectionToSource");
    QTest::newRow("null") << QItemSelection() << QItemSelection();
    QTest::newRow("empty") << QItemSelection(QModelIndex(), QModelIndex()) << QItemSelection(QModelIndex(), QModelIndex());
}
void KUI_project::newProjectDialogSlot()
{
  updateActions(QItemSelection(), QItemSelection());
  
 
  NewProjectDialog *dialogSettings = new NewProjectDialog(this);
  connect( dialogSettings, SIGNAL( newProjectEnd(QString)),
           this, SLOT( userEditationSlot( QString )) );
  
  dialogSettings->setModal(true);
  dialogSettings->show();
}
void KUI_project::unhideSlot()
{
  delete recorder;
  trayIcon->setVisible(false);
  
  updateActions( QItemSelection(), QItemSelection() );
  
  this->setVisible(true);
  
  
  
}
Exemple #10
0
void AuthorGroupPage::setData(const ModXData *data)
{
    model->setList(data->authorGroup);
    if (data->authorGroup.isEmpty())
    {
        updateDetails(QItemSelection(), QItemSelection());
    }
    else
    {
        ui.authorList->selectionModel()->select(model->index(0, 0), QItemSelectionModel::SelectCurrent);
    }
}
ScreenTab::ScreenTab(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ScreenTab),
    _currentMedia(NULL),
    _screen(NULL),
    _desktopMediaPlayer(new DesktopMediaPlayer(this))
{
    ui->setupUi(this);
    setScreen(new Screen(this));

//    ui->currentDisplaySpinBox->setMaximum(QApplication::desktop()->screenCount() - 1);

    ui->splitter->setStretchFactor(0, 1);
    ui->splitter->setSizes(QList<int>() << 10000 << 1);
    setContextMenuPolicy(Qt::PreventContextMenu);

    addAction(ui->actionStartStopPlaying);

    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::FilePatch, QHeaderView::Stretch);
    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::NumberToShow, QHeaderView::ResizeToContents);
    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::RandomWeigth, QHeaderView::ResizeToContents);
    ui->mediaListTableView->addAction(ui->actionAddMedia);
    ui->mediaListTableView->addAction(ui->actionAddExtension);
    ui->mediaListTableView->addAction(ui->actionRemoveRow);
    ui->mediaListTableView->addAction(ui->actionMoveMediaUp);
    ui->mediaListTableView->addAction(ui->actionMoveMediaDown);
    ui->mediaListTableView->setContextMenuPolicy(Qt::ActionsContextMenu);
    connect(ui->actionAddMedia, SIGNAL(triggered()), this, SLOT(addMedia()));
    connect(ui->actionAddExtension, SIGNAL(triggered()), this, SLOT(addExtension()));
    connect(ui->actionRemoveRow, SIGNAL(triggered()), this, SLOT(removeMedia()));
    connect(ui->actionMoveMediaUp, SIGNAL(triggered()), this, SLOT(moveMediaUp()));
    connect(ui->actionMoveMediaDown, SIGNAL(triggered()), this, SLOT(moveMediaDown()));
    connect(ui->actionStartStopPlaying, SIGNAL(triggered()), this, SLOT(startStopPlaying()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(load()));

//    connect(ui->currentDisplaySpinBox, SIGNAL(valueChanged(int)), this, SLOT(onCurrentDisplaySpinBoxChanged(int)));

    connect(_desktopMediaPlayer, SIGNAL(graphicSceneChanged(QGraphicsScene*)), this, SLOT(setSceneToPreview(QGraphicsScene*)));
    connect(_desktopMediaPlayer, SIGNAL(escKeyPressed()), this, SLOT(stopPlaying()));

    mediaListSelectedChanded(QItemSelection(), QItemSelection());

    //Законектим изменение данных в энжайне расширений со слотом обновления расширений
    connect(MDVPlayerApplication::instance(), SIGNAL(extensionEngineDataChanged()), this, SLOT(updateExtensions()));

    onCurrentDisplaySpinBoxChanged(1);
//    onCurrentDisplaySpinBoxChanged(ui->currentDisplaySpinBox->value());
}
void ViewDepartments::slotCancel()
{
	if (m_model->cancel())
	{
		m_editMode = false;
		emit signalSave(-1, false);
	}
	else
		QMessageBox::critical(this, "", "Не удалось отменить изменения", QMessageBox::Ok);
	auto index = ui->tableView->selectionModel()->currentIndex();
	ui->tableView->reset();
	ui->tableView->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select |
		QItemSelectionModel::Rows);
	slotSelectionChanged(QItemSelection(), QItemSelection());
}
Exemple #13
0
	ItemListWidget::ItemListWidget(QWidget *parent)
	  : QWidget(parent),
		ui(new Ui::ItemListWidget),
        mModel(new ItemListModel(this))
	{
		ui->setupUi(this);

		QAbstractItemModel *oldModel = ui->itemsListView->model();
		ui->itemsListView->setModel(mModel);
		delete oldModel;

		connect(ui->itemsListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged(QItemSelection,QItemSelection)));

		selectionChanged(QItemSelection(), QItemSelection());
	}
Exemple #14
0
TreeRegions::TreeRegions(QWidget * parent): ui(new Ui::TreeRegions) // ??
{
	ui->setupUi(this);
	setupModel();
	QObject::connect(ui->action_New, SIGNAL(triggered()), this, SLOT(slotAdd()));
	QObject::connect(ui->action_NewRoot, SIGNAL(triggered()), this, SLOT(slotAddRoot()));
	QObject::connect(ui->action_Delete, SIGNAL(triggered()), this, SLOT(slotDelete()));
	QObject::connect(ui->action_Edit, SIGNAL(triggered()), this, SLOT(slotEdit()));
	QObject::connect(ui->action_Yes, SIGNAL(triggered()), this, SLOT(slotSave()));
	QObject::connect(ui->action_No, SIGNAL(triggered()), this, SLOT(slotCancel()));
	QObject::connect(ui->treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
		this, SLOT(slotEnableButtons(const QItemSelection &, const QItemSelection &)));
	QObject::connect(this, SIGNAL(signalChangeEditMode()), this, SLOT(slotEnableButtons()));
	slotEnableButtons(QItemSelection(), QItemSelection());
}
void tst_QAbstractProxyModel::qabstractproxymodel()
{
    SubQAbstractProxyModel model;
    model.data(QModelIndex());
    model.flags(QModelIndex());
    model.headerData(0, Qt::Vertical, 0);
    model.itemData(QModelIndex());
    model.mapFromSource(QModelIndex());
    model.mapSelectionFromSource(QItemSelection());
    model.mapSelectionToSource(QItemSelection());
    model.mapToSource(QModelIndex());
    model.revert();
    model.setSourceModel(0);
    QCOMPARE(model.sourceModel(), (QAbstractItemModel*)0);
    model.submit();
}
Exemple #16
0
ServerLogDialog::ServerLogDialog(QWidget *parent)
	: QDialog(parent)
{
	m_ui = new Ui_ServerLogDialog;
	m_ui->setupUi(this);

	m_eventlogProxy = new QSortFilterProxyModel(this);
	m_ui->view->setModel(m_eventlogProxy);

	m_eventlogProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
	connect(m_ui->filter, &QLineEdit::textChanged, m_eventlogProxy, &QSortFilterProxyModel::setFilterFixedString);

	m_userlistProxy = new QSortFilterProxyModel(this);
	m_ui->userlistView->setModel(m_userlistProxy);

	m_userlistProxy->setFilterKeyColumn(0);
	m_userlistProxy->setFilterRole(Qt::DisplayRole);
	m_userlistProxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
	connect(m_ui->userlistFilter, &QLineEdit::textChanged, m_userlistProxy, &QSortFilterProxyModel::setFilterFixedString);

	connect(m_ui->inspectMode, &QPushButton::toggled, this, &ServerLogDialog::setInspectMode);
	connect(m_ui->kickUser, &QPushButton::clicked, this, &ServerLogDialog::kickSelected);
	connect(m_ui->banUser, &QPushButton::clicked, this, &ServerLogDialog::banSelected);
	connect(m_ui->undoUser, &QPushButton::clicked, this, &ServerLogDialog::undoSelected);
	connect(m_ui->redoUser, &QPushButton::clicked, this, &ServerLogDialog::redoSelected);

	userSelected(QItemSelection());
}
Exemple #17
0
void QgsFeatureListView::selectRow( const QModelIndex &index, bool anchor )
{
  QItemSelectionModel::SelectionFlags command = selectionCommand( index );
  int row = index.row();

  if ( anchor )
    mRowAnchor = row;

  if ( selectionMode() != QListView::SingleSelection
       && command.testFlag( QItemSelectionModel::Toggle ) )
  {
    if ( anchor )
      mCtrlDragSelectionFlag = mFeatureSelectionModel->isSelected( index )
                               ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
    command &= ~QItemSelectionModel::Toggle;
    command |= mCtrlDragSelectionFlag;
    if ( !anchor )
      command |= QItemSelectionModel::Current;
  }

  QModelIndex tl = model()->index( std::min( mRowAnchor, row ), 0 );
  QModelIndex br = model()->index( std::max( mRowAnchor, row ), model()->columnCount() - 1 );

  mFeatureSelectionModel->selectFeatures( QItemSelection( tl, br ), command );
}
void KLinkItemSelectionModel::select(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
{
    Q_D(KLinkItemSelectionModel);
    // When an item is removed, the current index is set to the top index in the model.
    // That causes a selectionChanged signal with a selection which we do not want.
    if (d->m_ignoreCurrentChanged) {
        return;
    }
    // Do *not* replace next line with: QItemSelectionModel::select(index, command)
    //
    // Doing so would end up calling KLinkItemSelectionModel::select(QItemSelection, QItemSelectionModel::SelectionFlags)
    //
    // This is because the code for QItemSelectionModel::select(QModelIndex, QItemSelectionModel::SelectionFlags) looks like this:
    // {
    //     QItemSelection selection(index, index);
    //     select(selection, command);
    // }
    // So it calls KLinkItemSelectionModel overload of
    // select(QItemSelection, QItemSelectionModel::SelectionFlags)
    //
    // When this happens and the selection flags include Toggle, it causes the
    // selection to be toggled twice.
    QItemSelectionModel::select(QItemSelection(index, index), command);
    if (index.isValid())
        d->m_linkedItemSelectionModel->select(d->m_indexMapper->mapSelectionLeftToRight(QItemSelection(index, index)), command);
    else {
        d->m_linkedItemSelectionModel->clearSelection();
    }
}
Exemple #19
0
bool QAccessibleTable::unselectColumn(int column)
{
    if (!view()->model() || !view()->selectionModel())
        return false;

    QModelIndex index = view()->model()->index(0, column, view()->rootIndex());
    if (!index.isValid())
        return false;

    QItemSelection selection(index, index);

    switch (view()->selectionMode()) {
    case QAbstractItemView::SingleSelection:
        //In SingleSelection and ContiguousSelection once an item
        //is selected, there's no way for the user to unselect all items
        if (selectedColumnCount() == 1)
            return false;
        break;
    case QAbstractItemView::ContiguousSelection:
        if (selectedColumnCount() == 1)
            return false;

        if ((!column || view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex()))
            && view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex())) {
            //If there are columns selected both at the left of the current row and at the right
            //of the current rown, the ones which are at the right will be deselected
            selection = QItemSelection(index, view()->model()->index(0, columnCount() - 1, view()->rootIndex()));
        }
    default:
        break;
    }

    view()->selectionModel()->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Columns);
    return true;
}
Exemple #20
0
bool QAccessibleTable::unselectRow(int row)
{
    if (!view()->model() || !view()->selectionModel())
        return false;

    QModelIndex index = view()->model()->index(row, 0, view()->rootIndex());
    if (!index.isValid())
        return false;

    QItemSelection selection(index, index);

    switch (view()->selectionMode()) {
    case QAbstractItemView::SingleSelection:
        //In SingleSelection and ContiguousSelection once an item
        //is selected, there's no way for the user to unselect all items
        if (selectedRowCount() == 1)
            return false;
        break;
    case QAbstractItemView::ContiguousSelection:
        if (selectedRowCount() == 1)
            return false;

        if ((!row || view()->selectionModel()->isRowSelected(row - 1, view()->rootIndex()))
            && view()->selectionModel()->isRowSelected(row + 1, view()->rootIndex())) {
            //If there are rows selected both up the current row and down the current rown,
            //the ones which are down the current row will be deselected
            selection = QItemSelection(index, view()->model()->index(rowCount() - 1, 0, view()->rootIndex()));
        }
    default:
        break;
    }

    view()->selectionModel()->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
    return true;
}
GraphicalUriArray::GraphicalUriArray(const QString& sep, QWidget * parent)
  : GraphicalValue(parent)
{
  m_groupBox = new QGroupBox(parent);
  m_editAdd = new QLineEdit(m_groupBox);
  m_model = new QStringListModel(m_groupBox);
  m_listView = new QListView(m_groupBox);
  m_btAdd = new QPushButton("+", m_groupBox);
  m_btRemove = new QPushButton("-", m_groupBox);
  m_btUp = new QPushButton("Up", m_groupBox);
  m_btDown = new QPushButton("Down", m_groupBox);
  m_comboType = new QComboBox(m_groupBox);
  m_separator = sep;

  m_buttonsLayout = new QVBoxLayout();
  m_boxLayout = new QGridLayout(m_groupBox);

  m_listView->setModel(m_model);
  m_listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
//  m_listView->setDragDropMode(QAbstractItemView::InternalMove);
//  m_listView->setDragEnabled(true);
//  m_listView->setAcceptDrops(true);

  setProtocols(std::vector<std::string>());

  m_buttonsLayout->addWidget(m_btUp);
  m_buttonsLayout->addWidget(m_btDown);

  m_boxLayout->addWidget(m_comboType, 0, 0);
  m_boxLayout->addWidget(m_editAdd, 0, 1);
  m_boxLayout->addWidget(m_btAdd, 0, 2);
  m_boxLayout->addWidget(m_btRemove, 0, 3);
  m_boxLayout->addWidget(m_listView, 1, 0, 1, 4);
  m_boxLayout->addLayout(m_buttonsLayout, 1, 4);

  m_layout->addWidget(m_groupBox);

  selectionChanged(QItemSelection(), QItemSelection());

  connect(m_btAdd, SIGNAL(clicked()), this, SLOT(btAddClicked()));
  connect(m_btRemove, SIGNAL(clicked()), this, SLOT(btRemoveClicked()));
  connect(m_comboType, SIGNAL(activated(QString)), this, SLOT(changeType(QString)));
  connect(m_btUp, SIGNAL(clicked()), this, SLOT(moveUp()));
  connect(m_btDown, SIGNAL(clicked()), this, SLOT(moveDown()));
  connect(m_listView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
          this, SLOT(selectionChanged(QItemSelection,QItemSelection)));
}
Exemple #22
0
void RPCConsole::peerLayoutChanged()
{
    if (!clientModel)
        return;

    const CNodeCombinedStats *stats = NULL;
    bool fUnselect = false;
    bool fReselect = false;

    if (cachedNodeid == -1) // no node selected yet
        return;

    // find the currently selected row
    int selectedRow;
    QModelIndexList selectedModelIndex = ui->peerWidget->selectionModel()->selectedIndexes();
    if (selectedModelIndex.isEmpty())
        selectedRow = -1;
    else
        selectedRow = selectedModelIndex.first().row();

    // check if our detail node has a row in the table (it may not necessarily
    // be at selectedRow since its position can change after a layout change)
    int detailNodeRow = clientModel->getPeerTableModel()->getRowByNodeId(cachedNodeid);

    if (detailNodeRow < 0)
    {
        // detail node dissapeared from table (node disconnected)
        fUnselect = true;
        cachedNodeid = -1;
        ui->detailWidget->hide();
        ui->peerHeading->setText(tr("Select a peer to view detailed information."));
    }
    else
    {
        if (detailNodeRow != selectedRow)
        {
            // detail node moved position
            fUnselect = true;
            fReselect = true;
        }

        // get fresh stats on the detail node.
        stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
    }

    if (fUnselect && selectedRow >= 0)
    {
        ui->peerWidget->selectionModel()->select(QItemSelection(selectedModelIndex.first(), selectedModelIndex.last()),
            QItemSelectionModel::Deselect);
    }

    if (fReselect)
    {
        ui->peerWidget->selectRow(detailNodeRow);
    }

    if (stats)
        updateNodeDetail(stats);
}
Exemple #23
0
void ServerLogDialog::setOperatorMode(bool op)
{
	m_opMode = op;
	if(m_ui->userlistView->selectionModel())
		userSelected(m_ui->userlistView->selectionModel()->selection());
	else
		userSelected(QItemSelection());
}
Exemple #24
0
void Pageview::selectPage (QModelIndex ind)
   {
   QItemSelectionModel *sel = selectionModel ();

   sel->select (QItemSelection (ind, ind),
      QItemSelectionModel::Clear | QItemSelectionModel::Select);
   scrollTo (ind);
   }
void Project_selection_model::select ( const QModelIndex & index, QItemSelectionModel::SelectionFlags command ){
	if(index.isValid()) {
		this->select(QItemSelection(index,index),command);
	}




}
Exemple #26
0
void characteristic::sNew()
{
  int row = _charoptModel->rowCount();
  _charoptModel->insertRows(row,1);
  _charoptModel->setData(_charoptModel->index(row,1), QVariant(_charid));
  _charoptModel->setData(_charoptModel->index(row,3), 0);
  QModelIndex idx = _charoptModel->index(row,0);
  _charoptView->selectionModel()->select(QItemSelection(idx, idx),
                                         QItemSelectionModel::ClearAndSelect |
                                         QItemSelectionModel::Rows);
}
void ViewDepartments::createTable()
{
	auto comboDelegate = new ComboDelegate(GeodataType::getList(), this);
	ui->tableView->setItemDelegateForColumn(7, comboDelegate);

	ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
	ui->tableView->setColumnHidden(0, true);
	ui->tableView->resizeColumnsToContents();
	ui->tableView->resizeRowsToContents();

	ui->tableView->setColumnWidth(1, 300);
	ui->tableView->setColumnWidth(2, 150);
	ui->tableView->setColumnWidth(3, 350);
	ui->tableView->setColumnWidth(4, 100);
	ui->tableView->setColumnWidth(5, 100);
	ui->tableView->setColumnWidth(6, 200);
	ui->tableView->setColumnWidth(7, 350);
	ui->tableView->setColumnWidth(8, 350);

	slotSelectionChanged(QItemSelection(), QItemSelection());
}
void QgsStyleManagerDialog::populateColorRamps( const QStringList& colorRamps, bool check )
{
  QStandardItemModel* model = qobject_cast<QStandardItemModel*>( listItems->model() );
  model->clear();

  for ( int i = 0; i < colorRamps.count(); ++i )
  {
    QString name = colorRamps[i];
    QScopedPointer< QgsColorRamp > ramp( mStyle->colorRamp( name ) );

    QStandardItem* item = new QStandardItem( name );
    QIcon icon = QgsSymbolLayerUtils::colorRampPreviewIcon( ramp.data(), listItems->iconSize() );
    item->setIcon( icon );
    item->setData( name ); // used to find out original name when user edited the name
    item->setCheckable( check );
    item->setToolTip( name );
    model->appendRow( item );
  }
  selectedSymbolsChanged( QItemSelection(), QItemSelection() );
  symbolSelected( listItems->currentIndex() );
}
Exemple #29
0
void TreeView::_append_children_to_selection(const QModelIndex &ind, QItemSelection &sel, int fl)
{
    while(model()->canFetchMore(ind))
        model()->fetchMore(ind);

    sel.merge(QItemSelection(model()->index(0, 0, ind),
                             model()->index(model()->rowCount(ind) - 1, 0, ind)),
              QItemSelectionModel::SelectionFlags(fl));

    for(int i = 0; i < model()->rowCount(ind); i++)
        _append_children_to_selection(model()->index(i, 0, ind), sel, fl);
}
CategoriesWidget::CategoriesWidget(QWidget *parent)
    : QWidget(parent)
{
    setupUi(this);

    m_buttonAddCategory->setIcon(KIcon(QLatin1String("list-add")));
    m_buttonRemoveCategory->setIcon(KIcon(QLatin1String("list-remove")));
    m_buttonEditCategory->setIcon(KIcon(QLatin1String("configure")));

    connect(m_buttonAddCategory, SIGNAL(clicked()), this, SLOT(slotAddCategory()));
    connect(m_buttonRemoveCategory, SIGNAL(clicked()), this, SLOT(slotRemoveCategory()));
    connect(m_buttonEditCategory, SIGNAL(clicked()), this, SLOT(slotEditCategory()));

    m_categoriesModel = new CategoriesModel(this);
    m_viewCategories->setModel(m_categoriesModel);

    connect(m_viewCategories->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection)));
    connect(m_viewCategories, SIGNAL(doubleClicked(QModelIndex)),
            this, SLOT(slotEditCategory()));
    slotSelectionChanged(QItemSelection(), QItemSelection());
}