void RealTimeMultiSampleArrayWidget::channelContextMenu(QPoint pos)
{
    //obtain index where index was clicked
    QModelIndex index = m_pTableView->indexAt(pos);

    //get selected items
    QModelIndexList selected = m_pTableView->selectionModel()->selectedIndexes();

    //create custom context menu and actions
    QMenu *menu = new QMenu(this);

    //**************** Marking ****************
    if(!m_qListBadChannels.contains(index.row())) {
        QAction* doMarkChBad = menu->addAction(tr("Mark as bad"));
        connect(doMarkChBad, &QAction::triggered,
                this, &RealTimeMultiSampleArrayWidget::markChBad);
    } else {
        QAction* doMarkChGood = menu->addAction(tr("Mark as good"));
        connect(doMarkChGood, &QAction::triggered,
                this, &RealTimeMultiSampleArrayWidget::markChBad);
    }

    // non C++11 alternative
    m_qListCurrentSelection.clear();
    for(qint32 i = 0; i < selected.size(); ++i)
        if(selected[i].column() == 1)
            m_qListCurrentSelection.append(m_pRTMSAModel->getIdxSelMap()[selected[i].row()]);

    QAction* doSelection = menu->addAction(tr("Apply selection"));
    connect(doSelection, &QAction::triggered,
            this, &RealTimeMultiSampleArrayWidget::applySelection);

    //select channels
    QAction* hideSelection = menu->addAction(tr("Hide selection"));
    connect(hideSelection, &QAction::triggered, this,
            &RealTimeMultiSampleArrayWidget::hideSelection);

    //undo selection
    QAction* resetAppliedSelection = menu->addAction(tr("Reset selection"));
    connect(resetAppliedSelection, &QAction::triggered,
            m_pRTMSAModel.data(), &RealTimeMultiSampleArrayModel::resetSelection);
    connect(resetAppliedSelection, &QAction::triggered,
            this, &RealTimeMultiSampleArrayWidget::resetSelection);

    //show context menu
    menu->popup(m_pTableView->viewport()->mapToGlobal(pos));
}
Esempio n. 2
0
void GeneralDataGUI::insertUnitMeasure(){
    if( m_d->project != NULL ){
        QModelIndexList listIndexs = m_d->ui->unitMeasureView->selectionModel()->selectedIndexes();
        QList<int> listRows;
        for( int i=0; i < listIndexs.size(); ++i){
            if( !listRows.contains( listIndexs.at(i).row() )){
                listRows.append( listIndexs.at(i).row() );
            }
        }
        qSort( listRows );
        if( listRows.size() > 0 ){
            m_d->project->unitMeasureModel()->insert( listRows.last()+1, listRows.size() );
        } else {
            m_d->project->unitMeasureModel()->insert( 0 );
        }
    }
}
Esempio n. 3
0
void ConditionWidget::onDeleteTriggered()
{
    QModelIndexList indexes = selectedIndexes();
    QStandardItem* item = 0;
    AbstractCondition* condition = 0;
    qSort(indexes);
    for(int i=indexes.size()-1; i >= 0; --i) {
        item = mModel->itemFromIndex(indexes[i]);
        if (item && mItemToCondition.contains(item)) {
            condition = mItemToCondition.take(item);
            mCondition->removeCondition(condition, true);
            mModel->removeRow(item->row());
        }
    }

    reload();
}
Esempio n. 4
0
void CmdSpreadsheetStyleUnderline::activated(int iMsg)
{
    Q_UNUSED(iMsg);
    if (getActiveGuiDocument()) {
        Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();
        SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);

        if (sheetView) {
            Sheet * sheet = sheetView->getSheet();
            QModelIndexList selection = sheetView->selectedIndexes();

            if (selection.size() > 0) {
                bool allUnderline = true;

                for (QModelIndexList::const_iterator it = selection.begin(); it != selection.end(); ++it) {
                    const Cell * cell = sheet->getCell(CellAddress((*it).row(), (*it).column()));

                    if (cell) {
                        std::set<std::string> style;

                        cell->getStyle(style);
                        if (style.find("underline") == style.end()) {
                            allUnderline = false;
                            break;
                        }
                    }
                }

                std::vector<Range> ranges = sheetView->selectedRanges();
                std::vector<Range>::const_iterator i = ranges.begin();

                Gui::Command::openCommand("Set underline text");
                for (; i != ranges.end(); ++i) {
                    if (!allUnderline)
                        Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setStyle('%s', 'underline', 'add')", sheet->getNameInDocument(),
                                                i->rangeString().c_str());
                    else
                        Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.setStyle('%s', 'underline', 'remove')", sheet->getNameInDocument(),
                                                i->rangeString().c_str());
                }
                Gui::Command::commitCommand();
                Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
            }
        }
    }
}
Esempio n. 5
0
void ContactsTable::onSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
  {
  QItemSelectionModel* selection_model = ui->contact_table->selectionModel();
  QModelIndexList      indexes = selection_model->selectedRows();
  bool                 oneRow = (indexes.size() == 1);

  if (oneRow)
    {
    QModelIndex mapped_index = _sorted_addressbook_model->mapToSource(indexes[0]);
    auto        contact_id = _addressbook_model->getContact(mapped_index).wallet_index;
    Q_EMIT      contactOpened(contact_id);      
    }
  else
    {
    ui->contact_details_view->setCurrentWidget(ui->page_message);        
    }
  }
Esempio n. 6
0
void Peers::remove_enrollee_uuid(QString uuid)
{
	if (model.rowCount() == 0)
		return;

	QModelIndexList lst = model.match(model.index(0, 0),
					  peer_role_uuid, uuid);
	for (int i = 0; i < lst.size(); i++) {
		QStandardItem *item = model.itemFromIndex(lst[i]);
		if (item == NULL)
			continue;
		int type = item->data(peer_role_type).toInt();
		if (type == PEER_TYPE_WPS_ER_ENROLLEE ||
		    type == PEER_TYPE_WPS_ENROLLEE)
			model.removeRow(lst[i].row());
	}
}
Esempio n. 7
0
        void Overlay::reset_colourmap(const ColourMapButton&)
        {
            QModelIndexList indices = image_list_view->selectionModel()->selectedIndexes();
            Displayable* overlay = nullptr;
            for (size_t i = 0, N = indices.size(); i < N; ++i) {
              overlay = dynamic_cast<Displayable*> (image_list_model->get_image (indices[i]));
              overlay->reset_windowing();
            }

            // Reset the min/max adjust button fields of last selected overlay
            if(overlay) {
             min_value->setValue(overlay->intensity_min());
             max_value->setValue(overlay->intensity_max());
            }

            updateGL();
        }
Esempio n. 8
0
void Window::connectAsSpectatorSelected()
{
    QModelIndexList selectedIndexes = planetTreeView->selectionModel()->selectedIndexes();
    if (selectedIndexes.size() == 0) {
        return;
    }
    QString configPath = getBasenfkPath()+ "spec.cfg";
    QFile config(configPath);
    if (!config.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)) {
        error("Couldn't open:\n\"" + configPath + "\"");
        return;
    }
    QString configContent = "spectator 1\necho spectator on\nconnect " + selectedIndexes.at(4).data().toString();
    config.write(configContent.toLatin1());
    config.flush();
    startGame("+exec spec ");
}
Esempio n. 9
0
        void Tractography::geom_type_selection_slot (int selected_index)
        {
          // Combo box shows the "(variable)" message, and the user has
          //   re-clicked on it -> nothing to do
          if (selected_index == 3)
            return;

          TrackGeometryType geom_type = geometry_index2type (selected_index);

          QModelIndexList indices = tractogram_list_view->selectionModel()->selectedIndexes();
          for (int i = 0; i < indices.size(); ++i)
            tractogram_list_model->get_tractogram (indices[i])->set_geometry_type (geom_type);

          update_geometry_type_gui();

          window().updateGL();
        }
