Source

lrc / src / gui / EditDialog.hxx

/*
 * EditDialog.hxx
 *
 * Copyright 2013 Andreas Tscharner <andy@vis.ethz.ch>
 *
 * 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 2 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; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 */


/*! \file EditDialog.hxx
 *
 * This file contains the EditDialog class. It is responsible for the
 * logic for the edit dialog of one entry
 *
 * \author Andreas Tscharner
 * \date 2013-08-24
 */


#ifndef __EDITDIALOG_HXX__
#define __EDITDIALOG_HXX__


#include <gtkmm/builder.h>
#include <gtkmm/dialog.h>
#include <gtkmm/comboboxtext.h>
#include "ResColumnModel.hxx"


/*! \class EditDialog
 *  \brief Class to handle the edit dialog for one entry
 *
 * Class that handles the logic for the edit dialog which is responsible
 * for one resource entry
 */
class EditDialog
{
	private:
		Glib::RefPtr<Gtk::Builder> m_refBuilder; //!< Reference to main builder
		Gtk::Dialog *m_editDialog;               //!< Reference to dialog for editing the selected resource
		Gtk::ComboBoxText *m_compSelect;         //!< Reference to compression combobox
		Gtk::ComboBoxText *m_encSelect;          //!< Reference to encryption combobox
		ResColumnModel *m_resColModel;           //!< Reference to instance of column model

		/*! \brief Get integer index from compression name
		 *
		 * This method returns the index of the given compression name
		 * within the static array of all compression names
		 *
		 * \param[in] p_compName Compression name
		 *
		 * \return Index within array
		 */
		inline int compNameToIndex(const char *);
		/*! \brief Get integer index from encryption name
		 *
		 * This method returns the index of the given encryption name within
		 * the static array of all encryption names
		 *
		 * \param[in] p_encName Encryption name
		 *
		 * \return Index within array
		 */
		inline int encNameToIndex(const char *);

		/*! \brief Set the values for the dialog up
		 *
		 * This method sets up the dialog with the given values to edit
		 *
		 * \param[in] p_row Row containing the values to edit
		 */
		void SetUpValues(Gtk::TreeModel::Row);

	protected:
		/*! \brief Signal handler for changed encryption combo box
		 *
		 * This method is called whenever the encryption combo box changes its
		 * value
		 */
		void on_enc_combo_changed(void);

	public:
		/*! \brief Constructor
		 *
		 * The constructor sets up the dialog fo editing with the
		 * given values
		 *
		 * \param[in] p_refBuilder Reference to the builder that loaded the
		 *                         glade GUI file
		 * \param[in] p_resColModel Reference to instance of column model
		 */
		EditDialog(Glib::RefPtr<Gtk::Builder>, ResColumnModel *);
		/*! \brief Destructor
		 *
		 * Frees all the used memory
		 */
		~EditDialog(void);

		/*! \brief Shows the dialog with the given data
		 *
		 * This method shows the dialog with the given data and hides
		 * it again after the user clicked [OK] or [ESC]
		 *
		 * \param[in] p_row Row containing the values
		 *
		 * \return Value of clicked button
		 */
		int show_dialog(Gtk::TreeModel::Row);

		/*! \brief Gets the edited values from  the dialog
		 *
		 * This method gets the edited values from the dialog and uses
		 * them to update the list model
		 *
		 * \param[in] p_row Row to put the edited values
		 */
		void GetEditedValues(Gtk::TreeModel::Row);
};


#endif /* __EDITDIALOG_HXX__ */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.