mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 16:50:53 +01:00
Added a "+" button to add a new diagram to an edited project.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1902 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -44,36 +44,9 @@ ProjectView::ProjectView(QETProject *project, QWidget *parent) :
|
|||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
project_(0)
|
project_(0)
|
||||||
{
|
{
|
||||||
setObjectName("ProjectView");
|
initActions();
|
||||||
setWindowIcon(QET::Icons::ProjectFile);
|
initWidgets();
|
||||||
|
initLayout();
|
||||||
// construit le widget "fallback"
|
|
||||||
fallback_widget_ = new QWidget();
|
|
||||||
QVBoxLayout *fallback_widget_layout_ = new QVBoxLayout(fallback_widget_);
|
|
||||||
QLabel *label_widget = new QLabel(tr("Ce projet ne contient aucun sch\351ma"));
|
|
||||||
label_widget -> setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
|
||||||
fallback_widget_layout_ -> addWidget(label_widget);
|
|
||||||
|
|
||||||
tabs_ = new QETTabWidget();
|
|
||||||
tabs_ -> setMovable(true);
|
|
||||||
connect(tabs_, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
|
||||||
connect(tabs_, SIGNAL(tabDoubleClicked(int)), this, SLOT(tabDoubleClicked(int)));
|
|
||||||
connect(tabs_, SIGNAL(firstTabInserted()), this, SLOT(firstTabInserted()));
|
|
||||||
connect(tabs_, SIGNAL(lastTabRemoved()), this, SLOT(lastTabRemoved()));
|
|
||||||
connect(tabs_, SIGNAL(tabMoved(int, int)), this, SLOT(tabMoved(int, int)));
|
|
||||||
|
|
||||||
layout_ = new QVBoxLayout(this);
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
layout_ -> setContentsMargins(0, 8, 0, 0);
|
|
||||||
#else
|
|
||||||
layout_ -> setContentsMargins(0, 0, 0, 0);
|
|
||||||
#endif
|
|
||||||
layout_ -> setSpacing(0);
|
|
||||||
layout_ -> addWidget(fallback_widget_);
|
|
||||||
layout_ -> addWidget(tabs_);
|
|
||||||
|
|
||||||
fallback_widget_ -> setVisible(false);
|
|
||||||
tabs_ -> setVisible(false);
|
|
||||||
|
|
||||||
setProject(project);
|
setProject(project);
|
||||||
}
|
}
|
||||||
@@ -693,6 +666,68 @@ bool ProjectView::saveAs() {
|
|||||||
return(save());
|
return(save());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize actions for this widget.
|
||||||
|
*/
|
||||||
|
void ProjectView::initActions() {
|
||||||
|
add_new_diagram_ = new QAction(QET::Icons::Add, tr("Ajouter un sch\351ma"), this);
|
||||||
|
connect(add_new_diagram_, SIGNAL(triggered()), this, SLOT(addNewDiagram()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize child widgets for this widget.
|
||||||
|
*/
|
||||||
|
void ProjectView::initWidgets() {
|
||||||
|
setObjectName("ProjectView");
|
||||||
|
setWindowIcon(QET::Icons::ProjectFile);
|
||||||
|
|
||||||
|
// initialize the "fallback" widget
|
||||||
|
fallback_widget_ = new QWidget();
|
||||||
|
fallback_label_ = new QLabel(
|
||||||
|
tr(
|
||||||
|
"Ce projet ne contient aucun sch\351ma",
|
||||||
|
"label displayed when a project contains no diagram"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
fallback_label_ -> setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
||||||
|
|
||||||
|
// initialize tabs
|
||||||
|
tabs_ = new QETTabWidget();
|
||||||
|
tabs_ -> setMovable(true);
|
||||||
|
|
||||||
|
QToolButton *add_new_diagram_button = new QToolButton();
|
||||||
|
add_new_diagram_button -> setDefaultAction(add_new_diagram_);
|
||||||
|
add_new_diagram_button -> setAutoRaise(true);
|
||||||
|
tabs_ -> setCornerWidget(add_new_diagram_button, Qt::TopRightCorner);
|
||||||
|
|
||||||
|
connect(tabs_, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
||||||
|
connect(tabs_, SIGNAL(tabDoubleClicked(int)), this, SLOT(tabDoubleClicked(int)));
|
||||||
|
connect(tabs_, SIGNAL(firstTabInserted()), this, SLOT(firstTabInserted()));
|
||||||
|
connect(tabs_, SIGNAL(lastTabRemoved()), this, SLOT(lastTabRemoved()));
|
||||||
|
connect(tabs_, SIGNAL(tabMoved(int, int)), this, SLOT(tabMoved(int, int)));
|
||||||
|
|
||||||
|
fallback_widget_ -> setVisible(false);
|
||||||
|
tabs_ -> setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize layout for this widget.
|
||||||
|
*/
|
||||||
|
void ProjectView::initLayout() {
|
||||||
|
QVBoxLayout *fallback_widget_layout_ = new QVBoxLayout(fallback_widget_);
|
||||||
|
fallback_widget_layout_ -> addWidget(fallback_label_);
|
||||||
|
|
||||||
|
layout_ = new QVBoxLayout(this);
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
layout_ -> setContentsMargins(0, 8, 0, 0);
|
||||||
|
#else
|
||||||
|
layout_ -> setContentsMargins(0, 0, 0, 0);
|
||||||
|
#endif
|
||||||
|
layout_ -> setSpacing(0);
|
||||||
|
layout_ -> addWidget(fallback_widget_);
|
||||||
|
layout_ -> addWidget(tabs_);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Charge les schemas du projet
|
Charge les schemas du projet
|
||||||
*/
|
*/
|
||||||
@@ -725,8 +760,12 @@ void ProjectView::updateWindowTitle() {
|
|||||||
du mode lecture seule.
|
du mode lecture seule.
|
||||||
*/
|
*/
|
||||||
void ProjectView::adjustReadOnlyState() {
|
void ProjectView::adjustReadOnlyState() {
|
||||||
// on empeche l'utilisateur de deplacer les onglets
|
bool editable = !(project_ -> isReadOnly());
|
||||||
tabs_ -> setMovable(!(project_ -> isReadOnly()));
|
|
||||||
|
// prevent users from moving existing diagrams
|
||||||
|
tabs_ -> setMovable(editable);
|
||||||
|
// prevent users from adding new diagrams
|
||||||
|
add_new_diagram_ -> setEnabled(editable);
|
||||||
|
|
||||||
// on met a jour le titre du widget, qui reflete l'etat de lecture seule
|
// on met a jour le titre du widget, qui reflete l'etat de lecture seule
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ class ProjectView : public QWidget {
|
|||||||
void editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool);
|
void editTitleBlockTemplate(const TitleBlockTemplateLocation &, bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initActions();
|
||||||
|
void initWidgets();
|
||||||
|
void initLayout();
|
||||||
void loadDiagrams();
|
void loadDiagrams();
|
||||||
DiagramView *findDiagram(Diagram *);
|
DiagramView *findDiagram(Diagram *);
|
||||||
void rebuildDiagramsMap();
|
void rebuildDiagramsMap();
|
||||||
@@ -101,9 +104,11 @@ class ProjectView : public QWidget {
|
|||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
|
QAction *add_new_diagram_;
|
||||||
QETProject *project_;
|
QETProject *project_;
|
||||||
QVBoxLayout *layout_;
|
QVBoxLayout *layout_;
|
||||||
QWidget *fallback_widget_;
|
QWidget *fallback_widget_;
|
||||||
|
QLabel *fallback_label_;
|
||||||
QETTabWidget *tabs_;
|
QETTabWidget *tabs_;
|
||||||
QMap<int, DiagramView *> diagram_ids_;
|
QMap<int, DiagramView *> diagram_ids_;
|
||||||
QList<DiagramView *> diagrams_;
|
QList<DiagramView *> diagrams_;
|
||||||
|
|||||||
Reference in New Issue
Block a user