Esempio n. 10
0
 void Tractography::colour_track_by_direction_slot()
 {
   QModelIndexList indices = tractogram_list_view->selectionModel()->selectedIndexes();
   for (int i = 0; i < indices.size(); ++i)  {
     Tractogram* tractogram = tractogram_list_model->get_tractogram (indices[i]);
     tractogram->set_color_type (TrackColourType::Direction);
     if (tractogram->get_threshold_type() == TrackThresholdType::UseColourFile)
       tractogram->set_threshold_type (TrackThresholdType::None);
   }
   colour_combobox->blockSignals (true);
   colour_combobox->setCurrentIndex (0);
   colour_combobox->clearError();
   colour_combobox->blockSignals (false);
   colour_button->setEnabled (false);
   update_scalar_options();
   window().updateGL();
 }
Esempio n. 11
0
/**
  * If a module is loaded not through the ModuleDock, select the module.
  */
void ModuleDockWidget::loadedModule(const int id)
{
    if(id == -1) {
        m_selectionModel->clearSelection();
        return;
    }
    if(m_moduleID == id)
        return;

    m_moduleID = id;
    const QModelIndexList list = m_proxyModel->match(m_moduleManager->m_moduleModel->invisibleRootItem()->index(), Qt::UserRole + 1, QString::number(id));

    if(list.size() == 1) {
        m_selectionModel->clearSelection();
        m_selectionModel->setCurrentIndex(m_proxyModel->mapFromSource(list.at(0)), QItemSelectionModel::Select);
    }
}
Esempio n. 12
0
void AtlasDialog::on_add_atlas_clicked()
{
    atlas_index = ui->atlasListBox->currentIndex();
    atlas_name = ui->atlasListBox->currentText().toStdString();
    QModelIndexList indexes = ui->region_list->selectionModel()->selectedRows();
    if(!indexes.count())
    {
        reject();
        return;
    }
    for(unsigned int index = 0; index < indexes.size(); ++index)
    {
        roi_list.push_back(indexes[index].row());
        roi_name.push_back(((QStringListModel*)ui->region_list->model())->stringList()[indexes[index].row()].toStdString());
    }
    accept();
}
Esempio n. 13
0
QSharedPointer<EyetrackerBrowserEventArgs> MainWindow::browserDataFromCurrentSelection()
{
    QModelIndexList selectionList = ui->listView->selectionModel()->selectedRows();
    if(selectionList.size() > 0)
    {
        const QModelIndex& selectedIndex = selectionList[0];
        QString productIdToUpgrade = qvariant_cast<QString>(selectedIndex.data(ListviewDelegate::ProductIdRole));

        BrowserDataMap::iterator browserDataIt = browserDataMap.find(productIdToUpgrade);
        if(browserDataIt != browserDataMap.end())
        {
            return browserDataIt.value();
        }
    }

    return QSharedPointer<EyetrackerBrowserEventArgs>();
}
Esempio n. 14
0
void AddCommandDialog::accept()
{
    const QModelIndexList indexes =
            ui->listViewCommands->selectionModel()->selectedIndexes();

    if (!indexes.isEmpty()) {
        QVector<Command> commands;

        commands.reserve( indexes.size() );
        for (const auto &index : indexes)
            commands.append( index.data(Qt::UserRole).value<Command>() );

        emit addCommands(commands);
    }

    QDialog::accept();
}
Esempio n. 15
0
/*!
    \fn VPresupuestos::modificar()
 */
