author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 20:15:53 +0300 | |
branch | RCL_3 |
changeset 13 | c0432d11811c |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the examples of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include <QtGui> |
|
43 |
||
44 |
#include "tabdialog.h" |
|
45 |
||
46 |
//! [0] |
|
47 |
TabDialog::TabDialog(const QString &fileName, QWidget *parent) |
|
48 |
: QDialog(parent) |
|
49 |
{ |
|
50 |
QFileInfo fileInfo(fileName); |
|
51 |
||
52 |
tabWidget = new QTabWidget; |
|
53 |
tabWidget->addTab(new GeneralTab(fileInfo), tr("General")); |
|
54 |
tabWidget->addTab(new PermissionsTab(fileInfo), tr("Permissions")); |
|
55 |
tabWidget->addTab(new ApplicationsTab(fileInfo), tr("Applications")); |
|
56 |
//! [0] |
|
57 |
||
58 |
//! [1] //! [2] |
|
59 |
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok |
|
60 |
//! [1] //! [3] |
|
61 |
| QDialogButtonBox::Cancel); |
|
62 |
||
63 |
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); |
|
64 |
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); |
|
65 |
//! [2] //! [3] |
|
66 |
||
67 |
//! [4] |
|
68 |
QVBoxLayout *mainLayout = new QVBoxLayout; |
|
69 |
mainLayout->addWidget(tabWidget); |
|
70 |
mainLayout->addWidget(buttonBox); |
|
71 |
setLayout(mainLayout); |
|
72 |
//! [4] |
|
73 |
||
74 |
//! [5] |
|
75 |
setWindowTitle(tr("Tab Dialog")); |
|
76 |
} |
|
77 |
//! [5] |
|
78 |
||
79 |
//! [6] |
|
80 |
GeneralTab::GeneralTab(const QFileInfo &fileInfo, QWidget *parent) |
|
81 |
: QWidget(parent) |
|
82 |
{ |
|
83 |
QLabel *fileNameLabel = new QLabel(tr("File Name:")); |
|
84 |
QLineEdit *fileNameEdit = new QLineEdit(fileInfo.fileName()); |
|
85 |
||
86 |
QLabel *pathLabel = new QLabel(tr("Path:")); |
|
87 |
QLabel *pathValueLabel = new QLabel(fileInfo.absoluteFilePath()); |
|
88 |
pathValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
|
89 |
||
90 |
QLabel *sizeLabel = new QLabel(tr("Size:")); |
|
91 |
qlonglong size = fileInfo.size()/1024; |
|
92 |
QLabel *sizeValueLabel = new QLabel(tr("%1 K").arg(size)); |
|
93 |
sizeValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
|
94 |
||
95 |
QLabel *lastReadLabel = new QLabel(tr("Last Read:")); |
|
96 |
QLabel *lastReadValueLabel = new QLabel(fileInfo.lastRead().toString()); |
|
97 |
lastReadValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
|
98 |
||
99 |
QLabel *lastModLabel = new QLabel(tr("Last Modified:")); |
|
100 |
QLabel *lastModValueLabel = new QLabel(fileInfo.lastModified().toString()); |
|
101 |
lastModValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
|
102 |
||
103 |
QVBoxLayout *mainLayout = new QVBoxLayout; |
|
104 |
mainLayout->addWidget(fileNameLabel); |
|
105 |
mainLayout->addWidget(fileNameEdit); |
|
106 |
mainLayout->addWidget(pathLabel); |
|
107 |
mainLayout->addWidget(pathValueLabel); |
|
108 |
mainLayout->addWidget(sizeLabel); |
|
109 |
mainLayout->addWidget(sizeValueLabel); |
|
110 |
mainLayout->addWidget(lastReadLabel); |
|
111 |
mainLayout->addWidget(lastReadValueLabel); |
|
112 |
mainLayout->addWidget(lastModLabel); |
|
113 |
mainLayout->addWidget(lastModValueLabel); |
|
114 |
mainLayout->addStretch(1); |
|
115 |
setLayout(mainLayout); |
|
116 |
} |
|
117 |
//! [6] |
|
118 |
||
119 |
//! [7] |
|
120 |
PermissionsTab::PermissionsTab(const QFileInfo &fileInfo, QWidget *parent) |
|
121 |
: QWidget(parent) |
|
122 |
{ |
|
123 |
QGroupBox *permissionsGroup = new QGroupBox(tr("Permissions")); |
|
124 |
||
125 |
QCheckBox *readable = new QCheckBox(tr("Readable")); |
|
126 |
if (fileInfo.isReadable()) |
|
127 |
readable->setChecked(true); |
|
128 |
||
129 |
QCheckBox *writable = new QCheckBox(tr("Writable")); |
|
130 |
if ( fileInfo.isWritable() ) |
|
131 |
writable->setChecked(true); |
|
132 |
||
133 |
QCheckBox *executable = new QCheckBox(tr("Executable")); |
|
134 |
if ( fileInfo.isExecutable() ) |
|
135 |
executable->setChecked(true); |
|
136 |
||
137 |
QGroupBox *ownerGroup = new QGroupBox(tr("Ownership")); |
|
138 |
||
139 |
QLabel *ownerLabel = new QLabel(tr("Owner")); |
|
140 |
QLabel *ownerValueLabel = new QLabel(fileInfo.owner()); |
|
141 |
ownerValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
|
142 |
||
143 |
QLabel *groupLabel = new QLabel(tr("Group")); |
|
144 |
QLabel *groupValueLabel = new QLabel(fileInfo.group()); |
|
145 |
groupValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
|
146 |
||
147 |
QVBoxLayout *permissionsLayout = new QVBoxLayout; |
|
148 |
permissionsLayout->addWidget(readable); |
|
149 |
permissionsLayout->addWidget(writable); |
|
150 |
permissionsLayout->addWidget(executable); |
|
151 |
permissionsGroup->setLayout(permissionsLayout); |
|
152 |
||
153 |
QVBoxLayout *ownerLayout = new QVBoxLayout; |
|
154 |
ownerLayout->addWidget(ownerLabel); |
|
155 |
ownerLayout->addWidget(ownerValueLabel); |
|
156 |
ownerLayout->addWidget(groupLabel); |
|
157 |
ownerLayout->addWidget(groupValueLabel); |
|
158 |
ownerGroup->setLayout(ownerLayout); |
|
159 |
||
160 |
QVBoxLayout *mainLayout = new QVBoxLayout; |
|
161 |
mainLayout->addWidget(permissionsGroup); |
|
162 |
mainLayout->addWidget(ownerGroup); |
|
163 |
mainLayout->addStretch(1); |
|
164 |
setLayout(mainLayout); |
|
165 |
} |
|
166 |
//! [7] |
|
167 |
||
168 |
//! [8] |
|
169 |
ApplicationsTab::ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent) |
|
170 |
: QWidget(parent) |
|
171 |
{ |
|
172 |
QLabel *topLabel = new QLabel(tr("Open with:")); |
|
173 |
||
174 |
QListWidget *applicationsListBox = new QListWidget; |
|
175 |
QStringList applications; |
|
176 |
||
177 |
for (int i = 1; i <= 30; ++i) |
|
178 |
applications.append(tr("Application %1").arg(i)); |
|
179 |
applicationsListBox->insertItems(0, applications); |
|
180 |
||
181 |
QCheckBox *alwaysCheckBox; |
|
182 |
||
183 |
if (fileInfo.suffix().isEmpty()) |
|
184 |
alwaysCheckBox = new QCheckBox(tr("Always use this application to " |
|
185 |
"open this type of file")); |
|
186 |
else |
|
187 |
alwaysCheckBox = new QCheckBox(tr("Always use this application to " |
|
188 |
"open files with the extension '%1'").arg(fileInfo.suffix())); |
|
189 |
||
190 |
QVBoxLayout *layout = new QVBoxLayout; |
|
191 |
layout->addWidget(topLabel); |
|
192 |
layout->addWidget(applicationsListBox); |
|
193 |
layout->addWidget(alwaysCheckBox); |
|
194 |
setLayout(layout); |
|
195 |
} |
|
196 |
//! [8] |