123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- /****************************************************************************
- **
- ** Copyright (C) 2012 Róbert Márki
- **
- ** This file is part of Web Feeds.
- **
- ** Web Feeds is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** Web Feeds is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with Web Feeds. If not, see <http://www.gnu.org/licenses/>.
- ****************************************************************************/
- import QtQuick 1.1
- import com.nokia.meego 1.0
- import WebFeeds 1.0
- import NewsBlur 1.0
- import "../../../../shared/qml" as Shared
- import "../../../../shared/qml/UIConstants.js" as UIConstants
- Item {
- id: root
- property alias text: label.text
- property string position: ""
- property int classification: 0
- property string __classificationText: !(root.classification > 0) ? (!(root.classification < 0) ? "neutral" : "negative") : "positive"
- signal classificationSet(int newClassification);
- width: 300
- height: UIConstants.DEFAULT_DELEGATE_HEIGHT
- Item {
- id: dislikeItem
- anchors.left: parent.left
- height: parent.height
- width: parent.height
- BorderImage {
- id: leftBackground
- anchors.fill: parent
- border { left: UIConstants.CORNER_MARGINS; top: UIConstants.CORNER_MARGINS;
- right: UIConstants.CORNER_MARGINS; bottom: UIConstants.CORNER_MARGINS }
- source: "qrc:/plugins/newsblur/images/classifier_button/" + (root.position ? (root.position + "-") : "")
- + "left" + (dislikeMouseArea.pressed ? "-pressed" :
- ((root.classification < 0) ? "-selected" : ""))
- + ".png"
- // source: "qrc:/plugins/newsblur/images/classifier_button/" + root.__classificationText + "-" + (root.position ? (root.position + "-") : "")
- // + "left" + (dislikeMouseArea.pressed ? "-pressed" : "")
- // + ".png"
- }
- Image {
- id: dislikeImage
- anchors.centerIn: parent
- source: "qrc:/plugins/newsblur/images/dislike_icon" + ((root.classification < 0) ? "-inverted" : "") + ".png"
- // source: "qrc:/plugins/newsblur/images/dislike_icon-inverted.png"
- }
- MouseArea {
- id: dislikeMouseArea
- anchors.fill: parent
- onClicked: {
- if(root.classification >= 0)
- root.classificationSet(-1);
- }
- }
- }
- Item {
- id: centerItem
- anchors.left: dislikeItem.right
- anchors.right: likeItem.left
- height: parent.height
- BorderImage {
- id: centerBackground
- anchors.fill: parent
- border { left: UIConstants.CORNER_MARGINS; top: UIConstants.CORNER_MARGINS;
- right: UIConstants.CORNER_MARGINS; bottom: UIConstants.CORNER_MARGINS }
- source: "qrc:/plugins/newsblur/images/classifier_button/" + (root.position ? (root.position + "-") : "")
- + "center" + (centerMouseArea.pressed ? "-pressed" :
- ((root.classification == 0) ? "-selected" : ""))
- + ".png"
- // source: "qrc:/plugins/newsblur/images/classifier_button/" + root.__classificationText + "-" + (root.position ? (root.position + "-") : "")
- // + "center" + (dislikeMouseArea.pressed ? "-pressed" : "")
- // + ".png"
- }
- Label {
- id: label
- anchors.fill: parent
- anchors.leftMargin: UIConstants.BUTTON_SPACING
- anchors.rightMargin: UIConstants.BUTTON_SPACING
- anchors.topMargin: UIConstants.BUTTON_SPACING
- anchors.bottomMargin: UIConstants.BUTTON_SPACING
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- text: modelData
- elide: Text.ElideRight
- wrapMode: Text.Wrap
- maximumLineCount: 2
- textFormat: Text.PlainText
- color: (root.classification == 0) ? "white" : "black"
- }
- MouseArea {
- id: centerMouseArea
- anchors.fill: parent
- onClicked: {
- if(root.classification != 0)
- root.classificationSet(0);
- }
- }
- }
- Item {
- id: likeItem
- anchors.right: parent.right
- height: parent.height
- width: parent.height
- BorderImage {
- id: rightBackground
- anchors.fill: parent
- border { left: UIConstants.CORNER_MARGINS; top: UIConstants.CORNER_MARGINS;
- right: UIConstants.CORNER_MARGINS; bottom: UIConstants.CORNER_MARGINS }
- source: "qrc:/plugins/newsblur/images/classifier_button/" + (root.position ? (root.position + "-") : "")
- + "right" + (likeMouseArea.pressed ? "-pressed" :
- ((root.classification > 0) ? "-selected" : ""))
- + ".png"
- // source: "qrc:/plugins/newsblur/images/classifier_button/" + root.__classificationText + "-" + (root.position ? (root.position + "-") : "")
- // + "right" + (dislikeMouseArea.pressed ? "-pressed" : "")
- // + ".png"
- }
- Image {
- id: likeImage
- anchors.centerIn: parent
- source: "qrc:/plugins/newsblur/images/like_icon" + ((root.classification > 0) ? "-inverted" : "") + ".png"
- // source: "qrc:/plugins/newsblur/images/like_icon-inverted.png"
- }
- MouseArea {
- id: likeMouseArea
- anchors.fill: parent
- onClicked: {
- if(root.classification <= 0)
- root.classificationSet(1);
- }
- }
- }
- }
|