Connection manager can now open a query window for selected connection.

Query window has now buttons with icons made in the designer for better looks.
Depending on received responses from the database the tabcontrol with the message, data and explain tab
now switches to the appropriate tab.
This commit is contained in:
Eelke Klein 2017-01-15 21:01:40 +01:00
parent 88fcc0338d
commit d19741f111
26 changed files with 408 additions and 116 deletions

View file

@ -66,7 +66,11 @@ ConnectionListModel::ConnectionListModel(QObject *parent)
int ConnectionListModel::rowCount(const QModelIndex &parent) const
{
return m_connections.size();
int result = 0;
if (parent == QModelIndex()) {
result = m_connections.size();
}
return result;
}
int ConnectionListModel::columnCount(const QModelIndex &/*parent*/) const
@ -150,7 +154,12 @@ bool ConnectionListModel::setData(const QModelIndex &index, const QVariant &valu
Qt::ItemFlags ConnectionListModel::flags(const QModelIndex &index) const
{
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
Qt::ItemFlags result;
int row = index.row();
if (row >= 0 && row < m_connections.size()) {
result = Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
}
return result;
}
@ -176,6 +185,28 @@ void ConnectionListModel::add(const ConnectionConfig &cfg)
emit dataChanged(idx, idx);
}
Expected<ConnectionConfig> ConnectionListModel::get(int row)
{
if (row >= 0 && row < m_connections.size()) {
return m_connections.at(row).m_config;
}
else {
return Expected<ConnectionConfig>::fromException(std::out_of_range("Invalid row"));
}
}
//void ConnectionListModel::del(const int idx)
bool ConnectionListModel::removeRows(int row, int count, const QModelIndex &parent)
{
bool result = false;
if (row >= 0 && row < m_connections.size()) {
auto f = m_connections.begin() + row;
m_connections.erase(f, f + count);
result = true;
}
return result;
}
/// \todo should return an expected as creation of the folder can fail
QString ConnectionListModel::iniFileName()
{