📄 fileiconview-main-cpp.html
字号:
"a c #ff0000", "f c #303030", "n c white", ". c None", "...###..........................", "...#aa##........................", ".###baaa##......................", ".#cde#baaa##....................", ".#cccdeebaaa##..##f.............", ".#cccccdeebaaa##aaa##...........", ".#cccccccdeebaaaaaaaa##.........", ".#cccccccccdeebababaaa#.........", ".#cccccgcgghhebbbbbbbaa#........", ".#ccccccgcgggdebbbbbbba#........", ".#cccgcgcgcgghdeebiebbba#.......", ".#ccccgcggggggghdeddeeba#.......", ".#cgcgcgcggggggggghghdebb#......", ".#ccgcggggggggghghghghd#b#......", ".#cgcgcggggggggghghghhd#b#......", ".#gcggggggggghghghhhhhd#b#......", ".#cgcggggggggghghghhhhd#b#......", ".#ggggggggghghghhhhhhhdib#......", ".#gggggggggghghghhhhhhd#b#......", ".#hhggggghghghhhhhhhhhd#b#......", ".#ddhhgggghghghhhhhhhhd#b#......", "..##ddhhghghhhhhhhhhhhdeb#......", "############hhhhhhhhhhd#b#......", "#nnnnnnnnnn#hhhhhhhhhhd#b#......", "#nnnnnnnnnn#hhhhhhhhhhd#b#......", "#nn#nn#nnnn#ddhhhhhhhhd#b#......", "#nn##n##nnn###ddhhhhhhd#b###....", "#nnn#####nn#..##ddhhhhd#b#####..", "#nnnnn##nnn#....##ddhhd#b######.", "#nnnnn#nnnn#......##dddeb#####..", "#nnnnnnnnnn#........##d#b###....", "############..........####......"};static const char * folder_locked_icon[]={ "32 32 12 1", "# c #000000", "g c #808080", "h c #c0c0c0", "f c #c05800", "c c #ffffff", "d c #585858", "b c #ffa858", "a c #ffdca8", "e c #000000", "i c #a0a0a4", "j c #c0c0c0", ". c None", "...###..........................", "...#aa##........................", ".###baaa##......................", ".#cde#baaa##....................", ".#cccdeeba#######...............", ".#cccccde##fffff##..............", ".#cccccc##fffgggg#..............", ".#ccccccc#ffg####a##............", ".#ccccchc#ffg#eebbaa##..........", ".#ccccccc#ffg#ddeebbba##........", ".#ccchccc#ffg#ihddeebbba##......", ".#cccccaa#ffg#ihhhddeeba##......", ".#chchhbbaafg#ihhhihidebb#......", ".#cchccbbbbaa#ihhihihid#b#......", ".#chchhbb#bbbaaiihihiid#b#......", ".#hchhcbb#fbbbafhiiiiid#b#......", ".#chchhbb#ffgbbfihiiiid#b#......", ".#hhhhhbb#ffg#bfiiiiiid#b#......", ".#hhhhhbbaffg#bfiiiiiid#b#......", ".#iihhhjbbaab#bfiiiiiid#b#......", ".#ddiihhh#bbbabfiiiiiid#b#......", "..##ddiih#ffbbbfiiiiiid#b#......", "....##ddi#ffg#biiiiiiid#b#......", "......##d#ffg#iiiiiiiid#b#......", "........##ffg#iiiiiiiid#b#......", ".........#ffg#iiiiiiiid#b#......", ".........#ffg#ddiiiiiid#b###....", ".........##fg###ddiiiid#b#####..", "...........####.##ddiid#b######.", "..................##dddeb#####..", "....................##d#b###....", "......................####......"};static QPixmap *iconFolderLockedLarge = 0;static QPixmap *iconFolderLarge = 0;static QPixmap *iconFileLarge = 0;static QPixmap *iconLinkLarge = 0;static QPixmap *iconFolderLockedSmall = 0;static QPixmap *iconFolderSmall = 0;static QPixmap *iconFileSmall = 0;static QPixmap *iconLinkSmall = 0;static void cleanup(){ delete iconFolderLockedLarge; iconFolderLockedLarge = 0; delete iconFolderLarge; iconFolderLarge = 0; delete iconFileLarge; iconFileLarge = 0; delete iconLinkLarge; iconLinkLarge = 0; delete iconFolderLockedSmall; iconFolderLockedSmall = 0; delete iconFolderSmall; iconFolderSmall = 0; delete iconFileSmall; iconFileSmall = 0; delete iconLinkSmall; iconLinkSmall = 0;}/***************************************************************************** * * Class QtFileIconDrag * *****************************************************************************/QtFileIconDrag::QtFileIconDrag( <a href="qwidget.html">QWidget</a> * dragSource, const char* name ) : <a href="qicondrag.html">QIconDrag</a>( dragSource, name ){}const char* <a name="172"></a>QtFileIconDrag::format( int i ) const{ if ( i == 0 ) return "application/x-qiconlist"; else if ( i == 1 ) return "text/uri-list"; else return 0;}<a href="qbytearray.html">QByteArray</a> <a name="173"></a>QtFileIconDrag::encodedData( const char* mime ) const{ <a href="qbytearray.html">QByteArray</a> a; if ( <a href="qstring.html">QString</a>( mime ) == "application/x-qiconlist" ) { a = QIconDrag::encodedData( mime ); } else if ( <a href="qstring.html">QString</a>( mime ) == "text/uri-list" ) { <a href="qstring.html">QString</a> s = urls.join( "\r\n" ); a.<a href="qbytearray.html#191333">resize</a>( s.<a href="qstring.html#0ecbda">length</a>() ); memcpy( a.<a href="qbytearray.html#2733f4">data</a>(), s.<a href="qstring.html#ea8169">latin1</a>(), s.<a href="qstring.html#0ecbda">length</a>() ); } return a;}bool <a name="174"></a>QtFileIconDrag::canDecode( <a href="qmimesource.html">QMimeSource</a>* e ){ return e-><a href="qdropevent.html#e9bf16">provides</a>( "application/x-qiconlist" ) || e-><a href="qdropevent.html#e9bf16">provides</a>( "text/uri-list" );}void <a name="175"></a>QtFileIconDrag::append( const QIconDragItem &item, const QRect &pr, const QRect &tr, const QString &url ){ <a href="qicondrag.html#e2f3cc">QIconDrag::append</a>( item, pr, tr ); urls << url;}/***************************************************************************** * * Class QtFileIconViewItem * *****************************************************************************/QtFileIconViewItem::QtFileIconViewItem( QtFileIconView *parent, QFileInfo *fi ) : <a href="qiconviewitem.html">QIconViewItem</a>( parent, fi-><a href="qfileinfo.html#a9e3d2">fileName</a>() ), itemFileName( fi-><a href="qfileinfo.html#ebb5a0">filePath</a>() ), itemFileInfo( fi ), checkSetText( FALSE ){ vm = QtFileIconView::Large; if ( itemFileInfo->isDir() ) itemType = Dir; else if ( itemFileInfo->isFile() ) itemType = File; if ( itemFileInfo->isSymLink() ) itemType = Link; <a href=#177>viewModeChanged</a>( ( (QtFileIconView*)iconView() )->viewMode() ); if ( itemFileInfo->fileName() == "." || itemFileInfo->fileName() == ".." ) <a href="qiconviewitem.html#2eb423">setRenameEnabled</a>( FALSE ); checkSetText = TRUE; <a href="qobject.html#7f8e37">QObject::connect</a>( &timer, SIGNAL( timeout() ), <a href="qiconviewitem.html#cc030e">iconView</a>(), SLOT( openFolder() ) );}void <a name="176"></a>QtFileIconViewItem::paintItem( <a href="qpainter.html">QPainter</a> *p, const QColorGroup &cg ){ if ( itemFileInfo->isSymLink() ) { <a href="qfont.html">QFont</a> f( p->font() ); f.<a href="qfont.html#b6af25">setItalic</a>( TRUE ); p->setFont( f ); } <a href="qiconviewitem.html#9f712d">QIconViewItem::paintItem</a>( p, cg );}void <a name="177"></a>QtFileIconViewItem::viewModeChanged( QtFileIconView::ViewMode m ){ vm = m; <a href="qiconviewitem.html#015768">setDropEnabled</a>( itemType == Dir && <a href="qdir.html">QDir</a>( itemFileName ).isReadable() ); <a href="qiconviewitem.html#c2e4a4">calcRect</a>();}<a href="qpixmap.html">QPixmap</a> *<a name="178"></a>QtFileIconViewItem::pixmap() const{ switch ( itemType ) { case Dir: { if ( !QDir( itemFileName ).isReadable() ) { if ( vm == QtFileIconView::Small ) return iconFolderLockedSmall; else return iconFolderLockedLarge; } else { if ( vm == QtFileIconView::Small ) return iconFolderSmall; else return iconFolderLarge; } } case Link: { if ( vm == QtFileIconView::Small ) return iconLinkSmall; else return iconLinkLarge; } default: { if ( vm == QtFileIconView::Small ) return iconFileSmall; else return iconFileLarge; } }}QtFileIconViewItem::~QtFileIconViewItem(){ delete itemFileInfo;}void <a name="179"></a>QtFileIconViewItem::setText( const QString &text ){ if ( checkSetText ) { if ( text == "." || text == "." || text.isEmpty() ) return; <a href="qdir.html">QDir</a> dir( itemFileInfo->dir() ); if ( dir.<a href="qdir.html#a7d8c0">rename</a>( itemFileInfo->fileName(), text ) ) { itemFileName = itemFileInfo->dirPath( TRUE ) + "/" + text; delete itemFileInfo; itemFileInfo = new <a href="qfileinfo.html">QFileInfo</a>( itemFileName ); <a href="qiconviewitem.html#3ecbc5">QIconViewItem::setText</a>( text ); } } else { <a href="qiconviewitem.html#3ecbc5">QIconViewItem::setText</a>( text ); }}bool <a name="180"></a>QtFileIconViewItem::acceptDrop( const QMimeSource *e ) const{ if ( type() == Dir && e-><a href="qdropevent.html#e9bf16">provides</a>( "text/uri-list" ) && <a href="qiconviewitem.html#eca4f0">dropEnabled</a>() ) return TRUE; return FALSE;}void <a name="181"></a>QtFileIconViewItem::dropped( <a href="qdropevent.html">QDropEvent</a> *e, const QValueList<<a href="qicondragitem.html">QIconDragItem</a>> & ){ timer.stop(); if ( !QUriDrag::canDecode( e ) ) { e-><a href="qdropevent.html#e7a50f">ignore</a>(); return; } <a href="qstrlist.html">QStrList</a> lst; <a href="quridrag.html#e14cb1">QUriDrag::decode</a>( e, lst ); <a href="qstring.html">QString</a> str; if ( e-><a href="qdropevent.html#d9f8b7">action</a>() == QDropEvent::Copy ) str = "Copy\n\n"; else str = "Move\n\n"; for ( uint i = 0; i < lst.<a href="qlist.html#359d9f">count</a>(); ++i ) str += QString( " %1\n" ).arg( lst.<a href="qlist.html#0e7e42">at</a>( i ) ); str += QString( "\n" "To\n\n" " %1" ).arg( filename() ); <a href="qmessagebox.html#66b7c8">QMessageBox::information</a>( <a href="qiconviewitem.html#cc030e">iconView</a>(), e-><a href="qdropevent.html#d9f8b7">action</a>() == QDropEvent::Copy ? "Copy" : "Move" , str, "Not Implemented" ); if ( e-><a href="qdropevent.html#d9f8b7">action</a>() == QDropEvent::Move ) <a href="qmessagebox.html#66b7c8">QMessageBox::information</a>( <a href="qiconviewitem.html#cc030e">iconView</a>(), "Remove" , str, "Not Implemented" ); e-><a href="qdropevent.html#d37a0e">acceptAction</a>();}void <a name="182"></a>QtFileIconViewItem::dragEntered(){ if ( type() != Dir || type() == Dir && !QDir( itemFileName ).isReadable() ) return; ( (QtFileIconView*)iconView() )->setOpenItem( this ); timer.start( 1500 );}void <a name="183"></a>QtFileIconViewItem::dragLeft(){ if ( type() != Dir || type() == Dir && !QDir( itemFileName ).isReadable() ) return; timer.stop();}/***************************************************************************** * * Class QtFileIconView * *****************************************************************************/QtFileIconView::QtFileIconView( const QString &dir, QWidget *parent, const char *name ) : <a href="qiconview.html">QIconView</a>( parent, name ), viewDir( dir ), newFolderNum( 0 ){ if ( !iconFolderLockedLarge ) { <a href="qapplication.html#6382b3">qAddPostRoutine</a>( cleanup ); <a href="qwmatrix.html">QWMatrix</a> m; m.<a href="qwmatrix.html#41a356">scale</a>( 0.6, 0.6 ); <a href="qpixmap.html">QPixmap</a> iconpix( folder_locked_icon ); iconFolderLockedLarge = new <a href="qpixmap.html">QPixmap</a>( folder_locked_icon ); iconpix = iconpix.<a href="qpixmap.html#ff5fcf">xForm</a>( m ); iconFolderLockedSmall = new <a href="qpixmap.html">QPixmap</a>( iconpix ); iconpix = QPixmap( folder_icon ); iconFolderLarge = new <a href="qpixmap.html">QPixmap</a>( folder_icon ); iconpix = iconpix.<a href="qpixmap.html#ff5fcf">xForm</a>( m ); iconFolderSmall = new <a href="qpixmap.html">QPixmap</a>( iconpix ); iconpix = QPixmap( file_icon ); iconFileLarge = new <a href="qpixmap.html">QPixmap</a>( file_icon ); iconpix = iconpix.<a href="qpixmap.html#ff5fcf">xForm</a>( m );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -