void AddressBookPage::on_signMessage_clicked()
{
    QTableView *table = ui->tableView;
    QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
    QString addr;

    foreach (QModelIndex index, indexes)
    {
        QVariant address = index.data();
        addr = address.toString();
    }
void AcceptedOfferListPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        ui->copyOffer->setEnabled(true);
		ui->messageButton->setEnabled(true);
		ui->detailButton->setEnabled(true);
    }
    else
    {
        ui->copyOffer->setEnabled(false);
		ui->messageButton->setEnabled(false);
		ui->detailButton->setEnabled(false);
    }
}
Example #3
0
void AddressBookPage::on_giveButton_clicked()
{
    QTableView *table = ui->tableView;
    QModelIndex index;

    if (!table->selectionModel())
        return;

    QModelIndexList indexes = table->selectionModel()->selectedRows(1);
    if(!indexes.isEmpty())
    {
        index = indexes.at(0);

        QString pubKey = index.data().toString(), label = index.sibling(index.row(), 0).data(Qt::EditRole).toString();

        QMetaObject::invokeMethod(this->parent()->parent(), "gotoSendCoinsGiftPage", GUIUtil::blockingGUIThreadConnection(),
                                  Q_ARG(QString, pubKey),
                                  Q_ARG(QString, label));
    }
}
void AddressBookDialog::on_copyToClipboard_clicked()
{
    // Copy currently selected address to clipboard
    //   (or nothing, if nothing selected)
    QTableView *table = getCurrentTable();
    QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);

    foreach (QModelIndex index, indexes)
    {
        QVariant address = index.data();
        QApplication::clipboard()->setText(address.toString());
    }
Example #5
0
void MyCertListPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        ui->copyCert->setEnabled(true);
		ui->sellCertButton->setEnabled(true);
		ui->editButton->setEnabled(true);
		ui->transferButton->setEnabled(true);
    }
    else
    {
        ui->copyCert->setEnabled(false);
		ui->sellCertButton->setEnabled(false);
		ui->editButton->setEnabled(false);
		ui->transferButton->setEnabled(false);
    }
}
Example #6
0
void AddressBookPage::done(int retval)
{
    QTableView *table = ui->tableView;
    if(!table->selectionModel() || !table->model())
        return;

    // Figure out which address was selected, and return it
    QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);

    for (const QModelIndex& index : indexes) {
        QVariant address = table->model()->data(index);
        returnValue = address.toString();
    }

    if(returnValue.isEmpty())
    {
        // If no address entry selected, return rejected
        retval = Rejected;
    }

    QDialog::done(retval);
}
void AddressBookPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        switch(tab)
        {
        case SendingTab:
            // In sending tab, allow deletion of selection
            ui->deleteButton->setEnabled(true);
            ui->deleteButton->setVisible(true);
            deleteAction->setEnabled(true);
            ui->signMessage->setEnabled(false);
            ui->signMessage->setVisible(false);
            break;
        case ReceivingTab:
            // Deleting receiving addresses, however, is not allowed
            ui->deleteButton->setEnabled(false);
            ui->deleteButton->setVisible(false);
            deleteAction->setEnabled(false);
            ui->signMessage->setEnabled(true);
            ui->signMessage->setVisible(true);
            break;
        }
        ui->copyToClipboard->setEnabled(true);
        ui->showQRCode->setEnabled(true);
    }
    else
    {
        ui->deleteButton->setEnabled(false);
        ui->showQRCode->setEnabled(false);
        ui->copyToClipboard->setEnabled(false);
        ui->signMessage->setEnabled(false);
    }
}
void InvoicePage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        replyAction->setEnabled(true);
        copyFromAddressAction->setEnabled(true);
        copyToAddressAction->setEnabled(true);
        deleteAction->setEnabled(true);

        ui->copyFromAddressButton->setEnabled(true);
        ui->copyToAddressButton->setEnabled(true);
        ui->replyButton->setEnabled(true);
        ui->deleteButton->setEnabled(true);

        // Figure out which message was selected, and return it
        QModelIndexList typeColumn = table->selectionModel()->selectedRows(InvoiceTableModel::Type);

        foreach (QModelIndex index, typeColumn)
        {
            bool sent = (table->model()->data(index).toString() == MessageModel::Sent);

            resendAction->setEnabled(sent);
            ui->resendButton->setEnabled(sent);
            ui->resendButton->setVisible(sent);

            receiptAction->setEnabled(sent);
            ui->receiptButton->setEnabled(sent);
            ui->receiptButton->setVisible(sent);

            //payAction->setEnabled(!sent);
            //ui->payButton->setEnabled(!sent);
            //ui->payButton->setVisible(!sent);
        }
Example #9
0
void MessagePage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        replyAction->setEnabled(true);
        copyFromAddressAction->setEnabled(true);
        copyToAddressAction->setEnabled(true);
        deleteAction->setEnabled(true);

        ui->copyFromAddressButton->setEnabled(true);
        ui->copyToAddressButton->setEnabled(true);
        ui->deleteButton->setEnabled(true);

        ui->newButton->setEnabled(false);
        ui->newButton->setVisible(false);
        ui->sendButton->setEnabled(true);
        ui->sendButton->setVisible(true);
        ui->messageEdit->setVisible(true);

        ui->tableView->hide();

        // Figure out which message was selected
        QModelIndexList labelColumn       = table->selectionModel()->selectedRows(MessageModel::Label);
        QModelIndexList addressFromColumn = table->selectionModel()->selectedRows(MessageModel::FromAddress);
        QModelIndexList addressToColumn   = table->selectionModel()->selectedRows(MessageModel::ToAddress);
        QModelIndexList typeColumn        = table->selectionModel()->selectedRows(MessageModel::Type);

        int type;

        foreach (QModelIndex index, typeColumn)
            type = table->model()->data(index).toInt();

        foreach (QModelIndex index, labelColumn)
            ui->contactLabel->setText(table->model()->data(index).toString());

        foreach (QModelIndex index, addressFromColumn)
            if(type == MessageTableEntry::Sent)
                replyFromAddress = table->model()->data(index).toString();
            else
                replyToAddress = table->model()->data(index).toString();

        foreach (QModelIndex index, addressToColumn)
            if(type == MessageTableEntry::Sent)
                replyToAddress = table->model()->data(index).toString();
            else
                replyFromAddress = table->model()->data(index).toString();

        QString filter = replyToAddress;

        //QString filter = replyFromAddress;
        ui->messageDetails->show();
        ui->listConversation->setCurrentIndex(model->proxyModel->index(0, 0, QModelIndex()));
    }
