?? collectionbrowser.cpp
字號(hào):
appendSearchResults(); } return true; default: return false; } } // (Joe Rabinoff) the code that was here which dealt with wrapping // the selection around when Key_Up or Key_Down was pressed was // moved to CollectionView::keyPressEvent(). That code also // skips dividers. if( ( e->key() >= Key_0 && e->key() <= Key_Z ) || e->key() == Key_Backspace || e->key() == Key_Escape ) { m_searchEdit->setFocus(); QApplication::sendEvent( m_searchEdit, e ); return true; } #undef e break; default: break; } return QVBox::eventFilter( o, e );}voidCollectionBrowser::layoutToolbar(){ if ( !m_toolbar ) return; m_toolbar->clear(); m_toolbar->setIconText( KToolBar::IconTextRight, false ); m_tagfilterMenuButton->plug( m_toolbar ); m_toolbar->setIconText( KToolBar::IconOnly, false ); m_toolbar->insertLineSeparator(); m_treeViewAction->plug( m_toolbar ); m_flatViewAction->plug( m_toolbar ); m_ipodViewAction->plug( m_toolbar ); m_toolbar->insertLineSeparator(); m_showDividerAction->plug( m_toolbar ); m_configureAction->plug( m_toolbar ); //This would break things if the toolbar is too big, see bug #121915 //setMinimumWidth( m_toolbar->sizeHint().width() + 2 ); //set a reasonable minWidth}// (De)activate the iPod toolbar when switching into and out of// iPod browsing modevoidCollectionBrowser::ipodToolbar( bool activate ){ if( activate ) m_ipodToolbar->show(); else m_ipodToolbar->hide();}//////////////////////////////////////////////////////////////////////////////////////////// CLASS CollectionView//////////////////////////////////////////////////////////////////////////////////////////CollectionView* CollectionView::m_instance = 0;CollectionView::CollectionView( CollectionBrowser* parent ) : KListView( parent ) , m_parent( parent ) , m_timeFilter( 0 ) , m_currentDepth( 0 ) , m_ipodIncremented ( 1 ) , m_dirty( true ) , m_organizingFileCancelled( false ){ DEBUG_FUNC_INFO m_instance = this; setSelectionMode( QListView::Extended ); setItemsMovable( false ); setSorting( 0 ); setShowSortIndicator( true ); setAcceptDrops( true ); setAllColumnsShowFocus( true ); //<READ CONFIG> KConfig* config = Amarok::config( "Collection Browser" ); m_cat1 = config->readNumEntry( "Category1", IdArtist ); m_cat2 = config->readNumEntry( "Category2", IdAlbum ); m_cat3 = config->readNumEntry( "Category3", IdNone );#define saneCat(x) (x==IdAlbum||x==IdArtist||x==IdComposer||x==IdGenre||x==IdYear \ ||x==IdNone \ ||x==IdArtistAlbum||x==IdGenreArtist||x==IdGenreArtistAlbum||x==IdVisYearAlbum||x==IdArtistVisYearAlbum) if( !saneCat(m_cat1) ) { m_cat1 = IdArtist; m_cat2 = IdAlbum; m_cat2 = IdNone; } if( !saneCat(m_cat2) || !saneCat(m_cat3) ) { m_cat2 = m_cat3 = IdNone; }#undef saneCat m_viewMode = config->readNumEntry( "ViewMode", modeTreeView ); m_showDivider = config->readBoolEntry( "ShowDivider", true); updateTrackDepth(); m_flatColumnWidths.clear(); QStringList flatWidths = config->readListEntry( "FlatColumnWidths" ); for( QStringList::iterator it = flatWidths.begin(); it != flatWidths.end(); it++ ) m_flatColumnWidths.push_back( (*it).toInt() ); //</READ CONFIG> KActionCollection* ac = new KActionCollection( this ); KStdAction::selectAll( this, SLOT( selectAll() ), ac, "collectionview_select_all" ); connect( CollectionDB::instance(), SIGNAL( scanStarted() ), this, SLOT( scanStarted() ) ); connect( CollectionDB::instance(), SIGNAL( scanDone( bool ) ), this, SLOT( scanDone( bool ) ) ); connect( BrowserBar::instance(), SIGNAL( browserActivated( int ) ), this, SLOT( renderView() ) ); // renderView() checks if current tab is this connect( CollectionDB::instance(), SIGNAL( ratingChanged( const QString&, int ) ), this, SLOT( ratingChanged( const QString&, int ) ) ); connect( this, SIGNAL( expanded( QListViewItem* ) ), this, SLOT( slotExpand( QListViewItem* ) ) ); connect( this, SIGNAL( collapsed( QListViewItem* ) ), this, SLOT( slotCollapse( QListViewItem* ) ) ); connect( this, SIGNAL( returnPressed( QListViewItem* ) ), this, SLOT( invokeItem( QListViewItem* ) ) ); connect( this, SIGNAL( doubleClicked( QListViewItem*, const QPoint&, int ) ), this, SLOT( invokeItem( QListViewItem*, const QPoint&, int ) ) ); connect( this, SIGNAL( clicked( QListViewItem*, const QPoint&, int ) ), this, SLOT( ipodItemClicked( QListViewItem*, const QPoint&, int ) ) ); connect( this, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), this, SLOT( rmbPressed( QListViewItem*, const QPoint&, int ) ) ); connect( header(), SIGNAL( sizeChange( int, int, int ) ), this, SLOT( triggerUpdate() ) ); connect( MountPointManager::instance(), SIGNAL( mediumConnected( int ) ), this, SLOT( databaseChanged() ) ); connect( MountPointManager::instance(), SIGNAL( mediumRemoved( int ) ), this, SLOT( databaseChanged() ) );}CollectionView::~CollectionView() { DEBUG_FUNC_INFO KConfig* const config = Amarok::config( "Collection Browser" ); config->writeEntry( "Category1", m_cat1 ); config->writeEntry( "Category2", m_cat2 ); config->writeEntry( "Category3", m_cat3 ); config->writeEntry( "ViewMode", m_viewMode ); config->writeEntry( "ShowDivider", m_showDivider ); QStringList flatWidths; for( QValueList<int>::iterator it = m_flatColumnWidths.begin(); it != m_flatColumnWidths.end(); it++ ) flatWidths.push_back( QString::number( (*it) ) ); config->writeEntry( "FlatColumnWidths", flatWidths );}voidCollectionView::setShowDivider( bool show ){ if (show != m_showDivider) { m_showDivider = show; renderView(true); }}// Reimplemented for iPod-style navigation, and to skip dividers// Specifically, this method traps the Key_Up/Down/Left/Right events.// When Up or Down is pressed, it skips dividers and wraps around when// necessary. When Left or Right is pressed and we are viewing in// iPod mode, the iPod "move forward / backward" actions are activated.voidCollectionView::keyPressEvent( QKeyEvent *e ){ typedef QListViewItemIterator It; // Reimplement up and down to skip dividers and to loop around. // Some of this code used to be in CollectionBrowser::eventFilter. // This rewritten code is more faithful to the ordinary moving // behavior, even when looping around. (For instance, it behaves // correctly if control-up is pressed at the top of the screen.) // It sends fake keypress events to the parent instead of programatically // selecting items. if( (e->key() == Key_Up || e->key() == Key_Down ) && currentItem() ) { // Handle both up and down at once to avoid code duplication (it's // a delicate piece of logic, and was hard to get right) QListViewItem *cur = currentItem(); #define nextItem (e->key() == Key_Up ? cur->itemAbove() : cur->itemBelow()) bool wraparound = true; // First skip any dividers directly above / below do { KListView::keyPressEvent( e ); if( currentItem() == cur ) // Prevent infinite loops { if( nextItem != 0 ) wraparound = false; break; } cur = currentItem(); if( cur && dynamic_cast<DividerItem*>( cur ) == 0 ) wraparound = false; // Found an item above / below } while( cur != NULL && dynamic_cast<DividerItem*>(cur) != 0 && nextItem != 0 ); if( cur == 0 ) return; // Shouldn't happen // Wrap around if necessary, by sending a Key_Home/Key_End event. if( wraparound ) { QKeyEvent e2 ( e->type(), (e->key() == Key_Up ? Key_End : Key_Home), 0, e->state(), QString::null, e->isAutoRepeat(), e->count() ); QApplication::sendEvent( this, &e2 ); cur = currentItem(); // The first item may also be a divider, so keep moving // until it's not while ( cur != 0 && dynamic_cast<DividerItem*>(cur) != 0 && nextItem != 0 ) { KListView::keyPressEvent( e ); if( currentItem() == cur ) // Prevent infinite loops break; cur = currentItem(); } } #undef nextItem } // When Right/Left is pressed in iPod view mode, activate the iPod // "move forward/backward" action. else if( (e->key() == Key_Left || e->key() == Key_Right) && m_viewMode == modeIpodView ) { if( e->key() == Key_Right ) m_parent->m_ipodIncrement->activate(); else if( e->key() == Key_Left ) m_parent->m_ipodDecrement->activate(); } else // we don't want the event KListView::keyPressEvent( e );}//////////////////////////////////////////////////////////////////////////////////////////// public slots//////////////////////////////////////////////////////////////////////////////////////////voidCollectionView::renderView(bool force /* = false */) //SLOT{ SHOULD_BE_GUI if(!force && !m_dirty ) return; if( BrowserBar::instance()->currentBrowser() != m_parent ) { // the collectionbrowser is intensive for sql, so we only renderView() if the tab // is currently active. else, wait until user focuses it.// debug() << "current browser is not collection, aborting renderView()" << endl; m_dirty = true; return; } m_dirty = false; // Don't cache / restore view if we're in ipod mode and we've // just incremented or decremented, since we'll run selectIpodItems() // below anyway. if( childCount() && !(m_viewMode == modeIpodView && m_ipodIncremented > 0) ) cacheView(); //clear(); safeClear(); if ( m_viewMode == modeFlatView ) { renderFlatModeView( force ); } if( m_viewMode == modeIpodView ) { renderIpodModeView( force ); } if( m_viewMode == modeTreeView ) { renderTreeModeView( force ); } // Don't cache or restore view when we're just going to run // selectIpodItems() below anyway. if( !(m_viewMode == modeIpodView && m_ipodIncremented > 0) ) restoreView(); else selectIpodItems();}//////////////////////////////////////////////////////////////////////////////////////////// private slots//////////////////////////////////////////////////////////////////////////////////////////voidCollectionView::setupDirs() //SLOT{ KDialogBase dialog( this, 0, false ); kapp->setTopWidget( &dialog ); dialog.setCaption( kapp->makeStdCaption( i18n("Configure Collection") ) ); CollectionSetup *setup = new CollectionSetup( &dialog ); dialog.setMainWidget( setup ); dialog.showButtonApply( false ); dialog.adjustSize(); // Make the dialog a bit bigger, default is too small to be useful dialog.resize( dialog.width() + 50, dialog.height() + 150 ); if ( dialog.exec() != QDialog::Rejected ) { const bool rescan = ( MountPointManager::instance()->collectionFolders() != setup->dirs() ); setup->writeConfig(); if ( rescan ) CollectionDB::instance()->startScan();
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -