summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index 652f830..b655c96 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,190 +1,191 @@
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//#define QTOPIA_INTERNAL_MIMEEXT 14//#define QTOPIA_INTERNAL_MIMEEXT
15#include "fileBrowser.h" 15#include "fileBrowser.h"
16//#include "inputDialog.h" 16//#include "inputDialog.h"
17 17
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20#include <qpe/fileselector.h> 20#include <qpe/fileselector.h>
21#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
22#include <qpe/menubutton.h> 22#include <qpe/menubutton.h>
23#include <qpe/mimetype.h> 23#include <qpe/mimetype.h>
24 24
25#include <qdict.h> 25#include <qdict.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qcombo.h> 28#include <qcombo.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qfile.h> 30#include <qfile.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <unistd.h> 33#include <unistd.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qlineedit.h> 35#include <qlineedit.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37 37
38#include <unistd.h> 38#include <unistd.h>
39#include <stdlib.h> 39#include <stdlib.h>
40 40
41static int u_id = 1; 41static int u_id = 1;
42static int get_unique_id() 42static int get_unique_id()
43{ 43{
44 return u_id++; 44 return u_id++;
45} 45}
46 46
47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter ) 47fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
48 : QDialog( parent, name, modal, fl ) 48 : QDialog( parent, name, modal, fl )
49{ 49{
50 if ( !name ) 50 if ( !name )
51 setName( "fileBrowser" ); 51 setName( "fileBrowser" );
52 setCaption(tr( name ) ); 52 setCaption(tr( name ) );
53// mimeType = mimeFilter; 53// mimeType = mimeFilter;
54// MimeType mt( mimeType); 54// MimeType mt( mimeType);
55// if( mt.extension().isEmpty()) 55// if( mt.extension().isEmpty())
56 QStringList filterList; 56// QStringList filterList;
57 filterList=QStringList::split(";",mimeFilter,FALSE); 57// filterList=QStringList::split(";",mimeFilter,FALSE);
58 for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) { 58// for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) {
59 printf( "%s \n", (*it).latin1() ); 59// printf( "%s \n", (*it).latin1() );
60 } 60// }
61 61
62 filterStr = mimeFilter.right(mimeFilter.length()- mimeFilter.find("/",0,TRUE) - 1);// "*"; 62 filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*";
63
63 qDebug(filterStr); 64 qDebug(filterStr);
64// else 65// else
65// filterStr = "*."+ mt.extension(); 66// filterStr = "*."+ mt.extension();
66// qDebug("description "+mt.description()); 67// qDebug("description "+mt.description());
67// qDebug( "id "+mt.id()); 68// qDebug( "id "+mt.id());
68// qDebug("extension "+mt.extension()); 69// qDebug("extension "+mt.extension());
69 70
70// channel = new QCopChannel( "QPE/fileDialog", this ); 71// channel = new QCopChannel( "QPE/fileDialog", this );
71// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 72// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
72// this, SLOT(receive(const QCString&, const QByteArray&)) ); 73// this, SLOT(receive(const QCString&, const QByteArray&)) );
73 74
74 QGridLayout *layout = new QGridLayout( this ); 75 QGridLayout *layout = new QGridLayout( this );
75 layout->setSpacing( 4 ); 76 layout->setSpacing( 4 );
76 layout->setMargin( 4 ); 77 layout->setMargin( 4 );
77 78
78 dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" ); 79 dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" );
79 dirPathCombo->setEditable(TRUE); 80 dirPathCombo->setEditable(TRUE);
80 81
81 connect( dirPathCombo, SIGNAL( activated( const QString & ) ), 82 connect( dirPathCombo, SIGNAL( activated( const QString & ) ),
82 this, SLOT( dirPathComboActivated( const QString & ) ) ); 83 this, SLOT( dirPathComboActivated( const QString & ) ) );
83 84
84 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), 85 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ),
85 this, SLOT( dirPathEditPressed( ) ) ); 86 this, SLOT( dirPathEditPressed( ) ) );
86 87
87 dirPathStringList << "/"; 88 dirPathStringList << "/";
88// we can get the storage here 89// we can get the storage here
89 90
90 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); 91 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 );
91 92
92 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); 93 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
93 cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); 94 cdUpButton ->setMinimumSize( QSize( 20, 20 ) );
94 cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); 95 cdUpButton ->setMaximumSize( QSize( 20, 20 ) );
95 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 96 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
96 cdUpButton ->setFlat(TRUE); 97 cdUpButton ->setFlat(TRUE);
97 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); 98 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 );
98 99
99 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 100 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
100 docButton->setMinimumSize( QSize( 20, 20 ) ); 101 docButton->setMinimumSize( QSize( 20, 20 ) );
101 docButton->setMaximumSize( QSize( 20, 20 ) ); 102 docButton->setMaximumSize( QSize( 20, 20 ) );
102 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 103 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
103 docButton->setFlat(TRUE); 104 docButton->setFlat(TRUE);
104 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 105 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
105 106
106 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 107 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
107 homeButton->setMinimumSize( QSize( 20, 20 ) ); 108 homeButton->setMinimumSize( QSize( 20, 20 ) );
108 homeButton->setMaximumSize( QSize( 20, 20 ) ); 109 homeButton->setMaximumSize( QSize( 20, 20 ) );
109 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 110 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
110 homeButton->setFlat(TRUE); 111 homeButton->setFlat(TRUE);
111 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); 112 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 );
112 113
113 FileStack = new QWidgetStack( this ); 114 FileStack = new QWidgetStack( this );
114 115
115 ListView = new QListView( this, "ListView" ); 116 ListView = new QListView( this, "ListView" );
116// ListView->setMinimumSize( QSize( 100, 25 ) ); 117// ListView->setMinimumSize( QSize( 100, 25 ) );
117 ListView->addColumn( tr( "Name" ) ); 118 ListView->addColumn( tr( "Name" ) );
118 ListView->setColumnWidth(0,120); 119 ListView->setColumnWidth(0,120);
119 ListView->setSorting( 2, FALSE); 120 ListView->setSorting( 2, FALSE);
120 ListView->addColumn( tr( "Size" ) ); 121 ListView->addColumn( tr( "Size" ) );
121 ListView->setColumnWidth(1,-1); 122 ListView->setColumnWidth(1,-1);
122 ListView->addColumn( "Date",-1); 123 ListView->addColumn( "Date",-1);
123 124
124 ListView->setColumnWidthMode(0,QListView::Manual); 125 ListView->setColumnWidthMode(0,QListView::Manual);
125 ListView->setColumnAlignment(1,QListView::AlignRight); 126 ListView->setColumnAlignment(1,QListView::AlignRight);
126 ListView->setColumnAlignment(2,QListView::AlignRight); 127 ListView->setColumnAlignment(2,QListView::AlignRight);
127 ListView->setAllColumnsShowFocus( TRUE ); 128 ListView->setAllColumnsShowFocus( TRUE );
128 129
129 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); 130 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
130 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 131 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
131 this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 132 this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
132 133
133 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 134 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
134 135
135 FileStack->addWidget( ListView, get_unique_id() ); 136 FileStack->addWidget( ListView, get_unique_id() );
136 137
137 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy 138 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
138// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 139// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
139// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 140// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
140 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), 141 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
141 this, SLOT( docOpen( const DocLnk & ) ) ); 142 this, SLOT( docOpen( const DocLnk & ) ) );
142 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); 143 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
143 144
144 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); 145 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
145 SelectionCombo->insertItem( tr( "Documents" ) ); 146 SelectionCombo->insertItem( tr( "Documents" ) );
146 SelectionCombo->insertItem( tr( "All files" ) ); 147 SelectionCombo->insertItem( tr( "All files" ) );
147 SelectionCombo->insertItem( tr( "Hidden files" ) ); 148 SelectionCombo->insertItem( tr( "Hidden files" ) );
148// SelectionCombo->setMaximumWidth(120); 149// SelectionCombo->setMaximumWidth(120);
149 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); 150 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 );
150 151
151 connect( SelectionCombo, SIGNAL( activated( const QString & ) ), 152 connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
152 this, SLOT( selectionChanged( const QString & ) ) ); 153 this, SLOT( selectionChanged( const QString & ) ) );
153 154
154 typemb = new MenuButton(this); 155 typemb = new MenuButton(this);
155 typemb->setLabel(tr("Type: %1")); 156 typemb->setLabel(tr("Type: %1"));
156 typemb->setMinimumWidth(110); 157 typemb->setMinimumWidth(110);
157 typemb->setFixedHeight(22); 158 typemb->setFixedHeight(22);
158 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); 159 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 );
159 updateMimeTypeMenu() ; 160 updateMimeTypeMenu() ;
160 161
161 currentDir.setPath(QDir::currentDirPath()); 162 currentDir.setPath(QDir::currentDirPath());
162 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); 163 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
163 currentDir.setNameFilter(filterStr); 164 currentDir.setNameFilter(filterStr);
164 165
165 populateList(); 166 populateList();
166 move(0,15); 167 move(0,15);
167} 168}
168 169
169fileBrowser::~fileBrowser() 170fileBrowser::~fileBrowser()
170{ 171{
171} 172}
172 173
173void fileBrowser::setFileView( int selection ) 174void fileBrowser::setFileView( int selection )
174{ 175{
175 SelectionCombo->setCurrentItem( selection ); 176 SelectionCombo->setCurrentItem( selection );
176 selectionChanged( SelectionCombo->currentText() ); 177 selectionChanged( SelectionCombo->currentText() );
177} 178}
178 179
179void fileBrowser::populateList() 180void fileBrowser::populateList()
180{ 181{
181 ListView->clear(); 182 ListView->clear();
182 QListViewItem * item; 183 QListViewItem * item;
183 bool isDir=FALSE; 184 bool isDir=FALSE;
184//qDebug(currentDir.canonicalPath()); 185//qDebug(currentDir.canonicalPath());
185 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 186 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
186 currentDir.setMatchAllDirs(TRUE); 187 currentDir.setMatchAllDirs(TRUE);
187 188
188// currentDir.setNameFilter("*.txt;*.etx"); 189// currentDir.setNameFilter("*.txt;*.etx");
189 QString fileL, fileS, fileDate; 190 QString fileL, fileS, fileDate;
190 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 191 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);