summaryrefslogtreecommitdiff
path: root/models/FrequencySuggestions.hpp
blob: 74ed2eb65557ef87c20ef16e9e8f7b7b90531500 (plain)
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
#ifndef FREQUENCY_SUGGESTIONS_HPP__
#define FREQUENCY_SUGGESTIONS_HPP__

#include "models/FrequencyList.hpp"

#include <QSet>
#include <QStringList>

class Bands;

namespace FrequencySuggestions
{
  using Item = FrequencyList_v2_101::Item;
  using Items = FrequencyList_v2_101::FrequencyItems;

  QString key (Item const&);
  bool is_present (Item const&, Items const& working);
  Items prepare_additions (Items const& selected, Items const& working, Bands const&);

  class NoticeState
  {
  public:
    enum class Visibility { Hidden, Available, New };

    NoticeState (QStringList seen_keys = {}, bool has_seen_catalog = false);

    Visibility visibility (Items const& catalog, Items const& working) const;
    void selected_additions (Items const& additions);
    void cancel ();
    bool commit (Items const& catalog, Items const& committed_working);
    bool acknowledge_present_catalog (Items const& catalog, Items const& committed_working);
    void dismiss (Items const& catalog);
    QStringList seen_keys () const;

  private:
    void acknowledge (Items const& catalog);

    QSet<QString> seen_keys_;
    bool has_seen_catalog_ {false};
    Items pending_additions_;
  };
}

#endif