Source

lrc / src / gui / ListHandler.hxx

/*
 * ListHandler.hxx
 *
 * Copyright 2012, 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 ListHandler.hxx
 *
 * This file contains the definition of the ListHandler class. This class is
 * responsible to manage the list in the TreeView, especially for adding and
 * removing new entries
 *
 * \author Andreas Tscharner
 * \date 2013-03-10
 */


#ifndef __LISTHANDLER_HXX__
#define __LISTHANDLER_HXX__


#include <gtkmm/liststore.h>
#include <gtkmm/treeselection.h>
#include "ResColumnModel.hxx"


/*! \class ListHandler
 *  \brief Class to handle the list in the Gtk::TreeView
 *
 * This class handles the list in the Gtk::TreeView. It is especially
 * responsible to add new entries to the list and remove the ones that are
 * no longer used. Finally it provides the data as resource entries if the
 * user selects "Save (as)"
 */
class ListHandler
{
	private:
		Glib::RefPtr<Gtk::ListStore> m_listResEntries; //!< Reference to list store for the main list view
		ResColumnModel *m_resColModel;                 //!< Class that defines the column model for the list store

	public:
		/*! \brief Constructor
		 *
		 * The constructor expects a reference to the list store and a
		 * pointer to the instance of the column model
		 *
		 * \param[in] p_listResEntries Reference to TreeView ListStore
		 * \param[in] p_resColModel Pointer to single instance of
		 *            ResColumnModel
		 */
		ListHandler(Glib::RefPtr<Gtk::ListStore>, ResColumnModel *);
		~ListHandler();

		/*! \brief Add new files to TreeView
		 *
		 * This method adds the new (given) files into the TreeView. It
		 * checks for duplicates and removes them if any
		 *
		 * \param[in] p_newFiles List of (new) files
		 *
		 * \retval NO_ERROR Files successfully added
		 */
		int newFilesAdded(std::vector<std::string>);

		/*! \brief Remove the selected resource
		 *
		 * This method removes the currently selected resources from the list
		 * without confirmation
		 *
		 * \param[in] p_selection Selection in view
		 *
		 * \retval NO_ERROR Resource successfully removed
		 */
		int removeSelected(Glib::RefPtr<Gtk::TreeSelection>);

		/*! \brief Return desired resource entry
		 *
		 * This method returns the desired resource entry from the list
		 *
		 * \param[in] p_treemodelPath Path to entry within the tree model
		 *
		 * \return Resource entry as row of the tree model
		 */
		Gtk::TreeModel::Row getResourceEntry(Gtk::TreeModel::Path);
};


#endif /* __LISTHANDLER_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.