Diffstat (limited to 'core/apps/textedit/fileSaver.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index 07fb5ba..f2a5355 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -11,12 +11,13 @@ | |||
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileSaver.h" | 14 | #include "fileSaver.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/mimetype.h> | ||
17 | 18 | ||
18 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
19 | #include <qlistview.h> | 20 | #include <qlistview.h> |
20 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
21 | #include <qfile.h> | 22 | #include <qfile.h> |
22 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
@@ -44,26 +45,29 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
44 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 45 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
45 | homeButton->setFlat(TRUE); | 46 | homeButton->setFlat(TRUE); |
46 | 47 | ||
47 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 48 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
48 | docButton->setGeometry(170,4,25,25); | 49 | docButton->setGeometry(170,4,25,25); |
49 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 50 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
51 | |||
50 | docButton->setFlat(TRUE); | 52 | docButton->setFlat(TRUE); |
51 | 53 | ||
52 | hideButton = new QPushButton( Resource::loadIconSet("textedit/s_hidden"),"",this,"hideButton"); | 54 | hideButton = new QPushButton( Resource::loadIconSet("textedit/s_hidden"),"",this,"hideButton"); |
53 | hideButton->setGeometry(140,4,25,25); | 55 | hideButton->setGeometry(140,4,25,25); |
54 | connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) ); | 56 | connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) ); |
55 | hideButton->setToggleButton(TRUE); | 57 | hideButton->setToggleButton(TRUE); |
56 | hideButton->setFlat(TRUE); | 58 | hideButton->setFlat(TRUE); |
57 | 59 | ||
58 | ListView = new QListView( this, "ListView" ); | 60 | ListView = new QListView( this, "ListView" ); |
59 | ListView->addColumn( tr( "Name" ) ); | 61 | ListView->addColumn( tr( "Name" ) ); |
60 | ListView->setColumnWidth(0,140); | 62 | ListView->setColumnWidth(0,120); |
61 | ListView->setSorting( 2, FALSE); | 63 | ListView->setSorting( 2, FALSE); |
62 | ListView->addColumn( tr( "Size" ) ); | 64 | ListView->addColumn( tr( "Size" ) ); |
63 | ListView->setColumnWidth(1,59); | 65 | ListView->setColumnWidth(1,-1); |
66 | ListView->addColumn( "Date",-1); | ||
67 | |||
64 | ListView->setColumnWidthMode(0,QListView::Manual); | 68 | ListView->setColumnWidthMode(0,QListView::Manual); |
65 | ListView->setColumnAlignment(1,QListView::AlignRight); | 69 | ListView->setColumnAlignment(1,QListView::AlignRight); |
66 | // ListView->setMultiSelection(true); | 70 | // ListView->setMultiSelection(true); |
67 | // ListView->setSelectionMode(QListView::Extended); | 71 | // ListView->setSelectionMode(QListView::Extended); |
68 | 72 | ||
69 | ListView->setAllColumnsShowFocus( TRUE ); | 73 | ListView->setAllColumnsShowFocus( TRUE ); |
@@ -94,17 +98,18 @@ fileSaver::~fileSaver() | |||
94 | { | 98 | { |
95 | } | 99 | } |
96 | 100 | ||
97 | void fileSaver::populateList() | 101 | void fileSaver::populateList() |
98 | { | 102 | { |
99 | ListView->clear(); | 103 | ListView->clear(); |
104 | bool isDir=FALSE; | ||
100 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 105 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
101 | currentDir.setMatchAllDirs(TRUE); | 106 | currentDir.setMatchAllDirs(TRUE); |
102 | 107 | ||
103 | currentDir.setNameFilter("*"); | 108 | currentDir.setNameFilter("*"); |
104 | QString fileL, fileS; | 109 | QString fileL, fileS, fileDate; |
105 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 110 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
106 | QFileInfoListIterator it(*list); | 111 | QFileInfoListIterator it(*list); |
107 | QFileInfo *fi; | 112 | QFileInfo *fi; |
108 | while ( (fi=it.current()) ) { | 113 | while ( (fi=it.current()) ) { |
109 | 114 | ||
110 | if (fi->isSymLink() ){ | 115 | if (fi->isSymLink() ){ |
@@ -117,16 +122,48 @@ void fileSaver::populateList() | |||
117 | } else { | 122 | } else { |
118 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 123 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
119 | fileS.sprintf( "%10li", fi->size() ); | 124 | fileS.sprintf( "%10li", fi->size() ); |
120 | fileL.sprintf( "%s",fi->fileName().data() ); | 125 | fileL.sprintf( "%s",fi->fileName().data() ); |
121 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 126 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
122 | fileL+="/"; | 127 | fileL+="/"; |
128 | isDir=TRUE; | ||
123 | // qDebug(currentDir.canonicalPath()+fileL); | 129 | // qDebug(currentDir.canonicalPath()+fileL); |
124 | } | 130 | } |
125 | } | 131 | } |
126 | item= new QListViewItem( ListView,fileL,fileS ); | 132 | if(fileL !="./") { |
133 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | ||
134 | QPixmap pm; | ||
135 | |||
136 | if(isDir || fileL.find("/",0,TRUE) != -1) { | ||
137 | if( !QDir( fi->filePath() ).isReadable()) | ||
138 | pm = Resource::loadPixmap( "lockedfolder" ); | ||
139 | else | ||
140 | pm= Resource::loadPixmap( "folder" ); | ||
141 | item->setPixmap( 0,pm ); | ||
142 | } else { | ||
143 | if( !fi->isReadable() ) | ||
144 | pm = Resource::loadPixmap( "locked" ); | ||
145 | else { | ||
146 | MimeType mt(fi->filePath()); | ||
147 | pm=mt.pixmap(); | ||
148 | if(pm.isNull()) | ||
149 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
150 | item->setPixmap( 0,pm); | ||
151 | } | ||
152 | } | ||
153 | if( fileL.find("->",0,TRUE) != -1) { | ||
154 | // overlay link image | ||
155 | pm= Resource::loadPixmap( "folder" ); | ||
156 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | ||
157 | QPainter painter( &pm ); | ||
158 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
159 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
160 | item->setPixmap( 0, pm); | ||
161 | } | ||
162 | } | ||
163 | isDir=FALSE; | ||
127 | ++it; | 164 | ++it; |
128 | } | 165 | } |
129 | ListView->setSorting( 2, FALSE); | 166 | ListView->setSorting( 2, FALSE); |
130 | dirLabel->setText(currentDir.canonicalPath()); | 167 | dirLabel->setText(currentDir.canonicalPath()); |
131 | 168 | ||
132 | 169 | ||