mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-18 01:09:59 +01:00
Added File > New in the title block template editor
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1444 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -159,12 +159,23 @@ void QETTitleBlockTemplateEditor::editLogos() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
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 @@ void QETTitleBlockTemplateEditor::initActions() {
|
||||
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 @@ void QETTitleBlockTemplateEditor::initActions() {
|
||||
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 @@ void QETTitleBlockTemplateEditor::initMenus() {
|
||||
display_menu_ -> setTearOffEnabled(true);
|
||||
help_menu_ -> setTearOffEnabled(true);
|
||||
|
||||
file_menu_ -> addAction(new_);
|
||||
file_menu_ -> addAction(save_);
|
||||
file_menu_ -> addAction(save_as_);
|
||||
file_menu_ -> addSeparator();
|
||||
|
||||
@@ -49,7 +49,7 @@ class QETTitleBlockTemplateEditor : public QMainWindow {
|
||||
/// 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 @@ class QETTitleBlockTemplateEditor : public QMainWindow {
|
||||
bool editCopyOf(const TitleBlockTemplate *);
|
||||
bool edit(TitleBlockTemplate *);
|
||||
void editLogos();
|
||||
void newTemplate();
|
||||
void save();
|
||||
void saveAs();
|
||||
void quit();
|
||||
|
||||
@@ -51,7 +51,10 @@ QString TitleBlockTemplateLocationChooser::name() const {
|
||||
@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());
|
||||
@@ -83,6 +86,16 @@ void TitleBlockTemplateLocationChooser::init() {
|
||||
setLayout(form_layout);
|
||||
}
|
||||
|
||||
/**
|
||||
@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
|
||||
*/
|
||||
|
||||
@@ -40,8 +40,10 @@ class TitleBlockTemplateLocationChooser : public QWidget {
|
||||
TitleBlockTemplatesCollection *collection() const;
|
||||
QString name() const;
|
||||
void setLocation(const TitleBlockTemplateLocation &);
|
||||
|
||||
private:
|
||||
void init();
|
||||
int indexForCollection(TitleBlockTemplatesCollection *) const;
|
||||
|
||||
// slots
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user