mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-20 19:19:58 +01:00
QetGraphicsTableItem : add dialog to inform user
When user edit the query of an existing table/s if the content to display is bigger than the content who can be displayed by the table/s a dialog is opened for inform user of the current situation.
This commit is contained in:
@@ -309,8 +309,6 @@ void ProjectDBModel::dataBaseUpdated()
|
||||
auto new_record = m_record;
|
||||
m_record = original_record;
|
||||
|
||||
//This a very special case, if this nomenclature model is added
|
||||
//befor any element, column count return 0, so in this case we emit column inserted
|
||||
if (new_record.size() != m_record.size())
|
||||
{
|
||||
emit beginResetModel();
|
||||
|
||||
@@ -61,6 +61,56 @@ void QetGraphicsTableItem::adjustTableToFolio(QetGraphicsTableItem *table, QMarg
|
||||
table->setDisplayNRow(int(floor(available_height/min_row_height))); //Convert a double to int, but max_row_to_display is already rounded an integer so we assume everything is ok
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QetGraphicsTableItem::checkInsufficientRowsCount
|
||||
* Check if the number of rows of @table + linked table is enough to display all
|
||||
* content of the model, if not open a dialog to advise user what to do.
|
||||
* @param table
|
||||
*/
|
||||
void QetGraphicsTableItem::checkInsufficientRowsCount(QetGraphicsTableItem *table)
|
||||
{
|
||||
if (!table->diagram() || !table->model()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto first_table = table;
|
||||
while (first_table->previousTable())
|
||||
first_table = first_table->previousTable();
|
||||
|
||||
if (first_table->displayNRow() <= 0) //displayed rows is unlimited
|
||||
return;
|
||||
|
||||
int count_ = first_table->displayNRow();
|
||||
bool several_table = false;
|
||||
while (first_table->nextTable())
|
||||
{
|
||||
several_table = true;
|
||||
first_table = first_table->nextTable();
|
||||
if (first_table->displayNRow() <= 0) { //displayed rows is unlimited
|
||||
return;
|
||||
} else {
|
||||
count_ += first_table->displayNRow();
|
||||
first_table->displayNRowOffset();
|
||||
}
|
||||
}
|
||||
|
||||
if (count_ < first_table->model()->rowCount())
|
||||
{
|
||||
QWidget *parent = first_table->diagram()->views().first() ? first_table->diagram()->views().first() : nullptr;
|
||||
|
||||
QString text;
|
||||
if (several_table) {
|
||||
text = tr("Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par les tableaux.\n"
|
||||
"Veuillez ajouter un nouveau tableau ou regler les tableaux existant afin d'afficher l'integralité des informations.");
|
||||
} else {
|
||||
text = tr("Les information à afficher sont supérieurs à la quantité maximal pouvant être affiché par le tableau.\n"
|
||||
"Veuillez ajouter un nouveau tableau ou regler le tableau existant afin d'afficher l'integralité des informations.");
|
||||
}
|
||||
QMessageBox::information(parent, tr("Limitation de tableau"), text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QetGraphicsTableItem::QetGraphicsTableItem
|
||||
* Default constructor
|
||||
@@ -601,6 +651,10 @@ QVariant QetGraphicsTableItem::itemChange(QGraphicsItem::GraphicsItemChange chan
|
||||
void QetGraphicsTableItem::modelReseted() {
|
||||
dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>());
|
||||
setToMinimumHeight();
|
||||
|
||||
if (!previousTable()) { //this is the head table
|
||||
checkInsufficientRowsCount(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,7 @@ class QetGraphicsTableItem : public QetGraphicsItem
|
||||
|
||||
public :
|
||||
static void adjustTableToFolio(QetGraphicsTableItem *table, QMargins margins = QMargins(20,20,20,0));
|
||||
static void checkInsufficientRowsCount(QetGraphicsTableItem *first_table);
|
||||
|
||||
public:
|
||||
QetGraphicsTableItem(QGraphicsItem *parent= nullptr);
|
||||
|
||||
Reference in New Issue
Block a user