Files
qelectrotech-source-mirror/sources/factory/ui/addtabledialog.h
T
ispyisail 219273a8e5 Add table placement to the scripting API
QetGraphicsTableFactory::create() only reads settings already set on an
AddTableDialog and never depended on the dialog being shown, so make it
public alongside setTableName()/setAdjustTableToFolio()/
setAddNewTableToNewDiagram() on AddTableDialog -- this lets the scripting
API build and configure a dialog headlessly instead of exec()'ing one.

qet.addTable() requires a non-empty query: ElementQueryWidget and
SummaryQueryWidget both default to zero selected columns, so an empty
query silently produced a table with no rows rather than a sensible
default. qet.tables()/deleteTable() list and remove by a position-sorted
index. qet.setTablePosition() repositions one, since newTable() always
places a new table at a fixed (50, 50) and a folio with more than one
needs to move all but the first itself.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-22 21:56:31 +12:00

88 lines
2.4 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ADDTABLEDIALOG_H
#define ADDTABLEDIALOG_H
#include "../../qetapp.h"
#include <QDialog>
namespace Ui {
class AddTableDialog;
}
/**
@brief The AddTableDialog class
Provide a dialog used to edit the properties of table before adding to a diagram.
The main difference between this dialog and the widget used to edit the properties of table
is that the dialog have two extra check box.
One for adjust the size of the table to diagram
Second for add new tables on new folios if the table can't fit into diagram
*/
class AddTableDialog : public QDialog
{
Q_OBJECT
public:
explicit AddTableDialog(QWidget *content_widget, QWidget *parent = nullptr);
~AddTableDialog();
void setQueryWidget(QWidget *widget);
bool adjustTableToFolio() const;
void setAdjustTableToFolio(bool set);
bool addNewTableToNewDiagram() const;
void setAddNewTableToNewDiagram(bool set);
QString tableName() const;
void setTableName(const QString &name);
QMargins headerMargins() const;
Qt::Alignment headerAlignment() const;
QFont headerFont() const;
QMargins tableMargins() const;
Qt::Alignment tableAlignment() const;
QFont tableFont() const;
QWidget *contentWidget() const;
private slots:
void on_m_header_font_pb_clicked();
void on_m_table_font_pb_clicked();
void on_m_edit_header_margins_pb_clicked();
void on_m_table_margins_pb_clicked();
void saveConfig();
void loadConfig();
void fillSavedQuery();
private:
Ui::AddTableDialog *ui;
QWidget *m_content_widget = nullptr;
QMargins m_header_margins = QMargins(5,5,10,5),
m_table_margins = QMargins(5,5,10,5);
QFont m_header_font = QETApp::diagramTextsFont();
QFont m_table_font = QETApp::diagramTextsFont();
QString m_identifier;
};
#endif // ADDTABLEDIALOG_H