File: ReactionWidget.h

package info (click to toggle)
dyssol 1.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,184 kB
  • sloc: cpp: 53,870; sh: 85; python: 59; makefile: 11
file content (40 lines) | stat: -rw-r--r-- 1,369 bytes parent folder | download | duplicates (3)
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
/* Copyright (c) 2021, Dyssol Development Team. All rights reserved. This file is part of Dyssol. See LICENSE file for license information. */

#pragma once

#include "ui_ReactionWidget.h"
#include "ChemicalReaction.h"
#include <QButtonGroup>

class CMaterialsDatabase;

class CReactionWidget : public QWidget
{
	enum ECols : int { BASE = 0, NU, MATERIAL, PHASE, TYPE, ORDER };
	Q_OBJECT
	Ui::CReactionWidget ui{};

	CChemicalReaction* m_reaction{ nullptr };				// Reaction.
	const std::vector<std::string>* m_compounds{ nullptr };	// All available compounds.
	const CMaterialsDatabase* m_database{ nullptr };		// Materials database.

	QButtonGroup m_radioGroup;								// Group to manage radio buttons in substance widgets.

public:
	CReactionWidget(CChemicalReaction* _reaction, const std::vector<std::string>* _compounds, const CMaterialsDatabase* _database, QWidget* _parent = nullptr);

	[[nodiscard]] QSize sizeHint() const override;

private:
	void InitializeConnections() const;	// Connects all signals.

	void UpdateWholeView();				// Updates all.

	void AddSubstance();				// Adds new substance.
	void RemoveSubstance();				// Removes selected substance.

	void ApplyChanges() const;			// Updates current state of the reaction according to the user's selection.

signals:
	void SubstancesNumberChanged();		// Emitted when the number of substances changes.
};