videocollection/videocollectionwrapper/src/videoproxymodelcontent.cpp
changeset 62 0e1e938beb1a
equal deleted inserted replaced
59:a76e86df7ccd 62:0e1e938beb1a
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   VideoProxyModelContent implementation
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "videoproxymodelgeneric.h"
       
    22 #include "videoproxymodelcontent.h"
       
    23 #include "videolistdatamodel.h"
       
    24 #include "videocollectiontrace.h"
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // VideoProxyModelContent::VideoProxyModelGeneric
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 VideoProxyModelContent::VideoProxyModelContent(QObject *parent) :
       
    31 VideoProxyModelGeneric(parent)
       
    32 {
       
    33 	FUNC_LOG_ADDR(this);
       
    34 }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // VideoProxyModelContent::~VideoProxyModelContent
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 VideoProxyModelContent::~VideoProxyModelContent()
       
    41 {
       
    42 	FUNC_LOG_ADDR(this);
       
    43 }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // VideoProxyModelContent::connectSignals
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 bool VideoProxyModelContent::connectSignals()
       
    50 {
       
    51     FUNC_LOG_ADDR(this);
       
    52     
       
    53     if(!VideoProxyModelGeneric::connectSignals())
       
    54     {
       
    55         return false;
       
    56     }
       
    57 
       
    58     if(!connect(mModel, SIGNAL(albumChanged()), 
       
    59             this, SLOT(albumChangedSlot()))) 
       
    60     {
       
    61         return false;
       
    62     }
       
    63 
       
    64     return true;
       
    65 }
       
    66    
       
    67 // -----------------------------------------------------------------------------
       
    68 // VideoProxyModelContent::disconnectSignals
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void VideoProxyModelContent::disconnectSignals()
       
    72 {
       
    73     FUNC_LOG_ADDR(this);
       
    74     
       
    75     VideoProxyModelGeneric::disconnectSignals();
       
    76     
       
    77     disconnect(mModel, SIGNAL(albumChanged()), 
       
    78             this, SLOT(albumChangedSlot()));
       
    79 }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // VideoProxyModelContent::filterAcceptsRow
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 bool VideoProxyModelContent::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
       
    86 {
       
    87     Q_UNUSED(source_parent);
       
    88     
       
    89     if(!sourceModel())
       
    90     {
       
    91         return false;
       
    92     }
       
    93 
       
    94     if(source_row < 0 || source_row >= sourceModel()->rowCount())
       
    95     {
       
    96         return false;
       
    97     }
       
    98     
       
    99     TMPXItemId id = mModel->mediaIdAtIndex(source_row);
       
   100 
       
   101     // Accept item if it belongs to the open album.
       
   102     if(mModel->belongsToAlbum(id))
       
   103     {
       
   104         return true;
       
   105     }
       
   106     
       
   107     return false;
       
   108 }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // VideoProxyModelContent::getOpenItem()
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 TMPXItemId VideoProxyModelContent::getOpenItem() const
       
   115 {
       
   116 	FUNC_LOG_ADDR(this);
       
   117     TMPXItemId itemId = TMPXItemId::InvalidId();
       
   118     
       
   119     if(mModel && mCollectionClient)
       
   120     {
       
   121         INFO_1("VideoProxyModelContent::getOpenItem() [0x%x] category or album is open.", this);
       
   122         itemId = mModel->albumInUse();
       
   123     }
       
   124 
       
   125     return itemId;
       
   126 }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // VideoProxyModelContent::albumChangedSlot()
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 void VideoProxyModelContent::albumChangedSlot()
       
   133 {
       
   134     FUNC_LOG_ADDR(this);
       
   135     // Sort and invalidate filtering, otherwise newly created album content won't sort.
       
   136     invalidateFilter();
       
   137     setSortRole(mWantedSortRole);
       
   138     sort(0, mWantedSortOrder);
       
   139 }
       
   140 
       
   141 // End of file