author | bipolar <bipolar> | 2002-03-01 14:49:41 (UTC) |
---|---|---|
committer | bipolar <bipolar> | 2002-03-01 14:49:41 (UTC) |
commit | 2dfc5c76379baf8ae8ad6aed5f6c44d59d79087b (patch) (unidiff) | |
tree | d4b0572e3204ab4b7bdacde937bca46392182f75 | |
parent | 38e7dc570dfbcea350795d9cf8f66b643ad159a8 (diff) | |
download | opie-2dfc5c76379baf8ae8ad6aed5f6c44d59d79087b.zip opie-2dfc5c76379baf8ae8ad6aed5f6c44d59d79087b.tar.gz opie-2dfc5c76379baf8ae8ad6aed5f6c44d59d79087b.tar.bz2 |
ljp (llornkcor) commited this. Fixes fileSaveas and filedialog positioning
when input method is opened. Added home buttons on each.
-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,121 +1,130 @@ | |||
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); |
70 | // currentDir.setNameFilter("*.txt;*.etx"); | 79 | // currentDir.setNameFilter("*.txt;*.etx"); |
71 | QString fileL, fileS; | 80 | QString fileL, fileS; |
72 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); | 81 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); |
73 | QFileInfoListIterator it(*list); | 82 | QFileInfoListIterator it(*list); |
74 | QFileInfo *fi; | 83 | QFileInfo *fi; |
75 | while ( (fi=it.current()) ) { | 84 | while ( (fi=it.current()) ) { |
76 | 85 | ||
77 | if (fi->isSymLink() ){ | 86 | if (fi->isSymLink() ){ |
78 | QString symLink=fi->readLink(); | 87 | QString symLink=fi->readLink(); |
79 | // qDebug("Symlink detected "+symLink); | 88 | // qDebug("Symlink detected "+symLink); |
80 | QFileInfo sym( symLink); | 89 | QFileInfo sym( symLink); |
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); |
114 | // qDebug("strItem is "+strItem); | 123 | // qDebug("strItem is "+strItem); |
115 | strSize.stripWhiteSpace(); | 124 | strSize.stripWhiteSpace(); |
116 | // qDebug(strSize); | 125 | // qDebug(strSize); |
117 | 126 | ||
118 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 127 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
119 | // is symlink | 128 | // is symlink |
120 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 129 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
121 | // qDebug("strItem symlink is "+strItem2); | 130 | // qDebug("strItem symlink is "+strItem2); |
@@ -141,24 +150,31 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
141 | } else { | 150 | } else { |
142 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 151 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
143 | if( QFile::exists(strItem ) ) { | 152 | if( QFile::exists(strItem ) ) { |
144 | //currentDir.canonicalPath() | 153 | //currentDir.canonicalPath() |
145 | qDebug("We found our files!!"+strItem); | 154 | qDebug("We found our files!!"+strItem); |
146 | OnOK(); | 155 | OnOK(); |
147 | } | 156 | } |
148 | } //end not symlink | 157 | } //end not symlink |
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 | |||
@@ -29,39 +29,39 @@ class QGridLayout; | |||
29 | class QListView; | 29 | class QListView; |
30 | class QListViewItem; | 30 | class QListViewItem; |
31 | class QPushButton; | 31 | class QPushButton; |
32 | 32 | ||
33 | class fileBrowser : public QDialog | 33 | class fileBrowser : public QDialog |
34 | { | 34 | { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | 36 | ||
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,136 +1,144 @@ | |||
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; |
87 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); | 95 | const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/); |
88 | QFileInfoListIterator it(*list); | 96 | QFileInfoListIterator it(*list); |
89 | QFileInfo *fi; | 97 | QFileInfo *fi; |
90 | while ( (fi=it.current()) ) { | 98 | while ( (fi=it.current()) ) { |
91 | 99 | ||
92 | if (fi->isSymLink() ){ | 100 | if (fi->isSymLink() ){ |
93 | QString symLink=fi->readLink(); | 101 | QString symLink=fi->readLink(); |
94 | // qDebug("Symlink detected "+symLink); | 102 | // qDebug("Symlink detected "+symLink); |
95 | QFileInfo sym( symLink); | 103 | QFileInfo sym( symLink); |
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); |
129 | QString strSize=selectedItem->text(1); | 137 | QString strSize=selectedItem->text(1); |
130 | // qDebug("strItem is "+strItem); | 138 | // qDebug("strItem is "+strItem); |
131 | strSize.stripWhiteSpace(); | 139 | strSize.stripWhiteSpace(); |
132 | // qDebug(strSize); | 140 | // qDebug(strSize); |
133 | 141 | ||
134 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 142 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
135 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 143 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
136 | // qDebug("strItem symlink is "+strItem2); | 144 | // qDebug("strItem symlink is "+strItem2); |
@@ -165,24 +173,31 @@ void fileSaver::listClicked(QListViewItem *selectedItem) | |||
165 | } | 173 | } |
166 | 174 | ||
167 | 175 | ||
168 | void fileSaver::closeEvent( QCloseEvent *e ) | 176 | void fileSaver::closeEvent( QCloseEvent *e ) |
169 | { | 177 | { |
170 | if(e->isAccepted()) { | 178 | if(e->isAccepted()) { |
171 | e->accept(); | 179 | e->accept(); |
172 | } else { | 180 | } else { |
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 | |||
@@ -34,41 +34,41 @@ class QLineEdit; | |||
34 | class QCheckBox; | 34 | class QCheckBox; |
35 | 35 | ||
36 | class fileSaver : public QDialog | 36 | class fileSaver : public QDialog |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | void populateList(); | 41 | void populateList(); |
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 | |||
@@ -742,49 +742,49 @@ bool TextEdit::saveAs() | |||
742 | 742 | ||
743 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { | 743 | if( currentFileName.isEmpty() || currentFileName == "Unnamed") { |
744 | qDebug("do silly TT filename thing"); | 744 | qDebug("do silly TT filename thing"); |
745 | if ( doc->name().isEmpty() ) { | 745 | if ( doc->name().isEmpty() ) { |
746 | QString pt = rt.simplifyWhiteSpace(); | 746 | QString pt = rt.simplifyWhiteSpace(); |
747 | int i = pt.find( ' ' ); | 747 | int i = pt.find( ' ' ); |
748 | QString docname = pt; | 748 | QString docname = pt; |
749 | if ( i > 0 ) | 749 | if ( i > 0 ) |
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); |
783 | // editor->setText(rt); | 783 | // editor->setText(rt); |
784 | qDebug("openFile doclnk "+currentFileName); | 784 | qDebug("openFile doclnk "+currentFileName); |
785 | doc->setName( currentFileName); | 785 | doc->setName( currentFileName); |
786 | updateCaption( currentFileName); | 786 | updateCaption( currentFileName); |
787 | 787 | ||
788 | FileManager fm; | 788 | FileManager fm; |
789 | if ( !fm.saveFile( *doc, rt ) ) { | 789 | if ( !fm.saveFile( *doc, rt ) ) { |
790 | return false; | 790 | return false; |
@@ -868,31 +868,32 @@ void TextEdit::changeFont() { | |||
868 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 868 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
869 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 869 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
870 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 870 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
871 | 871 | ||
872 | defaultFont = fdb.font(family,style,i_size,charSet); | 872 | defaultFont = fdb.font(family,style,i_size,charSet); |
873 | 873 | ||
874 | FontDialog *fontDlg; | 874 | FontDialog *fontDlg; |
875 | fontDlg=new FontDialog(this,"FontDialog",TRUE); | 875 | fontDlg=new FontDialog(this,"FontDialog",TRUE); |
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 | } |