00001 #include "imagedlg.h" 00002 #include "image.h" 00003 00004 ImageDlg::ImageDlg( std::string &img, int &type ) : 00005 QDialog( NULL, NULL, true ), 00006 mImg( img ), 00007 mType( type ) { 00008 setCaption( "Image Selection" ); 00009 00010 for ( int imffn=0; imffn < Image::NUM_MFF; imffn++ ) 00011 mTypeSet.push_back( Image::MFF_NAMES[imffn] ); 00012 00013 buildDialog(); 00014 } 00015 00016 00017 void ImageDlg::buildDialog( ) { 00018 QHBox *hbox = NULL; 00019 QGrid *grid = NULL; 00020 QPushButton *but = NULL; 00021 00022 QVBoxLayout *vbox = new QVBoxLayout( this ); 00023 vbox->setAutoAdd( true ); 00024 vbox->setMargin( 10 ); 00025 00026 grid = new QGrid( 2, this ); 00027 grid->setSpacing( 7 ); 00028 grid->setMargin( 5 ); 00029 00030 // grid = new QGrid( 2, this ); 00031 new QLabel( "Image: ", grid ); 00032 hbox = new QHBox( grid ); 00033 hbox->setSpacing( 5 ); 00034 mTxtImg = new QLineEdit( hbox ); 00035 mTxtImg->setMinimumWidth( 225 ); 00036 but = new QPushButton( "Browse", hbox ); 00037 connect( but, SIGNAL( clicked() ), this, SLOT( setImg() ) ); 00038 00039 mChkMulti = new QCheckBox( "Multi File", grid ); 00040 connect( mChkMulti, SIGNAL( toggled( bool ) ), this, SLOT( chkToggle( bool ) ) ); 00041 mCmbType = new QComboBox( grid ); 00042 mCmbType->setEnabled( false ); 00043 mCmbType->setMaximumWidth( 200 ); 00044 loadTypes(); 00045 00046 // grid = new QGrid( 2, this ); 00047 hbox = new QHBox( this ); 00048 hbox->setMargin( 5 ); 00049 but = new QPushButton( "Open", hbox ); 00050 but->setMaximumWidth( 85 ); 00051 connect( but, SIGNAL( clicked() ), this, SLOT( create() ) ); 00052 but = new QPushButton( "Cancel", hbox ); 00053 but->setMaximumWidth( 85 ); 00054 connect( but, SIGNAL( clicked() ), this, SLOT( reject() ) ); 00055 } 00056 00057 void ImageDlg::setImg( ) { 00058 QString img = QFileDialog::getOpenFileName( QString::null, QString::null, this ); 00059 if ( img.isNull() ) 00060 return; 00061 mTxtImg->setText( (const char*)img ); 00062 } 00063 00064 void ImageDlg::create( ) { 00065 mImg = (const char*)mTxtImg->text(); 00066 if ( mChkMulti->isChecked() ) 00067 mType = mCmbType->currentItem(); 00068 else 00069 mType = -1; 00070 00071 accept(); 00072 } 00073 00074 void ImageDlg::chkToggle( bool toggle ) { 00075 mCmbType->setEnabled( toggle ); 00076 } 00077 00078 void ImageDlg::loadTypes( ) { 00079 for ( int i=0; i < (int)mTypeSet.size(); i++ ) 00080 mCmbType->insertItem( mTypeSet[i].c_str() ); 00081 } 00082 00083
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |