ListElements/ModelViewList/mainwindow.cpp
author wesleyt@symbian.org
Thu, 09 Sep 2010 11:30:41 -0700
changeset 45 b23ec2b62c45
parent 44 ca3ea89c80a3
child 46 702dd26c0f4d
permissions -rwxr-xr-x
resizing layouts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
     1
#include <QMenuBar>
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
     2
#include <QMessageBox>
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
     3
#include <QResizeEvent>
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
     4
#include <QtGlobal>
42
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
     5
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
     6
#include "mainwindow.h"
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
     7
#include "ui_mainwindow.h"
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
#include "zodiacmodel.h"
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
#include "zodiacdelegate.h"
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    10
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    11
42
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
MainWindow::MainWindow(QWidget *parent) :
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
    QMainWindow(parent),
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
    ui(new Ui::MainWindow)
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
{
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    16
    ui->setupUi(this);
44
ca3ea89c80a3 remove obsolete dependencies
John Kern <johnk@symbian.org>
parents: 42
diff changeset
    17
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    18
    // Create widgets.
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    19
    listView = new QListView;
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    20
    listView->setFrameStyle(QFrame::Panel | QFrame::Raised);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    21
    listView->setLineWidth(4);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    22
    exitButton = new QPushButton(this);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    23
    exitButton->setText("Exit");
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    24
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    25
    // define the model
42
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    26
    ZodiacModel *zModel = new ZodiacModel(this);
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    27
    listView->setModel(zModel);
42
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    28
    ZodiacDelegate *delegate = new ZodiacDelegate(this);
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    29
    listView->setItemDelegate(delegate);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    30
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    31
    // create landscape layout
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    32
    layoutLandscape = new QHBoxLayout(this);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    33
    layoutLandscape->addWidget(listView);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    34
    layoutLandscape->addWidget(exitButton);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    35
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    36
    //create portrait layout
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    37
    layoutPortrait = new QVBoxLayout(this);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    38
    layoutPortrait->addWidget(listView);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    39
    layoutPortrait->addWidget(exitButton);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    40
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    41
    portLandLayout = new PLLayout();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    42
    portLandLayout->setPLayout(layoutPortrait);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    43
    portLandLayout->setLLayout(layoutLandscape);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    44
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    45
    centralWidget = new QWidget();
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    46
    centralWidget->setLayout(portLandLayout);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    47
    this->setCentralWidget(centralWidget);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    48
42
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    49
}
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    50
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    51
42
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    52
MainWindow::~MainWindow()
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    53
{
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    54
    delete ui;
b9716e8867f1 checking in example; variations on List Widgets
John Kern <johnk@symbian.org>
parents:
diff changeset
    55
}
45
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    56
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    57
void MainWindow::resizeEvent(QResizeEvent *e)
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    58
{
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    59
    portLandLayout->resizeEvent(e);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    60
    // Call base class impl
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    61
    QWidget::resizeEvent(e);
b23ec2b62c45 resizing layouts
wesleyt@symbian.org
parents: 44
diff changeset
    62
}