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

Method updateNavButtons

pj_widgets/src/DateRangePicker.cpp:778–824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776}
777
778void DualCalendarWidget::updateNavButtons() {
779 int ln_y = left_year_, ln_m = left_month_;
780 advanceMonth(ln_y, ln_m, 1);
781 bool at_max = ln_y > left_max_year_ || (ln_y == left_max_year_ && ln_m > left_max_month_);
782 bool at_right = ln_y > right_year_ || (ln_y == right_year_ && ln_m >= right_month_);
783 left_next_->setEnabled(!at_max && !at_right);
784
785 int rp_y = right_year_, rp_m = right_month_;
786 advanceMonth(rp_y, rp_m, -1);
787 const bool currently_ge_min =
788 right_year_ > right_min_year_ || (right_year_ == right_min_year_ && right_month_ >= right_min_month_);
789 bool at_minimum =
790 currently_ge_min && (rp_y < right_min_year_ || (rp_y == right_min_year_ && rp_m < right_min_month_));
791 bool at_left = rp_y < left_year_ || (rp_y == left_year_ && rp_m <= left_month_);
792 right_prev_->setEnabled(!at_minimum && !at_left);
793
794 left_prev_->setEnabled(true);
795 right_next_->setEnabled(true);
796
797 // Direction hint: color the arrow text green/red when clicking it would
798 // reveal the start/end date (currently outside both calendars' views).
799 const int from_l = monthCmp(range_from_, left_year_, left_month_);
800 const int from_r = monthCmp(range_from_, right_year_, right_month_);
801 const int to_l = monthCmp(range_to_, left_year_, left_month_);
802 const int to_r = monthCmp(range_to_, right_year_, right_month_);
803
804 const bool from_before_l = from_l < 0;
805 const bool from_in_gap = from_l > 0 && from_r < 0;
806 const bool from_after_r = from_r > 0;
807 const bool to_before_l = to_l < 0;
808 const bool to_in_gap = to_l > 0 && to_r < 0;
809 const bool to_after_r = to_r > 0;
810
811 // Direction hint: recolor the chevron green/red when clicking it would reveal the
812 // start/end date (currently outside both calendars' views); resting state is the
813 // theme ink. The flat-button stylesheet set in the ctor is left untouched.
814 const QColor ink = pickerTokens().text;
815 auto apply_hint = [ink](QPushButton* btn, bool left, bool hint_from, bool hint_to) {
816 const QColor c = hint_from ? kFromHintColor : (hint_to ? kToHintColor : ink);
817 btn->setIcon(renderChevronIcon(left, c, kNavChevronPx));
818 };
819
820 apply_hint(left_prev_, /*left=*/true, from_before_l, to_before_l);
821 apply_hint(left_next_, /*left=*/false, from_in_gap, to_in_gap);
822 apply_hint(right_prev_, /*left=*/true, from_in_gap, to_in_gap);
823 apply_hint(right_next_, /*left=*/false, from_after_r, to_after_r);
824}
825
826void DualCalendarWidget::onDateClicked(const QDate& date) {
827 if (!selecting_) {

Callers

nothing calls this directly

Calls 5

monthCmpFunction · 0.85
pickerTokensFunction · 0.85
renderChevronIconFunction · 0.85
setEnabledMethod · 0.45
setIconMethod · 0.45

Tested by

no test coverage detected