examples/QtQuick/descriptors/qml/descriptors/main.qml

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation
00006 **
00007 **
00008 ** $QT_BEGIN_LICENSE:BSD$
00009 ** You may use this file under the terms of the BSD license as follows:
00010 **
00011 ** "Redistribution and use in source and binary forms, with or without
00012 ** modification, are permitted provided that the following conditions are
00013 ** met:
00014 **   * Redistributions of source code must retain the above copyright
00015 **     notice, this list of conditions and the following disclaimer.
00016 **   * Redistributions in binary form must reproduce the above copyright
00017 **     notice, this list of conditions and the following disclaimer in
00018 **     the documentation and/or other materials provided with the
00019 **     distribution.
00020 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00021 **     the names of its contributors may be used to endorse or promote
00022 **     products derived from this software without specific prior written
00023 **     permission.
00024 **
00025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00036 ** $QT_END_LICENSE$
00037 **
00038 ****************************************************************************/
00039 
00040 
00041 
00042 import QtQuick 1.0
00043 import com.nokia.symbian 1.0
00044 
00045 ApplicationWindow {
00046     id: window
00047 
00048     function setStateIfFound(target, name) {
00049         for (var i = 0; i < target.states.length; i++) {
00050             var curState = target.states[i];
00051             if(curState.name == name) {
00052                 target.state = name
00053                 break
00054             }
00055         }
00056     }
00057 
00058     ToolBarLayout {
00059         id: commonTools
00060         ToolButton {
00061             flat: true
00062             iconSource: "qrc:/qtg_toolbar_back.svg"
00063             onClicked: pageStack.depth <= 1 ? Qt.quit() : pageStack.pop()
00064         }
00065         ToolButton {
00066             flat: true
00067             iconSource: "qrc:/qtg_toolbar_options.svg"
00068             onClicked: viewMenu.open();
00069         }
00070     }
00071 
00072     Page {
00073         id: page
00074         anchors.fill: parent
00075         tools: commonTools
00076 
00077         Component.onCompleted: {
00078             if(screen.currentOrientation == Screen.Portrait) {
00079                 setStateIfFound(page, "PortraitState")
00080             } else if(screen.currentOrientation == Screen.Landscape) {
00081                 setStateIfFound(page, "LandscapeState")
00082             }
00083         }
00084 
00085         PageHeading{
00086             id: heading
00087             anchors.top: parent.top
00088             width: parent.width
00089             text: qsTr("Descriptors")
00090             fontItalic:true
00091         }
00092 
00093         // Text Editor used for displaying the descriptor operation results.
00094         Rectangle{
00095             id: editorLayout
00096             anchors.top: parent.top
00097             anchors.topMargin: 70
00098             anchors.left: parent.left
00099             anchors.leftMargin: 10
00100             anchors.right: parent.right
00101             anchors.rightMargin: 10
00102             anchors.bottom: parent.bottom
00103             anchors.bottomMargin: 60
00104             border.color: "grey"
00105             border.width: 4
00106         Flickable {
00107              id: flick
00108              width: editorLayout.width; height: editorLayout.height;
00109              contentWidth: textEdit.paintedWidth
00110              contentHeight: textEdit.paintedHeight
00111              clip: true
00112 
00113              function ensureVisible(r)
00114              {
00115                  if (contentX >= r.x)
00116                      contentX = r.x;
00117                  else if (contentX+width <= r.x+r.width)
00118                      contentX = r.x+r.width-width;
00119                  if (contentY >= r.y)
00120                      contentY = r.y;
00121                  else if (contentY+height <= r.y+r.height)
00122                      contentY = r.y+r.height-height;
00123              }
00124 
00125              TextEdit {
00126                  id: textEdit
00127                  width: flick.width
00128                  height: flick.height
00129                  anchors.top: parent.top
00130                  anchors.topMargin: 10
00131                  anchors.left: parent.left
00132                  anchors.leftMargin: 10
00133                  font.family: "Helvetica"
00134                  font.pointSize: 7
00135                  color: "darkblue"
00136                  text: "Welcome To Descriptors Example"
00137                  smooth: true
00138                  activeFocusOnPress: false
00139                  wrapMode: TextEdit.Wrap
00140                  onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
00141              }
00142          }
00143         }
00144 
00145         Menu{
00146             id: viewMenu
00147 
00148                 content:
00149                 Column{
00150                 MenuItem {
00151                     text: "Declarations"
00152 
00153                     onClicked:
00154                     {
00155 
00156                         viewMenuDeclaration.open()
00157                         viewMenu.close()
00158                     }
00159                 }
00160                 MenuItem { text: "Manipulations"
00161                     onClicked:
00162                     {
00163                         viewMenuManipulations.open()
00164                         viewMenu.close()
00165                     }
00166                 }
00167                 MenuItem { text: "Other Buffers"
00168                     onClicked:
00169                     {
00170                         viewMenuOtherBuffer.open()
00171                         viewMenu.close()
00172                     }
00173                 }
00174 
00175 
00176             }
00177 
00178         }
00179 
00180 
00181 
00182         Menu{
00183             id: viewMenuDeclaration
00184 
00185                 content:
00186                 Column{
00187                 MenuItem {
00188                     text: "OnStack"
00189 
00190                     onClicked:
00191                     {
00192                         descriptors.createOnStack()
00193                         viewMenuDeclaration.close()
00194                         viewMenu.close()
00195                     }
00196                 }
00197                 MenuItem { text: "OnHeap"
00198                     onClicked:
00199                     {
00200                         descriptors.createOnHeap()
00201                         viewMenuDeclaration.close()
00202                         viewMenu.close()
00203                     }
00204                 }
00205                 MenuItem { text: "Literals"
00206                     onClicked:
00207                     {
00208                         descriptors.createLiterals()
00209                         viewMenuDeclaration.close()
00210                         viewMenu.close()
00211                     }
00212                 }
00213                }
00214 
00215         }
00216 
00217 
00218 
00219         Menu{
00220             id: viewMenuManipulations
00221 
00222                 content:
00223                 Column{
00224                 MenuItem {
00225                     text: "NonModifying Methods"
00226 
00227                     onClicked:
00228                     {
00229                         descriptors.callNonModifyingMethods()
00230                         viewMenuManipulations.close()
00231                         viewMenu.close()
00232                     }
00233                 }
00234                 MenuItem { text: "Modifying Methods"
00235                     onClicked:
00236                     {
00237                         descriptors.callModifyingMethods()
00238                         viewMenuManipulations.close()
00239                         viewMenu.close()
00240                     }
00241                 }
00242                 MenuItem { text: "Character Conversions"
00243                     onClicked:
00244                     {
00245                         descriptors.callCharacterConversions()
00246                         viewMenuManipulations.close()
00247                         viewMenu.close()
00248                     }
00249                 }
00250 
00251                 MenuItem { text: "Lexical Analysis"
00252                     onClicked:
00253                     {
00254                         descriptors.doLexicalAnalysis()
00255                         viewMenuManipulations.close()
00256                         viewMenu.close()
00257                     }
00258                 }
00259 
00260 
00261             }
00262 
00263         }
00264 
00265 
00266 
00267         Menu{
00268             id: viewMenuOtherBuffer
00269 
00270                 content:
00271                 Column{
00272                 MenuItem {
00273                     text: "Circular Buffers"
00274 
00275                     onClicked:
00276                     {
00277                         descriptors.useCircularBuffers()
00278                         viewMenuOtherBuffer.close()
00279                         viewMenu.close()
00280                     }
00281                 }
00282                 MenuItem { text: "Flat Dynamic Buffers"
00283                     onClicked:
00284                     {
00285                         descriptors.useFlatDynamicBuffers()
00286                         viewMenuOtherBuffer.close()
00287                         viewMenu.close()
00288                     }
00289                 }
00290                 MenuItem { text: "Segmntd Dynamic Buffers"
00291                     onClicked:
00292                     {
00293                         descriptors.useSegmentedDynamicBuffers()
00294                         viewMenuOtherBuffer.close()
00295                         viewMenu.close()
00296                     }
00297                 }
00298 
00299                 MenuItem { text: "Package Buffers"
00300                     onClicked:
00301                     {
00302                        descriptors.usePackageBuffers()
00303                        viewMenuOtherBuffer.close()
00304                         viewMenu.close()
00305                     }
00306                 }
00307 
00308 
00309             }
00310 
00311         }
00312 
00313         // Invokes showResponse() method of Descriptors class when
00314         // printMessage signal is emitted.
00315         Connections {
00316             target: descriptors
00317             onPrintMessage: textEdit.text = descriptors.showResponse();
00318        }
00319     }
00320     Component.onCompleted: pageStack.push(page)
00321 }

Generated by  doxygen 1.6.2