source: trunk/examples/tabdialog/tabdialog.cpp@ 7

Last change on this file since 7 was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1/****************************************************************************
2** $Id: tabdialog.cpp 2 2005-11-16 15:49:26Z dmik $
3**
4** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5**
6** This file is part of an example program for Qt. This example
7** program may be used, distributed and modified without limitation.
8**
9*****************************************************************************/
10
11#include "tabdialog.h"
12
13#include <qvbox.h>
14#include <qlabel.h>
15#include <qlineedit.h>
16#include <qdatetime.h>
17#include <qbuttongroup.h>
18#include <qcheckbox.h>
19#include <qlistbox.h>
20#include <qapplication.h>
21
22TabDialog::TabDialog( QWidget *parent, const char *name, const QString &_filename )
23 : QTabDialog( parent, name ), filename( _filename ), fileinfo( filename )
24{
25 setupTab1();
26 setupTab2();
27 setupTab3();
28
29 connect( this, SIGNAL( applyButtonPressed() ), qApp, SLOT( quit() ) );
30}
31
32void TabDialog::setupTab1()
33{
34 QVBox *tab1 = new QVBox( this );
35 tab1->setMargin( 5 );
36
37 (void)new QLabel( "Filename:", tab1 );
38 QLineEdit *fname = new QLineEdit( filename, tab1 );
39 fname->setFocus();
40
41 (void)new QLabel( "Path:", tab1 );
42 QLabel *path = new QLabel( fileinfo.dirPath( TRUE ), tab1 );
43 path->setFrameStyle( QFrame::Panel | QFrame::Sunken );
44
45 (void)new QLabel( "Size:", tab1 );
46 ulong kb = (ulong)(fileinfo.size()/1024);
47 QLabel *size = new QLabel( QString( "%1 KB" ).arg( kb ), tab1 );
48 size->setFrameStyle( QFrame::Panel | QFrame::Sunken );
49
50 (void)new QLabel( "Last Read:", tab1 );
51 QLabel *lread = new QLabel( fileinfo.lastRead().toString(), tab1 );
52 lread->setFrameStyle( QFrame::Panel | QFrame::Sunken );
53
54 (void)new QLabel( "Last Modified:", tab1 );
55 QLabel *lmodif = new QLabel( fileinfo.lastModified().toString(), tab1 );
56 lmodif->setFrameStyle( QFrame::Panel | QFrame::Sunken );
57
58 addTab( tab1, "General" );
59}
60
61void TabDialog::setupTab2()
62{
63 QVBox *tab2 = new QVBox( this );
64 tab2->setMargin( 5 );
65
66 QButtonGroup *bg = new QButtonGroup( 1, QGroupBox::Horizontal, "Permissions", tab2 );
67
68 QCheckBox *readable = new QCheckBox( "Readable", bg );
69 if ( fileinfo.isReadable() )
70 readable->setChecked( TRUE );
71
72 QCheckBox *writable = new QCheckBox( "Writeable", bg );
73 if ( fileinfo.isWritable() )
74 writable->setChecked( TRUE );
75
76 QCheckBox *executable = new QCheckBox( "Executable", bg );
77 if ( fileinfo.isExecutable() )
78 executable->setChecked( TRUE );
79
80 QButtonGroup *bg2 = new QButtonGroup( 2, QGroupBox::Horizontal, "Owner", tab2 );
81
82 (void)new QLabel( "Owner", bg2 );
83 QLabel *owner = new QLabel( fileinfo.owner(), bg2 );
84 owner->setFrameStyle( QFrame::Panel | QFrame::Sunken );
85
86 (void)new QLabel( "Group", bg2 );
87 QLabel *group = new QLabel( fileinfo.group(), bg2 );
88 group->setFrameStyle( QFrame::Panel | QFrame::Sunken );
89
90 addTab( tab2, "Permissions" );
91}
92
93void TabDialog::setupTab3()
94{
95 QVBox *tab3 = new QVBox( this );
96 tab3->setMargin( 5 );
97 tab3->setSpacing( 5 );
98
99 (void)new QLabel( QString( "Open %1 with:" ).arg( filename ), tab3 );
100
101 QListBox *prgs = new QListBox( tab3 );
102 for ( unsigned int i = 0; i < 30; i++ ) {
103 QString prg = QString( "Application %1" ).arg( i );
104 prgs->insertItem( prg );
105 }
106 prgs->setCurrentItem( 3 );
107
108 (void)new QCheckBox( QString( "Open files with the extension '%1' always with this application" ).arg( fileinfo.extension() ), tab3 );
109
110 addTab( tab3, "Applications" );
111}
Note: See TracBrowser for help on using the repository browser.