// wrapper class to extract info from QTableWidget regarding sorting and // position of each label in the header MailListView::MailListView(QWidget *parent, const char *name) : QTableWidget( parent) { setObjectName( name ); setFrameStyle( NoFrame ); connect(horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(sizeChange(int,int,int)) ); horizontalHeader()->setSortIndicatorShown(false); sortColumn = -1; ascending = false; emailsOnly = false; connect( &menuTimer, SIGNAL(timeout()), SLOT(itemMenuRequested()) ); connect( this, SIGNAL(itemSelectionChanged()), SLOT(cancelMenuTimer()) ); connect( horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrollToLeft(int)) ); arrival = false; hVisible = true; //part of sizeChangefix (avoid unnecessary flickering) maxColumnWidth = 0; mSingleColumnMode = true; QSoftMenuBar::setLabel(this, Qt::Key_Select, QSoftMenuBar::NoLabel); columns << ""; if(!mSingleColumnMode) { columns << tr( "From" ); columns << tr( "Subject" ); columns << tr( "Date" ); } setColumnCount( columns.count() ); setHorizontalHeaderLabels( columns ); verticalHeader()->hide(); // Row height should be the size of the text - the second line being 3/4ths of the first int textHeight = QFontMetrics(font()).height() * 7 / 4; // Also, the icon could be larger than the text int iconHeight = style()->pixelMetric(QStyle::PM_ListViewIconSize); verticalHeader()->setDefaultSectionSize( qMax(textHeight, iconHeight) ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setAlternatingRowColors( true ); horizontalHeaderItem(0)->setIcon(QPixmap(":image/flag")); QAction *hhWhatsThis = QWhatsThis::createAction( horizontalHeader() ); hhWhatsThis->setText( tr("Select the sort order by tapping any of the columns in this header. Tapping the same column twice will switch between ascending and descending order.") ); QAction *tWhatsThis = QWhatsThis::createAction( this ); tWhatsThis->setText( tr("A list of the messages in your current folder. Tap a message to examine it.") ); // setRootIsDecorated( true ); setSelectionMode( QAbstractItemView::ExtendedSelection ); EmailListItemDelegate *delegate = new EmailListItemDelegate( this ); setItemDelegate( delegate ); scrollToLeft( 0 ); horizontalHeader()->setResizeMode(QHeaderView::Stretch); }
CoverFoundDialog::CoverFoundDialog( const CoverFetchUnit::Ptr unit, const CoverFetch::Metadata &data, QWidget *parent ) : KDialog( parent ) , m_album( unit->album() ) , m_isSorted( false ) , m_sortEnabled( false ) , m_unit( unit ) , m_queryPage( 0 ) { DEBUG_BLOCK setButtons( KDialog::Ok | KDialog::Cancel | KDialog::User1 ); // User1: clear icon view setButtonGuiItem( KDialog::User1, KStandardGuiItem::clear() ); connect( button( KDialog::User1 ), SIGNAL(clicked()), SLOT(clearView()) ); m_save = button( KDialog::Ok ); QSplitter *splitter = new QSplitter( this ); m_sideBar = new CoverFoundSideBar( m_album, splitter ); KVBox *vbox = new KVBox( splitter ); vbox->setSpacing( 4 ); KHBox *breadcrumbBox = new KHBox( vbox ); QLabel *breadcrumbLabel = new QLabel( i18n( "Finding cover for" ), breadcrumbBox ); AlbumBreadcrumbWidget *breadcrumb = new AlbumBreadcrumbWidget( m_album, breadcrumbBox ); QFont breadcrumbLabelFont; breadcrumbLabelFont.setBold( true ); breadcrumbLabel->setFont( breadcrumbLabelFont ); breadcrumbLabel->setIndent( 4 ); connect( breadcrumb, SIGNAL(artistClicked(QString)), SLOT(addToCustomSearch(QString)) ); connect( breadcrumb, SIGNAL(albumClicked(QString)), SLOT(addToCustomSearch(QString)) ); KHBox *searchBox = new KHBox( vbox ); vbox->setSpacing( 4 ); QStringList completionNames; QString firstRunQuery( m_album->name() ); completionNames << firstRunQuery; if( m_album->hasAlbumArtist() ) { const QString &name = m_album->albumArtist()->name(); completionNames << name; firstRunQuery += ' ' + name; } m_query = firstRunQuery; m_album->setSuppressImageAutoFetch( true ); m_search = new KComboBox( searchBox ); m_search->setEditable( true ); // creates a KLineEdit for the combobox m_search->setTrapReturnKey( true ); m_search->setInsertPolicy( QComboBox::NoInsert ); // insertion is handled by us m_search->setCompletionMode( KGlobalSettings::CompletionPopup ); m_search->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ); qobject_cast<KLineEdit*>( m_search->lineEdit() )->setClickMessage( i18n( "Enter Custom Search" ) ); m_search->completionObject()->setOrder( KCompletion::Insertion ); m_search->completionObject()->setIgnoreCase( true ); m_search->completionObject()->setItems( completionNames ); m_search->insertItem( 0, KStandardGuiItem::find().icon(), QString() ); m_search->insertSeparator( 1 ); m_search->insertItem( 2, KIcon("filename-album-amarok"), m_album->name() ); if( m_album->hasAlbumArtist() ) m_search->insertItem( 3, KIcon("filename-artist-amarok"), m_album->albumArtist()->name() ); m_searchButton = new KPushButton( KStandardGuiItem::find(), searchBox ); KPushButton *sourceButton = new KPushButton( KStandardGuiItem::configure(), searchBox ); updateSearchButton( firstRunQuery ); QMenu *sourceMenu = new QMenu( sourceButton ); QAction *lastFmAct = new QAction( i18n( "Last.fm" ), sourceMenu ); QAction *googleAct = new QAction( i18n( "Google" ), sourceMenu ); QAction *discogsAct = new QAction( i18n( "Discogs" ), sourceMenu ); lastFmAct->setCheckable( true ); googleAct->setCheckable( true ); discogsAct->setCheckable( true ); connect( lastFmAct, SIGNAL(triggered()), this, SLOT(selectLastFm()) ); connect( googleAct, SIGNAL(triggered()), this, SLOT(selectGoogle()) ); connect( discogsAct, SIGNAL(triggered()), this, SLOT(selectDiscogs()) ); m_sortAction = new QAction( i18n( "Sort by size" ), sourceMenu ); m_sortAction->setCheckable( true ); connect( m_sortAction, SIGNAL(triggered(bool)), this, SLOT(sortingTriggered(bool)) ); QActionGroup *ag = new QActionGroup( sourceButton ); ag->addAction( lastFmAct ); ag->addAction( googleAct ); ag->addAction( discogsAct ); sourceMenu->addActions( ag->actions() ); sourceMenu->addSeparator(); sourceMenu->addAction( m_sortAction ); sourceButton->setMenu( sourceMenu ); connect( m_search, SIGNAL(returnPressed(QString)), SLOT(insertComboText(QString)) ); connect( m_search, SIGNAL(returnPressed(QString)), SLOT(processQuery(QString)) ); connect( m_search, SIGNAL(returnPressed(QString)), SLOT(updateSearchButton(QString)) ); connect( m_search, SIGNAL(editTextChanged(QString)), SLOT(updateSearchButton(QString)) ); connect( m_search->lineEdit(), SIGNAL(clearButtonClicked()), SLOT(clearQueryButtonClicked())); connect( m_searchButton, SIGNAL(clicked()), SLOT(processQuery()) ); m_view = new KListWidget( vbox ); m_view->setAcceptDrops( false ); m_view->setContextMenuPolicy( Qt::CustomContextMenu ); m_view->setDragDropMode( QAbstractItemView::NoDragDrop ); m_view->setDragEnabled( false ); m_view->setDropIndicatorShown( false ); m_view->setMovement( QListView::Static ); m_view->setGridSize( QSize( 140, 150 ) ); m_view->setIconSize( QSize( 120, 120 ) ); m_view->setSpacing( 4 ); m_view->setViewMode( QListView::IconMode ); m_view->setResizeMode( QListView::Adjust ); connect( m_view, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(currentItemChanged(QListWidgetItem*,QListWidgetItem*)) ); connect( m_view, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(itemDoubleClicked(QListWidgetItem*)) ); connect( m_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(itemMenuRequested(QPoint)) ); splitter->addWidget( m_sideBar ); splitter->addWidget( vbox ); setMainWidget( splitter ); const KConfigGroup config = Amarok::config( "Cover Fetcher" ); const QString source = config.readEntry( "Interactive Image Source", "LastFm" ); m_sortEnabled = config.readEntry( "Sort by Size", false ); m_sortAction->setChecked( m_sortEnabled ); m_isSorted = m_sortEnabled; restoreDialogSize( config ); // call this after setMainWidget() if( source == "LastFm" ) lastFmAct->setChecked( true ); else if( source == "Discogs" ) discogsAct->setChecked( true ); else googleAct->setChecked( true ); typedef CoverFetchArtPayload CFAP; const CFAP *payload = dynamic_cast< const CFAP* >( unit->payload() ); if( !m_album->hasImage() ) m_sideBar->setPixmap( QPixmap::fromImage( m_album->image(190 ) ) ); else if( payload ) add( m_album->image(), data, payload->imageSize() ); else add( m_album->image(), data ); m_view->setCurrentItem( m_view->item( 0 ) ); updateGui(); connect( The::networkAccessManager(), SIGNAL(requestRedirected(QNetworkReply*,QNetworkReply*)), this, SLOT(fetchRequestRedirected(QNetworkReply*,QNetworkReply*)) ); }