/*
	Copyright (C) 2022-2024 Mark Tyler

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program in the file COPYING.
*/

#include "qt5.h"



template < typename Tparser >
void MainWindow::TabUIelements<Tparser>::click_show_funcs ()
{
	std::map<std::string, std::string> map;
	char	const	* name;
	std::string	result;
	std::string	help;

	for ( int i = 0; ; i++ )
	{
		if ( m_parser.get_function_data ( i, &name, help ) )
		{
			break;
		}

		map[ name ] = help;
	}

	for ( auto && it : map )
	{
		result += it.first;
		result += " ";
		result += it.second;
		result += "\n";
	}

	mtQEX::DialogAbout dialog ( &mainwindow, VERSION );
	std::string title (
		(std::is_same<Tparser, mtDW::FloatParser>::value)
			? TEXT_TITLE_FLOAT :
		(std::is_same<Tparser, mtDW::DoubleParser>::value)
			? TEXT_TITLE_DOUBLE :
		(std::is_same<Tparser, mtDW::IntegerParser>::value)
			? TEXT_TITLE_INTEGER :
		(std::is_same<Tparser, mtDW::RationalParser>::value)
			? TEXT_TITLE_RATIONAL :
		TEXT_TITLE_ERROR );

	title += " Functions";

	dialog.add_info ( title.c_str(), result.c_str() );

	dialog.exec ();
}

template void MainWindow::TabUIelements<mtDW::FloatParser>::click_show_funcs ();
template void MainWindow::TabUIelements<mtDW::DoubleParser>::click_show_funcs ();
template void MainWindow::TabUIelements<mtDW::IntegerParser>::click_show_funcs ();
template void MainWindow::TabUIelements<mtDW::RationalParser>::click_show_funcs ();

