- Timestamp:
- 02/21/09 00:05:30 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/jackMidi/gui/src/AudioFileBrowser/AudioFileBrowser.cpp
r822 r824 20 20 * 21 21 */ 22 23 22 24 23 #include "AudioFileBrowser.h" … … 34 33 #include <hydrogen/audio_engine.h> 35 34 35 #include <QModelIndex> 36 36 #include <QTreeWidget> 37 37 #include <QMessageBox> … … 44 44 , Object ( "AudioFileBrowser" ) 45 45 { 46 47 46 setupUi ( this ); 48 47 INFOLOG ( "INIT" ); … … 50 49 setFixedSize ( width(), height() ); 51 50 installEventFilter( this ); 52 53 51 54 52 model = new QDirModel(); … … 68 66 tree->setAlternatingRowColors( true ); 69 67 tree->setRootIndex( model->index( Preferences::getInstance()->__lastsampleDirectory ) ); 70 68 71 69 pathLineEdit->setText( Preferences::getInstance()->__lastsampleDirectory ); 72 70 m_psamplefilename = ""; 73 m_pselectedFile << "false" << "false" << "";71 m_pselectedFile << "false" << "false"; 74 72 75 73 sEmptySampleFilename = DataPath::get_data_path() + "/emptySample.wav"; … … 82 80 83 81 connect( tree, SIGNAL( clicked( const QModelIndex&) ), SLOT( clicked( const QModelIndex& ) ) ); 84 connect( pathLineEdit, SIGNAL( returnPressed() ), SLOT( updateModelIndex() ) ); 85 82 connect( pathLineEdit, SIGNAL( returnPressed() ), SLOT( updateModelIndex() ) ); 86 83 } 87 84 … … 94 91 INFOLOG ( "DESTROY" ); 95 92 } 93 94 95 96 void AudioFileBrowser::keyPressEvent (QKeyEvent *ev) 97 { 98 if( ev->modifiers()==Qt::ControlModifier ){ 99 tree->setSelectionMode( QAbstractItemView::MultiSelection ); 100 openBTN->setEnabled( true ); 101 } 102 } 103 104 105 106 void AudioFileBrowser::keyReleaseEvent (QKeyEvent *ev) 107 { 108 tree->setSelectionMode( QAbstractItemView::SingleSelection ); 109 } 110 96 111 97 112 … … 113 128 } 114 129 130 131 115 132 void AudioFileBrowser::clicked( const QModelIndex& index ) 116 133 { … … 142 159 pathLineEdit->setText( onlypath ); 143 160 161 QApplication::setOverrideCursor(Qt::WaitCursor); 144 162 145 163 if ( … … 154 172 ) { 155 173 156 157 174 Sample *pNewSample = Sample::load( path2 ); 175 158 176 if ( pNewSample ) { 159 177 m_pNBytesLable->setText( trUtf8( "Size: %1 bytes" ).arg( pNewSample->get_size() / 2 ) ); … … 167 185 m_psamplefilename = path2; 168 186 169 187 m_pSampleWaveDisplay->updateDisplay( path2 ); 188 m_pPlayBtn->setEnabled( true ); 189 openBTN->setEnabled( true ); 190 191 //important this will only working correct if m_pSampleWaveDisplay->updateDisplay( file ) 192 //is ready with painting the wav file. else the playing sample get crackled sound!! 170 193 if (playSamplescheckBox->isChecked()){ 171 194 if ( sec <= 600.00){ … … 176 199 } 177 200 } 178 179 m_pSampleWaveDisplay->updateDisplay( path2 );180 m_pPlayBtn->setEnabled( true );181 openBTN->setEnabled( true );182 183 201 } 184 202 … … 195 213 m_psamplefilename = ""; 196 214 } 215 QApplication::restoreOverrideCursor(); 197 216 } 198 217 … … 213 232 214 233 234 215 235 void AudioFileBrowser::on_m_pStopBtn_clicked() 216 236 { … … 227 247 m_pselectedFile << "false" << "false" << ""; 228 248 reject(); 229 230 249 } 231 250 … … 234 253 void AudioFileBrowser::on_openBTN_clicked() 235 254 { 236 if ( 237 ( ( filelineedit->text().endsWith( ".wav" ) ) || 238 ( filelineedit->text().endsWith( ".WAV" ) ) || 239 ( filelineedit->text().endsWith( ".au" ) ) || 240 ( filelineedit->text().endsWith( ".AU" ) ) || 241 ( filelineedit->text().endsWith( ".aiff" ) ) || 242 ( filelineedit->text().endsWith( ".AIFF" ) ) || 243 ( filelineedit->text().endsWith( ".flac" ) ) || 244 ( filelineedit->text().endsWith( ".FLAC" ) ) ) && 245 ( QFile( filelineedit->text() ).exists() == true ) 246 ) { 247 m_pselectedFile[2] = filelineedit->text(); 248 249 }else 250 { 251 m_pselectedFile << "false" << "false" << ""; 255 if( tree->selectionModel()->selectedIndexes().size() / 4 > 0){ 256 257 QList<QModelIndex>::iterator i; 258 QList<QModelIndex> list = tree->selectionModel()->selectedIndexes(); 259 260 for (i = list.begin(); i != list.end(); ++i){ 261 QString path2 = (*i).data().toString(); 262 if ( 263 ( path2.endsWith( ".wav" ) ) || 264 ( path2.endsWith( ".WAV" ) ) || 265 ( path2.endsWith( ".au" ) ) || 266 ( path2.endsWith( ".AU" ) ) || 267 ( path2.endsWith( ".aiff" ) ) || 268 ( path2.endsWith( ".AIFF" ) ) || 269 ( path2.endsWith( ".flac" ) ) || 270 ( path2.endsWith( ".FLAC" ) ) 271 ) { 272 QString path = pathLineEdit->text(); 273 QString act_filename = path + path2; 274 m_pselectedFile << act_filename ; 275 276 } 277 ++i;++i;++i; 252 278 } 279 } 253 280 Preferences::getInstance()->__lastsampleDirectory = pathLineEdit->text(); 254 281 accept(); … … 305 332 tree->collapse( model->index( updir ) ); 306 333 } 334 335 336 337 void AudioFileBrowser::on_hiddenCB_clicked() 338 { 339 if ( hiddenCB->isChecked() ){ 340 model->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden ); 341 }else 342 { 343 model->setFilter( QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot ); 344 tree->setRootIndex( model->index( pathLineEdit->text() ) ); 345 } 346 }