-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 22 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 2 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 29 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.h | 2 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 3 |
5 files changed, 45 insertions, 13 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 2275388..3e3cc3a 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -1,69 +1,78 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 | 3 | ** Created: Fri Dec 14 08:16:46 2001 |
4 | ** | 4 | ** |
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 "fileBrowser.h" | 14 | #include "fileBrowser.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/resource.h> | ||
16 | 17 | ||
17 | #include <qlistview.h> | 18 | #include <qlistview.h> |
18 | #include <qpushbutton.h> | 19 | #include <qpushbutton.h> |
19 | #include <qfile.h> | 20 | #include <qfile.h> |
20 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
21 | #include <unistd.h> | 22 | #include <unistd.h> |
22 | 23 | ||
23 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) | 24 | fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) |
24 | : QDialog( parent, name, modal, fl ) | 25 | : QDialog( parent, name, modal, fl ) |
25 | { | 26 | { |
26 | if ( !name ) | 27 | if ( !name ) |
27 | setName( "fileBrowser" ); | 28 | setName( "fileBrowser" ); |
28 | resize( 236, 280 ); | 29 | resize( 240, 280 ); |
29 | setCaption(tr( "Browse for file" ) ); | 30 | setCaption(tr( "Browse for file" ) ); |
30 | filterStr=filter; | 31 | filterStr=filter; |
32 | |||
31 | dirLabel = new QLabel(this, "DirLabel"); | 33 | dirLabel = new QLabel(this, "DirLabel"); |
32 | dirLabel->setText(currentDir.canonicalPath()); | 34 | dirLabel->setText(currentDir.canonicalPath()); |
33 | dirLabel->setGeometry(10,4,230,30); | 35 | dirLabel->setGeometry(10,20,230,15); |
36 | |||
37 | QPushButton *homeButton; | ||
38 | homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); | ||
39 | homeButton->setGeometry(200,4,25,25); | ||
40 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | ||
41 | |||
34 | ListView = new QListView( this, "ListView" ); | 42 | ListView = new QListView( this, "ListView" ); |
35 | ListView->addColumn( tr( "Name" ) ); | 43 | ListView->addColumn( tr( "Name" ) ); |
36 | ListView->setColumnWidth(0,140); | 44 | ListView->setColumnWidth(0,140); |
37 | ListView->setSorting( 2, FALSE); | 45 | ListView->setSorting( 2, FALSE); |
38 | ListView->addColumn( tr( "Size" ) ); | 46 | ListView->addColumn( tr( "Size" ) ); |
39 | ListView->setColumnWidth(1,59); | 47 | ListView->setColumnWidth(1,59); |
40 | // ListView->addColumn( tr( "" ) ); | 48 | // ListView->addColumn( tr( "" ) ); |
41 | ListView->setColumnWidthMode(0,QListView::Manual); | 49 | ListView->setColumnWidthMode(0,QListView::Manual); |
42 | ListView->setColumnAlignment(1,QListView::AlignRight); | 50 | ListView->setColumnAlignment(1,QListView::AlignRight); |
43 | // ListView->setMultiSelection(true); | 51 | // ListView->setMultiSelection(true); |
44 | // ListView->setSelectionMode(QListView::Extended); | 52 | // ListView->setSelectionMode(QListView::Extended); |
45 | 53 | ||
46 | ListView->setAllColumnsShowFocus( TRUE ); | 54 | ListView->setAllColumnsShowFocus( TRUE ); |
47 | ListView->setGeometry( QRect( 10, 35, 220, 240 ) ); | 55 | ListView->setGeometry( QRect( 10, 35, 220, 240 ) ); |
48 | 56 | ||
49 | // signals and slots connections | 57 | // signals and slots connections |
50 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 58 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
51 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 59 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
52 | currentDir.setPath(QDir::currentDirPath()); | 60 | currentDir.setPath(QDir::currentDirPath()); |
53 | populateList(); | 61 | populateList(); |
62 | move(0,15); | ||
54 | } | 63 | } |
55 | 64 | ||
56 | fileBrowser::~fileBrowser() | 65 | fileBrowser::~fileBrowser() |
57 | { | 66 | { |
58 | } | 67 | } |
59 | 68 | ||
60 | 69 | ||
61 | void fileBrowser::populateList() | 70 | void fileBrowser::populateList() |
62 | { | 71 | { |
63 | ListView->clear(); | 72 | ListView->clear(); |
64 | //qDebug(currentDir.canonicalPath()); | 73 | //qDebug(currentDir.canonicalPath()); |
65 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); | 74 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); |
66 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 75 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
67 | currentDir.setMatchAllDirs(TRUE); | 76 | currentDir.setMatchAllDirs(TRUE); |
68 | 77 | ||
69 | currentDir.setNameFilter(filterStr); | 78 | currentDir.setNameFilter(filterStr); |
@@ -81,33 +90,33 @@ void fileBrowser::populateList() | |||
81 | fileS.sprintf( "%10li", sym.size() ); | 90 | fileS.sprintf( "%10li", sym.size() ); |
82 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 91 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
83 | 92 | ||
84 | } else { | 93 | } else { |
85 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 94 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
86 | fileS.sprintf( "%10li", fi->size() ); | 95 | fileS.sprintf( "%10li", fi->size() ); |
87 | fileL.sprintf( "%s",fi->fileName().data() ); | 96 | fileL.sprintf( "%s",fi->fileName().data() ); |
88 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 97 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
89 | fileL+="/"; | 98 | fileL+="/"; |
90 | // qDebug(currentDir.canonicalPath()+fileL); | 99 | // qDebug(currentDir.canonicalPath()+fileL); |
91 | } | 100 | } |
92 | } | 101 | } |
93 | item= new QListViewItem( ListView,fileL,fileS ); | 102 | item= new QListViewItem( ListView,fileL,fileS ); |
94 | ++it; | 103 | ++it; |
95 | } | 104 | } |
96 | ListView->setSorting( 2, FALSE); | 105 | ListView->setSorting( 2, FALSE); |
97 | dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath()); | 106 | dirLabel->setText(currentDir.canonicalPath()); |
98 | } | 107 | } |
99 | 108 | ||
100 | void fileBrowser::upDir() | 109 | void fileBrowser::upDir() |
101 | { | 110 | { |
102 | // qDebug(currentDir.canonicalPath()); | 111 | // qDebug(currentDir.canonicalPath()); |
103 | } | 112 | } |
104 | 113 | ||
105 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) | 114 | void fileBrowser::listDoubleClicked(QListViewItem *selectedItem) |
106 | { | 115 | { |
107 | } | 116 | } |
108 | 117 | ||
109 | // you may want to switch these 2 functions. I like single clicks | 118 | // you may want to switch these 2 functions. I like single clicks |
110 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 119 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
111 | { | 120 | { |
112 | QString strItem=selectedItem->text(0); | 121 | QString strItem=selectedItem->text(0); |
113 | QString strSize=selectedItem->text(1); | 122 | QString strSize=selectedItem->text(1); |
@@ -149,16 +158,23 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
149 | chdir(strItem.latin1()); | 158 | chdir(strItem.latin1()); |
150 | } | 159 | } |
151 | } | 160 | } |
152 | 161 | ||
153 | void fileBrowser::OnOK() | 162 | void fileBrowser::OnOK() |
154 | { | 163 | { |
155 | QListViewItemIterator it1( ListView); | 164 | QListViewItemIterator it1( ListView); |
156 | for ( ; it1.current(); ++it1 ) { | 165 | for ( ; it1.current(); ++it1 ) { |
157 | if ( it1.current()->isSelected() ) { | 166 | if ( it1.current()->isSelected() ) { |
158 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 167 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
159 | qDebug("selected filename is "+selectedFileName); | 168 | qDebug("selected filename is "+selectedFileName); |
160 | fileList.append( selectedFileName ); | 169 | fileList.append( selectedFileName ); |
161 | } | 170 | } |
162 | } | 171 | } |
163 | accept(); | 172 | accept(); |
164 | } | 173 | } |
174 | |||
175 | void fileBrowser::homeButtonPushed() { | ||
176 | chdir( QDir::homeDirPath().latin1() ); | ||
177 | currentDir.cd( QDir::homeDirPath(), TRUE); | ||
178 | populateList(); | ||
179 | update(); | ||
180 | } | ||
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 17ed862..c0e1d4a 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h | |||
@@ -37,31 +37,31 @@ class fileBrowser : public QDialog | |||
37 | public: | 37 | public: |
38 | void populateList(); | 38 | void populateList(); |
39 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); | 39 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); |
40 | ~fileBrowser(); | 40 | ~fileBrowser(); |
41 | 41 | ||
42 | QPushButton* buttonOk; | 42 | QPushButton* buttonOk; |
43 | QListView* ListView; | 43 | QListView* ListView; |
44 | QPushButton* buttonCancel; | 44 | QPushButton* buttonCancel; |
45 | QLabel *dirLabel; | 45 | QLabel *dirLabel; |
46 | QString selectedFileName, filterStr; | 46 | QString selectedFileName, filterStr; |
47 | QDir currentDir; | 47 | QDir currentDir; |
48 | QFile file; | 48 | QFile file; |
49 | QStringList fileList; | 49 | QStringList fileList; |
50 | 50 | ||
51 | QListViewItem * item; | 51 | QListViewItem * item; |
52 | public slots: | 52 | public slots: |
53 | 53 | void homeButtonPushed(); | |
54 | private: | 54 | private: |
55 | 55 | ||
56 | private slots: | 56 | private slots: |
57 | void upDir(); | 57 | void upDir(); |
58 | void listDoubleClicked(QListViewItem *); | 58 | void listDoubleClicked(QListViewItem *); |
59 | void listClicked(QListViewItem *); | 59 | void listClicked(QListViewItem *); |
60 | void OnOK(); | 60 | void OnOK(); |
61 | protected slots: | 61 | protected slots: |
62 | 62 | ||
63 | protected: | 63 | protected: |
64 | 64 | ||
65 | }; | 65 | }; |
66 | 66 | ||
67 | #endif // FILEBROWSER_H | 67 | #endif // FILEBROWSER_H |
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 | |||
@@ -1,86 +1,94 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp | 3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp |
4 | ** | 4 | ** |
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> | ||
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() |
79 | { | 87 | { |
80 | ListView->clear(); | 88 | ListView->clear(); |
81 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); | 89 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden ); |
82 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 90 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
83 | currentDir.setMatchAllDirs(TRUE); | 91 | currentDir.setMatchAllDirs(TRUE); |
84 | 92 | ||
85 | currentDir.setNameFilter("*"); | 93 | currentDir.setNameFilter("*"); |
86 | QString fileL, fileS; | 94 | QString fileL, fileS; |
@@ -96,33 +104,33 @@ void fileSaver::populateList() | |||
96 | fileS.sprintf( "%10li", sym.size() ); | 104 | fileS.sprintf( "%10li", sym.size() ); |
97 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 105 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
98 | 106 | ||
99 | } else { | 107 | } else { |
100 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 108 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
101 | fileS.sprintf( "%10li", fi->size() ); | 109 | fileS.sprintf( "%10li", fi->size() ); |
102 | fileL.sprintf( "%s",fi->fileName().data() ); | 110 | fileL.sprintf( "%s",fi->fileName().data() ); |
103 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 111 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
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 | } |
121 | 129 | ||
122 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) | 130 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) |
123 | { | 131 | { |
124 | } | 132 | } |
125 | 133 | ||
126 | void fileSaver::listClicked(QListViewItem *selectedItem) | 134 | void fileSaver::listClicked(QListViewItem *selectedItem) |
127 | { | 135 | { |
128 | QString strItem=selectedItem->text(0); | 136 | QString strItem=selectedItem->text(0); |
@@ -173,16 +181,23 @@ void fileSaver::closeEvent( QCloseEvent *e ) | |||
173 | qDebug("not accepted"); | 181 | qDebug("not accepted"); |
174 | done(-1); | 182 | done(-1); |
175 | } | 183 | } |
176 | } | 184 | } |
177 | 185 | ||
178 | void fileSaver::accept() { | 186 | void fileSaver::accept() { |
179 | selectedFileName = fileEdit->text(); | 187 | selectedFileName = fileEdit->text(); |
180 | QString path = currentDir.canonicalPath()+"/" + selectedFileName; | 188 | QString path = currentDir.canonicalPath()+"/" + selectedFileName; |
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 | } | ||
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h index ce4493e..526085d 100644 --- a/core/apps/textedit/fileSaver.h +++ b/core/apps/textedit/fileSaver.h | |||
@@ -42,33 +42,33 @@ public: | |||
42 | fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); | 42 | fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); |
43 | ~fileSaver(); | 43 | ~fileSaver(); |
44 | QLineEdit *fileEdit; | 44 | QLineEdit *fileEdit; |
45 | 45 | ||
46 | QPushButton* buttonOk; | 46 | QPushButton* buttonOk; |
47 | QListView* ListView; | 47 | QListView* ListView; |
48 | QPushButton* buttonCancel; | 48 | QPushButton* buttonCancel; |
49 | QLabel *dirLabel; | 49 | QLabel *dirLabel; |
50 | QString selectedFileName, filterStr; | 50 | QString selectedFileName, filterStr; |
51 | QDir currentDir; | 51 | QDir currentDir; |
52 | QFile file; | 52 | QFile file; |
53 | QStringList fileList; | 53 | QStringList fileList; |
54 | QCheckBox *filePermCheck; | 54 | QCheckBox *filePermCheck; |
55 | 55 | ||
56 | QListViewItem * item; | 56 | QListViewItem * item; |
57 | public slots: | 57 | public slots: |
58 | 58 | void homeButtonPushed(); | |
59 | private: | 59 | private: |
60 | 60 | ||
61 | private slots: | 61 | private slots: |
62 | void accept(); | 62 | void accept(); |
63 | void upDir(); | 63 | void upDir(); |
64 | void listDoubleClicked(QListViewItem *); | 64 | void listDoubleClicked(QListViewItem *); |
65 | void listClicked(QListViewItem *); | 65 | void listClicked(QListViewItem *); |
66 | void closeEvent( QCloseEvent * ); | 66 | void closeEvent( QCloseEvent * ); |
67 | 67 | ||
68 | protected slots: | 68 | protected slots: |
69 | 69 | ||
70 | protected: | 70 | protected: |
71 | 71 | ||
72 | }; | 72 | }; |
73 | 73 | ||
74 | #endif // FILESAVER_H | 74 | #endif // FILESAVER_H |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index bc975f3..72cc4d1 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -750,33 +750,33 @@ bool TextEdit::saveAs() | |||
750 | docname = pt.left( i ); | 750 | docname = pt.left( i ); |
751 | // remove "." at the beginning | 751 | // remove "." at the beginning |
752 | while( docname.startsWith( "." ) ) | 752 | while( docname.startsWith( "." ) ) |
753 | docname = docname.mid( 1 ); | 753 | docname = docname.mid( 1 ); |
754 | docname.replace( QRegExp("/"), "_" ); | 754 | docname.replace( QRegExp("/"), "_" ); |
755 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 755 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
756 | if ( docname.length() > 40 ) | 756 | if ( docname.length() > 40 ) |
757 | docname = docname.left(40); | 757 | docname = docname.left(40); |
758 | if ( docname.isEmpty() ) | 758 | if ( docname.isEmpty() ) |
759 | docname = "Unnamed"; | 759 | docname = "Unnamed"; |
760 | doc->setName(docname); | 760 | doc->setName(docname); |
761 | currentFileName=docname; | 761 | currentFileName=docname; |
762 | } | 762 | } |
763 | } | 763 | } |
764 | 764 | ||
765 | 765 | ||
766 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); | 766 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE, 0, currentFileName); |
767 | qDebug("wanna save filename "+currentFileName); | 767 | qDebug("wanna save filename "+currentFileName); |
768 | fileSaveDlg->exec(); | 768 | fileSaveDlg->exec(); |
769 | if( fileSaveDlg->result() == 1 ) { | 769 | if( fileSaveDlg->result() == 1 ) { |
770 | QString fileNm=fileSaveDlg->selectedFileName; | 770 | QString fileNm=fileSaveDlg->selectedFileName; |
771 | qDebug("saving filename "+fileNm); | 771 | qDebug("saving filename "+fileNm); |
772 | QFileInfo fi(fileNm); | 772 | QFileInfo fi(fileNm); |
773 | currentFileName=fi.fileName(); | 773 | currentFileName=fi.fileName(); |
774 | if(doc) { | 774 | if(doc) { |
775 | qDebug("doclnk exists"); | 775 | qDebug("doclnk exists"); |
776 | // QString file = doc->file(); | 776 | // QString file = doc->file(); |
777 | // doc->removeFiles(); | 777 | // doc->removeFiles(); |
778 | delete doc; | 778 | delete doc; |
779 | DocLnk nf; | 779 | DocLnk nf; |
780 | nf.setType("text/plain"); | 780 | nf.setType("text/plain"); |
781 | nf.setFile( fileNm); | 781 | nf.setFile( fileNm); |
782 | doc = new DocLnk(nf); | 782 | doc = new DocLnk(nf); |
@@ -876,23 +876,24 @@ void TextEdit::changeFont() { | |||
876 | 876 | ||
877 | fontDlg->exec(); | 877 | fontDlg->exec(); |
878 | 878 | ||
879 | QFont myFont=fontDlg->selectedFont; | 879 | QFont myFont=fontDlg->selectedFont; |
880 | editor->setFont( myFont); | 880 | editor->setFont( myFont); |
881 | delete fontDlg; | 881 | delete fontDlg; |
882 | 882 | ||
883 | } | 883 | } |
884 | 884 | ||
885 | void TextEdit::editDelete() | 885 | void TextEdit::editDelete() |
886 | { | 886 | { |
887 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { | 887 | switch ( QMessageBox::warning(this,"Text Editor","Do you really want\nto delete the current file\nfrom the disk?\nThis is irreversable!!","Yes","No",0,0,1) ) { |
888 | case 0: | 888 | case 0: |
889 | if(doc) { | 889 | if(doc) { |
890 | doc->removeFiles(); | 890 | doc->removeFiles(); |
891 | clear(); | 891 | clear(); |
892 | setCaption( tr("Text Editor") ); | ||
892 | } | 893 | } |
893 | break; | 894 | break; |
894 | case 1: | 895 | case 1: |
895 | // exit | 896 | // exit |
896 | break; | 897 | break; |
897 | }; | 898 | }; |
898 | } | 899 | } |