void VPresupuestos::modificar()
{
 QItemSelectionModel *selectionModel = vista->selectionModel();
 QModelIndexList indices = selectionModel->selectedRows();
 if( indices.size() < 1 )
 {
   QMessageBox::warning( this, "Seleccione un item",
                   "Por favor, seleccione un item para modificar",
                   QMessageBox::Ok );
   return;
 }
 FormModificarPresupuesto *form = new FormModificarPresupuesto();
 form->setId( modelo->data( modelo->index( indices.at(0).row(), 0 ), Qt::EditRole ).toInt() );
 form->setModelo( this->modelo );
 // Consigo el numero de presupuesto que se quiere modificar
 emit agregarVentana( form );
}
Esempio n. 16
0
void QgsWFSSourceSelect::addButtonClicked()
{
  //get selected entry in treeview
  QModelIndex currentIndex = treeView->selectionModel()->currentIndex();
  if ( !currentIndex.isValid() )
  {
    return;
  }

  QgsWfsConnection connection( cmbConnections->currentText() );

  QString pCrsString( labelCoordRefSys->text() );

  //create layers that user selected from this WFS source
  QModelIndexList list = treeView->selectionModel()->selectedRows();
  for ( int i = 0; i < list.size(); i++ )
  {
    //add a wfs layer to the map
    QModelIndex idx = mModelProxy->mapToSource( list[i] );
    if ( !idx.isValid() )
    {
      continue;
    }
    int row = idx.row();
    QString typeName = mModel->item( row, MODEL_IDX_NAME )->text(); //WFS repository's name for layer
    QString titleName = mModel->item( row, MODEL_IDX_TITLE )->text(); //WFS type name title for layer name (if option is set)
    QString sql = mModel->item( row, MODEL_IDX_SQL )->text(); //optional SqL specified by user
    QString layerName = typeName;
    if ( cbxUseTitleLayerName->isChecked() && !titleName.isEmpty() )
    {
      layerName = titleName;
    }
    QgsDebugMsg( "Layer " + typeName + " SQL is " + sql );

    mUri = QgsWFSDataSourceURI::build( connection.uri().uri(), typeName, pCrsString,
                                       sql, cbxFeatureCurrentViewExtent->isChecked() );

    emit addVectorLayer( mUri, layerName );
  }

  if ( ! mHoldDialogOpen->isChecked() && widgetMode() == QgsProviderRegistry::WidgetMode::None )
  {
    accept();
  }
}
Esempio n. 17
0
void SideBarView::slotSidebarContextMenu(){
    QItemSelectionModel *s_m = selectionModel();
    QModelIndexList selected = s_m->selectedRows(0);

    if (selected.size() < 1)
        return;

    SideBarItem *item = reinterpret_cast<SideBarItem*>(selected.at(0).internalPointer());

    QMenu *menu = NULL;
    
    if (item && item->childCount() > 0){
        menu = new QMenu(this);
        menu->addAction(WICON(WulforUtil::eiEDITDELETE), tr("Close all"));

        if (menu->exec(QCursor::pos())){
            QList<SideBarItem*> childs = item->childItems;

            for (const auto &child : childs){
                if (child && child->getWidget())
                    ArenaWidgetManager::getInstance()->rem(child->getWidget());
            }
        }
        
        menu->deleteLater();
    }
    else if (item && item->getWidget()){
        menu = item->getWidget()->getMenu();
        
        if (!menu && (item->getWidget()->state() & ArenaWidget::Singleton))
            return;

        if(!menu){
            menu = new QMenu(this);
            menu->addAction(WICON(WulforUtil::eiEDITDELETE), tr("Close"));

            if (menu->exec(QCursor::pos()))
                ArenaWidgetManager::getInstance()->rem(item->getWidget());
            
            menu->deleteLater();
        }
        else
            menu->exec(QCursor::pos());
    }
}
Esempio n. 18
0
void ui_module_articulos::on_pushButton_editar_2_clicked()
{

    QModelIndexList  list = ui->tableView_articulos->selectionModel()->selectedRows();
    int filas = list.size();


    if(filas>1)
    {
        QMessageBox::information(this,"Error","Solo se puede editar una fila a la vez");
    }
    else
    {
        if(filas==0)
        {
            QMessageBox::information(this,"Error","Por favor, seleccione una fila para editar");
        }
        else
        {
            object_e_articulo  articulo;

            QSqlRelationalTableModel * model = (QSqlRelationalTableModel*)ui->tableView_articulos->model();
            QSqlRecord record = model->record(list.at(0).row());



            articulo.mf_set_pk_articulo(record.value(COD).toString());
            articulo.mf_set_descripcion(record.value(DESCRIPCION).toString());
            articulo.mf_set_fk_marca(record.value(MARCA).toString());
            articulo.mf_set_fk_grupo(record.value(GRUPO).toString());
            articulo.mf_set_fk_medida(record.value(MEDIDA).toString());
            articulo.mf_set_precio_lista(record.value(PRECIO).toString());
            articulo.mf_set_stock(record.value(STOCK).toString());


            ui_edit_articulo  form_edit_articulos(&articulo) ;
            form_edit_articulos.exec();


            //Actualizamos la tabla de articulos
            update_table_articulos();
        }
    }

}
Esempio n. 19
0
void PreferencesDialog::on_button_settings_clicked()
{
    //Uploader settings
    QModelIndex selectedIndex;
    QModelIndexList indexes = ui->list_uploaders->selectionModel()->selectedIndexes();
    if(indexes.size() > 0)
    {
        selectedIndex = indexes.at(0);
        QString shortname = selectedIndex.model()->data(selectedIndex, Qt::UserRole).toString();
        if(shortname != "screencloud")
        {
            uploadManager->getUploader(shortname)->showSettingsUI(this);
        }else
        {
            ui->tabWidget->setCurrentIndex(1);
        }
    }
}
Esempio n. 20
0
 void Tractography::colour_button_slot()
 {
   // Button brings up its own colour prompt; if set_track_colour_slot()
   //   were to be called, this would present its own selection prompt
   // Need to instead set the colours here explicitly
   const QColor color = colour_button->color();
   if (color.isValid()) {
     QModelIndexList indices = tractogram_list_view->selectionModel()->selectedIndexes();
     float c[3] = { color.red()/255.0f, color.green()/255.0f, color.blue()/255.0f };
     for (int i = 0; i < indices.size(); ++i)
       tractogram_list_model->get_tractogram (indices[i])->set_colour (c);
     colour_combobox->blockSignals (true);
     colour_combobox->setCurrentIndex (3); // In case it was on random
     colour_combobox->clearError();
     colour_combobox->blockSignals (false);
     window().updateGL();
   }
 }