Example #10
0
void ShoppingPage::selectionChanged()
{
    // Set button states based on selected tab and selection
    QTableView *table = ui->tableView;
    if(!table->selectionModel())
        return;

    if(table->selectionModel()->hasSelection())
    {
        switch(tab)
        {
        case SendingTab:
            // In sending tab, allow deletion of selection
            deleteAction->setEnabled(true);
            break;
        case ReceivingTab:
            // Deleting receiving addresses, however, is not allowed
            deleteAction->setEnabled(false);
            break;
        }
    }

}
Example #11
0
bool RequestsForm::eventFilter(QObject *obj, QEvent *event)
{
    QTableView *table = qobject_cast<QTableView *>(obj);

    if (table && event->type() == QEvent::KeyPress) {
        QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
        if (keyEvent->key() == Qt::Key_Delete) {
            QModelIndexList indexes = table->selectionModel()->selectedRows();
            removeRequests(indexes);
            return true;
        }
    }

    return QObject::eventFilter(obj, event);
}
void QmitkTractbasedSpatialStatisticsView::RemoveGroup()
{

  QTableView *temp = static_cast<QTableView*>(m_Controls->m_GroupInfo);

  QItemSelectionModel *selectionModel = temp->selectionModel();

  QModelIndexList indices = selectionModel->selectedRows();

  QModelIndex index;

  foreach(index, indices)
  {
    int row = index.row();
    m_GroupModel->removeRows(row, 1, QModelIndex());
  }
Example #13
0
void MainWindow::setRightView()
{
    QTableView *view = ui->m_rightTableInfo;
    view->setModel(m_dirsContentsModel);
    view->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    view->horizontalHeader()->resizeSection(0, 280); // 'Name' section. User can resize
    view->horizontalHeader()->resizeSection(3, 130); // 'Type' section

    connect(view, SIGNAL(activated(QModelIndex)),
            view, SLOT(clearSelection())); // NOTE: must be the first connection
    connect(view, SIGNAL(activated(QModelIndex)),
            this, SLOT(slotSetLeftViewCurrentIndex(QModelIndex)));
    connect(view, SIGNAL(activated(QModelIndex)),
            this, SLOT(slotActivatedOnlyDirs(QModelIndex)));
    connect(view->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
            this, SLOT(slotUpdateSelection(QItemSelection,QItemSelection)));
}
Example #14
0
//! [4a]
void AddressWidget::editEntry()
{
    QTableView *temp = static_cast<QTableView*>(currentWidget());
    QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
    QItemSelectionModel *selectionModel = temp->selectionModel();

    QModelIndexList indexes = selectionModel->selectedRows();
    QString name;
    QString address;
    int row = -1;

    foreach (QModelIndex index, indexes) {
        row = proxy->mapToSource(index).row();
        QModelIndex nameIndex = table->index(row, 0, QModelIndex());
        QVariant varName = table->data(nameIndex, Qt::DisplayRole);
        name = varName.toString();

        QModelIndex addressIndex = table->index(row, 1, QModelIndex());
        QVariant varAddr = table->data(addressIndex, Qt::DisplayRole);
        address = varAddr.toString();
    }
Example #15
0
/** Called when switching between tabs
*  @param index :: The index of the new active tab
*/
void MantidMatrix::viewChanged(int index) {
  // get the previous view and selection model
  QTableView *prevView = (QTableView *)m_tabs->widget(m_PrevIndex);
  if (prevView) {
    QItemSelectionModel *oldSelModel = prevView->selectionModel();
    QItemSelectionModel *selModel = activeView()->selectionModel();
    // Copy the selection from the previous tab into the newly-activated one
    selModel->select(oldSelModel->selection(), QItemSelectionModel::Select);
    // Clear the selection on the now-hidden tab
    oldSelModel->clearSelection();

    m_PrevIndex = index;
    // get the previous tab scrollbar positions
    int hValue = prevView->horizontalScrollBar()->value();
    int vValue = prevView->verticalScrollBar()->value();
    // to synchronize the views
    // set  the previous view  scrollbar positions to current view
    activeView()->horizontalScrollBar()->setValue(hValue);
    activeView()->verticalScrollBar()->setValue(vValue);
  }
}
Example #16
0
void MainWindow::do_copyPathName_Clipboard()
{
    QTableView *tab = ui->tableView_result;
    QString t;

    QItemSelectionModel *selections = tab->selectionModel();
    QList<QModelIndex> list= selections->selectedRows();
    for(int i=0; i<list.size(); i++)
    {
        //修改时间
        QString filename=
                modelResult->item(list.at(i).row(),1)->text().trimmed()
                +QDir::separator()
                +modelResult->item(list.at(i).row(),0)->text().trimmed();
        t += tr("文件名:") + filename + tr("\n");
        //行号信息
        QString lineno = modelResult->item(list.at(i).row(),2)->text().trimmed();
        if(!lineno.isEmpty())
        {
            t += tr("行号:") + lineno + tr("\n");
        }
        //行内容
        QString linestr = modelResult->item(list.at(i).row(),3)->text().trimmed();
        if(!linestr.isEmpty())
        {
            t += tr("行内容:") + linestr + tr("\n");
        }
        //修改时间
        QString modftime = modelResult->item(list.at(i).row(),4)->text().trimmed();
        if(!modftime.isEmpty())
        {
            t += tr("修改时间:") + modftime + tr("\n");
        }
        //换行
        t += "\n\n";
    }
    QClipboard *board = QApplication::clipboard();
    board->setText(t);
}
void ReceiveCoinsDialog::setModel(WalletModel *_model)
{
    this->model = _model;

    if(_model && _model->getOptionsModel())
    {
        _model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder);
        connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
        updateDisplayUnit();

        QTableView* tableView = ui->recentRequestsView;

        tableView->verticalHeader()->hide();
        tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
        tableView->setModel(_model->getRecentRequestsTableModel());
        tableView->setAlternatingRowColors(true);
        tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
        tableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
        tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH);
        tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH);
        tableView->setColumnWidth(RecentRequestsTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH);

        connect(tableView->selectionModel(),
            SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this,
            SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection)));
        // Last 2 columns are set by the columnResizingFixer, when the table geometry is ready.
        columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this);

        if (model->wallet().getDefaultAddressType() == OutputType::BECH32) {
            ui->useBech32->setCheckState(Qt::Checked);
        } else {
            ui->useBech32->setCheckState(Qt::Unchecked);
        }

        // eventually disable the main receive button if private key operations are disabled
        ui->receiveButton->setEnabled(!model->privateKeysDisabled());
    }
Example #18
0
void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
{
    QStandardItemModel model(3, 1);
    for (int i = 0; i < 3; ++i) {
        QStandardItem *item = new QStandardItem(QLatin1String("Item ") + QString::number(i));
        item->setCheckable(true);
        item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        model.setItem(i, item);
    }
    QTableView view;
    view.setModel(&model);
    view.setItemDelegate(new TestItemDelegate);
    view.show();
    view.selectAll();
    QTest::qWaitForWindowShown(&view);
    QStyleOptionViewItem option;
    option.rect = view.visualRect(model.index(0, 0));
    const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1;
    QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center()
                 + QPoint(checkMargin, 0);
    QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos);
    QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex()));
    QCOMPARE(model.item(0)->checkState(), Qt::Checked);
}
Example #19
0
void AddressOverviewWindow::editEntry()
{
    QTableView *temp = static_cast<QTableView*>(ui->AddressesTableView);
    QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
    QItemSelectionModel *selectionModel = temp->selectionModel();
    QModelIndexList indexes = selectionModel->selectedRows();
    QModelIndex index, i;
    QString firstName;
    QString lastName;
    QString address;
    QString city;
    QString zipCode;
    int row = -1;

    foreach (index, indexes) {
        row = proxy->mapToSource(index).row();
        i = model->index(row, 0, QModelIndex());
        QVariant varFirstName = model->data(i, Qt::DisplayRole);
        firstName = varFirstName.toString();

        i = model->index(row, 1, QModelIndex());
        QVariant varLastName = model->data(i, Qt::DisplayRole);
        lastName = varLastName.toString();

        i = model->index(row, 2, QModelIndex());
        QVariant varAddr = model->data(i, Qt::DisplayRole);
        address = varAddr.toString();

        i = model->index(row, 3, QModelIndex());
        QVariant varCity = model->data(i, Qt::DisplayRole);
        city = varCity.toString();

        i = model->index(row, 4, QModelIndex());
        QVariant varZip = model->data(i, Qt::DisplayRole);
        zipCode = varZip.toString();
    }
Example #20
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

//! [0]
    TableModel *model = new TableModel(8, 4, &app);

    QTableView *table = new QTableView(0);
    table->setModel(model);

    QItemSelectionModel *selectionModel = table->selectionModel();
//! [0] //! [1]
    QModelIndex topLeft;
    QModelIndex bottomRight;

    topLeft = model->index(0, 0, QModelIndex());
    bottomRight = model->index(5, 2, QModelIndex());
//! [1]

//! [2]
    QItemSelection selection(topLeft, bottomRight);
    selectionModel->select(selection, QItemSelectionModel::Select);
//! [2]

//! [3]
    QItemSelection toggleSelection;

    topLeft = model->index(2, 1, QModelIndex());
    bottomRight = model->index(7, 3, QModelIndex());
    toggleSelection.select(topLeft, bottomRight);

    selectionModel->select(toggleSelection, QItemSelectionModel::Toggle);
//! [3]

//! [4]
    QItemSelection columnSelection;

    topLeft = model->index(0, 1, QModelIndex());
    bottomRight = model->index(0, 2, QModelIndex());

    columnSelection.select(topLeft, bottomRight);

    selectionModel->select(columnSelection,
        QItemSelectionModel::Select | QItemSelectionModel::Columns);

    QItemSelection rowSelection;

    topLeft = model->index(0, 0, QModelIndex());
    bottomRight = model->index(1, 0, QModelIndex());

    rowSelection.select(topLeft, bottomRight);

    selectionModel->select(rowSelection,
        QItemSelectionModel::Select | QItemSelectionModel::Rows);
//! [4]

    table->setWindowTitle("Selected items in a table model");
    table->show();
    table->resize(460, 280);
    return app.exec();
}
Example #21
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();
    }
}
void TableEditor::removeSelectedRows()
{
    int currentTab = tabWidget->currentIndex();
    QTableView *tv = agentsTable;
    QSqlTableModel *stm = agentsModel;
    QString table = "agents";
    int idColumn = 0;
    if (currentTab == 1)
    {
        tv = determinationsTable;
        stm = determinationsModel;
        table = "determinations";
    }
    else if (currentTab == 2)
    {
        tv = imagesTable;
        stm = imagesModel;
        table = "images";
        idColumn = 20;
    }
    else if (currentTab == 3)
    {
        tv = taxaTable;
        stm = taxaModel;
        table = "taxa";
        idColumn = 1;
    }
    else if (currentTab == 4)
    {
        tv = organismsTable;
        stm = organismsModel;
        table = "organisms";
    }
    else if (currentTab == 5)
    {
        tv = sensuTable;
        stm = sensuModel;
        table = "sensu";
    }
    QItemSelectionModel *selected = tv->selectionModel();
    QModelIndexList rowList = selected->selectedIndexes();

    for (int i = rowList.count()-1; i >= 0; i--)
    {
        stm->removeRow(rowList.at(i).row(), rowList.at(i).parent());
        QString identifier;
        if (table == "determinations")
        {
            QString orgID = stm->data(stm->index(rowList.at(i).row(),0),Qt::DisplayRole).toString();
            QString date = stm->data(stm->index(rowList.at(i).row(),2),Qt::DisplayRole).toString();
            QString tsnID = stm->data(stm->index(rowList.at(i).row(),4),Qt::DisplayRole).toString();
            QString source = stm->data(stm->index(rowList.at(i).row(),5),Qt::DisplayRole).toString();
            reversions.append("INSERT OR REPLACE INTO determinations SELECT * FROM pub_determinations "
                              "WHERE dsw_identified = '" + orgID + "' AND "
                              "dwc_dateIdentified = '" + date + "' AND "
                              "tsnID = '" + tsnID + "' AND "
                              "nameAccordingToID = '" + source + "' LIMIT 1");

        }
        else
        {
            identifier = stm->data(stm->index(rowList.at(i).row(),idColumn),Qt::DisplayRole).toString();
            reversions.append("INSERT OR REPLACE INTO " + table + " SELECT * FROM pub_" + table + " WHERE dcterms_identifier = '" + identifier + "' LIMIT 1");
        }
    }
}