1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_AUTOFILL_DIALOG_MODELS_H_
#define CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_AUTOFILL_DIALOG_MODELS_H_
#include <string>
#include "ui/base/models/combobox_model.h"
#include "ui/base/models/simple_combobox_model.h"
namespace autofill {
// A model for possible months in the Gregorian calendar.
class MonthComboboxModel : public ui::ComboboxModel {
public:
MonthComboboxModel();
MonthComboboxModel(const MonthComboboxModel&) = delete;
MonthComboboxModel& operator=(const MonthComboboxModel&) = delete;
~MonthComboboxModel() override;
// Set |default_index_| to the given |month| before user interaction. There is
// no effect if the |month| is out of the range.
void SetDefaultIndexByMonth(int month);
// ui::Combobox implementation:
size_t GetItemCount() const override;
std::u16string GetItemAt(size_t index) const override;
std::optional<size_t> GetDefaultIndex() const override;
private:
// The index of the item that is selected by default (before user
// interaction).
size_t default_index_ = 0;
};
// A model for years between now and a decade hence.
class YearComboboxModel : public ui::SimpleComboboxModel {
public:
// If |additional_year| is not in the year range initially in this model
// [current year, current year + 9], this will add |additional_year| to the
// model. Passing 0 has no effect.
explicit YearComboboxModel(int additional_year = 0);
YearComboboxModel(const YearComboboxModel&) = delete;
YearComboboxModel& operator=(const YearComboboxModel&) = delete;
~YearComboboxModel() override;
// Set |default_index_| to the given |year| before user interaction. There is
// no effect if the |year| is out of the range.
void SetDefaultIndexByYear(int year);
// ui::Combobox implementation:
std::optional<size_t> GetDefaultIndex() const override;
private:
// The index of the item that is selected by default (before user
// interaction).
size_t default_index_ = 0;
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_AUTOFILL_PAYMENTS_AUTOFILL_DIALOG_MODELS_H_
|