Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatherly committed Nov 10, 2014
1 parent 1afeeb2 commit a2c5973
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/qml/views/filter/AttachedFilters.qml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ Rectangle {
signal itemAdded(int index)

function getModelIndex(visualIndex) {
if(visualIndex < 0 || visualIndex >= count) return -1
if (visualIndex < 0 || visualIndex >= count)
return -1
var item = items.get(visualIndex)
if (item) {
return item.model.index
Expand Down
28 changes: 14 additions & 14 deletions src/qml/views/filter/FilterMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,29 @@ var visibility = {
GPU: 1,
VIDEO: 2,
AUDIO: 3
};
}

var ITEM_HEIGHT = 30

function isVisible(meta, showType) {
if(meta.isHidden) return false
if(meta.needsGPU && !settings.playerGPU) return false
if(!meta.needsGPU && settings.playerGPU && meta.gpuAlt != "") return false
if(showType == visibility.FAVORITE && !meta.isFavorite) return false
if(showType == visibility.GPU && !meta.needsGPU) return false
if(showType == visibility.AUDIO && !meta.isAudio) return false
if(showType == visibility.VIDEO && meta.isAudio ) return false
if(showType == visibility.VIDEO && meta.needsGPU ) return false
if (meta.isHidden) return false
if (meta.needsGPU && !settings.playerGPU) return false
if (!meta.needsGPU && settings.playerGPU && meta.gpuAlt !== "") return false
if (showType == visibility.FAVORITE && !meta.isFavorite) return false
if (showType == visibility.GPU && !meta.needsGPU) return false
if (showType == visibility.AUDIO && !meta.isAudio) return false
if (showType == visibility.VIDEO && meta.isAudio ) return false
if (showType == visibility.VIDEO && meta.needsGPU ) return false
return true
}

function maxMenuHeight(showType, pad) {
// Calculate the max possible height of the menu
var i = 0
var visibleItems = 0;
for( i = 0; i < metadatamodel.rowCount(); i++ ) {
for (i = 0; i < metadatamodel.rowCount(); i++) {
var meta = metadatamodel.get(i)
if(Logic.isVisible(meta, showType)) {
if (Logic.isVisible(meta, showType)) {
visibleItems++
}
}
Expand All @@ -60,10 +60,10 @@ function calcMenuRect(triggerItem, showType, pad) {

// Calculate the y position
result.y = triggerPos.y - result.height / 2 // Ideal position is centered
if( result.y < mainWinRect.y ) {
if (result.y < mainWinRect.y) {
// Window would be higher than the application window. Move it down
result.y = mainWinRect.y
} else if( result.y + result.height > mainWinRect.y + mainWinRect.height ) {
} else if (result.y + result.height > mainWinRect.y + mainWinRect.height) {
// Window would be lower than the application window. Move it up
result.y = mainWinRect.y + mainWinRect.height - result.height
}
Expand All @@ -72,4 +72,4 @@ function calcMenuRect(triggerItem, showType, pad) {
result.x = triggerPos.x

return result
}
}
11 changes: 6 additions & 5 deletions src/qml/views/filter/FilterMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Loader {
sourceComponent = null
}
onHasFocusChanged: {
if (!item.hasFocus) sourceComponent = null
if (!item.hasFocus)
sourceComponent = null
}
}

Expand Down Expand Up @@ -128,7 +129,7 @@ Loader {
tooltip: qsTr('Show Favorite Filters')
exclusiveGroup: typeGroup
onCheckedChanged: {
if(checked) {
if (checked) {
menuListView.showType = Logic.visibility.FAVORITE
}
}
Expand All @@ -145,7 +146,7 @@ Loader {
tooltip: qsTr('Show GPU Filters')
exclusiveGroup: typeGroup
onCheckedChanged: {
if(checked) {
if (checked) {
menuListView.showType = Logic.visibility.GPU
}
}
Expand All @@ -160,7 +161,7 @@ Loader {
tooltip: qsTr('Show Video Filters')
exclusiveGroup: typeGroup
onCheckedChanged: {
if(checked) {
if (checked) {
menuListView.showType = Logic.visibility.VIDEO
}
}
Expand All @@ -175,7 +176,7 @@ Loader {
tooltip: qsTr('Show Audio Filters')
exclusiveGroup: typeGroup
onCheckedChanged: {
if(checked) {
if (checked) {
menuListView.showType = Logic.visibility.AUDIO
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/qml/views/filter/filterview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Rectangle {
onHeightChanged: _setLayout()

function _setLayout() {
if( height > width - 200 ) {
if (height > width - 200) {
root.state = "portrait"
} else {
root.state = "landscape"
Expand Down

0 comments on commit a2c5973

Please sign in to comment.