Commits

Andreas Tscharner  committed 07fc7d1

Move Combo models to list handler and prepare for drop down boxes

  • Participants
  • Parent commits 0fd4d8e

Comments (0)

Files changed (6)

File src/gui/ListHandler.cxx

 {
 	m_listResEntries = p_listResEntries;
 	m_resColModel = p_resColModel;
+
+	FCompColModel = new CompTypeModelColumns();
+	FEncColModel = new EncTypeModelColumns();
+}
+
+ListHandler::~ListHandler()
+{
+	delete FEncColModel;
+	delete FCompColModel;
 }
 
 int ListHandler::newFilesAdded(std::vector<std::string> p_newFiles)
 
 		singleRow[m_resColModel->FUniqueResID] = "";
 		singleRow[m_resColModel->FResFilename] = singleEntry;
-		singleRow[m_resColModel->FCompressType] = "Keine";
+		singleRow[m_resColModel->FCompressTypeName] = "Keine";
+//		singleRow[m_resColModel->FCompChoices] = FCompColModel;
 #ifndef NO_ENCRYPTION
-		singleRow[m_resColModel->FEncryptType] = "Keine";
+		singleRow[m_resColModel->FEncryptTypeName] = "Keine";
+//		singleRow[m_resColModel->FEncChoices] = FEncColModel;
 		singleRow[m_resColModel->FEncPassword] = "";
 #endif
 	};

File src/gui/ListHandler.hxx

 
 #include <gtkmm/liststore.h>
 #include <gtkmm/treeselection.h>
+#include "ComboModels.hxx"
 #include "ResColumnModel.hxx"
 
 
 		ResColumnModel *m_resColModel;                 //!< Class that defines the column model for the list store
 
 	public:
+		CompTypeModelColumns *FCompColModel;//!< Class that defines the column model for the compression type list store
+		EncTypeModelColumns *FEncColModel;  //!< Class that defines the column model for the encryption type list store
+
+	public:
 		/*! \brief Constructor
 		 *
 		 * The constructor expects a reference to the list store and a
 		 *            ResColumnModel
 		 */
 		ListHandler(Glib::RefPtr<Gtk::ListStore>, ResColumnModel *);
+		~ListHandler();
 
 		/*! \brief Add new files to TreeView
 		 *

File src/gui/MainWindow.cxx

 
 
 #include <gtkmm/treeview.h>
+#include <gtkmm/cellrenderercombo.h>
 #include "../include/CompressDecompress.hxx"
 #include "../include/EncryptDecrypt.hxx"
 #include "MainWindow.hxx"
 #include "AddRemoveHandlers.hxx"
+#include "ComboModels.hxx"
 #include "ResColumnModel.hxx"
 
 #ifdef HAVE_CONFIG_H
 {
 	Gtk::TreeView *resFileView;
 	Gtk::TreeModel::Row aRow;
+	Gtk::TreeView::Column *compCol;
+	Gtk::TreeView::Column *encCol;
+	Gtk::CellRendererCombo *compRenderer;
+	Gtk::CellRendererCombo *encRenderer;
 
 
 	m_mainWindow = p_mainWin;
 	m_refBuilder = p_refBuilder;
 
+	m_resColModel = new ResColumnModel();
+	m_listResFiles = Gtk::ListStore::create(*m_resColModel);
 	m_addRemove = new AddRemoveHandlers(m_refBuilder);
+	m_listHandler = new ListHandler(m_listResFiles, m_resColModel);
+	m_addRemove->setListHandler(m_listHandler);
 
-	m_compColModel = new CompTypeModelColumns();
-	m_listCompTypes = Gtk::ListStore::create(*m_compColModel);
+	m_listCompTypes = Gtk::ListStore::create(*m_listHandler->FCompColModel);
 	aRow = *(m_listCompTypes->append());
-	aRow[m_compColModel->FCompTypeName] = "Keine";
-	aRow[m_compColModel->FCompTypeData] = lrc::NoneCompression;
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "Keine";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::NoneCompression;
 	aRow = *(m_listCompTypes->append());
-	aRow[m_compColModel->FCompTypeName] = "zLib";
-	aRow[m_compColModel->FCompTypeData] = lrc::zLibCompression;
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "zLib";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::zLibCompression;
 	aRow = *(m_listCompTypes->append());
-	aRow[m_compColModel->FCompTypeName] = "bzip2";
-	aRow[m_compColModel->FCompTypeData] = lrc::bz2LibCompression;
+	aRow[m_listHandler->FCompColModel->FCompTypeName] = "bzip2";
+	aRow[m_listHandler->FCompColModel->FCompTypeData] = lrc::bz2LibCompression;
 
-	m_encColModel = new EncTypeModelColumns();
-	m_listEncTypes = Gtk::ListStore::create(*m_encColModel);
+	m_listEncTypes = Gtk::ListStore::create(*m_listHandler->FEncColModel);
 	aRow = *(m_listEncTypes->append());
-	aRow[m_encColModel->FEncTypeName] = "Keine";
-	aRow[m_encColModel->FEncTypeData] = lrc::NoneEncryption;
+	aRow[m_listHandler->FEncColModel->FEncTypeName] = "Keine";
+	aRow[m_listHandler->FEncColModel->FEncTypeData] = lrc::NoneEncryption;
 #ifndef NO_ENCRYPTION
 	aRow = *(m_listEncTypes->append());
-	aRow[m_encColModel->FEncTypeName] = "Serpent";
-	aRow[m_encColModel->FEncTypeData] = lrc::SerpentEncryption;
+	aRow[m_listHandler->FEncColModel->FEncTypeName] = "Serpent";
+	aRow[m_listHandler->FEncColModel->FEncTypeData] = lrc::SerpentEncryption;
 #endif
 
-	m_resColModel = new ResColumnModel();
-	m_listResFiles = Gtk::ListStore::create(*m_resColModel);
 	m_refBuilder->get_widget("resTreeView", resFileView);
 	resFileView->set_model(m_listResFiles);
 
 	resFileView->append_column_editable("Resource ID", m_resColModel->FUniqueResID);
 	resFileView->append_column("Dateiname", m_resColModel->FResFilename);
-	resFileView->append_column("Komprimierung", m_resColModel->FCompressType);
+	//resFileView->append_column("Komprimierung", m_resColModel->FCompressTypeName);
+	compCol = Gtk::manage(new Gtk::TreeView::Column("Komprimierung"));
+	compRenderer = Gtk::manage(new Gtk::CellRendererCombo);
+	compCol->pack_start(*compRenderer);
+	resFileView->append_column(*compCol);
+#ifdef GLIBMM_PROPERTIES_ENABLED
+	compCol->add_attribute(compRenderer->property_text(), m_resColModel->FCompressTypeName);
+#else
+	compCol->add_ttribute(*compRenderer, "Keine", m_resColModel->FCompressTypeName);
+#endif /* GLIBMM_PROPERTIES_ENABLED */
+
 #ifndef NO_ENCRYPTION
