import QtQuick 1.0
import "Util.js" as Utility


Item {

    id: background
    width: 1280//1280//2560//3000
    height: 720//720//1600//1875
    anchors.fill: parent;
    // color: "#343434";

    AppStateVars {
        id: appState
    }


    Component.onCompleted:Utility.renrenGetAccessToken();   //Utility.flickrGetPhotoSets();

    Rectangle {
        id: tabcontainer
        width: parent.width
        height: parent.height

        color: "#343434";


        VisualItemModel {
            id: tabsModel
            Tab {
                id:zonghejingxuanTab
                name: "\u7EFC\u5408\u7CBE\u9009"  //综合精选   http://www.nengcha.com/code/unicode/
                color: "#343434"

                TabContent{
                    id:zonghejingxuanTabContentID
                    width: background.width
                    height: background.height

                }

                /* Text {
                    id: debugText
                    anchors.right: parent.right
                    text: "debug info!";
                    font.pointSize: 24;
                    color: "red"
                }*/

                function callformatRenrenAlbumListModel(photosetJson)
                {
                    zonghejingxuanTabContentID.formatRenrenAlbumListModel(photosetJson);
                    zonghejingxuanTabContentID.setTabContentfocus();
                }

                function callformatRenrenPhotoListModel(photolistJson)
                {
                    zonghejingxuanTabContentID.formatRenrenPhotoListModel(photolistJson);
                }
            }


            Tab {
                id:meixiongTab
                name: "\u7F8E\u80F8"//美胸
                color: "#343434"

                TabContent{
                    id:meixiongTabContentID
                    width: background.width
                    height: background.height
                }

                function callformatRenrenAlbumListModel(photosetJson)
                {
                    meixiongTabContentID.formatRenrenAlbumListModel(photosetJson);
                    meixiongTabContentID.setTabContentfocus();
                }

                function callformatRenrenPhotoListModel(photolistJson)
                {
                    meixiongTabContentID.formatRenrenPhotoListModel(photolistJson);
                }
            }


            Tab {
                id:changtuisiwaTab
                name: "\u957F\u817F\u4E1D\u889C"//长腿丝袜
                color: "#343434"

                TabContent{
                    id:changtuisiwaTabContentID
                    width: background.width
                    height: background.height
                }

                function callformatRenrenAlbumListModel(photosetJson)
                {
                    changtuisiwaTabContentID.formatRenrenAlbumListModel(photosetJson);
                    changtuisiwaTabContentID.setTabContentfocus();
                }

                function callformatRenrenPhotoListModel(photolistJson)
                {
                    changtuisiwaTabContentID.formatRenrenPhotoListModel(photolistJson);
                }
            }

            Tab {
                id:xiangchemeinvTab
                name: "\u9999\u8F66\u7F8E\u5973"//香车美女
                color: "#343434"

                TabContent{
                    id:xiangchemeinvTabContentID
                    width: background.width
                    height: background.height
                }

                function callformatRenrenAlbumListModel(photosetJson)
                {
                    xiangchemeinvTabContentID.formatRenrenAlbumListModel(photosetJson);
                    xiangchemeinvTabContentID.setTabContentfocus();
                }

                function callformatRenrenPhotoListModel(photolistJson)
                {
                    xiangchemeinvTabContentID.formatRenrenPhotoListModel(photolistJson);
                }

            }

            Tab {
                id:zhifuTab
                name: "\u5236\u670D"//制服
                color: "#343434"

                TabContent{
                    id:zhifuTabContentID
                    width: background.width
                    height: background.height
                }

                function callformatRenrenAlbumListModel(photosetJson)
                {
                    zhifuTabContentID.formatRenrenAlbumListModel(photosetJson);
                    zhifuTabContentID.setTabContentfocus();
                }

                function callformatRenrenPhotoListModel(photolistJson)
                {
                    zhifuTabContentID.formatRenrenPhotoListModel(photolistJson);
                }



            }

            Tab {
                id:mingxingTab
                name: "\u660E\u661F"//明星
                color: "#343434"

                TabContent{
                    id:mingxingTabContentID
                    width: background.width
                    height: background.height
                }

                function callformatRenrenAlbumListModel(photosetJson)
                {
                    mingxingTabContentID.formatRenrenAlbumListModel(photosetJson);
                    mingxingTabContentID.setTabContentfocus();
                }

                function callformatRenrenPhotoListModel(photolistJson)
                {
                    mingxingTabContentID.formatRenrenPhotoListModel(photolistJson);
                }
            }

            /* Tab {

                id:shopTab
                name: "\u5546\u57CE"//商城
                color: "#343434"

            }*/




        } // end of VisualItemModel tabsModel

        TabbedUI {
            id: tabbedUIId
            tabsHeight: parent.height/34
            tabIndex: 0
            tabsModel: tabsModel
        }

        Keys.onPressed: {

            if (event.key == Qt.Key_Tab)
            {
                console.log("tabbedUIId.tabIndex: " + tabbedUIId.tabIndex);
                console.log("tabbedUIId.tabsModel.count: " + tabbedUIId.tabsModel.count);

                if ((tabbedUIId.tabIndex+1)< (tabbedUIId.tabsModel.count))
                {
                    tabbedUIId.tabClicked(tabbedUIId.tabIndex+1);


                }
                else
                {

                    tabbedUIId.tabClicked(0);
                }

            }

        }

        function callrenrenGetPhotos(photosetID)
        {
            Utility.renrenGetPhotos(photosetID);
        }
    }



    Rectangle {
        id: shoptabcontainer
        width: parent.width
        height: parent.height
        opacity: 0

        VisualItemModel {
            id: shoptabsModel
            Tab {
                id:shopTab1
                name: "\u5199\u771F\u5957\u56FE\u4E0B\u8F7D"  //  写真套图
                color: "#343434"


                ShopTabContent{
                    id: shopTabContentID1
                    width: parent.width
                    height: parent.height

                }

                function callformatRenrenShopAlbumListModel(photosetJson)
                {
                    shopTabContentID1.formatRenrenShopAlbumListModel(photosetJson);
                    shopTabContentID1.setShopTabContentfocus();
                }

                function callformatRenrenShopPhotoListModel(photolistJson)
                {
                    shopTabContentID1.formatRenrenShopPhotoListModel(photolistJson);
                }

            }


            Tab {
                id:shopTab2
                name: "\u5149\u76D8"//光盘
                color: "#343434"

                ShopTabContent{
                    id: shopTabContentID2
                    width: parent.width
                    height: parent.height

                }

                function callformatRenrenShopAlbumListModel(photosetJson)
                {
                    shopTabContentID2.formatRenrenShopAlbumListModel(photosetJson);
                    shopTabContentID2.setShopTabContentfocus();
                }

                function callformatRenrenShopPhotoListModel(photolistJson)
                {
                    shopTabContentID2.formatRenrenShopPhotoListModel(photolistJson);
                }

            }


            Tab {
                id:shopTab3
                name: "\u60C5\u8DA3\u5185\u8863"//情趣内衣
                color: "#343434"

                ShopTabContent{
                    id: shopTabContentID3
                    width: parent.width
                    height: parent.height

                }

                function callformatRenrenShopAlbumListModel(photosetJson)
                {
                    shopTabContentID3.formatRenrenShopAlbumListModel(photosetJson);
                    shopTabContentID3.setShopTabContentfocus();
                }

                function callformatRenrenShopPhotoListModel(photolistJson)
                {
                    shopTabContentID3.formatRenrenShopPhotoListModel(photolistJson);
                }

            }

             Tab {
                id:shopTab4
                name: "\u6210\u4EBA\u7528\u54C1"//成人用品
                color: "#343434"

                ShopTabContent{
                    id: shopTabContentID4
                    width: parent.width
                    height: parent.height

                }

                function callformatRenrenShopAlbumListModel(photosetJson)
                {
                    shopTabContentID4.formatRenrenShopAlbumListModel(photosetJson);
                    shopTabContentID4.setShopTabContentfocus();
                }

                function callformatRenrenShopPhotoListModel(photolistJson)
                {
                    shopTabContentID4.formatRenrenShopPhotoListModel(photolistJson);
                }

            }

         Tab {
                id:shopTab5
                name: "\u5370\u5237\u54C1"//印刷品
                color: "#343434"

                ShopTabContent{
                    id: shopTabContentID5
                    width: parent.width
                    height: parent.height

                }

                function callformatRenrenShopAlbumListModel(photosetJson)
                {
                    shopTabContentID5.formatRenrenShopAlbumListModel(photosetJson);
                    shopTabContentID5.setShopTabContentfocus();
                }

                function callformatRenrenShopPhotoListModel(photolistJson)
                {
                    shopTabContentID5.formatRenrenShopPhotoListModel(photolistJson);
                }

            }

            /*   Tab {
                id:shopTab6
                name: "\u660E\u661F"//明星
                color: "#343434"


            }*/

        } // end of VisualItemModel tabsModel

        ShopTabbedUI {
            id: shoptabbedUIId
            tabsHeight: parent.height/34
            tabIndex: 0
            tabsModel: shoptabsModel
        }

        Keys.onPressed: {

            if (event.key == Qt.Key_Tab)
            {
                console.log("shoptabbedUIId.tabIndex: " + shoptabbedUIId.tabIndex);
                console.log("shoptabbedUIId.tabsModel.count: " + shoptabbedUIId.tabsModel.count);

                if ((shoptabbedUIId.tabIndex+1)< (shoptabbedUIId.tabsModel.count))
                {
                    shoptabbedUIId.tabClicked(shoptabbedUIId.tabIndex+1);

                }
                else
                {

                    shoptabbedUIId.tabClicked(0);
                }

            }

        }

        function callrenrenShopGetPhotos(photosetID)
        {
            Utility.renrenShopGetPhotos(photosetID);
        }




    }//end of viptabcontainer


    Rectangle {
        id: vipContainer
        opacity: 0 ;
        color: "#343434";

        width: parent.width
        height: parent.height


        Image{
            id:vipImageID
            width:150
            height:150

            anchors.bottom: vipLoginInstance.top;
            anchors.bottomMargin: 20
            anchors.horizontalCenter:parent.horizontalCenter;
            smooth:true
            source:"images/vip.png";
        }



        VipLogin {
            id: vipLoginInstance

            anchors.horizontalCenter: parent.horizontalCenter;
            anchors.verticalCenter:parent.verticalCenter ;


        }


        Rectangle {
            id: viptabcontainer
            width: parent.width
            height: parent.height
            opacity: 0




            VisualItemModel {
                id: viptabsModel
                Tab {
                    id:vipTab1
                    name: "\u6BDB\u8C46\u79C0Vip 1\u533A"
                    color: "#343434"

                    VipTabContent{
                        id: vipTabContentID1
                        width: background.width
                        height: background.height

                    }

                    function callformatRenrenAlbumListModel(photosetJson)
                    {
                        vipTabContentID1.formatRenrenAlbumListModel(photosetJson);
                        vipTabContentID1.setVipTabContentfocus();
                    }

                    function callformatRenrenPhotoListModel(photolistJson)
                    {
                        vipTabContentID1.formatRenrenPhotoListModel(photolistJson);
                    }


                }


                Tab {
                    id:vipTab2
                    name: "\u6BDB\u8C46\u79C0Vip 2\u533A"
                    color: "#343434"

                    VipTabContent{
                        id: vipTabContentID2
                        width: background.width
                        height: background.height

                    }

                    function callformatRenrenAlbumListModel(photosetJson)
                    {
                        vipTabContentID2.formatRenrenAlbumListModel(photosetJson);
                        vipTabContentID2.setVipTabContentfocus();
                    }

                    function callformatRenrenPhotoListModel(photolistJson)
                    {
                        vipTabContentID2.formatRenrenPhotoListModel(photolistJson);
                    }


                }


                Tab {
                    id:vipTab3
                    name: "\u6BDB\u8C46\u79C0Vip 3\u533A"
                    color: "#343434"

                    VipTabContent{
                        id: vipTabContentID3
                        width: background.width
                        height: background.height

                    }

                    function callformatRenrenAlbumListModel(photosetJson)
                    {
                        vipTabContentID3.formatRenrenAlbumListModel(photosetJson);
                        vipTabContentID3.setVipTabContentfocus();
                    }

                    function callformatRenrenPhotoListModel(photolistJson)
                    {
                        vipTabContentID3.formatRenrenPhotoListModel(photolistJson);
                    }


                }

                  Tab {
                    id:vipTab4
                    name: "\u6BDB\u8C46\u79C0Vip 4\u533A"
                    color: "#343434"

                    VipTabContent{
                        id: vipTabContentID4
                        width: background.width
                        height: background.height

                    }

                    function callformatRenrenAlbumListModel(photosetJson)
                    {
                        vipTabContentID4.formatRenrenAlbumListModel(photosetJson);
                        vipTabContentID4.setVipTabContentfocus();
                    }

                    function callformatRenrenPhotoListModel(photolistJson)
                    {
                        vipTabContentID4.formatRenrenPhotoListModel(photolistJson);
                    }


                }

                Tab {
                    id:vipTab5
                    name: "\u6BDB\u8C46\u79C0Vip 5\u533A"
                    color: "#343434"

                    VipTabContent{
                        id: vipTabContentID5
                        width: background.width
                        height: background.height

                    }

                    function callformatRenrenAlbumListModel(photosetJson)
                    {
                        vipTabContentID5.formatRenrenAlbumListModel(photosetJson);
                        vipTabContentID5.setVipTabContentfocus();
                    }

                    function callformatRenrenPhotoListModel(photolistJson)
                    {
                        vipTabContentID5.formatRenrenPhotoListModel(photolistJson);
                    }


                }

                Tab {
                    id:vipTab6
                    name: "\u6BDB\u8C46\u79C0Vip 6\u533A"
                    color: "#343434"


                    VipTabContent{
                        id: vipTabContentID6
                        width: background.width
                        height: background.height

                    }

                    function callformatRenrenAlbumListModel(photosetJson)
                    {
                        vipTabContentID6.formatRenrenAlbumListModel(photosetJson);
                        vipTabContentID6.setVipTabContentfocus();
                    }

                    function callformatRenrenPhotoListModel(photolistJson)
                    {
                        vipTabContentID6.formatRenrenPhotoListModel(photolistJson);
                    }



                }

            } // end of VisualItemModel tabsModel

            VipTabbedUI {
                id: viptabbedUIId
                tabsHeight: parent.height/34
                tabIndex: 0
                tabsModel: viptabsModel
            }

            Keys.onPressed: {

                if (event.key == Qt.Key_Tab)
                {
                    console.log("tabbedUIId.tabIndex: " + viptabbedUIId.tabIndex);
                    console.log("tabbedUIId.tabsModel.count: " + viptabbedUIId.tabsModel.count);

                    if ((viptabbedUIId.tabIndex+1)< (viptabbedUIId.tabsModel.count))
                    {
                        viptabbedUIId.tabClicked(viptabbedUIId.tabIndex+1);

                    }
                    else
                    {

                        viptabbedUIId.tabClicked(0);
                    }

                }

            }

            function callrenrenVipGetPhotos(photosetID)
            {
                Utility.renrenVipGetPhotos(photosetID);
            }



        }//end of viptabcontainer

        Image
        {
            id:vipLoginBackImageID
            source:"images/back_button_pressed.png";

            anchors.top:vipContainer.top;
            anchors.topMargin:viptabbedUIId.tabsHeight+10

            anchors.right:vipContainer.right;
            anchors.rightMargin:10

            MouseArea {
                anchors.fill: parent
                onClicked: {
                    tabcontainer.opacity=1 ;
                    vipContainer.opacity=0;
                    // tabbedUIId.tabClicked(tabbedUIId.tabIndex);
                    //  tabcontainer.focus=true;

                    switch (tabbedUIId.tabIndex)
                    {
                    case 0:
                        zonghejingxuanTabContentID.setTabContentfocus();
                        break
                    case 1:
                        meixiongTabContentID.setTabContentfocus();
                        break

                    case 2:
                        changtuisiwaTabContentID.setTabContentfocus();
                        break

                    case 3:
                        xiangchemeinvTabContentID.setTabContentfocus();
                        break

                    case 4:
                        zhifuTabContentID.setTabContentfocus();
                        break

                    case 5:
                        mingxingTabContentID.setTabContentfocus();
                        break
                    }

                }
            }

        }  //end of  back image

    }//end of vipcontainer


}


