MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / DateRangePicker

Method DateRangePicker

pj_widgets/src/DateRangePicker.cpp:878–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876// ===========================================================================
877
878DateRangePicker::DateRangePicker(QWidget* parent) : QWidget(parent) {
879 auto* main_layout = new QVBoxLayout(this);
880 main_layout->setContentsMargins(0, 0, 0, 0);
881 // Match the host column's 2px row spacing: without this the preset-row -> date-row
882 // gap uses Qt's larger default, so the spacing between the preset buttons and the
883 // from/to fields reads bigger than the gaps to the header above / table below.
884 main_layout->setSpacing(2);
885
886 auto* preset_row = new QHBoxLayout;
887 preset_group_ = new QButtonGroup(this);
888 preset_group_->setExclusive(true);
889
890 auto add_preset = [&](int id, const QString& text) -> QPushButton* {
891 auto* btn = new QPushButton(text);
892 btn->setCheckable(true);
893 btn->setCursor(Qt::PointingHandCursor);
894 preset_group_->addButton(btn, id);
895 preset_row->addWidget(btn);
896 return btn;
897 };
898
899 all_button_ = add_preset(kPresetAll, "All");
900 add_preset(kPresetPast24h, "Past 24h");
901 add_preset(kPresetLast7Days, "Last 7 Days");
902 add_preset(kPresetLastMonth, "Last Month");
903 all_button_->setChecked(true);
904 connect(preset_group_, &QButtonGroup::idClicked, this, &DateRangePicker::onPresetClicked);
905 main_layout->addLayout(preset_row);
906
907 auto* date_row = new QHBoxLayout;
908 from_edit_ = new QLineEdit;
909 from_edit_->setPlaceholderText("DD/MM/YYYY");
910 // Material "Arrow Right Alt" between from/to, themed to the active ink (re-inked
911 // on a live theme switch in changeEvent). A QLabel pixmap, not a text glyph.
912 arrow_label_ = new QLabel;
913 arrow_label_->setPixmap(renderThemedIcon(QStringLiteral(":/resources/svg/arrow_right_alt.svg"), 18).pixmap(18, 18));
914 to_edit_ = new QLineEdit;
915 to_edit_->setPlaceholderText(QDate::currentDate().toString("dd/MM/yyyy"));
916 calendar_button_ = new QPushButton;
917 calendar_button_->setCursor(Qt::PointingHandCursor);
918 // 28x28 button with a 24px icon to match the panel's other icon buttons
919 // (refresh / search / regex toggles).
920 calendar_button_->setFixedSize(28, 28);
921 // Themed "Calendar Month" icon (recolored to the active theme's ink); the
922 // icon stays static — toggleCalendar() no longer swaps a glyph.
923 calendar_button_->setIcon(renderThemedIcon(QStringLiteral(":/resources/svg/calendar_month.svg"), 24));
924 calendar_button_->setIconSize(QSize(24, 24));
925 date_row->addWidget(from_edit_, 1);
926 date_row->addWidget(arrow_label_);
927 date_row->addWidget(to_edit_, 1);
928 date_row->addWidget(calendar_button_);
929 connect(from_edit_, &QLineEdit::textChanged, this, &DateRangePicker::checkCustomState);
930 connect(to_edit_, &QLineEdit::textChanged, this, &DateRangePicker::checkCustomState);
931 connect(calendar_button_, &QPushButton::clicked, this, &DateRangePicker::toggleCalendar);
932 main_layout->addLayout(date_row);
933}
934
935DateRangePicker::~DateRangePicker() {

Callers

nothing calls this directly

Calls 10

renderThemedIconFunction · 0.85
setCursorMethod · 0.80
addButtonMethod · 0.80
setPixmapMethod · 0.80
toStringMethod · 0.80
setIconSizeMethod · 0.80
QSizeClass · 0.50
setSpacingMethod · 0.45
setCheckedMethod · 0.45
setIconMethod · 0.45

Tested by

no test coverage detected