-	resFileView->append_column("Verschlüsselung", m_resColModel->FEncryptType);
+	//resFileView->append_column("Verschlüsselung", m_resColModel->FEncryptTypeName);
+	encCol = Gtk::manage(new Gtk::TreeView::Column("Verschlüsselung"));
+	encRenderer = Gtk::manage(new Gtk::CellRendererCombo);
+	encCol->pack_start(*encRenderer);
+	resFileView->append_column(*encCol);
+#ifdef GLIBMM_PROPERTIES_ENABLED
+	encCol->add_attribute(encRenderer->property_text(), m_resColModel->FEncryptTypeName);
+#else
+	encCol->add_ttribute(*encRenderer, "Keine", m_resColModel->FEncryptTypeName);
+#endif /* GLIBMM_PROPERTIES_ENABLED */
 	resFileView->append_column_editable("Passwort", m_resColModel->FEncPassword);
-#endif
-
-	m_listHandler = new ListHandler(m_listResFiles, m_resColModel);
-	m_addRemove->setListHandler(m_listHandler);
+#endif /* NO_ENCRYPTION */
 }
 
 MainWindow::~MainWindow()
 	delete m_resColModel;
 	delete m_addRemove;
 
+	//m_refBuilder = nullptr;
 	m_mainWindow = nullptr;
 }

File src/gui/MainWindow.hxx

 #include <gtkmm/liststore.h>
 #include "AddRemoveHandlers.hxx"
 #include "ResColumnModel.hxx"
-#include "ComboModels.hxx"
 #include "ListHandler.hxx"
 
 
 
 		AddRemoveHandlers *m_addRemove;//!< Class instance to handle the "Add" and "Remove" button
 		ResColumnModel *m_resColModel; //!< Class that defines the column model for the list store
-		CompTypeModelColumns *m_compColModel; //!< Class that defines the column model for the compression type list store
-		EncTypeModelColumns *m_encColModel; //!< Class that defines the column model for the encryption type list store
 		ListHandler *m_listHandler;    //!< Class for handling the list in the view
 
 	public:

File src/gui/ResColumnModel.cxx

 {
 	this->add(FUniqueResID);
 	this->add(FResFilename);
-	this->add(FCompressType);
+	this->add(FCompressTypeName);
+	this->add(FCompChoices);
 #ifndef NO_ENCRYPTION
-	this->add(FEncryptType);
+	this->add(FEncryptTypeName);
+	this->add(FEncChoices);
 	this->add(FEncPassword);
 #endif
 }

File src/gui/ResColumnModel.hxx

  * main part of the main window).
  *
  * \author Andreas Tscharner
- * \date 2012-09-01
+ * \date 2012-09-02
  */
 
 
 	public:
 		Gtk::TreeModelColumn<Glib::ustring> FUniqueResID;            //!< ID for resource
 		Gtk::TreeModelColumn<Glib::ustring> FResFilename;            //!< Filename for resource
-		Gtk::TreeModelColumn<Glib::ustring> FCompressType;           //!< Compression type for resource
-		Gtk::TreeModelColumn<Glib::ustring> FEncryptType;            //!< Encryption type for resource
+		Gtk::TreeModelColumn<Glib::ustring> FCompressTypeName;       //!< Compression type for resource
+		Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel>> FCompChoices;  //!< Combobox to select compression
+		Gtk::TreeModelColumn<Glib::ustring> FEncryptTypeName;        //!< Encryption type for resource
+		Gtk::TreeModelColumn<Glib::RefPtr<Gtk::TreeModel>> FEncChoices;   //!< Combobox to select encryption
 		Gtk::TreeModelColumn<Glib::ustring> FEncPassword;            //!< Password if resource is encrypted
 
 	public: