@ -56,17 +56,94 @@ PlasmaComponents.ListItem {
PlasmaComponents . Label {
height: implicitHeight
width: parent . width
maximumLineCount: 3
text: DisplayRole
visible: TypeRole != 1 / / T y p e R o l e : 0 : T e x t , 1 : I m a g e , 2 : U r l
visible: TypeRole == 0 / / T y p e R o l e : 0 : T e x t , 1 : I m a g e , 2 : U r l
textFormat: Text . PlainText
}
KQuickControlsAddons . QPixmapItem {
id: previewPixmap
width: parent . width
height: width * ( nativeHeight / nativeWidth )
pixmap: DecorationRole
visible: TypeRole == 1
fillMode: KQuickControlsAddons . QPixmapItem . PreserveAspectFit
}
Item {
visible: TypeRole == 2
height: units . gridUnit * 4
width: parent . width
Component.onCompleted: {
if ( TypeRole == 2 ) {
print ( "DisplayRole: " + DisplayRole ) ;
print ( " sliced: " + DisplayRole . slice ( 7 , DisplayRole . length ) ) ;
var urls = DisplayRole . slice ( 7 , DisplayRole . length ) . split ( "file://" ) ;
print ( "Model data inside delegate: " + urls ) ;
for ( var k in urls ) {
print ( "_____________ KEY: " + k + " " + urls [ k ] ) ;
}
previewList . model = urls
}
}
GridView {
id: previewList
/ / m o d e l : D i s p l a y R o l e . s p l i t ( " " )
property int itemWidth: units . gridUnit * 4
/ / o r i e n t a t i o n : Q t . H o r i z o n t a l
anchors.fill: parent
/ / c o l u m n s : p a r e n t . w i d t h / i t e m W i d t h
cellWidth: itemWidth
cellHeight: itemHeight
delegate: KQuickControlsAddons . QPixmapItem {
id: previewPixmap
/ / w i d t h : p a r e n t . w i d t h
/ / h e i g h t : w i d t h * ( n a t i v e H e i g h t / n a t i v e W i d t h )
/ / p i x m a p : D e c o r a t i o n R o l e
width: previewList . itemWidth
height: previewList . itemWidth
/ / v i s i b l e : T y p e R o l e = = 1 | | T y p e R o l e = = 2
fillMode: KQuickControlsAddons . QPixmapItem . PreserveAspectFit
Component.onCompleted: {
var service = clipboardSource . serviceForSource ( UuidRole )
var operation = "preview" ;
function result ( job ) {
/ / p r i n t ( " r e s u l t ! . . " ) ;
if ( ! job . error ) {
print ( "Cool!" ) ;
print ( " res: " + job . result [ "url" ] ) ;
pixmap = job . result [ "preview" ] ;
} else {
print ( "Job failed" ) ;
}
/ / s p i x m a p = j o b . r e s u l t ;
/ / p r i n t ( " S e r v i c e J o b e r r o r : " + j o b . e r r o r + " r e s u l t : " + j o b . r e s u l t + " o p : " + j o b . o p e r a t i o n N a m e ) ;
}
var operation = service . operationDescription ( operation ) ;
operation . urls = modelData ;
/ / o p e r a t i o n . p a s s w o r d = p a s s w o r d ;
var serviceJob = service . startOperationCall ( operation ) ;
serviceJob . finished . connect ( result ) ;
print ( "JOb started: " + modelData ) ;
}
Rectangle {
border.width: 2
border.color: "black"
color: "transparent"
anchors.fill: parent
}
}
}
}
}
RowLayout {