/* Component {
id: myDelegate

Item{

    width: 340
    height: 260

    visible: PathView.onPath
    z: PathView.zOrder

    Image{
        id:myImage
        width: 340
        height: 260


        source: photoUrl
        anchors.horizontalCenter: parent.horizontalCenter
        smooth: true
    }


    transform:[
        Rotation{
            angle: PathView.rotateY
            origin.x: 340/2
            axis { x: 0; y: 1; z: 0 }
        },
        Scale {
            xScale:PathView.scalePic; yScale:PathView.scalePic
            origin.x:  340/2;   origin.y:  260/2
        }
    ]
}//Item
}


PathView {
id: view
focus: true
model: photoStreamModel
delegate: myDelegate
anchors.fill: parent
pathItemCount: 13

preferredHighlightBegin: 0.5
preferredHighlightEnd: 0.5
highlightRangeMode: PathView.StrictlyEnforceRange

flickDeceleration: 390
path: Path {
    id: myPath
    startX: 0; startY: 150
    PathAttribute {name: "rotateY"; value: 50.0}
    PathAttribute {name: "scalePic"; value: 0.5}
    PathAttribute {name: "zOrder"; value: 1}

    PathLine{x:180; y: 150}
    PathPercent {value: 0.44}
    PathAttribute {name: "rotateY"; value: 50.0}
    PathAttribute {name: "scalePic"; value: 0.5}
    PathAttribute {name: "zOrder"; value: 10}

    PathQuad{x:320; y: 190; controlX: 290; controlY: 190}
    PathPercent {value: 0.50}
    PathAttribute {name: "rotateY"; value: 0.0}
    PathAttribute {name: "scalePic"; value: 1.0}
    PathAttribute {name: "zOrder"; value: 50}

    PathQuad{x:460; y: 150; controlX: 510; controlY: 150}
    PathPercent {value: 0.56}
    PathAttribute {name: "rotateY"; value: -50.0}
    PathAttribute {name: "scalePic"; value: 0.5}
    PathAttribute {name: "zOrder"; value: 10}

    PathLine{x:640; y: 150}
    PathPercent {value: 1.00}
    PathAttribute {name: "rotateY"; value: -50.0}
    PathAttribute {name: "scalePic"; value: 0.5}
    PathAttribute {name: "zOrder"; value: 1}
}
}*/


