Chatterino
HotkeyModel.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 #include "util/QStringHash.hpp"
6 
7 #include <unordered_map>
8 
9 namespace chatterino {
10 
11 class HotkeyController;
12 
13 class HotkeyModel : public SignalVectorModel<std::shared_ptr<Hotkey>>
14 {
15 public:
16  HotkeyModel(QObject *parent);
17 
18 protected:
19  // turn a vector item into a model row
20  virtual std::shared_ptr<Hotkey> getItemFromRow(
21  std::vector<QStandardItem *> &row,
22  const std::shared_ptr<Hotkey> &original) override;
23 
24  // turns a row in the model into a vector item
25  virtual void getRowFromItem(const std::shared_ptr<Hotkey> &item,
26  std::vector<QStandardItem *> &row) override;
27 
28  virtual int beforeInsert(const std::shared_ptr<Hotkey> &item,
29  std::vector<QStandardItem *> &row,
30  int proposedIndex) override;
31 
32  virtual void afterRemoved(const std::shared_ptr<Hotkey> &item,
33  std::vector<QStandardItem *> &row,
34  int index) override;
35 
36  friend class HotkeyController;
37 
38 private:
39  std::tuple<int, int> getCurrentAndNextCategoryModelIndex(
40  const QString &category) const;
41 
42  std::unordered_map<QString, int> categoryCount_;
43 };
44 
45 } // namespace chatterino
virtual void getRowFromItem(const std::shared_ptr< Hotkey > &item, std::vector< QStandardItem *> &row) override
Definition: HotkeyModel.cpp:21
Definition: HotkeyModel.hpp:13
Definition: Application.cpp:48
Definition: SignalVectorModel.hpp:15
virtual std::shared_ptr< Hotkey > getItemFromRow(std::vector< QStandardItem *> &row, const std::shared_ptr< Hotkey > &original) override
Definition: HotkeyModel.cpp:14
Definition: HotkeyController.hpp:22
HotkeyModel(QObject *parent)
Definition: HotkeyModel.cpp:8
virtual void afterRemoved(const std::shared_ptr< Hotkey > &item, std::vector< QStandardItem *> &row, int index) override
Definition: HotkeyModel.cpp:73
virtual int beforeInsert(const std::shared_ptr< Hotkey > &item, std::vector< QStandardItem *> &row, int proposedIndex) override
Definition: HotkeyModel.cpp:38