Esempio n. 21
0
bool CmdSpreadsheetSetAlias::isActive()
{
    if (getActiveGuiDocument()) {
        Gui::MDIView* activeWindow = Gui::getMainWindow()->activeWindow();

        if (activeWindow) {
            SpreadsheetGui::SheetView * sheetView = freecad_dynamic_cast<SpreadsheetGui::SheetView>(activeWindow);

            if (sheetView) {
                QModelIndexList selection = sheetView->selectedIndexes();

                if (selection.size() == 1)
                    return true;
            }
        }
    }
    return false;
}
Esempio n. 22
0
void X509SuperTreeView::fillContextMenu(QMenu *menu, QMenu *subExport,
		const QModelIndex &index, QModelIndexList indexes)
{
	pki_x509super *x = static_cast<pki_x509super *>
				(index.internalPointer());
	transform = NULL;

	if (indexes.size() != 1)
		return;

	subExport->addAction(tr("OpenSSL config"), this, SLOT(toOpenssl()));
	subExport->setEnabled(!x->isSpki());
	transform = menu->addMenu(tr("Transform"));
	transform->addAction(tr("Template"), this,
		SLOT(toTemplate()))->setEnabled(!x->isSpki());
	transform->addAction(tr("Public Key"), this,
		SLOT(extractPubkey()))->setEnabled(!x->getRefKey());
}
Esempio n. 23
0
int QT1::getRepoListSelectedIndex()
{
	if (this->repoList->count() == 0)return -1;
	QModelIndexList index = this->repoList->selectionModel()->selectedIndexes();
	if (index.size() == 0)
	{
		this->nameEdit->clear();
		this->breedEdit->clear();
		this->ageEdit->clear();
		this->linkEdit->clear();
		return -1;

	}
	int idx = index.at(0).row();
	return idx;


}
Esempio n. 24
0
// Get a list of selected lids from the table
void NTableView::getSelectedLids(QList<qint32> &lids) {

    lids.clear();

    // This is a bit of a hack.  Basically we loop through
    // everything selected.  For each item selected we look at
    // the lid position and pull the lid from the table.
    // Since multiple items in a row are selected, we end up
    // getting the same lid multiple times, but it is the best
    // way since I can't determine exactly how many rows are
    // selected.
    QModelIndexList l = selectedIndexes();
    for (int i=0; i<l.size(); i++) {
        qint32 currentLid =  l.at(i).sibling(l.at(i).row(),NOTE_TABLE_LID_POSITION).data().toInt();
        if (!lids.contains(currentLid)) {
            lids.append(currentLid);
        }
    }
}
Esempio n. 25
0
void CSVWorld::Table::viewRecord()
{
    if (!(mModel->getFeatures() & CSMWorld::IdTableBase::Feature_View))
        return;

    QModelIndexList selectedRows = selectionModel()->selectedRows();

    if (selectedRows.size()==1)
    {
        int row = selectedRows.begin()->row();

        row = mProxyModel->mapToSource (mProxyModel->index (row, 0)).row();

        std::pair<CSMWorld::UniversalId, std::string> params = mModel->view (row);

        if (params.first.getType()!=CSMWorld::UniversalId::Type_None)
            emit editRequest (params.first, params.second);
    }
}
Esempio n. 26
0
void ItemList::move_to_trash()
{
    QModelIndexList ids = selectionModel()->selectedIndexes();
    if (ids.size() == 0)
        return;
    QModelIndex index = ids.at(0);
    if (!index.isValid())
        return;
    PassItem *item = (PassItem*) index.internalPointer();
    if (NULL == item)
        return;

    ItemListModel *m = dynamic_cast<ItemListModel*>(model());
    assert(NULL != m);
    Sqlite3Db *db = m->get_db();
    const int trash_did = db->check_directory_path(Sqlite3Db::TRASH_PATH);
    db->move_item(item->get_id(), trash_did);
    m->_remove_after_drag(index.row());
}
void RealTimeMultiSampleArrayWidget::markChBad()
{
    QModelIndexList selected = m_pTableView->selectionModel()->selectedIndexes();

    for(int i=0; i<selected.size(); i++) {
        if(m_qListBadChannels.contains(selected[i].row())) { //mark as good
            m_pRTMSAModel->markChBad(selected[i], false);
            m_qListBadChannels.removeAll(selected[i].row());
        }
        else {
            m_pRTMSAModel->markChBad(selected[i], true);
            m_qListBadChannels.append(selected[i].row());
        }
    }

    m_pRTMSAModel->updateProjection();    

    m_pSelectionManagerWindow->updateBadChannels();
}
Esempio n. 28
0
void TableWidget::deleteCells(){

    bool enabled = isSortingEnabled();
    setSortingEnabled(false);
    QModelIndexList indexes = selectionModel()->selectedIndexes();
    for(int i=0;i<indexes.size();i++){
        int row = indexes[i].row();
        int column = indexes[i].column();
        //if( item(row,column) && !originCols_.contains(column) ){
        if( item(row,column)->flags().testFlag(Qt::ItemIsEditable) ){
            item(row,column)->setText("");
            //delete takeItem(row,column);
            //TableWidgetItem *newItem = new TableWidgetItem;
            //newItem->setFlags( newItem->flags() &= ~Qt::ItemIsEditable );
            //setItem( row, column, newItem );
        }
    }
    setSortingEnabled(enabled);    
}
Esempio n. 29
0
void
ProteinTable::selectionChanged( const QItemSelection& selected, const QItemSelection& deselected )
{
	QTableView::selectionChanged( selected, deselected );

    QModelIndexList list = selectionModel()->selectedIndexes();
    qSort( list );
    if ( list.size() < 1 )
        return;
	std::set<int> uniq;
    for ( auto index: list ) 
		uniq.insert( index.row() );
	
	QVector<int> rows;
	for ( auto row: uniq )
		rows.push_back( row );

    emit selectionChanged( rows );
}
void EditDirectoriesDialog::on_btnDelete_clicked()
{
    QModelIndexList indices = ui->lvDirectories->selectionModel()->selectedIndexes();
    if(indices.size() > 0)
    {
        if(directories[indices[0].row()].isHome)
        {
            QMessageBox mb;
            mb.setText("Can not delete a home directory");
            mb.setStandardButtons(QMessageBox::Ok);
            mb.exec();
        }
        else
        {
            dirModel->removeRow(indices[0].row());
            directories.erase(directories.begin() + indices[0].row());
        }
    }
}