13 #include <QSortFilterProxyModel> 42 setWindowTitle(tr(
"Choose the contract for send/call"));
43 ui->
labelExplanation->setText(tr(
"These are your saved contracts. Always check the contract address and the ABI before sending/calling."));
46 QAction *copyAddressAction =
new QAction(tr(
"Copy &Address"),
this);
47 QAction *copyNameAction =
new QAction(tr(
"Copy &Name"),
this);
48 QAction *copyABIAction =
new QAction(tr(
"Copy &Interface"),
this);
49 QAction *editAction =
new QAction(tr(
"&Edit"),
this);
50 QAction *deleteAction =
new QAction(tr(
"&Delete"),
this);
63 connect(copyNameAction, SIGNAL(triggered()),
this, SLOT(
onCopyNameAction()));
64 connect(copyABIAction, SIGNAL(triggered()),
this, SLOT(
onCopyABIAction()));
65 connect(editAction, SIGNAL(triggered()),
this, SLOT(
onEditAction()));
68 connect(
ui->
tableView, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(accept()));
88 proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
96 #if QT_VERSION < 0x050000 110 connect(_model, SIGNAL(rowsInserted(QModelIndex,
int,
int)),
this, SLOT(
selectNewContractInfo(QModelIndex,
int,
int)));
137 QModelIndexList indexes =
ui->
tableView->selectionModel()->selectedRows();
138 if(indexes.isEmpty())
143 QModelIndex origIndex =
proxyModel->mapToSource(indexes.at(0));
164 if(!table->selectionModel())
167 QModelIndexList indexes = table->selectionModel()->selectedRows();
168 if(!indexes.isEmpty())
170 int row = indexes.at(0).row();
172 QString contractAddress = table->model()->data(index).toString();
173 QString message = tr(
"Are you sure you want to delete the address \"%1\" from your contract address list?");
174 if(QMessageBox::Yes == QMessageBox::question(
this, tr(
"Delete contact address"), message.arg(contractAddress),
175 QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel))
177 table->model()->removeRow(row);
186 if(!table->selectionModel())
189 if(table->selectionModel()->hasSelection())
204 if(!table->selectionModel() || !table->model())
210 Q_FOREACH (
const QModelIndex& index, indexes) {
211 QVariant
address = table->model()->data(index);
223 QDialog::done(retval);
230 tr(
"Export Contract List"), QString(),
231 tr(
"Comma separated file (*.csv)"), NULL);
233 if (filename.isNull())
244 if(!writer.
write()) {
245 QMessageBox::critical(
this, tr(
"Exporting Failed"),
246 tr(
"There was an error trying to save the address list to %1. Please try again.").arg(filename));
QPushButton * exportButton
void addColumn(const QString &title, int column, int role=Qt::EditRole)
void contextualMenu(const QPoint &point)
Spawn contextual menu (right mouse menu) for contract info book entry.
#define SetObjectStyleSheet(object, name)
Dialog for editing a contract information.
void on_newContractInfo_clicked()
Create a new contract info.
void selectionChanged()
Set button states based on selection.
QPushButton * deleteContractInfo
void selectNewContractInfo(const QModelIndex &parent, int begin, int)
New entry/entries were added to contract info table.
Export a Qt table model to a CSV file.
QLabel * labelExplanation
QString getAddress() const
void onCopyNameAction()
Copy label of currently selected contract info entry to clipboard (no button)
void on_copyAddress_clicked()
Copy address of currently selected contract info entry to clipboard.
QPushButton * newContractInfo
ContractTableModel * model
void on_exportButton_clicked()
Export button clicked.
void setModel(ContractTableModel *model)
QPushButton * copyAddress
void setModel(ContractTableModel *model)
QPushButton * chooseContractInfo
QModelIndex index(int row, int column, const QModelIndex &parent) const
Qt model of the contract book in the core.
QSortFilterProxyModel * proxyModel
void setModel(const QAbstractItemModel *model)
Ui::ContractBookPage * ui
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut)
Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix when ...
void onCopyABIAction()
Copy ABI of currently selected contract info entry to clipboard (no button)
void on_deleteContractInfo_clicked()
Delete currently selected contract info entry.
ContractBookPage(const PlatformStyle *platformStyle, QWidget *parent=0)
struct evm_uint160be address(struct evm_env *env)
void setupUi(QWidget *ContractBookPage)
void copyEntryData(QAbstractItemView *view, int column, int role)
Copy a field of the currently selected entry of a view to the clipboard.
void onEditAction()
Edit currently selected contract info entry (no button)
bool write()
Perform export of the model to CSV.
QString newContractInfoToSelect