ListElements/ModelViewList/PLLayout.cpp
author wesleyt@symbian.org
Thu, 09 Sep 2010 11:30:41 -0700
changeset 45 b23ec2b62c45
permissions -rw-r--r--
resizing layouts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     1
#include "PLLayout.h"
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     2
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     3
#include <QDebug>
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     4
#include <QApplication>
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     5
#include <QDesktopWidget>
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     6
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     7
PLLayout::PLLayout()
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     8
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
     9
    m_numOfClients=0;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    10
    m_currentLayoutIdx=-1;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    11
    m_portraitLayoutIdx=-1;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    12
    m_landscapeLayoutIdx=-1;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    13
    m_hasLLayout=false;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    14
    m_hasPLayout=false;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    15
    m_isPLayout=false;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    16
    m_isLLayout=false;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    17
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    18
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    19
PLLayout::~PLLayout()
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    20
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    21
    //take ownership and responsibility to clean up the child layouts
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    22
    while(m_numOfClients>0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    23
        delete(m_layoutList[--m_numOfClients]);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    24
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    25
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    26
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    27
/*
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    28
  FIRST, some basic methods that implement the quite
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    29
  universal engine of this portrait landscape manager.
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    30
*/
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    31
int PLLayout::newLayout(QLayout *clientlayout)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    32
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    33
    m_layoutList.append(clientlayout);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    34
    if(m_currentLayoutIdx==-1)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    35
        m_currentLayoutIdx=0;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    36
    return m_numOfClients++;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    37
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    38
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    39
void PLLayout::activateLayout(int idx) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    40
    if((idx>-1)&&(idx<m_numOfClients)) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    41
        if(m_currentLayoutIdx != idx) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    42
            m_currentLayoutIdx = idx;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    43
            redrawParent();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    44
        }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    45
    } else
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    46
        qDebug() << "ERROR: selecting unassigned MultLayoutClient. IDX=" << idx
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    47
                 << " numOfClients=" << m_numOfClients;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    48
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    49
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    50
int PLLayout::getLayoutIdx() const
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    51
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    52
    return m_currentLayoutIdx;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    53
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    54
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    55
void PLLayout::redrawParent()
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    56
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    57
    activate(); //inherited from QLayout
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    58
    update();   //inherited from QLayout	
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    59
    QWidget *w = parentWidget();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    60
    if(!(w == 0))
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    61
        w->updateGeometry();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    62
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    63
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    64
/*
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    65
  NOW, implement all required methods of a QLayout Subclass, and point
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    66
  them to the actual activated layout
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    67
*/
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    68
void PLLayout::addItem(QLayoutItem *item)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    69
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    70
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    71
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    72
        return;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    73
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    74
    m_layoutList[getLayoutIdx()]->addItem(item);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    75
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    76
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    77
QSize PLLayout::sizeHint() const {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    78
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    79
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    80
        return QSize(0,0);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    81
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    82
    return (m_layoutList[getLayoutIdx()]->sizeHint());
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    83
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    84
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    85
QSize PLLayout::minimumSize() const
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    86
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    87
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    88
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    89
        return QSize(0,0);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    90
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    91
    return( m_layoutList[getLayoutIdx()]->minimumSize());
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    92
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    93
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    94
void PLLayout::setGeometry(const QRect &rect)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    95
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    96
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    97
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    98
        return ;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
    99
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   100
    m_layoutList[getLayoutIdx()]->setGeometry(rect);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   101
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   102
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   103
bool PLLayout::hasHeightForWidth() const
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   104
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   105
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   106
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   107
        return false;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   108
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   109
    return m_layoutList[getLayoutIdx()]->hasHeightForWidth();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   110
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   111
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   112
int PLLayout::heightForWidth(int n) const
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   113
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   114
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   115
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   116
        return 0;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   117
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   118
    return m_layoutList[getLayoutIdx()]->heightForWidth(n);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   119
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   120
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   121
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   122
QLayoutItem * PLLayout::itemAt(int index) const
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   123
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   124
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   125
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   126
        return 0;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   127
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   128
    return m_layoutList[getLayoutIdx()]->itemAt(index);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   129
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   130
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   131
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   132
QLayoutItem * PLLayout::takeAt(int index)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   133
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   134
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   135
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   136
        return 0;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   137
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   138
    return m_layoutList[getLayoutIdx()]->takeAt(index);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   139
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   140
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   141
int PLLayout::count() const
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   142
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   143
    if (m_numOfClients<0) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   144
        qDebug() << "ERROR: using MultLayout before assigning client.";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   145
        return 0;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   146
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   147
    return m_layoutList[getLayoutIdx()]->count();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   148
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   149
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   150
/*
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   151
  Now we add some convenience API methods to handle portrait/landscape comfortable
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   152
  While the above mechanism is quite universal and may be re-used beyond portrait
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   153
  landscape use case, these implement the dedicated API for portrait / landscape use.
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   154
*/
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   155
int PLLayout::setLLayout(QLayout *clientlayout)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   156
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   157
    if(m_hasLLayout) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   158
        qDebug() << "ERROR: re-assigning Layout to FthLPMultiLayout is not allowed";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   159
        return -1;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   160
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   161
    int i = newLayout(clientlayout);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   162
    m_hasLLayout = true;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   163
    m_landscapeLayoutIdx = i;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   164
    activateLayout(m_landscapeLayoutIdx);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   165
    m_isLLayout = true;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   166
    return i;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   167
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   168
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   169
int PLLayout::setPLayout(QLayout *clientlayout)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   170
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   171
    if(m_hasPLayout) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   172
        qDebug() << "ERROR: re-assigning Layout to FthLPMultiLayout is not allowed";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   173
        return -1;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   174
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   175
    int i = newLayout(clientlayout);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   176
    m_hasPLayout = true;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   177
    m_portraitLayoutIdx = i;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   178
    activateLayout(m_portraitLayoutIdx);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   179
    m_isPLayout = true;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   180
    return i;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   181
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   182
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   183
void PLLayout::activatePLayout()
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   184
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   185
    if((m_isLLayout)&&(m_hasPLayout)) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   186
        activateLayout(m_portraitLayoutIdx);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   187
        m_isPLayout = true;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   188
    } else {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   189
        qDebug() << "ERROR: first assign portrait and landscape layouts to FthLPMultiLayout";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   190
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   191
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   192
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   193
void PLLayout::activateLLayout()
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   194
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   195
    if((m_isPLayout)&&(m_hasLLayout)) {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   196
        activateLayout(m_landscapeLayoutIdx);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   197
        m_isLLayout = true;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   198
    } else {
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   199
        qDebug() << "ERROR: first assign portrait and landscape layouts to FthLPMultiLayout";
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   200
    }
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   201
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   202
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   203
/*
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   204
    and finally a convenience function for the parent widgets event handler
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   205
*/
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   206
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   207
void PLLayout::resizeEvent(QResizeEvent* event)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   208
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   209
    QRect qs=QApplication::desktop()->availableGeometry();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   210
    if(qs.height() > qs.width())
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   211
        activatePLayout();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   212
    else
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   213
        activateLLayout();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   214
}
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   215
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   216
/*
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   217
  REFERENCES
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   218
        http://lists.trolltech.com/qt-interest/2004-01/thread00746-0.html
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   219
        http://wiki.forum.nokia.com/index.php/CS001437_-_Listening_for_screen_orientation_changes_in_Qt
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   220
        http://wiki.forum.nokia.com/index.php/Dynamic_Layout_handling_with_QWidget
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents:
diff changeset
   221
*/