Commit e0553042 authored by Bob Obara's avatar Bob Obara
Browse files

Merge branch 'TabAndViewInfoChanges' into 'master'

Tab and view info changes

This commit adds the ability to set the tab position.  Also created a ViewInfo class that is used to initialize a qtView - this allows us to add additional information for View construction without needing to change the View's Constructor API.

See merge request !26
parents 5e2a9f57 6e7de15c
......@@ -224,8 +224,8 @@ void qtAttributeRefItem::onLaunchAttributeView()
attViewDlg.setWindowTitle(attDef->label().empty() ?
attDef->type().c_str() : attDef->label().c_str());
QVBoxLayout* layout = new QVBoxLayout(&attViewDlg);
qtAttributeView attView(newAttView, &attViewDlg, this->baseView()->uiManager());
smtk::attribute::ViewInfo vinfo(newAttView, &attViewDlg, this->baseView()->uiManager());
qtAttributeView attView(vinfo);
//layout->addWidget(attView.widget())
QDialogButtonBox* buttonBox=new QDialogButtonBox( &attViewDlg );
buttonBox->setStandardButtons(QDialogButtonBox::Ok);
......
......@@ -121,18 +121,17 @@ public:
//----------------------------------------------------------------------------
qtBaseView *
qtAttributeView::createViewWidget(smtk::common::ViewPtr dataObj,
QWidget* p, qtUIManager* uiman)
qtAttributeView::createViewWidget(const ViewInfo &info)
{
qtAttributeView *view = new qtAttributeView(dataObj, p, uiman);
qtAttributeView *view = new qtAttributeView(info);
view->buildUI();
return view;
}
//----------------------------------------------------------------------------
qtAttributeView::
qtAttributeView(smtk::common::ViewPtr dataObj, QWidget* p, qtUIManager* uiman) :
qtBaseView(dataObj, p, uiman)
qtAttributeView(const ViewInfo &info) :
qtBaseView(info)
{
this->Internals = new qtAttributeViewInternals;
}
......
......@@ -36,8 +36,8 @@ namespace smtk
Q_OBJECT
public:
static qtBaseView *createViewWidget(smtk::common::ViewPtr, QWidget* p, qtUIManager* uiman);
qtAttributeView(smtk::common::ViewPtr, QWidget* p, qtUIManager* uiman);
static qtBaseView *createViewWidget(const ViewInfo &info);
qtAttributeView(const ViewInfo &info);
virtual ~qtAttributeView();
const QMap<QString, QList<smtk::attribute::DefinitionPtr> > &attDefinitionMap() const;
......
......@@ -34,14 +34,7 @@ using namespace smtk::attribute;
class qtBaseViewInternals
{
public:
qtBaseViewInternals(smtk::common::ViewPtr dataObject, QWidget* p,
qtUIManager* uiman)
{
this->ParentWidget = p;
this->DataObject = dataObject;
this->UIManager = uiman;
this->FixedLabelWidth = uiman->maxValueLabelLength();
}
qtBaseViewInternals(){}
~qtBaseViewInternals()
{
this->clearWidgets();
......@@ -66,9 +59,6 @@ public:
}
}
smtk::common::ViewPtr DataObject;
QPointer<QWidget> ParentWidget;
QPointer<qtUIManager> UIManager;
QPointer<QComboBox> AdvLevelCombo;
QPointer<QCheckBox> FilterByCheck;
QPointer<QComboBox> ShowCategoryCombo;
......@@ -76,23 +66,25 @@ public:
QPointer<QToolButton> AdvLevelEditButton;
QPointer<QHBoxLayout> TopLevelLayout;
int FixedLabelWidth;
};
//----------------------------------------------------------------------------
qtBaseView::qtBaseView(smtk::common::ViewPtr dataObject, QWidget* p,
qtUIManager* uiman)
qtBaseView::qtBaseView(const ViewInfo &info)
{
this->Internals = new qtBaseViewInternals(dataObject, p, uiman);
this->m_viewInfo = info;
this->Internals = new qtBaseViewInternals;
this->m_fixedLabelWidth =
this->m_viewInfo.m_UIManager->maxValueLabelLength();
this->Widget = NULL;
this->m_advOverlayVisible = false;
this->m_ScrollArea = NULL;
this->m_isTopLevel = false;
this->m_topLevelInitialized = false;
if (dataObject)
if (this->m_viewInfo.m_view)
{
this->m_isTopLevel = dataObject->details().attributeAsBool("TopLevel");
this->m_isTopLevel =
this->m_viewInfo.m_view->details().attributeAsBool("TopLevel");
}
}
......@@ -109,17 +101,6 @@ qtBaseView::~qtBaseView()
}
}
//----------------------------------------------------------------------------
smtk::common::ViewPtr qtBaseView::getObject()
{
return this->Internals->DataObject;
}
//----------------------------------------------------------------------------
QWidget* qtBaseView::parentWidget()
{
return this->Internals->ParentWidget;
}
//----------------------------------------------------------------------------
void qtBaseView::getDefinitions(
smtk::attribute::DefinitionPtr attDef,
......@@ -152,12 +133,6 @@ bool qtBaseView::displayItem(smtk::attribute::ItemPtr item)
this->uiManager()->passItemCategoryCheck(item->definition());
}
//----------------------------------------------------------------------------
qtUIManager* qtBaseView::uiManager()
{
return this->Internals->UIManager;
}
//----------------------------------------------------------------------------
void qtBaseView::valueChanged(smtk::attribute::ItemPtr item)
{
......@@ -165,18 +140,12 @@ void qtBaseView::valueChanged(smtk::attribute::ItemPtr item)
this->uiManager()->onViewUIModified(this, item);
}
//----------------------------------------------------------------------------
int qtBaseView::fixedLabelWidth()
{
return this->Internals->FixedLabelWidth;
}
//----------------------------------------------------------------------------
bool qtBaseView::setFixedLabelWidth(int w)
{
w = std::min(w, this->uiManager()->maxValueLabelLength());
w = std::max(w, this->uiManager()->minValueLabelLength());
this->Internals->FixedLabelWidth = w;
this->m_fixedLabelWidth = w;
return false;
}
//----------------------------------------------------------------------------
......
......@@ -14,9 +14,11 @@
#define __smtk_attribute_qtBaseView_h
#include <QObject>
#include <QList>
#include <QLayout>
#include "smtk/extension/qt/Exports.h"
#include "smtk/PublicPointerDefs.h"
#include <QList>
class qtBaseViewInternals;
class QScrollArea;
......@@ -28,25 +30,49 @@ namespace smtk
class qtUIManager;
class qtItem;
// This struct is used to initialize qtView-based classes
struct SMTKQTEXT_EXPORT ViewInfo
{
ViewInfo(smtk::common::ViewPtr view, QWidget* parent, qtUIManager* uiman):
m_view(view), m_parent(parent), m_UIManager(uiman){}
ViewInfo(smtk::common::ViewPtr view, QWidget* parent, qtUIManager* uiman,
const std::map<std::string, QLayout *> &layoutDict):
m_view(view), m_parent(parent), m_UIManager(uiman), m_layoutDict(layoutDict){}
ViewInfo() {}
smtk::common::ViewPtr m_view; // View Definition
QWidget *m_parent; // Parent Widget of the View
qtUIManager *m_UIManager; // UI Manager
std::map<std::string, QLayout *> m_layoutDict; // Widget Layout Dictionary
};
class SMTKQTEXT_EXPORT qtBaseView : public QObject
{
Q_OBJECT
public:
qtBaseView(smtk::common::ViewPtr, QWidget* parent, qtUIManager* uiman);
qtBaseView(const ViewInfo &info);
virtual ~qtBaseView();
smtk::common::ViewPtr getObject();
QWidget* widget()
smtk::common::ViewPtr getObject() const
{return this->m_viewInfo.m_view;}
QWidget* widget() const
{return this->Widget;}
QWidget* parentWidget();
qtUIManager* uiManager();
QWidget* parentWidget() const
{return this->m_viewInfo.m_parent;}
qtUIManager* uiManager() const
{return this->m_viewInfo.m_UIManager;}
// Description:
// Determines if an item should be displayed
virtual bool displayItem(smtk::attribute::ItemPtr);
virtual void getDefinitions(smtk::attribute::DefinitionPtr attDef,
QList<smtk::attribute::DefinitionPtr>& defs);
int fixedLabelWidth();
int fixedLabelWidth()
{return m_fixedLabelWidth;}
bool setFixedLabelWidth(int w);
bool advanceLevelVisible()
{ return m_advOverlayVisible; }
......@@ -90,7 +116,6 @@ namespace smtk
// Creates the UI related to the view and properly assigns it
// to the parent widget.
virtual void buildUI();
protected:
// Description:
// Creates the main QT Widget that is associated with a View. Typically this
// is the only method a derived View needs to override.
......@@ -104,12 +129,12 @@ namespace smtk
QScrollArea *m_ScrollArea;
bool m_isTopLevel;
bool m_topLevelInitialized;
ViewInfo m_viewInfo;
private:
qtBaseViewInternals *Internals;
bool m_advOverlayVisible;
int m_fixedLabelWidth;
qtBaseViewInternals *Internals;
}; // class
}; // namespace attribute
}; // namespace smtk
......
......@@ -41,27 +41,27 @@ public:
TILED,
GROUP_BOX
};
qtGroupViewInternals() : m_style(TABBED), m_currentTabSelected(0) {}
qtGroupViewInternals() : m_style(TABBED), m_currentTabSelected(0),
m_tabPosition(QTabWidget::East) {}
QList<smtk::attribute::qtBaseView*> ChildViews;
qtGroupViewInternals::Style m_style;
std::vector<smtk::common::ViewPtr> m_views;
int m_currentTabSelected;
QTabWidget::TabPosition m_tabPosition;
};
//----------------------------------------------------------------------------
qtBaseView *
qtGroupView::createViewWidget(smtk::common::ViewPtr dataObj,
QWidget* p, qtUIManager* uiman)
qtGroupView::createViewWidget(const ViewInfo &info)
{
qtGroupView *view = new qtGroupView(dataObj, p, uiman);
qtGroupView *view = new qtGroupView(info);
view->buildUI();
return view;
}
//----------------------------------------------------------------------------
qtGroupView::
qtGroupView(smtk::common::ViewPtr dataObj, QWidget* p,
qtUIManager* uiman) : qtBaseView(dataObj, p, uiman)
qtGroupView(const ViewInfo &info) : qtBaseView(info)
{
this->Internals = new qtGroupViewInternals;
}
......@@ -115,6 +115,23 @@ void qtGroupView::createWidget( )
}
else
{
if (view->details().attribute("TabPosition", val))
{
std::transform(val.begin(), val.end(), val.begin(), ::tolower);
if (val == "north")
{
this->Internals->m_tabPosition = QTabWidget::North;
}
else if (val == "south")
{
this->Internals->m_tabPosition = QTabWidget::South;
}
else if (val == "west")
{
this->Internals->m_tabPosition = QTabWidget::West;
}
//Else leave it as the default which is East
}
QTabWidget *tab = new QTabWidget(this->parentWidget());
tab->setUsesScrollButtons( true );
this->Widget = tab;
......@@ -157,7 +174,12 @@ void qtGroupView::createWidget( )
continue;
}
qtView = this->uiManager()->createView(v, this->Widget);
// Setup the information for the new child view based off of
// this one
smtk::attribute::ViewInfo vinfo = this->m_viewInfo;
vinfo.m_view = v;
vinfo.m_parent = this->Widget;
qtView = this->uiManager()->createView(vinfo);
if (qtView)
{
this->addChildView(qtView);
......@@ -167,7 +189,7 @@ void qtGroupView::createWidget( )
{
tabWidget->setCurrentIndex(this->Internals->m_currentTabSelected);
tabWidget->setIconSize( QSize(24,24) );
tabWidget->setTabPosition(QTabWidget::East);
tabWidget->setTabPosition(this->Internals->m_tabPosition);
}
if(this->Internals->m_style == qtGroupViewInternals::TABBED)
{
......
......@@ -29,8 +29,8 @@ namespace smtk
Q_OBJECT
public:
static qtBaseView *createViewWidget(smtk::common::ViewPtr, QWidget* p, qtUIManager* uiman);
qtGroupView(smtk::common::ViewPtr, QWidget* p, qtUIManager* uiman);
static qtBaseView *createViewWidget(const ViewInfo &info);
qtGroupView(const ViewInfo &info);
virtual ~qtGroupView();
void getChildView(const std::string &viewType,
......
......@@ -39,18 +39,17 @@ public:
//----------------------------------------------------------------------------
qtBaseView *
qtInstancedView::createViewWidget(smtk::common::ViewPtr dataObj,
QWidget* p, qtUIManager* uiman)
qtInstancedView::createViewWidget(const ViewInfo &info)
{
qtInstancedView *view = new qtInstancedView(dataObj, p, uiman);
qtInstancedView *view = new qtInstancedView(info);
view->buildUI();
return view;
}
//----------------------------------------------------------------------------
qtInstancedView::
qtInstancedView(smtk::common::ViewPtr dataObj, QWidget* p, qtUIManager* uiman) :
qtBaseView(dataObj, p, uiman)
qtInstancedView(const ViewInfo &info) :
qtBaseView(info)
{
this->Internals = new qtInstancedViewInternals;
......
......@@ -30,10 +30,9 @@ namespace smtk
Q_OBJECT
public:
static qtBaseView *createViewWidget(smtk::common::ViewPtr view, QWidget* p,
qtUIManager* uiman);
static qtBaseView *createViewWidget(const ViewInfo &info);
qtInstancedView(smtk::common::ViewPtr view , QWidget* p, qtUIManager* uiman);
qtInstancedView(const ViewInfo &info);
virtual ~qtInstancedView();
public slots:
......
......@@ -119,19 +119,16 @@ public:
};
//----------------------------------------------------------------------------
qtBaseView *
qtSimpleExpressionView::createViewWidget(smtk::common::ViewPtr dataObj,
QWidget* p, qtUIManager* uiman)
qtBaseView *qtSimpleExpressionView::createViewWidget(const ViewInfo &info)
{
qtSimpleExpressionView *view = new qtSimpleExpressionView(dataObj, p, uiman);
qtSimpleExpressionView *view = new qtSimpleExpressionView(info);
view->buildUI();
return view;
}
//----------------------------------------------------------------------------
qtSimpleExpressionView::
qtSimpleExpressionView(smtk::common::ViewPtr dataObj, QWidget* p, qtUIManager* uiman) :
qtBaseView(dataObj, p, uiman)
qtSimpleExpressionView::qtSimpleExpressionView(const ViewInfo &info) :
qtBaseView(info)
{
this->Internals = new qtSimpleExpressionViewInternals;
}
......
......@@ -34,10 +34,8 @@ namespace smtk
Q_OBJECT
public:
static qtBaseView *createViewWidget(smtk::common::ViewPtr view, QWidget* p,
qtUIManager* uiman);
qtSimpleExpressionView(smtk::common::ViewPtr view, QWidget* parent,
qtUIManager* uiman);
static qtBaseView *createViewWidget(const ViewInfo &info);
qtSimpleExpressionView(const ViewInfo &info);
virtual ~qtSimpleExpressionView();
void buildSimpleExpression(
......
......@@ -232,7 +232,8 @@ void qtUIManager::initializeUI(QWidget* pWidget, bool useInternalFileBrowser)
}
this->internalInitialize();
this->m_topView = this->createView(this->m_smtkView, pWidget);
smtk::attribute::ViewInfo vinfo(this->m_smtkView, pWidget, this);
this->m_topView = this->createView(vinfo);
if (this->m_topView)
{
this->m_topView->showAdvanceLevel(this->m_currentAdvLevel);
......@@ -1242,18 +1243,23 @@ void qtUIManager::registerViewConstructor(const std::string &vtype,
this->m_constructors[vtype] = f;
}
//----------------------------------------------------------------------------
qtBaseView *qtUIManager::createView(smtk::common::ViewPtr smtkView,
QWidget *pWidget)
qtBaseView *qtUIManager::createView(const ViewInfo &info)
{
if (info.m_UIManager != this)
{
// The view being constructed is not refering to this manager!
return NULL;
}
std::map<std::string, widgetConstructor>::const_iterator it;
it = this->m_constructors.find(smtkView->type());
it = this->m_constructors.find(info.m_view->type());
if (it == this->m_constructors.end())
{
// Constructor for that type could not be found)
return NULL;
}
qtBaseView *qtView = (it->second)(smtkView, pWidget, this);
qtBaseView *qtView = (it->second)(info);
return qtView;
}
......
......@@ -17,6 +17,7 @@
#include "smtk/extension/qt/qtItem.h"
#include "smtk/extension/qt/Exports.h"
#include "smtk/extension/qt/qtBaseView.h" // Needed for ViewInfo definition
#include "smtk/attribute/System.h"
#include <map>
#include <QFont>
......@@ -40,7 +41,7 @@ namespace smtk
class qtBaseView;
class qtUIManager;
typedef qtBaseView* (*widgetConstructor)(smtk::common::ViewPtr, QWidget* p, qtUIManager* uiman);
typedef qtBaseView* (*widgetConstructor)(const ViewInfo &info);
class SMTKQTEXT_EXPORT qtUIManager : public QObject
{
......@@ -156,7 +157,7 @@ namespace smtk
const QList<smtk::attribute::ItemDefinitionPtr>& itemDefs,
const QFont &font);
qtBaseView* createView(smtk::common::ViewPtr smtkView, QWidget *pWidget);
qtBaseView* createView(const ViewInfo &info);
#ifdef _WIN32
#define LINE_BREAKER_STRING "\n";
......
......@@ -97,9 +97,9 @@ int testLifecycle()
AttributePtr att = createAttribForTest(system);
qtUIManager* mgr = new qtUIManager(system);
QWidget* w = new QWidget;
qtBaseView* v = new qtBaseView(
smtk::common::View::New("base", "test view"),
w, mgr);
smtk::attribute::ViewInfo vinfo(smtk::common::View::New("base", "test view"),
w, mgr);
qtBaseView* v = new qtBaseView(vinfo);
qtAttribute* qatt = new qtAttribute(att, w, v);
delete qatt;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment