overview_panel.hpp 2.31 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
#ifndef CVVISUAL_OVERVIEWPANEL_HPP
#define CVVISUAL_OVERVIEWPANEL_HPP

#include <vector>

#include <QWidget>
#include <QString>
#include <QSlider>
#include <QLabel>
#include <QPushButton>

#include "../stfl/stfl_engine.hpp"
#include "../impl/call.hpp"
#include "overview_table.hpp"
#include "overview_table_row.hpp"
#include "../util/util.hpp"
#include "../controller/view_controller.hpp"

namespace cvv
{

namespace controller
{
class ViewController;
}

namespace qtutil
{
class STFLQueryWidget;
}

namespace gui
{

class OverviewTable;
class OverviewTableRow;

/**
 * @brief The overview showing a filterable table displaying the different
 * calls.
 */
class OverviewPanel : public QWidget
{

	Q_OBJECT

      public:
	/**
	 * @brief Contructs an OverviewPanel.
	 * @param controller ViewController that inherits this overview
	 */
	OverviewPanel(util::Reference<controller::ViewController> controller);

	/**
	 * @brief Adds the given call to the shown overview table.
	 * @param newCall given call
	 */
	void addElement(const util::Reference<const impl::Call> newCall);

	/**
	 * @brief Changes the "Resume program execution" button label to "Exit
	 * Application."
	 */
	void showExitApplicationButton();

	/**
	 * @brief Adds the given call buffered to the shown overview table.
	 * @note Be sure to flush the buffer via flushElementBuffer() later.
	 * @param newCall given call
	 */
	void addElementBuffered(const util::Reference<const impl::Call> newCall);
	
	/**
	 * @brief Flushes the element buffer and shows its elements in the overview table.
	 */
	void flushElementBuffer();
	
	/**
	 * @brief Removes and deletes the element with the given id.
	 * @param id given element id
	 */
	void removeElement(size_t id);
	
private slots:

	void filterQuery(QString query);

	void updateQuery(QString query);

	void requestSuggestions(QString query);

	void imgSizeSliderAction();

	void showHelp(QString topic);

private:
	stfl::STFLEngine<OverviewTableRow> queryEngine{"Overview"};
	qtutil::STFLQueryWidget *queryWidget;
	OverviewTable *table;
	util::Reference<controller::ViewController> controller;
	QLabel *imgSizeSliderLabel;
	QSlider *imgSizeSlider;
	std::vector<util::Reference<const impl::Call>> elementBuffer;

	void initEngine();
	
	void openCommand(QStringList args,
		std::vector<stfl::ElementGroup<OverviewTableRow>>& groups);
};
}
}

#endif