call_window.hpp 2.97 KB
Newer Older
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
#ifndef CVVISUAL_CALLWINDOW_HPP
#define CVVISUAL_CALLWINDOW_HPP

#include <vector>
#include <map>

#include <QTabWidget>
#include <QMainWindow>
#include <QString>
#include <vector>
#include <QLabel>
#include <QKeyEvent>
#include <QPoint>
#include <QCloseEvent>
#include <QPushButton>

#include "call_tab.hpp"
#include "../controller/view_controller.hpp"
#include "../util/util.hpp"
#include "tabwidget.hpp"

namespace cvv
{

namespace controller
{
class ViewController;
}

namespace gui
{

/**
 * @brief Window inheriting some call tabs with in a tab widget.
 */
class CallWindow : public QMainWindow
{

	Q_OBJECT

public:
	/**
	 * @brief Contructs a new call window.
	 * @param controller view controller that this window belongs to
	 * @param id id of the window
	 */
	CallWindow(util::Reference<controller::ViewController> controller,
	           size_t id);

	/**
	 * @brief Shows an "Exit program" button.
	 */
	void showExitProgramButton();

	/**
	 * @brief Add a new tab to the inherited tab widget.
	 * @param tab new tab
	 */
	void addTab(CallTab *tab);

	/**
	 * @brief Get the id of this window.
	 * @return id of this window.
	 */
	size_t getId();

	/**
	 * @brief Remove the given tab from this window.
	 * @param given tab to remove
	 */
	void removeTab(CallTab *tab);

	/**
	 * @brief Remove the given tab from this window.
	 * @param id of the given tab
	 */
	void removeTab(size_t tabId);

	/**
	 * @brief Show the given tab.
	 * @param given tab
	 */
	void showTab(CallTab *tab);

	/**
	 * @brief Show the given tab.
	 * @param id of the given tab
	 */
	void showTab(size_t tabId);
	
	/**
	 * @brief Examines whether or not the given is inherited in this window.
	 * @param id of the given tab
	 */
	bool hasTab(size_t tabId);

	/**
	 * @brief Returns the number of tabs shown in this window.
	 * @return number of tabs
	 */
	size_t tabCount();

	/**
	 * @brief Returns the ids of the available call tabs.
	 * @return available call tabs' ids
	 */
	std::vector<size_t> getCallTabIds();

public slots:
	
	/**
	 * @brief Update the left footer with the given text.
	 * @param newText given text
	 */
	void updateLeftFooter(QString newText);

	/**
	 * @brief Update the right footer with the given text.
	 * @param newText given text
	 */
	void updateRightFooter(QString newText);

private slots:
	void contextMenuRequested(const QPoint &location);

	void contextMenuAction(QAction *action);

	void tabCloseRequested(int index);

	void step();

	void fastForward();

	void closeApp();

protected:
	size_t id;
	util::Reference<controller::ViewController> controller;
	TabWidget *tabWidget;
	QMainWindow *window;
	QPushButton *closeButton;
	QPushButton *stepButton;
	QPushButton *fastForwardButton;
	std::map<size_t, CallTab *> tabMap;
	QLabel *leftFooter;
	QLabel *rightFooter;
	int currentContextMenuTabId = -1;
	int tabOffset = 0;

	void initMenu();

	void initTabs();

	void initFooter();

	void closeEvent(QCloseEvent *event);

	size_t getCallTabIdByTabIndex(int index);

	bool hasTabAtIndex(int index);
};
}
}

#endif