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