Example #1
0
void SettingsDialog::removeSelectedDocsets()
{
    QItemSelectionModel *selectonModel = ui->installedDocsetList->selectionModel();
    if (!selectonModel->hasSelection())
        return;

    int ret;
    if (selectonModel->selectedIndexes().count() == 1) {
        const QString docsetTitle = selectonModel->selectedIndexes().first().data().toString();
        ret = QMessageBox::question(this, tr("Remove Docset"),
                                    QString(tr("Do you really want to remove <b>%1</b> docset?"))
                                    .arg(docsetTitle));
    } else {
        ret = QMessageBox::question(this, tr("Remove Docsets"),
                                    QString(tr("Do you really want to remove <b>%1</b> docsets?"))
                                    .arg(selectonModel->selectedIndexes().count()));
    }

    if (ret == QMessageBox::No)
        return;

    QStringList names;
    for (const QModelIndex &index : selectonModel->selectedIndexes())
        names << index.data(ListModel::DocsetNameRole).toString();
    removeDocsets(names);
}
Example #2
0
void AnimationList::on_addButton_clicked()
{
  QItemSelectionModel* selModel = ui->availableAnimsListView->selectionModel();

  int count = selModel->selectedIndexes().count();
  for(int i=0; i<count; i++)
  {
    int index = selModel->selectedIndexes().at(i).row();
//    qDebug("Animation file offered: %s", filename);                 //SIGILL fun begins here

    emit AnimationFileTaken(availableAnimations.at(index), i+1, count);
  }
}
Example #3
0
void AnimationList::removeSelectedItems()
{
  QStringListModel* model =  dynamic_cast<QStringListModel*>(ui->availableAnimsListView->model());
  QItemSelectionModel* selModel = ui->availableAnimsListView->selectionModel();

  int count = selModel->selectedIndexes().count();
  for(int i=0; i<count; i++)
  {
    int index = selModel->selectedIndexes().at(0).row();
    availableAnimations.removeAt(index);
  }
  model->setStringList(availableAnimations);                //TODO: bleh!

  onSelectionChanged();         //must be called explicitely
}
void QgsComposerLegendWidget::on_mRemoveToolButton_clicked()
{
  if ( !mLegend )
  {
    return;
  }

  QStandardItemModel* itemModel = qobject_cast<QStandardItemModel *>( mItemTreeView->model() );
  if ( !itemModel )
  {
    return;
  }

  mLegend->beginCommand( "Legend item removed" );

  QItemSelectionModel* selectionModel = mItemTreeView->selectionModel();
  if ( !selectionModel )
  {
    return;
  }

  QModelIndexList selection = selectionModel->selectedIndexes();
  for ( int i = selection.size() - 1; i >= 0; --i )
  {
    QModelIndex parentIndex = selection.at( i ).parent();
    itemModel->removeRow( selection.at( i ).row(), parentIndex );
  }

  mLegend->adjustBoxSize();
  mLegend->update();
  mLegend->endCommand();
}
Example #5
0
void BAMseek::copyCells(){
  QAbstractItemModel * model = tableview->model();
  QItemSelectionModel * selection = tableview->selectionModel();
  QModelIndexList indexes = selection->selectedIndexes();
  std::sort(indexes.begin(), indexes.end());

  QString selected_text;
  int row = 0;
  if(!indexes.empty()){
    row = indexes.first().row();
    selected_text.append(model->data(indexes.first()).toString());
    indexes.removeFirst();
  }
  QModelIndex current;
  foreach(current, indexes){
    QVariant data = model->data(current);
    QString text = data.toString();
    
    if(current.row() != row){
      selected_text.append('\n');
    }else{
      selected_text.append('\t');
    }
    row = current.row();

    selected_text.append(text);
  }
Example #6
0
void DisassemblerView::gotoFunction()
{
    QItemSelectionModel* selectionmodel = ui->functionList->selectionModel();

    if(selectionmodel->hasSelection())
        ui->disassemblerWidget->jumpTo(reinterpret_cast<Function*>(selectionmodel->selectedIndexes()[0].internalPointer()));
}
Example #7
0
bool BallotVoteWindow::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == tableView)
    {
        if (event->type() == QEvent::KeyPress)
        {
            QKeyEvent *ke = static_cast<QKeyEvent *>(event);
            if ((ke->key() == Qt::Key_C)
                && (ke->modifiers().testFlag(Qt::ControlModifier)))
            {
                /* Ctrl-C: copy the selected cells in TableModel */
                QString selected_text;
                QItemSelectionModel *selection = tableView->selectionModel();
                QModelIndexList indexes = selection->selectedIndexes();
                int prev_row = -1;
                for(int i=0; i < indexes.size(); i++) {
                    QModelIndex index = indexes.at(i);
                    if (i) {
                        char c = (index.row() != prev_row)? '\n': '\t';
                        selected_text.append(c);
                    }
                    QVariant data = tableView->model()->data(index);
                    selected_text.append( data.toString() );
                    prev_row = index.row();
                }
                QApplication::clipboard()->setText(selected_text);
                return true;
            }
        }
    }
    return QDialog::eventFilter(obj, event);
}
Example #8
0
// This returns all selected "cells", which means all cells of the same row are returned.
QModelIndexList FolderView::selectedIndexes() const {
  QItemSelectionModel* selModel = selectionModel();
  if(selModel) {
    return selModel->selectedIndexes();
  }
  return QModelIndexList();
}
Example #9
0
/*!
    \fn EVLista::eliminar()
	Elimina los items seleccionados de la vista
 */
void EVLista::eliminar()
{
 //Preguntar al usuario si esta seguro
 QItemSelectionModel *selectionModel = vista->selectionModel();
 QModelIndexList indices = selectionModel->selectedIndexes();
 if( indices.size() < 1 )
 {
   QMessageBox::warning( this, "Seleccione un item",
                   "Por favor, seleccione un item para eliminar",
                   QMessageBox::Ok );
   return;
 }
 //Hacer dialogo de confirmacion..
 int ret;
 ret = QMessageBox::warning( this, "Esta seguro?",
                   QString( "Esta seguro de eliminar %1 item?").arg( indices.size() ),
                   "Si", "No" );
 if ( ret == 0 )
 {
	QModelIndex indice;
	int ultima_row = -1;
	foreach( indice, indices )
	{
		if( indice.isValid() )
		{
			if( indice.row() != ultima_row )
			{
				ultima_row = indice.row();
				modelo->removeRow( indice.row() );
			}
		}
	}
 }
Example #10
0
void TimeWidget::copy()
{
  QApplication::clipboard()->clear();

  QItemSelectionModel* selected = table->selectionModel();
  QModelIndexList indices = selected->selectedIndexes();

  if(indices.size() < 1)
    return;
  qSort(indices);

  QModelIndex previous = indices.first();
  indices.removeFirst();
  QString selected_text;
  QModelIndex current;

  Q_FOREACH(current, indices)
  {
    QVariant data = table->model()->data(previous);
    QString text = data.toString();
    selected_text.append(text);

    // Add last character for this element based on row or element change
    if(current.row() != previous.row())
      selected_text.append(QLatin1Char('\n'));
    else
      selected_text.append(";");
    previous = current;
  }
Example #11
0
void VegetationWidget::slotDeleteSelected()
{
	QListView* view = qobject_cast<QListView*>(sender());
	QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model());
	QString dirString("");
	if (view == _treeListView)
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = chineseTextUTF8ToQString(plantDir + "Tree/");
	}
	else
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = chineseTextUTF8ToQString(plantDir + "Grass/");
	}
	QItemSelectionModel* selectionModel = view->selectionModel();
	QModelIndexList	modelList = selectionModel->selectedIndexes();
	if (modelList.size() < 1)
		return;
	for (int i = 0; i < modelList.size(); ++i)
	{
		QStandardItem* everyItem = model->itemFromIndex(modelList.at(i));
		QFile::remove(dirString + everyItem->text());
		int row = everyItem->row();
		model->removeRow(row);
	}
}
Example #12
0
/*!
    \fn VDuenos::eliminar()
 */
void VDuenos::eliminar()
{
 //Preguntar al usuario si esta seguro
 QItemSelectionModel *selectionModel = vista->selectionModel();
 QModelIndexList indices = selectionModel->selectedIndexes();
 QModelIndex indice;
 foreach( indice, indices )
 {
  QSqlQuery cola( QString( "SELECT COUNT(id) FROM mascotas WHERE id_dueno = %1" ).arg( modelo->data( modelo->index( indice.row(), 0 ), Qt::UserRole ).toInt() ) );
  if( cola.next() )
  {
   if( cola.record().value( 0 ).toInt() > 0 )
   {
    QMessageBox::warning( this, "No se puede eliminar", "No se puede eliminar este dueño, ya que tiene mascotas asociadas.\n Si desea eliminarlo cambie de dueño a las mascotas o eliminelas e intentelo nuevamente" );
    return;
   }
   else
   {
	return EVLista::eliminar();
   }
  }
  else
  {
 	qDebug( "Error, al generar la cola de obtencion de cantidad de mascotas" );
	qDebug( QString( "Detalles: tipo: %1, errno: %2, descripcion: %3" ).arg( cola.lastError().type() ).arg( cola.lastError().number() ).arg( cola.lastError().text() ).toLocal8Bit() );
	return;
  }
 }
void UIInformationView::keyPressEvent(QKeyEvent *pEvent)
{
    /* Copy the text: */
    if (pEvent == QKeySequence::Copy)
    {
        QString strText;
        /* Get Selection model: */
        QItemSelectionModel *pSelectionModel = selectionModel();
        if (pSelectionModel)
        {
            /* Check all the selected-indexes and copy the text: */
            foreach (const QModelIndex &index, pSelectionModel->selectedIndexes())
            {
                UIInformationItem *pItem = dynamic_cast<UIInformationItem*>(itemDelegate(index));
                if (pItem)
                {
                    /* Update the corresponding data: */
                    pItem->updateData(index);
                    /* Get and add the html-data of item: */
                    strText.append(pItem->htmlData());
                }
            }
        }
        /* Set the text to text-edit and copy from it: */
        m_pTextEdit->setText(strText);
        m_pTextEdit->selectAll();
        m_pTextEdit->copy();
        /* Accept/acknowledge event: */
        pEvent->accept();
    }
Example #14
0
void CStudentManage::slotDelStudentClicked()
{
    //开始事务
    m_Model->database().transaction();
    //获取被选中的model
    QItemSelectionModel *selectModel = m_View->selectionModel();

    //通过被选中的model, 获取被选中的格子
    QModelIndexList selectList = selectModel->selectedIndexes();

    QList<int> delRow;

    //遍历格子,获得行
    for (int i = 0; i < selectList.size(); ++i)
    {
        delRow << selectList.at(i).row();
    }

    //去除重复的行
    while (delRow.size() > 0)
    {
        int row = delRow.at(0);
        //去重
        delRow.removeAll(row);

        //删除行
        m_Model->removeRow(row);
    }
    //提交
    QString msg = "删除成功!";
    SubmitData(msg);
}
Example #15
0
void RouteView::EndRoute_E()       // SLOT
{
    //SQL sql;
    mainWindow * myParent = qobject_cast<mainWindow*>(m_parent);
    QItemSelectionModel * model = ui->selectionModel();
    QModelIndexList indexes = model->selectedIndexes();
    //qint32 row = model->currentIndex().row();
    //qint32 col =model->currentIndex().column();
    QModelIndex Index = indexes.at(0);
    qint32 segmentId = Index.data().toInt();

    TerminalInfo ti = SQL::instance()->getTerminalInfo(route, name, endDate);
    SQL::instance()->updateTerminals(route, name, endDate, endDate,
        ti.route < 0 ? segmentId : ti.startSegment, ti.route < 0 ? "?" : ti.startWhichEnd,
        segmentId, "E");
    ti = SQL::instance()->getTerminalInfo(route, name, endDate);
    endSegment = segmentId;
    updateRouteView();

//    Object[] objArray = new Object[] { ti.endLatLng.lat, ti.endLatLng.lon, getRouteMarkerImagePath(m_alphaRoute, false) };
//    webBrowser1.Document.InvokeScript("addRouteEndMarker", objArray);
    QVariantList objArray;
    objArray << ti.endLatLng.lat()<< ti.endLatLng.lon()<<myParent->getRouteMarkerImagePath(alphaRoute, false);
    webViewBridge::instance()->processScript("addRouteEndMarker", objArray);

}
Example #16
0
void FileBrowser::removeFile()
{
    // remove one or multiple files at once
    // function will ask confirmation for the action
    QItemSelectionModel *selectionModel = fileView->selectionModel();
    QModelIndexList indexList = selectionModel->selectedIndexes();
    int numberOfFiles = 0;
    for (const auto &index : indexList) {
        QFileInfo file(fileModel->filePath(index));
        if (!file.isDir())
            numberOfFiles += 1;
    }
    int ret = QMessageBox::warning(
        this, tr("File Browser"),
        tr("You are about to remove %1 selected file(s)\n"
           "Are you sure you want to continue?")
            .arg(qRound(static_cast<qreal>(numberOfFiles / 4))),
        QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok);
    switch (ret) {
    case QMessageBox::Ok:
        for (const auto &index : indexList) {
            QFileInfo file(fileModel->filePath(index));
            if (!file.isDir() && !fileModel->remove(index))
                qWarning("Could not remove file %s from the file system",
                         qPrintable(file.fileName()));
        }
        break;
    case QMessageBox::Cancel:
        return;
    default:
        break;
    }
}
//-----------------------------------------------------------------------------
void SetupTabMatrix::operationAdd()
{
    QAction *a = qobject_cast<QAction *>(sender());
    QVariant var = a->data();
    bool ok;
    int shift = var.toInt(&ok);

    if (ok)
    {
        QItemSelectionModel *selection = this->ui->tableViewOperations->selectionModel();
        QModelIndexList list = selection->selectedIndexes();

        bool left = shift < 0;
        shift = qAbs(shift);

        quint32 mask = 0;
        for (int i = 0; i < list.length(); i++)
        {
            if (list.at(i).row() == 0)
            {
                mask |= 0x00000001 << (31 - list.at(i).column());
            }
        }
        this->mPreset->matrix()->operationAdd(mask, shift, left);
    }
}
Example #18
0
void SAChartDatasViewWidget::onActionDeleteTriggered()
{
    SAWaitCursor waitCursor;
    QItemSelectionModel* selModel = ui->tableView->selectionModel();
    QModelIndexList indexs = selModel->selectedIndexes ();
    QMap<QwtPlotItem *, QVector<QPoint> > res;
    analysisSelectModelIndex(indexs,res);

    for(auto i=res.begin();i!=res.end();++i)
    {
        SAChart2D* chart = qobject_cast<SAChart2D*>(i.key()->plot());
        if(nullptr == chart)
        {
            continue;
        }
        QScopedPointer<SAFigureTableDeleteCommand> cmd(new SAFigureTableDeleteCommand(
                    chart
                    ,i.key()
                    ,i.value()
                    ,tr("delete plot datas")
                    ));
        if(!(cmd->isValid()))
        {
            continue;
        }
        chart->appendCommand(cmd.take());
    }
    SAPlotDataModel* model = getPlotModel();
    if(model)
    {
        model->updateRow();
    }
}
Example #19
0
void SettingsDialog::resetProgress()
{
    if (!m_replies.isEmpty())
        return;

    m_combinedReceived = 0;
    m_combinedTotal = 0;
    displayProgress();

    // Installed docsets
    ui->addFeedButton->setEnabled(true);
    QItemSelectionModel *selectionModel = ui->installedDocsetList->selectionModel();
    bool hasSelectedUpdates = false;
    for (const QModelIndex &index : selectionModel->selectedIndexes()) {
        if (index.data(Zeal::ListModel::UpdateAvailableRole).toBool()) {
            hasSelectedUpdates = true;
            break;
        }
    }
    ui->updateSelectedDocsetsButton->setEnabled(hasSelectedUpdates);
    ui->updateAllDocsetsButton->setEnabled(updatesAvailable());
    ui->removeDocsetsButton->setEnabled(selectionModel->hasSelection());

    // Available docsets
    ui->availableDocsetList->setEnabled(true);
    ui->refreshButton->setEnabled(true);
    ui->downloadDocsetButton->setText(tr("Download"));
}
void ExtendedTableWidget::copy()
{
    // Get list of selected items
    QItemSelectionModel* selection = selectionModel();
    QModelIndexList indices = selection->selectedIndexes();

    // Abort if there's nothing to copy
    if(indices.size() == 0)
    {
        return;
    } else if(indices.size() == 1) {
        qApp->clipboard()->setText(indices.front().data().toString());
        return;
    }

    // Sort the items by row, then by column
    qSort(indices);

    // Go through all the items...
    QString result;
    QModelIndex prev = indices.front();
    indices.removeFirst();
    foreach(QModelIndex index, indices)
    {
        // Add the content of this cell to the clipboard string
        result.append(QString("\"%1\"").arg(prev.data().toString()));

        // If this is a new row add a line break, if not add a tab for cell separation
        if(index.row() != prev.row())
            result.append("\r\n");
        else
            result.append("\t");

        prev = index;
    }
Example #21
0
void WineProcessWidget::procRenice_Click(void){
    bool ok=false;
    int newNice = QInputDialog::getInteger(this, tr("Select process priority"), tr("<p>Priority value can be in<br>the range from PRIO_MIN (-20)<br>to PRIO_MAX (20).</p><p>See \"man renice\" for details.</p>"), 0, -20, 20, 1, &ok);
    if (!ok)
        return;

    QItemSelectionModel *selectionModel = procTable->selectionModel();

    QModelIndexList indexes = selectionModel->selectedIndexes();
    QModelIndex index;
    QList<int> procList;

    foreach(index, indexes) {
        if (index.column()==0)
            procList.append(model->index(index.row(), 0, QModelIndex()).data().toInt());
    }

    if (procList.count()<=0)
        return;

    for (int i=0; i<procList.count(); i++){
        if (CoreLib->reniceProcess(procList.at(i), newNice)){
            emit(changeStatusText(tr("It seems process %1 renice to %2 end successfully.").arg(procList.at(i)).arg(newNice)));
        }
    }

    return;
}
Example #22
0
void WineProcessWidget::procKillWine_Click(void){
    if (QMessageBox::warning(this, tr("Warning"), tr("This action will send a KILL(-9) signal to all wine processes for selected prefixes<br><br>Do you really want to proceed?"), QMessageBox::Yes, QMessageBox::No)==QMessageBox::No)
        return;

    QItemSelectionModel *selectionModel = procTable->selectionModel();

    QModelIndexList indexes = selectionModel->selectedIndexes();
    QModelIndex index;
    QList<QString> prefixList;

    foreach(index, indexes) {
        if (index.column()==3){
            QString path = model->index(index.row(), 3, QModelIndex()).data().toString();
            if (prefixList.indexOf(path, 0)<0)
                prefixList.append(path);
        }
    }

    if (prefixList.count()<=0)
        return;

    for (int i=0; i<prefixList.count(); i++){
        CoreLib->killWineServer(prefixList.at(i));
    }

    return;
}
Example #23
0
void RouteView::editSegment()
{
 QItemSelectionModel * model = ui->selectionModel();
 QModelIndexList indexes = model->selectedIndexes();
 qint32 segmentId = indexes.at(0).data().toInt();
 EditSegmentDialog* dlg = new EditSegmentDialog(segmentId);
 dlg->exec();
}
void PageDestinations::deviceChanged()
{
    QItemSelectionModel *selection = ui->devicesTV->selectionModel();
    if (!selection->selectedIndexes().isEmpty() &&
            selection->selectedIndexes().size() == 1) {
        QModelIndex index = selection->selectedIndexes().first();
        QVariant uri = index.data(DevicesModel::DeviceUris);
        if (uri.type() == QVariant::String) {
            ui->connectionsGB->setVisible(false);
        } else  {
            ui->connectionsCB->clear();
            foreach (const QString &uri, uri.toStringList()) {
                ui->connectionsCB->addItem(uriText(uri), uri);
            }
            ui->connectionsGB->setVisible(true);
        }
    } else {
Example #25
0
void RouteView::on_selectSegment_triggered()
{
 QItemSelectionModel * model = ui->selectionModel();
 QModelIndexList indexes = model->selectedIndexes();
 QModelIndex Index = indexes.at(0);
 qint32 segmentId = Index.data().toInt();
 emit selectSegment(segmentId);
}
Example #26
0
void VegetationWidget::slotViewSelected()
{
	QListView* view = qobject_cast<QListView*>(sender());
	QItemSelectionModel* selectionModel = view->selectionModel();
	QModelIndexList	modelList = selectionModel->selectedIndexes();
	if (modelList.size() < 1)
		return;
	QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model());
	std::string dirString("");
	if (view == _treeListView)
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = plantDir + "Tree/";
	}
	else
	{
		std::string plantDir = g_SystemContext._workContextDir;
		plantDir.append(CONTEXT_DIR);
		plantDir.append("/Plant/");
		dirString = plantDir + "Grass/";
	}
	QStandardItem* currentItem = model->itemFromIndex(modelList.at(0));
	dirString.append(chineseTextToUTF8String(currentItem->text()));
	osg::ref_ptr<osg::Node> node;
	if (currentItem->text().endsWith(".osgb"))
	{
		node = g_SystemContext._resourceLoader->getNodeByName(dirString, false);
	}
	else
	{
		osg::ref_ptr<osg::Image> image = g_SystemContext._resourceLoader->getImageByFileName(dirString);
		if (image.valid())
		{
			float s = image->s();
			float t = image->t();
			osg::ref_ptr<osg::Geometry> geometry = osg::createTexturedQuadGeometry(osg::Vec3(-s / 2.0f, -t / 2.0f, 0), osg::Vec3(s, 0, 0), osg::Vec3(0, t, 0));
			osg::ref_ptr<osg::Geode> geode = new osg::Geode;
			geode->addDrawable(geometry);
			osg::StateSet* ss = geode->getOrCreateStateSet();
			ss->setMode(GL_BLEND, osg::StateAttribute::ON);
			ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
			osg::Texture2D* texture = new osg::Texture2D(image);
			ss->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
			node = geode;
		}
	}
	if (node.valid())
	{
		_nodeViewDialog = new NodeViewDialog;
		_nodeViewDialog->setNode(node);
		_nodeViewDialog->exec();
		//_nodeViewDialog->setNode(NULL);
	}
}
Example #27
0
void StandardPLPanel::popupPlView( const QPoint &point )
{
    QModelIndex index = currentView->indexAt( point );
    QPoint globalPoint = currentView->viewport()->mapToGlobal( point );
    QItemSelectionModel *selection = currentView->selectionModel();
    QModelIndexList list = selection->selectedIndexes();

    if( !model->popup( index, globalPoint, list ) )
        QVLCMenu::PopupMenu( p_intf, true );
}
Example #28
0
void PlayList::removeSelectedItems()
{
    QItemSelectionModel *selection = mpListView->selectionModel();
    if (!selection->hasSelection())
        return;
    QModelIndexList s = selection->selectedIndexes();
    for (int i = s.size()-1; i >= 0; --i) {
        mpModel->removeRow(s.at(i).row());
    }
}
void BreakWindow::keyPressEvent(QKeyEvent *ev)
{
    if (ev->key() == Qt::Key_Delete) {
        QItemSelectionModel *sm = selectionModel();
        QTC_ASSERT(sm, return);
        QModelIndexList si = sm->selectedIndexes();
        if (si.isEmpty())
            si.append(currentIndex().sibling(currentIndex().row(), 0));
        deleteBreakpoints(normalizeIndexes(si));
    }
Example #30
0
void FlyEmSplitControlForm::checkCurrentBookmark(bool checking)
{
  QItemSelectionModel *sel = getAssignedBookmarkView()->selectionModel();
  QModelIndexList selected = sel->selectedIndexes();

  foreach (const QModelIndex &index, selected) {
    ZFlyEmBookmark *bookmark = m_assignedBookmarkList.getBookmark(index.row());
    bookmark->setChecked(checking);
    m_assignedBookmarkList.update(index.row());
  }