Beispiel #1
0
// Merge the new bank list in without duplication
//
void
MidiDevice::mergeBankList(const BankList &bankList)
{
    BankList::const_iterator it;
    BankList::iterator oIt;
    bool clash = false;
    
    for (it = bankList.begin(); it != bankList.end(); ++it)
    {
        for (oIt = m_bankList.begin(); oIt != m_bankList.end(); ++oIt)
        {
            if (*it == *oIt)
            {
                clash = true;
                break;
            }
        }

        if (clash == false)
            addBank(*it);
        else
            clash = false;
    }

}
BankEditDialog::BankEditDialog(QWidget *parent, Qt::WFlags flags)
	: QDialog(parent, flags)
{
	setupUi(this);
	tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
	tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
	tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);

	//-------------------
	QSqlQuery query("SELECT bank.id, bank.title, country.title AS country, bank.attribute "
		"FROM work.bank INNER JOIN work.country ON bank.countryid = country.id ORDER BY bank.id ASC;");
	if(!query.isActive())
		QMessageBox::critical(this, tr("Error!"), tr("Could not select from database!<p>"
			"The database connection was probably lost. Try to reconnect"));
	
	int j = 0;
	while(query.next())
	{
		tableWidget->insertRow(j);
		for(int i = 1; i < 4; i++)
		{
			QString t = query.value(i).toString();
			QTableWidgetItem *item = new QTableWidgetItem(t.isNull() ? "" : t );
			tableWidget->setItem(j, i-1, item);
		}
		j++;
	}
	tableWidget->setCurrentCell(0,0);
	okButton->setEnabled(true);
	

	connect(tableWidget, SIGNAL( clicked(const QModelIndex &) ), this, SLOT( enableOkButton() ) );
	connect(okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked()));
	connect(addButton, SIGNAL(clicked()), this, SLOT(addBank()));
	connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteBank()));
}