19 changed files with 262 additions and 14 deletions
			
			
		@ -0,0 +1,31 @@ | 
				
			|||||
 | 
					#include "drawerviewmodel.h" | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					#include "sampleviewmodel.h" | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					DrawerViewModel::DrawerViewModel(QObject *parent) : | 
				
			||||
 | 
						ViewModel(parent), | 
				
			||||
 | 
						_navModel(new QStandardItemModel(0, 1, this)) | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						_navModel->appendRow(new QStandardItem(tr("Main Sample"))); | 
				
			||||
 | 
					} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					DrawerViewModel::~DrawerViewModel() | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						qInfo(Q_FUNC_INFO); | 
				
			||||
 | 
					} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					QStandardItemModel *DrawerViewModel::navModel() const | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						return _navModel; | 
				
			||||
 | 
					} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					void DrawerViewModel::open(int index) | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						switch (index) { | 
				
			||||
 | 
						case 0: | 
				
			||||
 | 
							show<SampleViewModel>(); | 
				
			||||
 | 
							break; | 
				
			||||
 | 
						default: | 
				
			||||
 | 
							break; | 
				
			||||
 | 
						} | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,26 @@ | 
				
			|||||
 | 
					#ifndef DRAWERVIEWMODEL_H | 
				
			||||
 | 
					#define DRAWERVIEWMODEL_H | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					#include <QtGui/QStandardItemModel> | 
				
			||||
 | 
					#include <QtMvvmCore/ViewModel> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					class DrawerViewModel : public QtMvvm::ViewModel | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						Q_OBJECT | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						Q_PROPERTY(QStandardItemModel* navModel READ navModel CONSTANT) | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					public: | 
				
			||||
 | 
						Q_INVOKABLE explicit DrawerViewModel(QObject *parent = nullptr); | 
				
			||||
 | 
						~DrawerViewModel(); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						QStandardItemModel* navModel() const; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					public Q_SLOTS: | 
				
			||||
 | 
						void open(int index); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					private: | 
				
			||||
 | 
						QStandardItemModel* _navModel; | 
				
			||||
 | 
					}; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					#endif // DRAWERVIEWMODEL_H
 | 
				
			||||
@ -0,0 +1,10 @@ | 
				
			|||||
 | 
					#include "tabviewmodel.h" | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					TabViewModel::TabViewModel(QObject *parent) : | 
				
			||||
 | 
						ViewModel(parent) | 
				
			||||
 | 
					{} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					TabViewModel::~TabViewModel() | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						qInfo(Q_FUNC_INFO); | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,15 @@ | 
				
			|||||
 | 
					#ifndef TABVIEWMODEL_H | 
				
			||||
 | 
					#define TABVIEWMODEL_H | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					#include <QtMvvmCore/ViewModel> | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					class TabViewModel : public QtMvvm::ViewModel | 
				
			||||
 | 
					{ | 
				
			||||
 | 
						Q_OBJECT | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					public: | 
				
			||||
 | 
						Q_INVOKABLE explicit TabViewModel(QObject *parent = nullptr); | 
				
			||||
 | 
						~TabViewModel(); | 
				
			||||
 | 
					}; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					#endif // TABVIEWMODEL_H
 | 
				
			||||
@ -0,0 +1,26 @@ | 
				
			|||||
 | 
					import QtQuick 2.10 | 
				
			||||
 | 
					import QtQuick.Controls 2.3 | 
				
			||||
 | 
					import de.skycoder42.QtMvvm.Sample 1.0 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					ListView { | 
				
			||||
 | 
						id: drawerView | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						property DrawerViewModel viewModel: null | 
				
			||||
 | 
						property Drawer drawer: null | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						model: viewModel.navModel | 
				
			||||
 | 
						anchors.fill: parent | 
				
			||||
 | 
						clip: true | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						ScrollBar.vertical: ScrollBar {} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						delegate: ItemDelegate { | 
				
			||||
 | 
							width: parent.width | 
				
			||||
 | 
							text: viewModel.navModel.data(viewModel.navModel.index(index, 0))  //because "display" is not accessible | 
				
			||||
 | 
					
 | 
				
			||||
 | 
							onClicked: { | 
				
			||||
 | 
								viewModel.open(index); | 
				
			||||
 | 
								drawer.close(); | 
				
			||||
 | 
							} | 
				
			||||
 | 
						} | 
				
			||||
 | 
					} | 
				
			||||
@ -0,0 +1,59 @@ | 
				
			|||||
 | 
					import QtQuick 2.10 | 
				
			||||
 | 
					import QtQuick.Controls 2.3 | 
				
			||||
 | 
					import QtQuick.Layouts 1.3 | 
				
			||||
 | 
					import de.skycoder42.QtMvvm.Core 1.0 | 
				
			||||
 | 
					import de.skycoder42.QtMvvm.Quick 1.0 | 
				
			||||
 | 
					import de.skycoder42.quickextras 2.0 | 
				
			||||
 | 
					import de.skycoder42.QtMvvm.Sample 1.0 | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					Page { | 
				
			||||
 | 
						id: tabView | 
				
			||||
 | 
						property TabViewModel viewModel: null | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						header: ActionBar { | 
				
			||||
 | 
							id: bar | 
				
			||||
 | 
							showMenuButton: true | 
				
			||||
 | 
							//showMenuAsBack: true | 
				
			||||
 | 
							title: qsTr("Sample") | 
				
			||||
 | 
					
 | 
				
			||||
 | 
							onMenuButtonClicked: QuickPresenter.toggleDrawer() | 
				
			||||
 | 
					
 | 
				
			||||
 | 
							tabBar: TabBar { | 
				
			||||
 | 
								id: tabBar | 
				
			||||
 | 
								currentIndex: swipe.currentIndex | 
				
			||||
 | 
					
 | 
				
			||||
 | 
								TabButton { | 
				
			||||
 | 
									text: "Test 1" | 
				
			||||
 | 
								} | 
				
			||||
 | 
								TabButton { | 
				
			||||
 | 
									text: "Test 2" | 
				
			||||
 | 
								} | 
				
			||||
 | 
							} | 
				
			||||
 | 
						} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						PresenterProgress {} | 
				
			||||
 | 
					
 | 
				
			||||
 | 
						SwipeView { | 
				
			||||
 | 
							id: swipe | 
				
			||||
 | 
							anchors.fill: parent | 
				
			||||
 | 
							currentIndex: bar.tabBarItem.currentIndex | 
				
			||||
 | 
					
 | 
				
			||||
 | 
							Pane { | 
				
			||||
 | 
								id: firstPage | 
				
			||||
 | 
					
 | 
				
			||||
 | 
								Switch { | 
				
			||||
 | 
									anchors.centerIn: parent | 
				
			||||
 | 
									checked: true | 
				
			||||
 | 
									text: qsTr("Click me!") | 
				
			||||
 | 
								} | 
				
			||||
 | 
							} | 
				
			||||
 | 
							Pane { | 
				
			||||
 | 
								id: secondPage | 
				
			||||
 | 
					
 | 
				
			||||
 | 
								Switch { | 
				
			||||
 | 
									anchors.centerIn: parent | 
				
			||||
 | 
									text: qsTr("Click me, too!") | 
				
			||||
 | 
								} | 
				
			||||
 | 
							} | 
				
			||||
 | 
						} | 
				
			||||
 | 
					} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue