Changeset 483

Show
Ignore:
Timestamp:
09/16/08 19:56:42 (5 years ago)
Author:
wolke
Message:

some work on audio file browser

Location:
branches/audiofilebrowser
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • branches/audiofilebrowser/gui/src/AudioFileBrowser/AudioFileBrowser.cpp

    r482 r483  
    6060        installEventFilter(this); 
    6161 
     62        QDir lastsampleDirectory =  Preferences::getInstance()->__lastsampleDirectory; 
     63 
    6264 
    6365        model = new QDirModel(); 
     
    7072 
    7173//      namelabel->setText(model->headerData()); 
    72         QTreeView *tree = new QTreeView(treeView); 
     74        tree = new QTreeView(treeView); 
    7375        tree->setModel(model); 
    7476        tree->resize(799, 310); 
    7577        tree->header()->resizeSection ( 0, 405 ); 
    76         tree->setRootIndex(model->index(QDir::homePath())); 
    77  
     78        tree->setRootIndex(model->index(Preferences::getInstance()->__lastsampleDirectory)); 
     79 
     80        pathLineEdit->setText(Preferences::getInstance()->__lastsampleDirectory); 
    7881        m_psamplefilename = "";  
    7982        m_pselectedFile = ""; 
    8083 
    8184        connect(tree, SIGNAL(clicked(const QModelIndex&)), SLOT(clicked(const QModelIndex&))); 
     85        connect(pathLineEdit, SIGNAL( returnPressed() ), SLOT( updateModelIndex( ) )); 
     86 
     87//      QTimer *timer = new QTimer( this ); 
     88//      connect(timer, SIGNAL(timeout() ), this, SLOT( updateModelIndex() ) ); 
     89//      timer->start( 1000 ); 
    8290         
    8391} 
     
    9199 
    92100 
     101void AudioFileBrowser::updateModelIndex( ) 
     102{ 
     103                tree->setRootIndex(model->index( pathLineEdit->text())); 
     104} 
    93105 
    94106void AudioFileBrowser::clicked(const QModelIndex& index) 
     
    96108 
    97109        QString path = model->filePath(index); 
     110        pathLineEdit->setText(path); 
    98111        filelineedit->setText(path); 
     112         
    99113        if ( model->isDir(index)) 
    100114                 return; 
    101  
     115         
    102116        QString name = path.section( '/', -1 );  
     117         
     118        QString path2 = path; 
     119        QString onlypath = path; 
     120        if (name != ""){ 
     121                onlypath = path.replace( name, ""); 
     122        } 
     123                 
    103124        name = name.left('.'); 
    104125 
    105126        QString message = "Name: " + name; 
    106         filelineedit->setText(path); 
     127        filelineedit->setText(path2); 
     128        pathLineEdit->setText(onlypath); 
    107129 
    108130 
    109131        if      ( 
    110                 ( path.endsWith( ".wav" ) ) || 
    111                 ( path.endsWith( ".WAV" ) ) || 
    112                 ( path.endsWith( ".au" ) ) || 
    113                 ( path.endsWith( ".AU" ) ) || 
    114                 ( path.endsWith( ".aiff" ) ) || 
    115                 ( path.endsWith( ".AIFF" ) ) || 
    116                 ( path.endsWith( ".flac" ) ) || 
    117                 ( path.endsWith( ".FLAC" ) ) 
     132                ( path2.endsWith( ".wav" ) ) || 
     133                ( path2.endsWith( ".WAV" ) ) || 
     134                ( path2.endsWith( ".au" ) ) || 
     135                ( path2.endsWith( ".AU" ) ) || 
     136                ( path2.endsWith( ".aiff" ) ) || 
     137                ( path2.endsWith( ".AIFF" ) ) || 
     138                ( path2.endsWith( ".flac" ) ) || 
     139                ( path2.endsWith( ".FLAC" ) ) 
    118140                ) { 
    119141 
    120142 
    121                         Sample *pNewSample = Sample::load( path ); 
     143                        Sample *pNewSample = Sample::load( path2 ); 
    122144                        if (pNewSample) { 
    123145                                m_pNBytesLable->setText( trUtf8( "Size: %1 bytes" ).arg( pNewSample->get_size() ) ); 
     
    131153                                        delete pNewSample; 
    132154                                } 
     155 
    133156                                m_pPlayBtn->setEnabled( true ); 
    134157                                openBTN->setEnabled( true ); 
    135                                 m_psamplefilename = path; 
     158                                m_psamplefilename = path2; 
    136159                        }                
    137160                        m_pNameLabel->setText(message);                  
     
    164187void AudioFileBrowser::on_cancelBTN_clicked() 
    165188{ 
     189        Preferences::getInstance()->__lastsampleDirectory = pathLineEdit->text(); 
    166190        m_pselectedFile = ""; 
    167191        reject(); 
     
    189213                        m_pselectedFile = ""; 
    190214                } 
     215        Preferences::getInstance()->__lastsampleDirectory = pathLineEdit->text(); 
    191216        accept(); 
    192217} 
  • branches/audiofilebrowser/gui/src/AudioFileBrowser/AudioFileBrowser.h

    r481 r483  
    5656                void clicked(const QModelIndex& index); 
    5757                void on_m_pPlayBtn_clicked(); 
     58                void updateModelIndex(); 
    5859 
    5960        private: 
     
    6263                QString m_pselectedFile; 
    6364                QDirModel *model; 
     65                QTreeView *tree; 
    6466                 
    6567 
  • branches/audiofilebrowser/gui/src/AudioFileBrowser/AudioFileBrowser_UI.ui

    r482 r483  
    77    <y>0</y> 
    88    <width>824</width> 
    9     <height>502</height> 
     9    <height>529</height> 
    1010   </rect> 
    1111  </property> 
     
    1616   <property name="geometry" > 
    1717    <rect> 
    18      <x>640</x> 
    19      <y>460</y> 
    20      <width>75</width> 
     18     <x>604</x> 
     19     <y>490</y> 
     20     <width>101</width> 
    2121     <height>26</height> 
    2222    </rect> 
     
    3030    <rect> 
    3131     <x>360</x> 
    32      <y>360</y> 
     32     <y>390</y> 
    3333     <width>451</width> 
    3434     <height>91</height> 
     
    4646    <rect> 
    4747     <x>10</x> 
    48      <y>360</y> 
     48     <y>390</y> 
    4949     <width>341</width> 
    5050     <height>91</height> 
     
    113113   <property name="geometry" > 
    114114    <rect> 
    115      <x>740</x> 
    116      <y>460</y> 
    117      <width>75</width> 
     115     <x>714</x> 
     116     <y>490</y> 
     117     <width>101</width> 
    118118     <height>26</height> 
    119119    </rect> 
     
    127127    <rect> 
    128128     <x>360</x> 
    129      <y>460</y> 
    130      <width>91</width> 
     129     <y>490</y> 
     130     <width>111</width> 
    131131     <height>26</height> 
    132132    </rect> 
     
    137137  </widget> 
    138138  <widget class="QWidget" name="layoutWidget" > 
     139   <property name="geometry" > 
     140    <rect> 
     141     <x>10</x> 
     142     <y>40</y> 
     143     <width>801</width> 
     144     <height>341</height> 
     145    </rect> 
     146   </property> 
     147   <layout class="QVBoxLayout" name="verticalLayout" > 
     148    <item> 
     149     <widget class="QTreeView" name="treeView" /> 
     150    </item> 
     151    <item> 
     152     <widget class="QLineEdit" name="filelineedit" /> 
     153    </item> 
     154   </layout> 
     155  </widget> 
     156  <widget class="QCheckBox" name="playSamplescheckBox" > 
     157   <property name="geometry" > 
     158    <rect> 
     159     <x>10</x> 
     160     <y>490</y> 
     161     <width>311</width> 
     162     <height>21</height> 
     163    </rect> 
     164   </property> 
     165   <property name="text" > 
     166    <string>Play samples by clicking</string> 
     167   </property> 
     168  </widget> 
     169  <widget class="QWidget" name="" > 
    139170   <property name="geometry" > 
    140171    <rect> 
     
    142173     <y>10</y> 
    143174     <width>801</width> 
    144      <height>341</height> 
    145     </rect> 
    146    </property> 
    147    <layout class="QVBoxLayout" name="verticalLayout" > 
    148     <item> 
    149      <widget class="QTreeView" name="treeView" /> 
    150     </item> 
    151     <item> 
    152      <widget class="QLineEdit" name="filelineedit" /> 
     175     <height>27</height> 
     176    </rect> 
     177   </property> 
     178   <layout class="QHBoxLayout" name="horizontalLayout" > 
     179    <item> 
     180     <widget class="QLineEdit" name="pathLineEdit" /> 
     181    </item> 
     182    <item> 
     183     <widget class="QToolButton" name="m_pPathUptoolButton" > 
     184      <property name="text" > 
     185       <string>up</string> 
     186      </property> 
     187     </widget> 
    153188    </item> 
    154189   </layout> 
    155190  </widget> 
    156   <widget class="QCheckBox" name="playSamplescheckBox" > 
    157    <property name="geometry" > 
    158     <rect> 
    159      <x>10</x> 
    160      <y>460</y> 
    161      <width>311</width> 
    162      <height>21</height> 
    163     </rect> 
    164    </property> 
    165    <property name="text" > 
    166     <string>Play samples by clicking</string> 
    167    </property> 
    168   </widget> 
    169191 </widget> 
     192 <tabstops> 
     193  <tabstop>pathLineEdit</tabstop> 
     194  <tabstop>m_pPathUptoolButton</tabstop> 
     195  <tabstop>treeView</tabstop> 
     196  <tabstop>filelineedit</tabstop> 
     197  <tabstop>playSamplescheckBox</tabstop> 
     198  <tabstop>m_pPlayBtn</tabstop> 
     199  <tabstop>openBTN</tabstop> 
     200  <tabstop>cancelBTN</tabstop> 
     201 </tabstops> 
    170202 <resources/> 
    171203 <connections/> 
  • branches/audiofilebrowser/libs/hydrogen/include/hydrogen/Preferences.h

    r452 r483  
    144144        QString m_sPreferencesFilename; 
    145145        QString m_sPreferencesDirectory; 
     146        QString __lastsampleDirectory; 
    146147 
    147148        bool m_bFollowPlayhead; 
  • branches/audiofilebrowser/libs/hydrogen/src/preferences.cpp

    r452 r483  
    125125        m_sDataDirectory = QDir::homePath().append( "/.hydrogen/data/" ); 
    126126#endif 
    127    
     127        __lastsampleDirectory = QDir::homePath(); 
     128  
    128129        loadPreferences( true );        // Global settings 
    129130        loadPreferences( false );       // User settings