]> Johnzone git - learnqt-cm.git/commitdiff
finish chapter 3 user interface
authorJohn Janus <mail@johnzone.org>
Wed, 15 Aug 2018 20:15:19 +0000 (22:15 +0200)
committerJohn Janus <mail@johnzone.org>
Wed, 15 Aug 2018 20:15:19 +0000 (22:15 +0200)
14 files changed:
cm-lib/cm-lib.pro
cm-lib/src/controllers/master-controller.cpp
cm-lib/src/controllers/master-controller.h
cm-lib/src/controllers/navigation-controller.h [new file with mode: 0644]
cm-lib/src/models/client.cpp
cm-lib/src/models/client.h
cm-ui/src/main.cpp
cm-ui/views/CreateClientView.qml
cm-ui/views/DashboardView.qml
cm-ui/views/EditClientView.qml
cm-ui/views/FindClientView.qml
cm-ui/views/MasterView.qml
cm-ui/views/SplashView.qml
qmake-destination-path.pri

index e7987f6e9ae62c9af09e0b5f0c3bead7a00c4b10..4ca5c40990fdae0d045d24f7e6e3986cbee4176d 100644 (file)
@@ -36,7 +36,8 @@ SOURCES += \
 HEADERS += \
         src/models/client.h \
         src/cm-lib_global.h \
-    src/controllers/master-controller.h
+    src/controllers/master-controller.h \
+    src/controllers/navigation-controller.h
 
 unix {
     target.path = /usr/lib
index 9601bc4427c2576605f49eed34155583f52584eb..a1bf6f6d8f25e05ae2b989b738b1421c5a973ef8 100644 (file)
@@ -1,9 +1,39 @@
 #include "master-controller.h"
 
 namespace cm::controllers {
-MasterController::MasterController(QObject *parent) : QObject(parent)
-{
 
-}
+  class MasterController::Implementation
+  {
+  public:
+    Implementation(MasterController* _masterController)
+      : masterController(_masterController)
+    {
+      navigationController = new NavigationController(_masterController);
+    }
+
+    MasterController* masterController{nullptr};
+    NavigationController* navigationController{nullptr};
+    QString welcomeMessage = "This is MasterController to Major Tom";
+  };
+
+  MasterController::MasterController(QObject *parent) : QObject(parent)
+  {
+    implementation.reset(new Implementation(this));
+  }
+
+  MasterController::~MasterController()
+  {
+
+  }
+
+  NavigationController* MasterController::navigationController()
+  {
+    return implementation->navigationController;
+  }
+
+  const QString& MasterController::welcomeMessage() const
+  {
+    return implementation->welcomeMessage;
+  }
 
 }
index 791dc5c5601f0c3192b068221336f06792bb5baa..685651219ef43d359d1866f6e3e652dd722e9e49 100644 (file)
@@ -2,23 +2,29 @@
 #define MASTERCONTROLLER_H
 
 #include <QObject>
+#include <QScopedPointer>
 #include <QString>
 
-#include <cm-lib_global.h>
+#include "cm-lib_global.h"
+#include "controllers/navigation-controller.h"
 
 namespace cm::controllers {
 
 class CMLIBSHARED_EXPORT MasterController : public QObject
 {
   Q_OBJECT
-  Q_PROPERTY(QString ui_welcomeMessage MEMBER welcomeMessage CONSTANT)
+  Q_PROPERTY( QString ui_welcomeMessage READ welcomeMessage CONSTANT )
+  Q_PROPERTY( cm::controllers::NavigationController* ui_navigationController READ navigationController CONSTANT )
+
 public:
   explicit MasterController(QObject *parent = nullptr);
-  QString welcomeMessage = "This is MasterController to Major Tom";
-
-signals:
+  ~MasterController();
+  NavigationController* navigationController();
+  const QString& welcomeMessage() const;
 
-public slots:
+private:
+  class Implementation;
+  QScopedPointer<Implementation> implementation;
 };
 }
 
diff --git a/cm-lib/src/controllers/navigation-controller.h b/cm-lib/src/controllers/navigation-controller.h
new file mode 100644 (file)
index 0000000..7d876a1
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef NAVIGATIONCONTROLLER_H
+#define NAVIGATIONCONTROLLER_H
+
+#include <QObject>
+
+#include "cm-lib_global.h"
+#include "models/client.h"
+
+namespace cm::controllers {
+  class CMLIBSHARED_EXPORT NavigationController : public QObject
+  {
+    Q_OBJECT
+
+  public:
+      explicit NavigationController(QObject* _parent = nullptr)
+          : QObject(_parent)
+      {}
+
+  signals:
+    void goCreateClientView();
+    void goDashboardView();
+    void goEditClientView(cm::models::Client* client);
+    void goFindClientView();
+
+  };
+}
+#endif // NAVIGATIONCONTROLLER_H
index 5e8dcfbe5ac88158e0873f1c30d90ec0443c4c4d..e20037a5c726b2eaef7d9effa28442ca69aa851a 100644 (file)
@@ -1,6 +1,7 @@
 #include "client.h"
 
-
-Client::Client()
-{
+namespace cm::models {
+  Client::Client()
+  {
+  }
 }
index d917e02156b745c014091330cd41912c5d6a62c2..098d11b93a877266bd568df713d839f852996160 100644 (file)
@@ -3,11 +3,13 @@
 
 #include "cm-lib_global.h"
 
+namespace cm::models {
+
 class CMLIBSHARED_EXPORT Client
 {
 
 public:
   Client();
 };
-
+}
 #endif // CLIENT_H
index e390e7e3ee11cc544953fa6c7f3520a2bd34b7bb..1a78b0ecd046b29ba3bbbf7026c516f26cc39aca 100644 (file)
@@ -11,6 +11,7 @@ int main(int argc, char *argv[])
 
   QGuiApplication app(argc, argv);
   qmlRegisterType<cm::controllers::MasterController>("CM", 1, 0, "MasterController");
+  qmlRegisterType<cm::controllers::NavigationController>("CM", 1, 0, "NavigationController");
   cm::controllers::MasterController masterController;
 
   QQmlApplicationEngine engine;
index 9c36e13c5bfc938decd97e1b1eba471841e202c1..3086c3e6562ebbc9384f31a7b28b86f66d084a3d 100644 (file)
@@ -1,5 +1,13 @@
-import QtQuick 2.0
+import QtQuick 2.10
 
 Item {
+  Rectangle {
+    anchors.fill: parent
+    color: "#f4c842"
 
+    Text {
+      anchors.centerIn: parent
+      text: "Create Client View"
+    }
+  }
 }
index 9c36e13c5bfc938decd97e1b1eba471841e202c1..21ea5cfadecdb8889fcbec6bd3eda05c30244cb0 100644 (file)
@@ -1,5 +1,13 @@
-import QtQuick 2.0
+import QtQuick 2.10
 
 Item {
+  Rectangle {
+    anchors.fill: parent
+    color: "#208010"
 
+    Text {
+      anchors.centerIn: parent
+      text: "Dashboard View"
+    }
+  }
 }
index 9c36e13c5bfc938decd97e1b1eba471841e202c1..00e507af6ad63a1ca062590990a2fbedac3f0758 100644 (file)
@@ -1,5 +1,13 @@
-import QtQuick 2.0
+import QtQuick 2.10
 
 Item {
+  Rectangle {
+    anchors.fill: parent
+    color: "#f4c842"
 
+    Text {
+      anchors.centerIn: parent
+      text: "Edit Client View"
+    }
+  }
 }
index 9c36e13c5bfc938decd97e1b1eba471841e202c1..f313b10d4bf5375557b51b69089c6f1298007a73 100644 (file)
@@ -1,5 +1,13 @@
-import QtQuick 2.0
+import QtQuick 2.10
 
 Item {
+  Rectangle {
+    anchors.fill: parent
+    color: "#f4c842"
 
+    Text {
+      anchors.centerIn: parent
+      text: "Find Client View"
+    }
+  }
 }
index efb366b9112f4625daad68b85a559bba908a65a9..b929166d75cb398099effdacf5db8b546b8de5da 100644 (file)
@@ -1,5 +1,6 @@
 import QtQuick 2.10
 import QtQuick.Window 2.10
+import QtQuick.Controls 2.2
 
 Window {
   visible: true
@@ -7,7 +8,56 @@ Window {
   height: 480
   title: qsTr("Client Management")
 
-  Text {
-    text: masterController.ui_welcomeMessage
+  Connections {
+    target: masterController.ui_navigationController
+    onGoCreateClientView: contentFrame.replace(Qt.resolvedUrl("qrc:/views/CreateClientView.qml"))
+    onGoDashboardView: contentFrame.replace(Qt.resolvedUrl("qrc:/views/DashboardView.qml"))
+    onGoEditClientView: contentFrame.replace(Qt.resolvedUrl("qrc:/views/EditClientView.qml"), { selectedClient: client })
+    onGoFindClientView: contentFrame.replace(Qt.resolvedUrl("qrc:/views/FindClientView.qml"))
   }
+
+  Rectangle {
+    id: navigationBar
+    anchors {
+      top: parent.top
+      bottom: parent.bottom
+      left: parent.left
+    }
+    width: 100
+    color:"#000000"
+    Column {
+
+      Button {
+        text: "Dashboard"
+        onClicked: masterController.ui_navigationController.goDashboardView()
+      }
+
+      Button {
+        text: "New Client"
+        onClicked: masterController.ui_navigationController.goCreateClientView()
+      }
+
+      Button {
+        text: "Find Client"
+        onClicked: masterController.ui_navigationController.goFindClientView()
+      }
+
+    }
+  }
+
+  StackView {
+    id: contentFrame
+    clip: true
+    anchors{
+      top: parent.top
+      left: navigationBar.right
+      bottom: parent.bottom
+      right: parent.right
+    }
+
+    initialItem: Qt.resolvedUrl("qrc:/views/SplashView.qml")
+  }
+
+  Component.onCompleted:
+      contentFrame.replace(Qt.resolvedUrl("qrc:/views/DashboardView.qml"))
 }
index 9c36e13c5bfc938decd97e1b1eba471841e202c1..9c3fcb0876c590fdfd4dce12f16f3375357efee4 100644 (file)
@@ -1,5 +1,13 @@
-import QtQuick 2.0
+import QtQuick 2.10
 
 Item {
+  Rectangle {
+    anchors.fill: parent
+    color: "#f4c842"
 
+    Text {
+      anchors.centerIn: parent
+      text: "Splash View"
+    }
+  }
 }
index 9d942d615620e00468dbd0c44b02550bddf76c67..940b490bd06bdcd781afc620cc2768b69de981c7 100644 (file)
@@ -28,7 +28,7 @@ COMPILER_CLANG {
 }
 
 PROCESSOR_x64 {
-  processor_path = x64
+  processor_path = x86_64
 }
 
 PROCESSOR_x86 {