Continue new summary feature

Header name is now well translated.
Open the good dialog from the properties dock widget
This commit is contained in:
Claveau Joshua
2020-06-21 16:00:14 +02:00
parent edb5217b31
commit 64f3001c86
10 changed files with 113 additions and 62 deletions

View File

@@ -118,7 +118,7 @@ void ElementQueryWidget::setQuery(const QString &query)
QString select = query;
select.remove(0,7); //Remove SELECT
select.truncate(select.indexOf("FROM")); //Truncate at FROM
select.replace(" ", ""); //Remove withe space
select.replace(" ", ""); //Remove white space
//Get the select -> the item in the right list
QStringList split = select.split(",");
@@ -367,25 +367,6 @@ QString ElementQueryWidget::queryStr() const
return q;
}
/**
* @brief ElementQueryWidget::header
* @return the name of each selected item is a QStringList.
* You can use the QStringList as header string of a table filled by the returned value of the query ElementQueryWidget::queryStr() to project database.
*/
QStringList ElementQueryWidget::header() const
{
//Made a string list with the colomns (keys) choosen by the user
QStringList headers;
int row = 0;
while (auto *item = ui->m_choosen_list->item(row))
{
headers.append(item->data(Qt::DisplayRole).toString());
++row;
}
return headers;
}
/**
* @brief ElementQueryWidget::updateQueryLine
*/

View File

@@ -42,7 +42,6 @@ class ElementQueryWidget : public QWidget
void setQuery(const QString &query);
QString queryStr() const;
QStringList header() const;
static QString modelIdentifier() {return "nomenclature";}

View File

@@ -47,7 +47,7 @@ SummaryQueryWidget::~SummaryQueryWidget()
/**
* @brief SummaryQueryWidget::queryStr
* @return
* @return The current query string
*/
QString SummaryQueryWidget::queryStr() const
{
@@ -78,6 +78,40 @@ QString SummaryQueryWidget::queryStr() const
return q;
}
/**
* @brief SummaryQueryWidget::setQuery
* @param query
* set the current query to @query.
* If it's possible, rebuild the state of the widget from the query
*/
void SummaryQueryWidget::setQuery(const QString &query)
{
if (query.startsWith("SELECT"))
{
reset();
ui->m_user_query_le->setText(query);
QString select = query;
select.remove(0,7); //remove SELECT
select.truncate(select.indexOf("FROM")); //Truncate at FROM
select.replace(" ",""); //Remove white
//Get the select -> the item in the right list
QStringList split = select.split(",");
for (auto str : split)
{
for (auto item : m_items_list)
{
if (item->data(Qt::UserRole).toString() == str) {
ui->m_available_list->takeItem(ui->m_available_list->row(item));
ui->m_choosen_list->addItem(item);
continue;
}
}
}
}
}
/**
* @brief SummaryQueryWidget::setUpItems
*/
@@ -97,6 +131,9 @@ void SummaryQueryWidget::setUpItems()
m_items_list << item;
}
/**
* @brief SummaryQueryWidget::fillSavedQuery
*/
void SummaryQueryWidget::fillSavedQuery()
{
@@ -126,6 +163,11 @@ QStringList SummaryQueryWidget::selectedKeys() const
return keys;
}
/**
* @brief SummaryQueryWidget::on_m_available_list_itemDoubleClicked
* @param item
*/
void SummaryQueryWidget::on_m_available_list_itemDoubleClicked(QListWidgetItem *item)
{
Q_UNUSED(item)
@@ -200,6 +242,9 @@ void SummaryQueryWidget::on_m_down_pb_clicked()
updateQueryLine();
}
/**
* @brief SummaryQueryWidget::on_m_edit_sql_query_cb_clicked
*/
void SummaryQueryWidget::on_m_edit_sql_query_cb_clicked()
{
ui->m_user_query_le->setEnabled(ui->m_edit_sql_query_cb->isChecked());
@@ -215,3 +260,16 @@ void SummaryQueryWidget::on_m_edit_sql_query_cb_clicked()
updateQueryLine();
}
}
/**
* @brief SummaryQueryWidget::reset
* Clear this widget aka set to initial state
*/
void SummaryQueryWidget::reset()
{
//Ugly hack to force to remove all selected infos
while (auto item = ui->m_choosen_list->takeItem(0)) {
ui->m_available_list->addItem(item);
}
ui->m_user_query_le->clear();
}

View File

@@ -36,6 +36,7 @@ class SummaryQueryWidget : public QWidget
static QString modelIdentifier() {return "summary";}
QString queryStr() const;
void setQuery(const QString &query);
private:
void setUpItems();
@@ -51,6 +52,7 @@ class SummaryQueryWidget : public QWidget
void on_m_remove_pb_clicked();
void on_m_down_pb_clicked();
void on_m_edit_sql_query_cb_clicked();
void reset();
private:
Ui::SummaryQueryWidget *ui;