Diffstat (limited to 'core/apps/textedit/fileSaver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index 9e9e863..de594aa 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -8,71 +8,79 @@ | |||
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> | ||
17 | |||
16 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
17 | #include <qlistview.h> | 19 | #include <qlistview.h> |
18 | #include <qpushbutton.h> | 20 | #include <qpushbutton.h> |
19 | #include <qfile.h> | 21 | #include <qfile.h> |
20 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
21 | #include <qlineedit.h> | 23 | #include <qlineedit.h> |
22 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
23 | 25 | ||
24 | #include <unistd.h> | 26 | #include <unistd.h> |
25 | 27 | ||
26 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) | 28 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) |
27 | : QDialog( parent, name, modal, fl ) | 29 | : QDialog( parent, name, modal, fl ) |
28 | { | 30 | { |
29 | if ( !name ) | 31 | if ( !name ) |
30 | setName( "fileSaver" ); | 32 | setName( "fileSaver" ); |
31 | resize( 236, 280 ); | 33 | resize( 240, 280 ); |
32 | setCaption(tr( "Save file" ) ); | 34 | setCaption(tr( "Save file" ) ); |
33 | QFileInfo fi(currentFileName); | 35 | QFileInfo fi(currentFileName); |
34 | QString tmpFileName=fi.fileName(); | 36 | QString tmpFileName=fi.fileName(); |
35 | // qDebug( tmpFileName); | 37 | // qDebug( tmpFileName); |
36 | |||
37 | dirLabel = new QLabel(this, "DirLabel"); | 38 | dirLabel = new QLabel(this, "DirLabel"); |
38 | dirLabel->setText(currentDir.canonicalPath()); | 39 | dirLabel->setText(currentDir.canonicalPath()); |
39 | dirLabel->setGeometry(10,4,230,30); | 40 | dirLabel->setGeometry(10,20,230,15); |
40 | 41 | ||
42 | QPushButton *homeButton; | ||
43 | homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); | ||
44 | homeButton->setGeometry(200,4,25,25); | ||
45 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | ||
46 | |||
41 | ListView = new QListView( this, "ListView" ); | 47 | ListView = new QListView( this, "ListView" ); |
42 | ListView->addColumn( tr( "Name" ) ); | 48 | ListView->addColumn( tr( "Name" ) ); |
43 | ListView->setColumnWidth(0,140); | 49 | ListView->setColumnWidth(0,140); |
44 | ListView->setSorting( 2, FALSE); | 50 | ListView->setSorting( 2, FALSE); |
45 | ListView->addColumn( tr( "Size" ) ); | 51 | ListView->addColumn( tr( "Size" ) ); |
46 | ListView->setColumnWidth(1,59); | 52 | ListView->setColumnWidth(1,59); |
47 | ListView->setColumnWidthMode(0,QListView::Manual); | 53 | ListView->setColumnWidthMode(0,QListView::Manual); |
48 | ListView->setColumnAlignment(1,QListView::AlignRight); | 54 | ListView->setColumnAlignment(1,QListView::AlignRight); |
49 | // ListView->setMultiSelection(true); | 55 | // ListView->setMultiSelection(true); |
50 | // ListView->setSelectionMode(QListView::Extended); | 56 | // ListView->setSelectionMode(QListView::Extended); |
51 | 57 | ||
52 | ListView->setAllColumnsShowFocus( TRUE ); | 58 | ListView->setAllColumnsShowFocus( TRUE ); |
53 | ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); | 59 | ListView->setGeometry( QRect( 10,35,220,125)); |
54 | 60 | ||
55 | fileEdit= new QLineEdit(this); | 61 | fileEdit= new QLineEdit(this); |
56 | fileEdit->setGeometry( QRect( 10, 200, 200, 22)); | 62 | fileEdit->setGeometry( QRect( 10, 162, 205, 17)); |
57 | 63 | ||
58 | fileEdit->setText( tmpFileName); | 64 | fileEdit->setText( tmpFileName); |
59 | 65 | ||
60 | filePermCheck = new QCheckBox( this, "SetFilePerms" ); | 66 | filePermCheck = new QCheckBox( this, "SetFilePerms" ); |
61 | filePermCheck->setText("set file permissions"); | 67 | filePermCheck->setText("set file permissions"); |
62 | filePermCheck->setGeometry(10, 220, 150,22); | 68 | filePermCheck->setGeometry(10, 178, 150,17); |
63 | // signals and slots connections | 69 | // signals and slots connections |
64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 70 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
65 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 71 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
66 | 72 | ||
67 | // tmpFileName=fi.FilePath(); | 73 | // tmpFileName=fi.FilePath(); |
68 | // qDebug( tmpFileName); | 74 | // qDebug( tmpFileName); |
69 | currentDir.setPath( QDir::currentDirPath() ); | 75 | currentDir.setPath( QDir::currentDirPath() ); |
70 | populateList(); | 76 | populateList(); |
77 | move(0,15); | ||
78 | |||
71 | } | 79 | } |
72 | 80 | ||
73 | fileSaver::~fileSaver() | 81 | fileSaver::~fileSaver() |
74 | { | 82 | { |
75 | } | 83 | } |
76 | 84 | ||
77 | 85 | ||
78 | void fileSaver::populateList() | 86 | void fileSaver::populateList() |
@@ -104,17 +112,17 @@ void fileSaver::populateList() | |||
104 | fileL+="/"; | 112 | fileL+="/"; |
105 | // qDebug(currentDir.canonicalPath()+fileL); | 113 | // qDebug(currentDir.canonicalPath()+fileL); |
106 | } | 114 | } |
107 | } | 115 | } |
108 | item= new QListViewItem( ListView,fileL,fileS ); | 116 | item= new QListViewItem( ListView,fileL,fileS ); |
109 | ++it; | 117 | ++it; |
110 | } | 118 | } |
111 | ListView->setSorting( 2, FALSE); | 119 | ListView->setSorting( 2, FALSE); |
112 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 120 | dirLabel->setText(currentDir.canonicalPath()); |
113 | 121 | ||
114 | 122 | ||
115 | } | 123 | } |
116 | 124 | ||
117 | void fileSaver::upDir() | 125 | void fileSaver::upDir() |
118 | { | 126 | { |
119 | // qDebug(currentDir.canonicalPath()); | 127 | // qDebug(currentDir.canonicalPath()); |
120 | } | 128 | } |
@@ -181,8 +189,15 @@ void fileSaver::accept() { | |||
181 | if( path.find("//",0,TRUE) ==-1 ) { | 189 | if( path.find("//",0,TRUE) ==-1 ) { |
182 | selectedFileName = path; | 190 | selectedFileName = path; |
183 | } else { | 191 | } else { |
184 | selectedFileName = currentDir.canonicalPath()+selectedFileName; | 192 | selectedFileName = currentDir.canonicalPath()+selectedFileName; |
185 | } | 193 | } |
186 | qDebug("going to save "+selectedFileName); | 194 | qDebug("going to save "+selectedFileName); |
187 | done(1); | 195 | done(1); |
188 | } | 196 | } |
197 | |||
198 | void fileSaver::homeButtonPushed() { | ||
199 | chdir( QDir::homeDirPath().latin1() ); | ||
200 | currentDir.cd( QDir::homeDirPath(), TRUE); | ||
201 | populateList(); | ||
202 | update(); | ||
203 | } | ||