ganeswidgets/inc/HgScrollBufferManager.h
changeset 0 89c329efa980
child 1 e48454f237ca
equal deleted inserted replaced
-1:000000000000 0:89c329efa980
       
     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:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef HGSCROLLBUFFERMANAGER_H_
       
    20 #define HGSCROLLBUFFERMANAGER_H_
       
    21 
       
    22 #include <qobject>
       
    23 #include <QTimer>
       
    24 
       
    25 class HgScrollBufferManager: public QObject
       
    26     {
       
    27     Q_OBJECT
       
    28 public:
       
    29 
       
    30     HgScrollBufferManager(
       
    31             int bufferSize,
       
    32             int bufferTreshold,
       
    33             int initialPosition,
       
    34             int totalCount);
       
    35 
       
    36     virtual ~HgScrollBufferManager();
       
    37 
       
    38     void resetBuffer(int aPosition, int aTotalCount);
       
    39 
       
    40     void scrollPositionChanged(int newPosition);
       
    41 
       
    42     bool positionInsideBuffer(int position);
       
    43 
       
    44     void removeItems(int start, int end, int totalCount);
       
    45     void addItems(int start, int end, int totalCount);
       
    46     void moveItems(int start, int end, int target, int totalCount);
       
    47 
       
    48     void currentBuffer(int& bufferStart, int& bufferEnd);
       
    49 
       
    50 signals:
       
    51 
       
    52     void releaseItems(int releaseStart, int releaseEnd);
       
    53     void requestItems(int requestStart, int requestEnd);
       
    54 
       
    55 protected slots:
       
    56 
       
    57     void timeout();
       
    58 
       
    59 protected:
       
    60 
       
    61     void init();
       
    62     void asyncUpdate();
       
    63     bool isInsideBuffer(int pos);
       
    64     bool isInsideBuffer(int start, int end);
       
    65 
       
    66 private:
       
    67 
       
    68     int mBufferSize;
       
    69     int mBufferTreshold;
       
    70     int mBufferPosition;
       
    71     int mDiff;
       
    72     int mTotalCount;
       
    73 
       
    74     bool mResetOrdered;
       
    75 
       
    76     int mRequestStart;
       
    77     int mRequestCount;
       
    78     int mReleaseStart;
       
    79     int mReleaseCount;
       
    80     QTimer mTimer;
       
    81 
       
    82 private:
       
    83     Q_DISABLE_COPY(HgScrollBufferManager)
       
    84     };
       
    85 
       
    86 #endif /*HGSCROLLBUFFERMANAGER_H_*/