@ -6,17 +6,19 @@ import QtQuick.Controls.Styles 1.3
import "."
ColumnLayout {
Rectangle
{
Layout.fillWidth: true
Layout.minimumHeight: hiddenHeightTopLevel ( )
height: hiddenHeightTopLevel ( )
Layout.maximumHeight: hiddenHeightTopLevel ( )
id: wrapperItem
signal documentSelected ( string doc , string groupName )
property alias model: filesList . model
property string sectionName ;
property variant selManager ;
Layout.fillWidth: true
Layout.minimumHeight: hiddenHeightTopLevel ( )
height: hiddenHeightTopLevel ( )
Layout.maximumHeight: hiddenHeightTopLevel ( )
spacing: 0
property int index ;
color: index % 2 === 0 ? "transparent" : ProjectFilesStyle . title . background
function hiddenHeightTopLevel ( )
{
@ -48,196 +50,203 @@ ColumnLayout {
model . remove ( i ) ;
}
SourceSansProRegular
{
id: fileNameFont
}
SourceSansProBold
{
id: boldFont
}
ColumnLayout {
anchors.fill: parent
spacing: 0
RowLayout
{
anchors.top: parent . top
id: rowCol
width: parent . width
height: ProjectFilesStyle . documentsList . height
Image {
source: "qrc:/qml/img/opentriangleindicator_filesproject.png"
width: 15
sourceSize.width: 12
id: imgArrow
anchors.right: section . left
anchors.rightMargin: 8
anchors.top: parent . top
anchors.topMargin: 6
SourceSansProRegular
{
id: fileNameFont
}
Text
SourceSansProBold
{
id: section
text: sectionName
anchors.left: parent . left
anchors.leftMargin: ProjectFilesStyle . general . leftMargin
color: ProjectFilesStyle . documentsList . sectionColor
font.family: boldFont . name
font.pointSize: ProjectFilesStyle . documentsList . sectionFontSize
states: [
State {
name: "hidden"
PropertyChanges { target: filesList ; visible: false ; }
PropertyChanges { target: rowCol ; Layout.minimumHeight: ProjectFilesStyle . documentsList . height ; Layout.maximumHeight: ProjectFilesStyle . documentsList . height ; height: ProjectFilesStyle . documentsList . height ; }
PropertyChanges { target: imgArrow ; source: "qrc:/qml/img/closedtriangleindicator_filesproject.png" }
}
]
id: boldFont
}
MouseArea {
id: titleMouseArea
anchors.fill: parent
hoverEnabled: true
z: 2
onClicked: {
if ( section . state === "hidden" )
section . state = "" ;
else
section . state = "hidden" ;
RowLayout
{
anchors.top: parent . top
id: rowCol
height: ProjectFilesStyle . documentsList . height
Layout.fillWidth: true
Image {
source: "qrc:/qml/img/opentriangleindicator_filesproject.png"
width: 15
sourceSize.width: 12
id: imgArrow
anchors.right: section . left
anchors.rightMargin: 8
anchors.top: parent . top
anchors.topMargin: 10
}
Text
{
id: section
text: sectionName
anchors.left: parent . left
anchors.leftMargin: ProjectFilesStyle . general . leftMargin
color: ProjectFilesStyle . documentsList . sectionColor
font.family: boldFont . name
font.pointSize: ProjectFilesStyle . documentsList . sectionFontSize
states: [
State {
name: "hidden"
PropertyChanges { target: filesList ; visible: false ; }
PropertyChanges { target: rowCol ; Layout.minimumHeight: ProjectFilesStyle . documentsList . height ; Layout.maximumHeight: ProjectFilesStyle . documentsList . height ; height: ProjectFilesStyle . documentsList . height ; }
PropertyChanges { target: imgArrow ; source: "qrc:/qml/img/closedtriangleindicator_filesproject.png" }
}
]
}
MouseArea {
id: titleMouseArea
anchors.fill: parent
hoverEnabled: true
z: 2
onClicked: {
if ( section . state === "hidden" )
section . state = "" ;
else
section . state = "hidden" ;
}
}
}
}
ColumnLayout {
height: wrapperItem . hiddenHeightRepeater ( )
Layout.minimumHeight: wrapperItem . hiddenHeightRepeater ( )
Layout.preferredHeight: wrapperItem . hiddenHeightRepeater ( )
Layout.maximumHeight: wrapperItem . hiddenHeightRepeater ( )
width: parent . width
visible: section . state !== "hidden"
spacing: 0
Repeater
{
id: filesList
ColumnLayout {
height: wrapperItem . hiddenHeightRepeater ( )
Layout.minimumHeight: wrapperItem . hiddenHeightRepeater ( )
Layout.preferredHeight: wrapperItem . hiddenHeightRepeater ( )
Layout.maximumHeight: wrapperItem . hiddenHeightRepeater ( )
width: parent . width
visible: section . state !== "hidden"
Rectangle
spacing: 0
Repeater
{
id: filesList
visible: section . state !== "hidden"
id: rootItem
Layout.fillWidth: true
Layout.minimumHeight: wrapperItem . hiddenHeightElement ( )
Layout.preferredHeight: wrapperItem . hiddenHeightElement ( )
Layout.maximumHeight: wrapperItem . hiddenHeightElement ( )
height: wrapperItem . hiddenHeightElement ( )
color: isSelected ? ProjectFilesStyle.documentsList.highlightColor : ProjectFilesStyle . documentsList . background
property bool isSelected
property bool renameMode
Text {
id: nameText
height: parent . height
visible: ! renameMode
color: rootItem . isSelected ? ProjectFilesStyle.documentsList.selectedColor : ProjectFilesStyle . documentsList . color
text: name ;
font.family: fileNameFont . name
font.pointSize: ProjectFilesStyle . documentsList . fontSize
anchors.verticalCenter: parent . verticalCenter
verticalAlignment: Text . AlignVCenter
anchors.left: parent . left
anchors.leftMargin: ProjectFilesStyle . general . leftMargin + 2
width: parent . width
Connections
{
target: selManager
onSelected: {
if ( groupName != sectionName )
rootItem . isSelected = false ;
else if ( doc === documentId )
rootItem . isSelected = true ;
else
rootItem . isSelected = false ;
Rectangle
{
visible: section . state !== "hidden"
id: rootItem
Layout.fillWidth: true
Layout.minimumHeight: wrapperItem . hiddenHeightElement ( )
Layout.preferredHeight: wrapperItem . hiddenHeightElement ( )
Layout.maximumHeight: wrapperItem . hiddenHeightElement ( )
height: wrapperItem . hiddenHeightElement ( )
color: isSelected ? ProjectFilesStyle.documentsList.highlightColor : "transparent"
property bool isSelected
property bool renameMode
Text {
id: nameText
height: parent . height
visible: ! renameMode
color: rootItem . isSelected ? ProjectFilesStyle.documentsList.selectedColor : ProjectFilesStyle . documentsList . color
text: name ;
font.family: fileNameFont . name
font.pointSize: ProjectFilesStyle . documentsList . fontSize
anchors.verticalCenter: parent . verticalCenter
verticalAlignment: Text . AlignVCenter
anchors.left: parent . left
anchors.leftMargin: ProjectFilesStyle . general . leftMargin + 2
width: parent . width
Connections
{
target: selManager
onSelected: {
if ( groupName != sectionName )
rootItem . isSelected = false ;
else if ( doc === documentId )
rootItem . isSelected = true ;
else
rootItem . isSelected = false ;
if ( rootItem . isSelected && section . state === "hidden" )
section . state = "" ;
if ( rootItem . isSelected && section . state === "hidden" )
section . state = "" ;
}
}
}
}
TextInput {
id: textInput
text: nameText . text
visible: renameMode
anchors.verticalCenter: parent . verticalCenter
anchors.left: parent . left
anchors.leftMargin: ProjectFilesStyle . general . leftMargin
MouseArea {
id: textMouseArea
anchors.fill: parent
hoverEnabled: true
z: 2
onClicked: {
textInput . forceActiveFocus ( ) ;
TextInput {
id: textInput
text: nameText . text
visible: renameMode
anchors.verticalCenter: parent . verticalCenter
anchors.left: parent . left
anchors.leftMargin: ProjectFilesStyle . general . leftMargin
MouseArea {
id: textMouseArea
anchors.fill: parent
hoverEnabled: true
z: 2
onClicked: {
textInput . forceActiveFocus ( ) ;
}
}
}
onVisibleChanged: {
if ( visible ) {
selectAll ( ) ;
forceActiveFocus ( ) ;
onVisibleChanged: {
if ( visible ) {
selectAll ( ) ;
forceActiveFocus ( ) ;
}
}
}
onAccepted: close ( true ) ;
onCursorVisibleChanged: {
if ( ! cursorVisible )
close ( false ) ;
}
onFocusChanged: {
if ( ! focus )
close ( false ) ;
}
function close ( accept ) {
rootItem . renameMode = false ;
if ( accept )
{
var i = getDocumentIndex ( documentId ) ;
projectModel . renameDocument ( documentId , textInput . text ) ;
wrapperItem . model . set ( i , projectModel . getDocument ( documentId ) ) ;
onAccepted: close ( true ) ;
onCursorVisibleChanged: {
if ( ! cursorVisible )
close ( false ) ;
}
onFocusChanged: {
if ( ! focus )
close ( false ) ;
}
function close ( accept ) {
rootItem . renameMode = false ;
if ( accept )
{
var i = getDocumentIndex ( documentId ) ;
projectModel . renameDocument ( documentId , textInput . text ) ;
wrapperItem . model . set ( i , projectModel . getDocument ( documentId ) ) ;
}
}
}
}
MouseArea {
id: mouseArea
z: 1
hoverEnabled: false
anchors.fill: parent
acceptedButtons: Qt . LeftButton | Qt . RightButton
onClicked: {
if ( mouse . button === Qt . RightButton && ! isContract )
contextMenu . popup ( ) ;
else if ( mouse . button === Qt . LeftButton )
{
rootItem . isSelected = true ;
projectModel . openDocument ( documentId ) ;
documentSelected ( documentId , groupName ) ;
MouseArea {
id: mouseArea
z: 1
hoverEnabled: false
anchors.fill: parent
acceptedButtons: Qt . LeftButton | Qt . RightButton
onClicked: {
if ( mouse . button === Qt . RightButton && ! isContract )
contextMenu . popup ( ) ;
else if ( mouse . button === Qt . LeftButton )
{
rootItem . isSelected = true ;
projectModel . openDocument ( documentId ) ;
documentSelected ( documentId , groupName ) ;
}
}
}
}
Menu {
id: contextMenu
MenuItem {
text: qsTr ( "Rename" )
onTriggered: {
rootItem . renameMode = true ;
Menu {
id: contextMenu
MenuItem {
text: qsTr ( "Rename" )
onTriggered: {
rootItem . renameMode = true ;
}
}
}
MenuItem {
text: qsTr ( "Delete" )
onTriggered: {
projectModel . removeDocument ( documentId ) ;
wrapperItem . removeDocument ( documentId ) ;
MenuItem {
text: qsTr ( "Delete" )
onTriggered: {
projectModel . removeDocument ( documentId ) ;
wrapperItem . removeDocument ( documentId ) ;
}
}
}
}
@ -245,4 +254,3 @@ ColumnLayout {
}
}
}