⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imageselector_p.cpp

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.10平台上编译为嵌入式图形界面操作系统。
💻 CPP
📖 第 1 页 / 共 2 页
字号:
{    DocLnk image = visible_collection.currentImage();    // If there is no current selection, return a null QString    if( !image.fileKnown() ) return QString();    // Otherwise, return the image filename    return image.file();}DocLnk ImageSelectorPrivate::selectedDocument() const{    // If there is no current selection, return invalid DocLnk    // Otherwise, return DocLnk for image    return visible_collection.currentImage();}QPixmap ImageSelectorPrivate::selectedImage( int width, int height ) const{    DocLnk image = visible_collection.currentImage();    // If there is no current selection, return a null QPixmap    if( !image.fileKnown() ) return QPixmap();    // Otherwise, copy selected image and resize maintaining w:h ratio    // Return resized image    QPixmap return_image;    return_image.convertFromImage(         Image::loadScaled( image.file(), width, height ) );    return return_image;}QValueList< DocLnk > ImageSelectorPrivate::fileList() const{    // Return list of currently visible images    return visible_collection.collection();}int ImageSelectorPrivate::fileCount() const{    return visible_collection.collection().count();}#ifdef QTOPIA_PHONEvoid ImageSelectorPrivate::enableDialogMode(){    single_view->enableDialogMode();    ContextBar::setLabel( single_view, Qt::Key_Select, ContextBar::Select );    ContextBar::setLabel( single_view, Qt::Key_Back, ContextBar::Cancel );    ContextBar::setLabel( thumbnail_view, Qt::Key_Select, ContextBar::View );    // Switch to thumbnail view when canceled recieved from single view    connect( single_view, SIGNAL( canceled() ),         this, SLOT( setViewThumbnail() ) );    // Disable selection in thumbnail mode    disconnect( thumbnail_view, SIGNAL( selected() ), this, SLOT( select() ) );    // Switch to single view when selected recieved from thumbnail view    connect( thumbnail_view, SIGNAL( selected() ),         this, SLOT( setViewSingle() ) );}#endifvoid ImageSelectorPrivate::select(){    // Emit selected signal    emit selected( visible_collection.currentImage() );}void ImageSelectorPrivate::hold( const QPoint& pos ){    // Emit held signal    emit held( visible_collection.currentImage(), pos );}void ImageSelectorPrivate::setViewSingle(){    setViewMode( ImageSelector::Single );}void ImageSelectorPrivate::setViewThumbnail(){    setViewMode( ImageSelector::Thumbnail );}void ImageSelectorPrivate::launchCategoryDialog(){    // Launch category selection dialog    QPEApplication::execDialog( category_dialog );}void ImageSelectorPrivate::reload(){    updateVisibleCollection();    raiseCurrentView();    emit reloaded();}void ImageSelectorPrivate::changeCategory( int id ){    setCategory( id );    widget_stack->visibleWidget()->setFocus();}void ImageSelectorPrivate::setFocus( QWidget* widget ){    widget->setFocus();}void ImageSelectorPrivate::linkChanged( const QString& lnk ){    DocLnk doclnk( lnk );        // Gather images from the source directories    DocLnkSet images;    if( !source_directories.isEmpty() ) {        QStringList::Iterator it;        for( it = source_directories.begin(); it != source_directories.end();            ++it ) {            DocLnkSet set( *it, "*/jpeg;*/png" );            images.appendFrom( set );        }    } else Global::findDocuments( &images, "image/*" );        // Find lnk in current directory    QList<DocLnk> image_list = images.children();    DocLnk *list_element;    for( list_element = image_list.first(); list_element &&         !( list_element->linkFileKnown() &&             list_element->linkFile() == lnk ) &&        list_element->file() != lnk && list_element->file() != doclnk.file();         list_element = image_list.next() );        // Find lnk in collection    QValueList< DocLnk >::ConstIterator it;    for( it = visible_collection.collection().begin();         it != visible_collection.collection().end() &&        !( (*it).linkFileKnown() && (*it).linkFile() == lnk ) &&        (*it).file() != lnk && (*it).file() != doclnk.file(); ++it );        // If lnk is in the current directory and lnk not in the collection    if( list_element && it == visible_collection.collection().end() ) {        // If the image is in the current category, add to the colleciton        if( inCurrentCategory( doclnk ) ) {            visible_collection.insert( doclnk );            // If first image in collection, make image current            if( visible_collection.collection().count() == 1 )                visible_collection.makeHeadCurrent();            emit fileAdded( doclnk );        }    }        // If lnk is in the current directory and lnk is in the collection    else if( list_element && it != visible_collection.collection().end() ) {        // If image is in the current category, update image in collection        // Otherwise, remove from collection        if( inCurrentCategory( doclnk ) ) {            visible_collection.update( doclnk );            emit fileUpdated( doclnk );        } else {            visible_collection.remove( doclnk );            emit fileRemoved( doclnk );        }    }        // If lnk is not in the current directory and lnk is in the collection    else if( !list_element && it != visible_collection.collection().end() ) {        // Remove image from collection        doclnk = *it;        visible_collection.remove( doclnk );        emit fileRemoved( doclnk );    }        // Raise current view to top of stack    raiseCurrentView();}void ImageSelectorPrivate::updateVisibleCollection(){    // Clear current collection    visible_collection.clear();        // Add images that match the current category to the visible collection    // Gather images from the source directories    DocLnkSet images;    if( !source_directories.isEmpty() ) {        QStringList::Iterator it;        for( it = source_directories.begin(); it != source_directories.end();            ++it ) {            DocLnkSet set( *it, "*/jpeg;*/png" );            images.appendFrom( set );        }    } else Global::findDocuments( &images, "image/*" );        // Add only thoes images in the current category    QList<DocLnk> image_list = images.children();    DocLnk *list_element;    for( list_element = image_list.first(); list_element;        list_element = image_list.next() )        if( inCurrentCategory( *list_element ) )            visible_collection.insert( *list_element );        // Make the first image the current image    visible_collection.makeHeadCurrent();}void ImageSelectorPrivate::focusInEvent( QFocusEvent* ){    widget_stack->visibleWidget()->setFocus();}void ImageSelectorPrivate::raiseCurrentView(){    // If no images in collection, raise message view to top of stack    if( visible_collection.isEmpty() ) {        widget_stack->raiseWidget( message_view );      } else {        if( widget_stack->visibleWidget() == message_view ) {            // Otherwise, raise current view to top of stack            switch( current_view ) {            case ImageSelector::Single:                widget_stack->raiseWidget( single_view );                break;            case ImageSelector::Thumbnail:                widget_stack->raiseWidget( thumbnail_view );                break;            }        }    }}bool ImageSelectorPrivate::inCurrentCategory( const DocLnk& image ) const{    switch( category_id ) {    case CATEGORY_ALL:        // If category all, pass all images        return true;    case CATEGORY_UNFILED:        // If category unfiled, pass only images without category        if( image.categories().isEmpty() )            return true;        break;    default:        // Otherwise, pass only images that belong to the current category        if( image.categories().contains( category_id ) )            return true;    }            return false;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -