示例#1
0
void MainWindow::OnConvertButtonClicked()
{
    QAbstractItemModel *model = ui->listView->model();
    if (!model || model->rowCount() == 0)
    {
        return;
    }

    while (model->rowCount())
    {
        QString pvrName = model->data(model->index(0, 0)).toString();
        QString pngName = pvrName;
        pngName.replace(".pvr", ".png", Qt::CaseInsensitive);

        unsigned char* data;
        unsigned long int size;
        PVRTHeader header;
        int ret = LoadPVRFromFile(pvrName.toUtf8().data(), &data, &size, &header);
        if (ret)
        {
            QFile file(pngName);
            file.open(QIODevice::WriteOnly);

            QImage image(data, header.width, header.height, QImage::Format_RGBA8888);
            QPixmap pixmap = QPixmap::fromImage(image);
            pixmap.save(&file, "PNG");

            free(data);
        }

        model->removeRow(0);
    }

    ui->statusBar->showMessage("Done!");
}
示例#2
0
void MainWindow::removeRow()
{
    QModelIndex index = view->selectionModel()->currentIndex();
    QAbstractItemModel *model = view->model();
    if (model->removeRow(index.row(), index.parent()))
        updateActions();
}
示例#3
0
void PageScheme::deleteRow()
{
    int numberOfDefaultSchemes = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes;
    if (selectScheme->currentIndex() < numberOfDefaultSchemes)
    {
        QMessageBox deniedMsg(this);
        deniedMsg.setIcon(QMessageBox::Warning);
        deniedMsg.setWindowTitle(QMessageBox::tr("Schemes - Warning"));
        deniedMsg.setText(QMessageBox::tr("Cannot delete default scheme '%1'!").arg(selectScheme->currentText()));
        deniedMsg.setWindowModality(Qt::WindowModal);
        deniedMsg.exec();
    }
    else
    {
        QMessageBox reallyDeleteMsg(this);
        reallyDeleteMsg.setIcon(QMessageBox::Question);
        reallyDeleteMsg.setWindowTitle(QMessageBox::tr("Schemes - Are you sure?"));
        reallyDeleteMsg.setText(QMessageBox::tr("Do you really want to delete the game scheme '%1'?").arg(selectScheme->currentText()));
        reallyDeleteMsg.setWindowModality(Qt::WindowModal);
        reallyDeleteMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);

        if (reallyDeleteMsg.exec() == QMessageBox::Ok)
        {
            QAbstractItemModel * model = mapper->model();
            model->removeRow(selectScheme->currentIndex());
        }
    }
}
void JsonEditorMain::deleteTreeNode()
{
    QModelIndex index = ui->jsonTree->selectionModel()->currentIndex();
    QAbstractItemModel *model = ui->jsonTree->model();
    if (model->removeRow(index.row(), index.parent()))
        updateActions();
}
void ScreenTab::removeMedia()
{
    QAbstractItemModel *mediaModel = ui->mediaListTableView->model();
    if (!mediaModel)
        return;
    int currentRow = getCurrentMediaTableRow();
    if (currentRow == -1)
        return;
    mediaModel->removeRow(currentRow);
    ui->mediaListTableView->clearSelection();
}
void WindowAnotationManager::on_btnRemoveBeat_clicked()
{
    VideoDataClip *clip = ui->widgetStrainVideo->getClip();
    if (!clip || clip->size() == 0) return;

    QAbstractItemModel *model = ui->listViewBeats->model();
    QModelIndex modelIndex = ui->listViewBeats->currentIndex();
    if (modelIndex.row() < 0) return;

    model->removeRow(modelIndex.row());
}
示例#7
0
void KOnlineJobOutbox::slotRemoveJob()
{
  QModelIndexList indexes = ui->m_onlineJobView->selectionModel()->selectedRows();

  if (indexes.isEmpty())
    return;

  QAbstractItemModel* model = ui->m_onlineJobView->model();
  const int count = indexes.count();
  for (int i = count - 1; i >= 0; --i) {
    model->removeRow(indexes.at(i).row());
  }
}
示例#8
0
void LineEdit::learnEntry()
{
    QAbstractItemModel *m = completer()->model();
    int rows = m->rowCount();
    for (int i = 0; i < rows; ++i) {
        if (m->index(i,0).data() == text()) {
            m->removeRow(i);
            --rows;
            break;
        }
    }
    m->insertRows(rows, 1);
    m->setData(m->index(rows, 0), text(), Qt::DisplayRole);
    m_historyPosition = rows + 1;
}
    void PathPlanningWidget::removeRow(int marker_nr)
    {
      /*! When the user deletes certain Way-Point either from the RViz or the RQT Widget the TreeView needs to delete that particular row and update the state of the TreeWidget.
      */
        QAbstractItemModel *model = ui_.treeView->model();

          model->removeRow(marker_nr,QModelIndex());
          ROS_INFO_STREAM("deleting point nr: "<< marker_nr);

          for(int i=marker_nr;i<=model->rowCount();++i)
          {
            model->setData(model->index((i-1),0,QModelIndex()),QVariant((i-1)),Qt::EditRole);
          }
          //check how to properly set the selection
          ui_.treeView->selectionModel()->setCurrentIndex(model->index((model->rowCount()-1),0,QModelIndex()),QItemSelectionModel::ClearAndSelect);
          ui_.txtPointName->setText(QString::number(model->rowCount()-1));
        pointRange();
    }
示例#10
0
// Auto-connected to actionCut's signal triggered()
void MainWindow::on_actionCut_triggered()
{
    QWidget *widget = ui->tabWidget->currentWidget();
    QTableView *tableView = qobject_cast<QTableView *>(widget);
    if (tableView)
    {
//         QModelIndexList selection = tableView->selectionModel()->selectedIndexes();
//         QSet<int> rows;
//         Q_FOREACH (QModelIndex index, selection)
//         {
//             rows.insert(index.row());
//         }
//         qDebug() << "Removing number of rows:" << rows.size();
        QModelIndex index = tableView->currentIndex();
        if (!index.isValid())
            return;
        QAbstractItemModel *model = tableView->model();
        Q_ASSERT(model);
        model->removeRow(index.row());
    }
}
void Button::on_clicked()
{
    QTableView* table = qobject_cast<QTableView*>(this->parent());
    if (!table)
        return;

    QAbstractItemModel* model = table->model();
    if (!model)
        return;

    if (_type == InsertRemove::Insert)
    {
        if (_orientation == Qt::Horizontal)
            model->insertColumn(_modelIndex);
        else
            model->insertRow(_modelIndex);
    }
    else // _type == InsertRemove::Remove
    {
        if (_orientation == Qt::Horizontal)
            model->removeColumn(_modelIndex);
        else
            model->removeRow(_modelIndex);
    }
}