00001 #include <QtCore/QString>
00002 #include <QtCore/QtDebug>
00003 #include <QtGui/QMessageBox>
00004
00005 #include "ACE/foldertreemodel.h"
00006 #include "ACE/FolderOpenDialog.h"
00007
00008
00009 FolderOpenDialog::FolderOpenDialog( QWidget* parent, Qt::WindowFlags f ) :
00010 QDialog( parent, f )
00011 {
00012 setupUi( this );
00013 setConnections();
00014 tagList = QStringList();
00015 dateTimeEdit_Since->setDateTime( QDateTime::currentDateTime() );
00016 }
00017
00018 FolderOpenDialog::~FolderOpenDialog()
00019 {}
00020
00021 void FolderOpenDialog::prepare( cool::IFolderPtr fPtr, QString fName )
00022 {
00023 folderName = fName;
00024 folderPtr = fPtr;
00025 label_FolderName->setText( folderName );
00026 fill();
00027 }
00028
00029 void FolderOpenDialog::setConnections()
00030 {
00031 QObject::connect( pushButton_Open, SIGNAL( clicked() ), this, SLOT( slotOpen() ) );
00032 }
00033
00034 void FolderOpenDialog::fill()
00035 {
00036
00037 comboBox_Tags->clear();
00038 tagList.clear();
00039 const std::vector< std::string > v = folderPtr->listTags();
00040 bool enableTags( v.size() > 0 );
00041 groupBox_TagSelection->setVisible( enableTags );
00042 if ( enableTags )
00043 {
00044 for ( unsigned i = 0; i < v.size(); ++i )
00045 {
00046 tagList.append( QString::fromStdString( v[ i ] ) );
00047 }
00048 comboBox_Tags->addItems( tagList );
00049 }
00050 else
00051 {
00052 groupBox_TagSelection->setChecked( false );
00053 }
00054
00055 listWidget_CurrentChannelSelection->clear();
00056 comboBox_From->clear();
00057 comboBox_To->clear();
00058 channelList.clear();
00059 const std::vector< cool::ChannelId > v1 = folderPtr->listChannels();
00060 for ( unsigned i = 0; i < v1.size(); ++i )
00061 {
00062 const unsigned int channelId = ( unsigned int ) v1[ i ];
00063 channelList.append( qMakePair( false, channelId ) );
00064 QString channelIdHex = QString( "%L1" ).arg( channelId, 0, 16 );
00065 comboBox_From->addItem( channelIdHex );
00066 comboBox_To->addItem( channelIdHex );
00067 }
00068 }
00069
00070 cool::ValidityKey FolderOpenDialog::getSinceIOV()
00071 {
00072 if ( !groupBox_IOVSelection->isChecked() )
00073 return cool::ValidityKeyMin;
00074
00075 cool::ValidityKey s;
00076 if ( radioButton_IOVrecent->isChecked() )
00077 s = cool::ValidityKeyMax;
00078 else
00079 s = (qulonglong)( dateTimeEdit_Since->dateTime().toTime_t() ) * (qulonglong)( 1000000000 );
00080 return s;
00081 }
00082
00083 cool::ChannelSelection FolderOpenDialog::getChannelSelection()
00084 {
00085 return cool::ChannelSelection();
00086 }
00087
00088 QString FolderOpenDialog::getTag()
00089 {
00090 if ( tagList.isEmpty() || !groupBox_TagSelection->isChecked() )
00091 {
00092 return QString( "" );
00093 }
00094 return comboBox_Tags->currentText();
00095 }
00096
00097 QString FolderOpenDialog::getFolderCharacteristics()
00098 {
00099 QString channels, iov;
00100 cool::ValidityKey IOVsince = getSinceIOV();
00101
00102
00103 if ( IOVsince == cool::ValidityKeyMin )
00104 iov = QString( "All IOVs" );
00105 else if ( IOVsince == cool::ValidityKeyMax )
00106 iov = QString( "Most recent IOVs" );
00107 else
00108 iov = QString( "IOVs since %1" ).arg( dateTimeEdit_Since->dateTime().toString( "ddd dd/MM/yyyy HH:mm:ss" ) );
00109
00110
00111 cool::ChannelSelection cs = getChannelSelection();
00112 if ( cs.allChannels() )
00113 channels = QString( "All" );
00114 else
00115 channels = QString( "subset" );
00116
00117 return QString( "Tag[%1] : Channels[%2] : %3" ).arg( getTag() ).arg( channels ).arg( iov );
00118 }
00119
00120 void FolderOpenDialog::slotOpen()
00121 {
00122 accept();
00123 }