home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / examples / tabdialog / tabdialog.cpp < prev    next >
C/C++ Source or Header  |  2001-10-11  |  4KB  |  111 lines

  1. /****************************************************************************
  2. ** $Id:  qt/tabdialog.cpp   3.0.0   edited Jun 22 13:24 $
  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.  
  22. TabDialog::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.  
  32. void 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.     QLabel *size = new QLabel( QString( "%1 KB" ).arg( fileinfo.size() ), tab1 );
  47.     size->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  48.  
  49.     (void)new QLabel( "Last Read:", tab1 );
  50.     QLabel *lread = new QLabel( fileinfo.lastRead().toString(), tab1 );
  51.     lread->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  52.  
  53.     (void)new QLabel( "Last Modified:", tab1 );
  54.     QLabel *lmodif = new QLabel( fileinfo.lastModified().toString(), tab1 );
  55.     lmodif->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  56.  
  57.     addTab( tab1, "General" );
  58. }
  59.  
  60. void TabDialog::setupTab2()
  61. {
  62.     QVBox *tab2 = new QVBox( this );
  63.     tab2->setMargin( 5 );
  64.  
  65.     QButtonGroup *bg = new QButtonGroup( 1, QGroupBox::Horizontal, "Permissions", tab2 );
  66.  
  67.     QCheckBox *readable = new QCheckBox( "Readable", bg );
  68.     if ( fileinfo.isReadable() )
  69.         readable->setChecked( TRUE );
  70.  
  71.     QCheckBox *writable = new QCheckBox( "Writeable", bg );
  72.     if ( fileinfo.isWritable() )
  73.         writable->setChecked( TRUE );
  74.  
  75.     QCheckBox *executable = new QCheckBox( "Executable", bg );
  76.     if ( fileinfo.isExecutable() )
  77.         executable->setChecked( TRUE );
  78.  
  79.     QButtonGroup *bg2 = new QButtonGroup( 2, QGroupBox::Horizontal, "Owner", tab2 );
  80.  
  81.     (void)new QLabel( "Owner", bg2 );
  82.     QLabel *owner = new QLabel( fileinfo.owner(), bg2 );
  83.     owner->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  84.  
  85.     (void)new QLabel( "Group", bg2 );
  86.     QLabel *group = new QLabel( fileinfo.group(), bg2 );
  87.     group->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  88.  
  89.     addTab( tab2, "Permissions" );
  90. }
  91.  
  92. void TabDialog::setupTab3()
  93. {
  94.     QVBox *tab3 = new QVBox( this );
  95.     tab3->setMargin( 5 );
  96.     tab3->setSpacing( 5 );
  97.     
  98.     (void)new QLabel( QString( "Open %1 with:" ).arg( filename ), tab3 );
  99.  
  100.     QListBox *prgs = new QListBox( tab3 );
  101.     for ( unsigned int i = 0; i < 30; i++ ) {
  102.         QString prg = QString( "Application %1" ).arg( i );
  103.         prgs->insertItem( prg );
  104.     }
  105.     prgs->setCurrentItem( 3 );
  106.  
  107.     (void)new QCheckBox( QString( "Open files with the extension '%1' always with this application" ).arg( fileinfo.extension() ), tab3 );
  108.  
  109.     addTab( tab3, "Applications" );
  110. }
  111.