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 /core/apps/textedit/fileBrowser.cpp | |
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.
Diffstat (limited to 'core/apps/textedit/fileBrowser.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 22 |
1 files changed, 19 insertions, 3 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 | |||
@@ -4,62 +4,71 @@ | |||
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 ); |
@@ -85,25 +94,25 @@ void fileBrowser::populateList() | |||
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 |
@@ -153,12 +162,19 @@ void fileBrowser::listClicked(QListViewItem *selectedItem) | |||
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 | } | ||