[qet] [1444] Added File > New in the title block template editor

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 1444
Author:   xavier
Date:     2012-01-09 19:50:26 +0100 (Mon, 09 Jan 2012)
Log Message:
-----------
Added File > New in the title block template editor

Modified Paths:
--------------
    branches/0.3/sources/titleblock/qettemplateeditor.cpp
    branches/0.3/sources/titleblock/qettemplateeditor.h
    branches/0.3/sources/titleblock/templatelocationchooser.cpp
    branches/0.3/sources/titleblock/templatelocationchooser.h

Modified: branches/0.3/sources/titleblock/qettemplateeditor.cpp
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.cpp	2012-01-08 23:36:50 UTC (rev 1443)
+++ branches/0.3/sources/titleblock/qettemplateeditor.cpp	2012-01-09 18:50:26 UTC (rev 1444)
@@ -160,11 +160,22 @@
 }
 
 /**
+	Launch a new title block template editor.
+*/
+void QETTitleBlockTemplateEditor::newTemplate() {
+	QETTitleBlockTemplateEditor *qet_template_editor = new QETTitleBlockTemplateEditor();
+	qet_template_editor -> edit(TitleBlockTemplateLocation());
+	qet_template_editor -> showMaximized();
+	
+}
+
+/**
 	Initialize the various actions.
 */
 void QETTitleBlockTemplateEditor::initActions() {
 	QETApp *qet_app = QETApp::instance();
 	
+	new_            = new QAction(QET::Icons::DocumentNew,          tr("&Nouveau",                     "menu entry"), this);
 	save_           = new QAction(QET::Icons::DocumentSave,         tr("&Enregistrer",                 "menu entry"), this);
 	save_as_        = new QAction(QET::Icons::DocumentSave,         tr("Enregistrer sous",             "menu entry"), this);
 	quit_           = new QAction(QET::Icons::ApplicationExit,      tr("&Quitter",                     "menu entry"), this);
@@ -178,6 +189,7 @@
 	merge_cells_    = new QAction(                                  tr("&Fusionner les cellules",      "menu entry"), this);
 	split_cell_     = new QAction(                                  tr("&S\351parer les cellules",     "menu entry"), this);
 	
+	new_              -> setShortcut(QKeySequence::New);
 	save_             -> setShortcut(QKeySequence::Save);
 	quit_             -> setShortcut(QKeySequence(tr("Ctrl+Q", "shortcut to quit")));
 	merge_cells_      -> setShortcut(QKeySequence(tr("Ctrl+K", "shortcut to merge cells")));
@@ -191,6 +203,7 @@
 	about_qet_    -> setStatusTip(tr("Affiche des informations sur QElectroTech",                       "status bar tip"));
 	about_qt_     -> setStatusTip(tr("Affiche des informations sur la biblioth\350que Qt",              "status bar tip"));
 	
+	connect(new_,             SIGNAL(triggered()), this,     SLOT(newTemplate()));
 	connect(save_,            SIGNAL(triggered()), this,     SLOT(save()));
 	connect(save_as_,         SIGNAL(triggered()), this,     SLOT(saveAs()));
 	connect(quit_,            SIGNAL(triggered()), this,     SLOT(quit()));
@@ -221,6 +234,7 @@
 	display_menu_ -> setTearOffEnabled(true);
 	help_menu_    -> setTearOffEnabled(true);
 	
+	file_menu_    -> addAction(new_);
 	file_menu_    -> addAction(save_);
 	file_menu_    -> addAction(save_as_);
 	file_menu_    -> addSeparator();

Modified: branches/0.3/sources/titleblock/qettemplateeditor.h
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.h	2012-01-08 23:36:50 UTC (rev 1443)
+++ branches/0.3/sources/titleblock/qettemplateeditor.h	2012-01-09 18:50:26 UTC (rev 1444)
@@ -49,7 +49,7 @@
 	/// menus TODO
 	QMenu *file_menu_, *edit_menu_,/* *paste_from_menu_, */*display_menu_,/* *tools_menu_,*/ *config_menu_, *help_menu_;
 	/// actions
-	QAction *save_, *save_as_, *quit_, *configure_, *about_qt_, *about_qet_, *merge_cells_, *split_cell_;
+	QAction *new_, *save_, *save_as_, *quit_, *configure_, *about_qt_, *about_qet_, *merge_cells_, *split_cell_;
 	QAction *zoom_in_, *zoom_out_, *zoom_fit_, *zoom_reset_;
 	/// Location of the currently edited template
 	TitleBlockTemplateLocation location_;
@@ -88,6 +88,7 @@
 	bool editCopyOf(const TitleBlockTemplate *);
 	bool edit(TitleBlockTemplate *);
 	void editLogos();
+	void newTemplate();
 	void save();
 	void saveAs();
 	void quit();

Modified: branches/0.3/sources/titleblock/templatelocationchooser.cpp
===================================================================
--- branches/0.3/sources/titleblock/templatelocationchooser.cpp	2012-01-08 23:36:50 UTC (rev 1443)
+++ branches/0.3/sources/titleblock/templatelocationchooser.cpp	2012-01-09 18:50:26 UTC (rev 1444)
@@ -51,7 +51,10 @@
 	@param location to be displayed by this widget
 */
 void TitleBlockTemplateLocationChooser::setLocation(const TitleBlockTemplateLocation &location) {
-	collections_ -> setCurrentIndex(collections_index_.keys(location.parentCollection()).first());
+	// hack: if o suitable index was found, set it to 1, which is supposed to be the user collection
+	int index = indexForCollection(location.parentCollection());
+	if (index == -1 && collections_ -> count() > 1) index = 1;
+	collections_ -> setCurrentIndex(index);
 	
 	if (!location.name().isEmpty()) {
 		int template_index = templates_ -> findText(location.name());
@@ -84,6 +87,16 @@
 }
 
 /**
+	@param coll A Title block templates collection which we want to know the index within the combo box of this dialog.
+	@return -1 if the collection is unknown to this dialog, or the index of \a coll
+*/
+int TitleBlockTemplateLocationChooser::indexForCollection(TitleBlockTemplatesCollection *coll) const {
+	QList<int> indexes = collections_index_.keys(coll);
+	if (indexes.count()) return(indexes.first());
+	return(-1);
+}
+
+/**
 	Update the collections list
 */
 void TitleBlockTemplateLocationChooser::updateCollections() {

Modified: branches/0.3/sources/titleblock/templatelocationchooser.h
===================================================================
--- branches/0.3/sources/titleblock/templatelocationchooser.h	2012-01-08 23:36:50 UTC (rev 1443)
+++ branches/0.3/sources/titleblock/templatelocationchooser.h	2012-01-09 18:50:26 UTC (rev 1444)
@@ -40,8 +40,10 @@
 	TitleBlockTemplatesCollection *collection() const;
 	QString name() const;
 	void setLocation(const TitleBlockTemplateLocation &);
+	
 	private:
 	void init();
+	int indexForCollection(TitleBlockTemplatesCollection *) const;
 	
 	// slots
 	private slots:


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/