Gui: ComboView always must be created because it includes the task view.

This commit is contained in:
wmayer
2020-02-08 14:52:28 +01:00
parent 7308db6331
commit 85aeef9384
3 changed files with 38 additions and 28 deletions

View File

@@ -44,8 +44,11 @@ using namespace Gui::DockWnd;
/* TRANSLATOR Gui::DockWnd::ComboView */
ComboView::ComboView(Gui::Document* pcDocument, QWidget *parent)
: DockWindow(pcDocument,parent), oldTabIndex(0)
ComboView::ComboView(bool showModel, Gui::Document* pcDocument, QWidget *parent)
: DockWindow(pcDocument,parent)
, oldTabIndex(0)
, modelIndex(-1)
, taskIndex(-1)
{
setWindowTitle(tr("Combo View"));
@@ -59,21 +62,23 @@ ComboView::ComboView(Gui::Document* pcDocument, QWidget *parent)
tabs->setTabPosition(QTabWidget::North);
pLayout->addWidget( tabs, 0, 0 );
// splitter between tree and property view
QSplitter *splitter = new QSplitter();
splitter->setOrientation(Qt::Vertical);
if (showModel) {
// splitter between tree and property view
QSplitter *splitter = new QSplitter();
splitter->setOrientation(Qt::Vertical);
tree = new TreePanel("ComboView", this);
splitter->addWidget(tree);
tree = new TreePanel("ComboView", this);
splitter->addWidget(tree);
// property view
prop = new PropertyView(this);
splitter->addWidget(prop);
tabs->addTab(splitter,trUtf8("Model"));
// property view
prop = new PropertyView(this);
splitter->addWidget(prop);
modelIndex = tabs->addTab(splitter,trUtf8("Model"));
}
// task panel
taskPanel = new Gui::TaskView::TaskView(this);
tabs->addTab(taskPanel, trUtf8("Tasks"));
taskIndex = tabs->addTab(taskPanel, trUtf8("Tasks"));
// task panel
//projectView = new Gui::ProjectWidget(this);
@@ -90,10 +95,16 @@ void ComboView::showDialog(Gui::TaskView::TaskDialog *dlg)
// switch to the TaskView tab
oldTabIndex = tabs->currentIndex();
tabs->setCurrentIndex(1);
tabs->setTabIcon(1, icon);
tabs->setCurrentIndex(taskIndex);
tabs->setTabIcon(taskIndex, icon);
// set the dialog
taskPanel->showDialog(dlg);
// force to show the combo view
if (modelIndex < 0) {
if (parentWidget())
parentWidget()->raise();
}
}
void ComboView::closeDialog()
@@ -108,26 +119,26 @@ void ComboView::closedDialog()
// dialog has been closed
tabs->setCurrentIndex(oldTabIndex);
tabs->setTabIcon(1, icon);
tabs->setTabIcon(taskIndex, icon);
}
void ComboView::showTreeView()
{
// switch to the tree view
tabs->setCurrentIndex(0);
tabs->setCurrentIndex(modelIndex);
}
void ComboView::showTaskView()
{
// switch to the task view
tabs->setCurrentIndex(1);
tabs->setCurrentIndex(taskIndex);
}
void ComboView::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
tabs->setTabText(0, trUtf8("Model"));
tabs->setTabText(1, trUtf8("Tasks"));
tabs->setTabText(modelIndex, trUtf8("Model"));
tabs->setTabText(taskIndex, trUtf8("Tasks"));
//tabs->setTabText(2, trUtf8("Project"));
}

View File

@@ -70,7 +70,7 @@ public:
* A constructor.
* A more elaborate description of the constructor.
*/
ComboView(Gui::Document* pcDocument, QWidget *parent=0);
ComboView(bool showModel, Gui::Document* pcDocument, QWidget *parent=0);
/**
* A destructor.
@@ -93,9 +93,10 @@ protected:
void closedDialog();
void changeEvent(QEvent *e);
int oldTabIndex;
private:
int oldTabIndex;
int modelIndex;
int taskIndex;
QTabWidget * tabs;
Gui::PropertyView * prop;
Gui::TreePanel * tree;

View File

@@ -441,12 +441,10 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
enable = group->GetBool("Enabled", true);
}
if (enable) {
ComboView* pcComboView = new ComboView(0, this);
pcComboView->setObjectName(QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Combo View")));
pcComboView->setMinimumWidth(150);
pDockMgr->registerDockWindow("Std_ComboView", pcComboView);
}
ComboView* pcComboView = new ComboView(enable, 0, this);
pcComboView->setObjectName(QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Combo View")));
pcComboView->setMinimumWidth(150);
pDockMgr->registerDockWindow("Std_ComboView", pcComboView);
}
#if QT_VERSION < 0x040500