示例#1
0
void PerCallerPreferencesDialog::remove()
{
	QModelIndexList sel = listWidget->selectionModel()->selectedIndexes();
	qSort(sel);
	while (!sel.isEmpty())
		model->removeRow(sel.takeLast().row());
}
示例#2
0
void PropertiesDock::on_RemoveTagButton_clicked()
{
    QTableView* TagTable = 0;
    switch (NowShowing)
    {
    case TrackPointUiShowing:
        TagTable = TrackPointUi.TagView; break;
    case RoadUiShowing:
        TagTable = RoadUi.TagView; break;
    case MultiShowing:
        TagTable = MultiUi.TagView; break;
    case RelationUiShowing:
        TagTable = RelationUi.TagView; break;
    default: break;
    }
    if (!TagTable) return;

    QModelIndexList indexes = TagTable->selectionModel()->selectedIndexes();
    if (indexes.isEmpty()) return;

    CommandList *L = 0;
    if (indexes.count()==1)
    {
        QModelIndex index = indexes.at(0);
        QModelIndex idx = index.sibling(index.row(),0);
        QVariant Content(theModel->data(idx,Qt::DisplayRole));
        if (Content.isValid())
        {
            QString KeyName = Content.toString();
            L = new CommandList(MainWindow::tr("Clear Tag '%1' on %2").arg(KeyName).arg(Selection[0]->id().numId), Selection[0]);
            for (int i=0; i<Selection.size(); ++i)
                if (Selection[i]->findKey(KeyName) != -1)
                    L->add(new ClearTagCommand(Selection[i],KeyName,Main->document()->getDirtyOrOriginLayer(Selection[i]->layer())));
        }
    }
    else
    {
        L = new CommandList(MainWindow::tr("Clear %1 tags on %2").arg(indexes.count()).arg(Selection[0]->id().numId), Selection[0]);
        while (!indexes.isEmpty()) {
            QModelIndex index = indexes.takeLast();
            QModelIndex idx = index.sibling(index.row(),0);
            QVariant Content(theModel->data(idx,Qt::DisplayRole));
            if (Content.isValid())
            {
                QString KeyName = Content.toString();
                for (int i=0; i<Selection.size(); ++i)
                    if (Selection[i]->findKey(KeyName) != -1)
                        L->add(new ClearTagCommand(Selection[i],KeyName,Main->document()->getDirtyOrOriginLayer(Selection[i]->layer())));
            }
        }
    }
    if (!L) return;
    if (L->empty()) {
        delete L;
    } else {
        Main->document()->addHistory(L);
        Main->invalidateView();
    }
}
示例#3
0
void PerCallerPreferencesDialog::radioChanged()
{
	AUTO_RECORD_TYPE ar;
	if (radioYes->isChecked())
		ar = AUTO_RECORD_ON;
	else if (radioNo->isChecked())
		ar = AUTO_RECORD_OFF;
	else
		ar = AUTO_RECORD_ASK;
	//
	QModelIndexList sel = listWidget->selectionModel()->selectedIndexes();
	while (!sel.isEmpty()) model->setData(sel.takeLast(), ar, Qt::UserRole);
}
void LandmarkBrowser::on_deleteCategoriesButton_clicked()
{
    QItemSelectionModel *selection  = categoryTable->selectionModel();
    QModelIndexList selectedIndexes = selection->selectedRows();

    QList<QLandmarkCategoryId> deleteIds;

    QLandmarkCategoryId id;
    QModelIndex index;
    bool alreadyWarned = false;
    while(selectedIndexes.count() > 0) {
        index = selectedIndexes.takeLast();
        id.setManagerUri(manager->managerUri());
        id.setLocalId(categoryTable->item(index.row(),1)->text());
        if (manager->isReadOnly(id)) {
            if (!alreadyWarned) {
                QMessageBox::warning(this,"Warning", "Cannot delete a global category", QMessageBox::Ok, QMessageBox::NoButton);
                alreadyWarned = true;
            }

            selection->setCurrentIndex(index, QItemSelectionModel::Deselect);
            categoryTable->setSelectionModel(selection);

        } else {
            deleteIds.append(id);
            categoryTable->removeRow(index.row());
        }

        selectedIndexes = categoryTable->selectionModel()->selectedRows();
    }

    if (deleteIds.count() == 0)
        return;

    categoryRemove->setCategoryIds(deleteIds);
    categoryRemove->start();
#ifdef Q_OS_SYMBIAN
    categoryRemove->waitForFinished(30);
#endif
}
示例#5
0
void ContactsTable::onDeleteContact()
  {
  //remove selected contacts from inbox model (and database)
  QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model());
  //model->setUpdatesEnabled(false);
  QItemSelectionModel*   selection_model = ui->contact_table->selectionModel();
  QModelIndexList        sortFilterIndexes = selection_model->selectedRows();
  if (sortFilterIndexes.count() == 0)
    return;
  if (QMessageBox::question(this, tr("Delete Contact"), tr("Are you sure you want to delete selected contact(s)?")) == QMessageBox::Button::No)
    return;
  QModelIndexList        indexes;
  for(const QModelIndex& sortFilterIndex : sortFilterIndexes)
    indexes.append(model->mapToSource(sortFilterIndex));
  qSort(indexes);
  auto sourceModel = model->sourceModel();
  auto app = bts::application::instance();
  auto profile = app->get_profile();

  for (int i = indexes.count() - 1; i > -1; --i)
  {
    auto contact_id = ((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).wallet_index;
    if(profile->isIdentityPresent(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string))
    {
      auto priv_key = profile->get_keychain().get_identity_key(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string);
      app->remove_receive_key(priv_key);
      profile->removeIdentity(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string);

      /// notify identity observers
      IdentityObservable::getInstance().notify();
    }
    sourceModel->removeRows(indexes.at(i).row(), 1);
    Q_EMIT contactDeleted(contact_id); //emit signal so that ContactGui is also deleted
  }
  //model->setUpdatesEnabled(true);
  //TODO Remove fullname/bitname for deleted contacts from QCompleter

  qSort(sortFilterIndexes);
  selectNextRow(sortFilterIndexes.takeLast().row(), indexes.count());
  }
void LandmarkBrowser::on_deleteLandmarksButton_clicked()
{
    QItemSelectionModel *selection  = table->selectionModel();
    QModelIndexList selectedIndexes = selection->selectedRows();

    QList<QLandmarkId> deleteIds;

    QLandmarkId id;
    QModelIndex index;

    while(selectedIndexes.count() > 0) {
        index = selectedIndexes.takeLast();
        deleteIds.append(landmarks.at(index.row()).landmarkId());
        table->removeRow(index.row());
        landmarks.removeAt(index.row());
        selectedIndexes = table->selectionModel()->selectedRows();
    }

    if (deleteIds.count() == 0)
        return;

    manager->removeLandmarks(deleteIds);
}
示例#7
0
void PerCallerPreferencesDialog::selectionChanged()
{
	QModelIndexList sel = listWidget->selectionModel()->selectedIndexes();
	bool notEmpty = !sel.isEmpty();
	int ar_mode = -1;
	while (!sel.isEmpty())
	{
		int m = model->data(sel.takeLast(), Qt::UserRole).toInt();
		if (ar_mode == -1) ar_mode = m;
		else if (ar_mode != m)
		{
			ar_mode = -1;
			break;
		}
	}
	if (ar_mode == -1)
	{
		// Qt is a bit annoying about this: You can't deselect
		// everything unless you disable auto-exclusive mode
		radioYes->setAutoExclusive(false);
		radioAsk->setAutoExclusive(false);
		radioNo ->setAutoExclusive(false);
		radioYes->setChecked(false);
		radioAsk->setChecked(false);
		radioNo ->setChecked(false);
		radioYes->setAutoExclusive(true);
		radioAsk->setAutoExclusive(true);
		radioNo ->setAutoExclusive(true);
	}
	else if (ar_mode == AUTO_RECORD_OFF) radioNo->setChecked(true);
	else if (ar_mode == AUTO_RECORD_ASK) radioAsk->setChecked(true);
	else if (ar_mode == AUTO_RECORD_ON) radioYes->setChecked(true);

	radioYes->setEnabled(notEmpty);
	radioAsk->setEnabled(notEmpty);
	radioNo ->setEnabled(notEmpty);
}