blob: 85a358d883c4704725c82c9ec7c77158c1aa965a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/
#include "comboboxpage.h"
#include <MLayout>
#include <MLinearLayoutPolicy>
#include <MLocale>
#include <MLabel>
#include <MComboBox>
#include <MPopupList>
#include <MButton>
#include <QStringListModel>
#include <QSortFilterProxyModel>
#include <QStringList>
ComboBoxPage::ComboBoxPage()
: model1(0),
proxyModel(0)
{
gid = TemplatePage::ListsGridsAndMenus;
}
ComboBoxPage::~ComboBoxPage()
{
}
QString ComboBoxPage::timedemoTitle()
{
return "ComboBox";
}
void ComboBoxPage::createContent()
{
MApplicationPage::createContent();
createLayout();
containerLayout = new MLayout(container);
containerPolicy = new MLinearLayoutPolicy(containerLayout, Qt::Vertical);
containerLayout->setPolicy(containerPolicy);
QStringList list;
for (int i = 0; i < 10000; ++i) {
list << QString::number(10000 + i);
}
comboBox1 = new MComboBox;
comboBox1->setIconID("Icon-pictures");
comboBox1->addItems(list);
comboBox2 = new MComboBox;
comboBox2->setIconID("Icon-pictures");
model1 = new QStringListModel(this);
model1->setStringList(list);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(model1);
proxyModel->setDynamicSortFilter(true);
proxyModel->sort(0, Qt::DescendingOrder);
comboBox2->setItemModel(proxyModel);
containerPolicy->addItem(comboBox1);
containerPolicy->addItem(comboBox2);
retranslateUi();
}
void ComboBoxPage::retranslateUi()
{
//% "ComboBox"
setTitle(qtTrId("xx_combobox_title"));
if (!isContentCreated())
return;
//% "Title"
comboBox1->setTitle(qtTrId("xx_popup_generic_title"));
//% "Sort - DescendingOrder"
comboBox2->setTitle(qtTrId("xx_popup_sort_descending_order"));
//% "The MComboBox widget is a combined button and popup list. "
//% "It is very similar to QComboBox, but does not allow editing the text."
infoLabel->setText("<a></a>" + qtTrId("xx_combobox_page_info"));
}
|