Changeset View
Changeset View
Standalone View
Standalone View
src/ViewContainer.cpp
Show First 20 Lines • Show All 824 Lines • ▼ Show 20 Line(s) | 823 | foreach (QWidget *widget, widgetsForItem(item)) { | |||
---|---|---|---|---|---|
825 | _tabBar->setTabIcon(index, item->icon()); | 825 | _tabBar->setTabIcon(index, item->icon()); | ||
826 | } | 826 | } | ||
827 | } | 827 | } | ||
828 | 828 | | |||
829 | ViewManager *TabbedViewContainer::connectedViewManager() | 829 | ViewManager *TabbedViewContainer::connectedViewManager() | ||
830 | { | 830 | { | ||
831 | return _connectedViewManager; | 831 | return _connectedViewManager; | ||
832 | } | 832 | } | ||
833 | | ||||
834 | StackedViewContainer::StackedViewContainer(QObject *parent) : | | |||
835 | ViewContainer(NavigationPositionTop, parent), | | |||
836 | _containerWidget(nullptr), | | |||
837 | _stackWidget(nullptr) | | |||
838 | { | | |||
839 | _containerWidget = new QWidget; | | |||
840 | auto layout = new QVBoxLayout(_containerWidget); | | |||
841 | | ||||
842 | _stackWidget = new QStackedWidget(_containerWidget); | | |||
843 | | ||||
844 | searchBar()->setParent(_containerWidget); | | |||
845 | layout->addWidget(searchBar()); | | |||
846 | layout->addWidget(_stackWidget); | | |||
847 | layout->setContentsMargins(0, 0, 0, 0); | | |||
848 | } | | |||
849 | | ||||
850 | StackedViewContainer::~StackedViewContainer() | | |||
851 | { | | |||
852 | if (!_containerWidget.isNull()) { | | |||
853 | _containerWidget->deleteLater(); | | |||
854 | } | | |||
855 | } | | |||
856 | | ||||
857 | QWidget *StackedViewContainer::containerWidget() const | | |||
858 | { | | |||
859 | return _containerWidget; | | |||
860 | } | | |||
861 | | ||||
862 | QWidget *StackedViewContainer::activeView() const | | |||
863 | { | | |||
864 | return _stackWidget->currentWidget(); | | |||
865 | } | | |||
866 | | ||||
867 | void StackedViewContainer::setActiveView(QWidget *view) | | |||
868 | { | | |||
869 | _stackWidget->setCurrentWidget(view); | | |||
870 | } | | |||
871 | | ||||
872 | void StackedViewContainer::addViewWidget(QWidget *view, int) | | |||
873 | { | | |||
874 | _stackWidget->addWidget(view); | | |||
875 | } | | |||
876 | | ||||
877 | void StackedViewContainer::removeViewWidget(QWidget *view) | | |||
878 | { | | |||
879 | if (_stackWidget.isNull()) { | | |||
880 | return; | | |||
881 | } | | |||
882 | _stackWidget->removeWidget(view); | | |||
883 | } | |