Firebase日历(多用户)

时间:2018-05-16 19:41:39

标签: qt firebase firebase-realtime-database calendar

我目前正在Qt中构建一个多用户日历应用程序,并打算使用firebase实时数据库来处理用户数据和计划任务。

每个用户都可以登录该应用并选择一旦点击“保存”的日期。按钮,将锁定他们的名字。我以前没有使用firebase的经验,并且想要开始构建数据库的一些帮助,我希望能够将用户分成几个部门。

下面是我的应用程序上的日历页面的代码,我将什么内容放入firebase以便能够连接这两个?

任何帮助都会非常感激!!

Page {

    title: "Calendar"

    rightBarItem: NavigationBarItem {
      contentWidth: saveButton.width

      AppButton {
          id: saveButton
          text: "Save & Request"
          anchors.right: parent.right
      }
    }


    SystemPalette {
        id: systemPalette
    }

    Flow {
        id: row
        anchors.fill: parent
        spacing: 10
        layoutDirection: "RightToLeft"
        Calendar {
            id: calendar
            width: (parent.width > parent.height ? parent.width * 0.6 - parent.spacing : parent.width)
            height: (parent.height > parent.width ? parent.height * 0.6 - parent.spacing : parent.height)
            selectedDate: new Date()
            focus: true


           style: CalendarStyle {
               dayDelegate: Item {
                   readonly property color sameMonthDateTextColor: "#444"
                   readonly property color selectedDateColor: Qt.platformos === "osx" ? "#3778d0" : systemPalette.highlight
                   readonly property color selectedDateTextColor: "white"
                   readonly property color differentMonthDateTextColor: "#bbb"
                   readonly property color invalidDatecolor: "#dddddd"

                   Rectangle {
                       anchors.fill: parent
                       border.color: "#00000000"
                       color: styleData.date !== undefined && styleData.selected? selectedDateColor : "#00000000"
                       anchors.margins: styleData.selected ? -1 : 0
                   }

                   Label {
                       id: dayDelegateText
                       text: styleData.date.getDate()
                       anchors.centerIn: parent
                       color:  {
                           var color = invalidDatecolor;
                           if (styleData.valid) {
                               color = styleData.visibleMonth ? sameMonthDateTextColor : differentMonthDateTextColor ;
                               if (styleData.selected) {
                                   color = selectedDateTextColor;
                               }
                           }
                           color ;
                       }
                   }
               }

           }

        }

        Component {
            id: eventListHeader

            Row {
                id: eventDateRow
                width: parent.width
                height: eventDayLabel.height
                spacing: 10

                Label {
                    id: eventDayLabel
                    text: calendar.selectedDate.getDate()
                    font.pointSize: 35
                }
                Column {
                    height: eventDayLabel.height

                    Label {
                        readonly property var options: { weekday: "long" }
                        text: Qt.locale().standaloneDayName(calendar.selectedDate.getDay(), Locale.LongFormat)
                        font.pointSize: 18
                    }
                    Label {
                        text: Qt.locale().standaloneMonthName(calendar.selectedDate.getMonth())
                              + calendar.selectedDate.toLocaleDateString(Qt.locale(), " yyyy")
                        font.pointSize: 12
                    }
                }
            }
        }
        Rectangle {
            width: (parent.width > parent.height ? parent.width * 0.4 - parent.spacing : parent.width)
            height: (parent.height > parent.width ? parent.height * 0.4 - parent.spacing : parent.height)

            ListView {
                id:eventListView
                spacing: 4
                clip: true
                header: eventListHeader
                anchors.fill: parent
                anchors.margins: 10
                model: eventModel.eventsForDate(calendar.selectedDate)

                delegate: Rectangle {
                    width: eventListView.width
                    height: eventItemColumn.height
                    anchors.horizontalCenter: parent.horizontalCenter

                    Image {
                        anchors.top: parent.top
                        anchors.topMargin: 4
                        width: 12
                        height: width
                        source: "qrc:/images/eventindicator.png"
                    }
                    Rectangle {
                        width: parent.width
                        height: 1
                        color: "#eee"
                    }
                    Column {
                        id: eventItemColumn
                        anchors.left: parent.left
                        anchors.leftMargin: 20
                        anchors.right: parent.right
                        height: timeLabel.height + nameLabel.height + 8

                        Label {
                            id: nameLabel
                            width: parent.width
                            wrapMode: Text.Wrap
                            text: modelData.name
                        }
                        Label {
                            id: timeLabel
                            width: parent.width
                            wrapMode: Text.Wrap
                            text: modelData.startDate.toLocaleTimeString(calendar.locale, Locale.ShortFormat)
                            color: "#aaa"
                        }
                    }
                }
            }
        }
    }

}

1 个答案:

答案 0 :(得分:0)

如果我理解正确,您还没有将Firebase集成到您的Qt项目中?

您可以查看此插件,以便在Qt Quick中使用Firebase:https://v-play.net/doc/plugin-firebase/

然后,您可以收听reatimeValueChanged信号并相应地更新日历。