Print preview dialog : Add selection by date.

Add two news option for select diagrams to print :
select "from the date :" and select "at the date".
This commit is contained in:
Claveau Joshua 2020-09-30 21:29:17 +02:00
parent 930bb70f99
commit add11e7c7a
3 changed files with 79 additions and 4 deletions

View File

@ -120,6 +120,10 @@ ProjectPrintWindow::ProjectPrintWindow(QETProject *project, QPrinter *printer, Q
ui->m_draw_terminal_cb->setChecked(exp.draw_terminals);
ui->m_keep_conductor_color_cb->setChecked(exp.draw_colored_conductors);
ui->m_date_cb->blockSignals(true);
ui->m_date_cb->setDate(QDate::currentDate());
ui->m_date_cb->blockSignals(false);
m_backup_diagram_background_color = Diagram::background_color;
Diagram::background_color = Qt::white;
}
@ -578,3 +582,28 @@ void ProjectPrintWindow::print()
savePageSetupForCurrentPrinter();
this->close();
}
void ProjectPrintWindow::on_m_date_cb_userDateChanged(const QDate &date)
{
on_m_uncheck_all_clicked();
auto index = ui->m_date_from_cb->currentIndex();
// 0 = from the date
// 1 = at the date
for (auto diagram : m_diagram_list_hash.keys())
{
auto diagram_date = diagram->border_and_titleblock.date();
if ( (index == 0 && diagram_date >= date) ||
(index == 1 && diagram_date == date) )
m_diagram_list_hash.value(diagram)->setChecked(true);
}
m_preview->updatePreview();
}
void ProjectPrintWindow::on_m_date_from_cb_currentIndexChanged(int index)
{
Q_UNUSED(index)
on_m_date_cb_userDateChanged(ui->m_date_cb->date());
}

View File

@ -73,7 +73,11 @@ class ProjectPrintWindow : public QMainWindow
void on_m_uncheck_all_clicked();
void print();
private:
void on_m_date_cb_userDateChanged(const QDate &date);
void on_m_date_from_cb_currentIndexChanged(int index);
private:
void requestPaint();
void printDiagram(Diagram *diagram, bool fit_page, QPainter *painter, QPrinter *printer);
QRect diagramRect(Diagram *diagram, const ExportProperties &option) const;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>956</width>
<height>543</height>
<height>554</height>
</rect>
</property>
<property name="sizePolicy">
@ -57,8 +57,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>936</width>
<height>66</height>
<width>932</width>
<height>75</height>
</rect>
</property>
</widget>
@ -78,6 +78,48 @@
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>9</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="m_date_from_cb">
<item>
<property name="text">
<string>À partir de la date du :</string>
</property>
</item>
<item>
<property name="text">
<string>À la date du :</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QDateEdit" name="m_date_cb">
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>