summaryrefslogtreecommitdiff
path: root/core/apps/textedit/fileSaver.cpp
Unidiff
Diffstat (limited to 'core/apps/textedit/fileSaver.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/fileSaver.cpp45
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
@@ -5,24 +5,25 @@
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
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>
23#include <qlineedit.h> 24#include <qlineedit.h>
24#include <qcheckbox.h> 25#include <qcheckbox.h>
25 26
26#include <unistd.h> 27#include <unistd.h>
27 28
28fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) 29fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName )
@@ -38,38 +39,41 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl
38 dirLabel = new QLabel(this, "DirLabel"); 39 dirLabel = new QLabel(this, "DirLabel");
39 dirLabel->setText(currentDir.canonicalPath()); 40 dirLabel->setText(currentDir.canonicalPath());
40 dirLabel->setGeometry(10,20,230,15); 41 dirLabel->setGeometry(10,20,230,15);
41 42
42 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); 43 homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton");
43 homeButton->setGeometry(200,4,25,25); 44 homeButton->setGeometry(200,4,25,25);
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 );
70 ListView->setGeometry( QRect( 10,35,220,125)); 74 ListView->setGeometry( QRect( 10,35,220,125));
71 75
72 fileEdit= new QLineEdit(this); 76 fileEdit= new QLineEdit(this);
73 fileEdit->setGeometry( QRect( 10, 162, 205, 17)); 77 fileEdit->setGeometry( QRect( 10, 162, 205, 17));
74 78
75 fileEdit->setText( tmpFileName); 79 fileEdit->setText( tmpFileName);
@@ -88,51 +92,84 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl
88 populateList(); 92 populateList();
89 move(0,15); 93 move(0,15);
90 fileEdit->setFocus(); 94 fileEdit->setFocus();
91} 95}
92 96
93fileSaver::~fileSaver() 97fileSaver::~fileSaver()
94{ 98{
95} 99}
96 100
97void fileSaver::populateList() 101void 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() ){
111 QString symLink=fi->readLink(); 116 QString symLink=fi->readLink();
112// qDebug("Symlink detected "+symLink); 117// qDebug("Symlink detected "+symLink);
113 QFileInfo sym( symLink); 118 QFileInfo sym( symLink);
114 fileS.sprintf( "%10li", sym.size() ); 119 fileS.sprintf( "%10li", sym.size() );
115 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 120 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
116 121
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
133} 170}
134 171
135void fileSaver::upDir() 172void fileSaver::upDir()
136{ 173{
137// qDebug(currentDir.canonicalPath()); 174// qDebug(currentDir.canonicalPath());
138} 175}