author | zecke <zecke> | 2002-10-28 19:55:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-28 19:55:18 (UTC) |
commit | 3ba494eb02e72e1f9a732c46ec8085e843f01eca (patch) (unidiff) | |
tree | cdc0e7af342cd0e205ed4ae1c1da92ced3fd5774 | |
parent | e9d8023028b7c996d8ff2a68b87dfde19fcfa892 (diff) | |
download | opie-3ba494eb02e72e1f9a732c46ec8085e843f01eca.zip opie-3ba494eb02e72e1f9a732c46ec8085e843f01eca.tar.gz opie-3ba494eb02e72e1f9a732c46ec8085e843f01eca.tar.bz2 |
This will probably not compile.. i did not even try to compile it
on my machine
I changed the data flow to be more extandable the Olister class
is now playing a bigger role it's dependant on
doing some assembly of the filepath and changedirs.
It now has also to take care of the location bar
-rw-r--r-- | libopie/ofileselector/ofilelistview.cpp | 20 | ||||
-rw-r--r-- | libopie/ofileselector/ofilelistview.h | 15 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 25 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselectoritem.cpp | 5 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselectoritem.h | 5 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.cpp | 14 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.h | 33 | ||||
-rw-r--r-- | libopie/ofileselector/olister.cpp | 58 | ||||
-rw-r--r-- | libopie/ofileselector/olister.h | 61 | ||||
-rw-r--r-- | libopie/ofileselector/olocallister.cpp | 3 |
10 files changed, 199 insertions, 40 deletions
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp index 691bf42..9cfdc48 100644 --- a/libopie/ofileselector/ofilelistview.cpp +++ b/libopie/ofileselector/ofilelistview.cpp | |||
@@ -1,193 +1,203 @@ | |||
1 | 1 | ||
2 | #include <qheader.h> | 2 | #include <qheader.h> |
3 | 3 | ||
4 | #include <qpe/mimetype.h> | 4 | #include <qpe/mimetype.h> |
5 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | #include "ofileselector.h" | 8 | #include "ofileselector.h" |
9 | #include "ofileselectoritem.h" | 9 | #include "ofileselectoritem.h" |
10 | #include "ofilelistview.h" | 10 | #include "ofilelistview.h" |
11 | 11 | ||
12 | 12 | ||
13 | OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) | 13 | OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) |
14 | : QListView( parent ), OFileView( sel ) | 14 | : QListView( parent ), OFileView( sel ) |
15 | { | 15 | { |
16 | QPEApplication::setStylusOperation( viewport(), | 16 | QPEApplication::setStylusOperation( viewport(), |
17 | QPEApplication::RightOnHold); | 17 | QPEApplication::RightOnHold); |
18 | addColumn(" " ); | 18 | addColumn(" " ); |
19 | addColumn(tr("Name"), 135 ); | 19 | addColumn(tr("Name"), 135 ); |
20 | addColumn(tr("Size"), -1 ); | 20 | addColumn(tr("Size"), -1 ); |
21 | addColumn(tr("Date"), 60 ); | 21 | addColumn(tr("Date"), 60 ); |
22 | addColumn(tr("Mime Type"), -1 ); | 22 | addColumn(tr("Mime Type"), -1 ); |
23 | QHeader *head = header(); | 23 | QHeader *head = header(); |
24 | head->hide(); | 24 | head->hide(); |
25 | setSorting( 1 ); | 25 | setSorting( 1 ); |
26 | setAllColumnsShowFocus( TRUE ); | 26 | setAllColumnsShowFocus( TRUE ); |
27 | 27 | ||
28 | connect(this, SIGNAL(selectionChanged() ), | 28 | connect(this, SIGNAL(selectionChanged() ), |
29 | this, SLOT(slotSelectionChanged() ) ); | 29 | this, SLOT(slotSelectionChanged() ) ); |
30 | 30 | ||
31 | connect(this, SIGNAL(currentChanged(QListViewItem *) ), | 31 | connect(this, SIGNAL(currentChanged(QListViewItem *) ), |
32 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | 32 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); |
33 | 33 | ||
34 | connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | 34 | connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), |
35 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | 35 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); |
36 | 36 | ||
37 | connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | 37 | connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), |
38 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | 38 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); |
39 | } | 39 | } |
40 | OFileListView::~OFileListView() { | 40 | OFileListView::~OFileListView() { |
41 | 41 | ||
42 | } | 42 | } |
43 | void OFileListView::clear() { | 43 | void OFileListView::clear() { |
44 | QListView::clear(); | 44 | QListView::clear(); |
45 | } | 45 | } |
46 | void OFileListView::addFile( const QPixmap& pix, | 46 | void OFileListView::addFile( const QPixmap& pix, |
47 | const QString&, | 47 | const QString&, |
48 | QFileInfo* info, | 48 | QFileInfo* info, |
49 | const QString& /*extra*/, | ||
49 | bool isSymlink ) { | 50 | bool isSymlink ) { |
50 | QString dir; | 51 | QString dir; |
51 | QString name; | 52 | QString name; |
52 | bool locked = false; | 53 | bool locked = false; |
53 | 54 | ||
54 | dir = info->dirPath( true ); | 55 | dir = info->dirPath( true ); |
55 | 56 | ||
56 | if( isSymlink ) | 57 | if( isSymlink ) |
57 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | 58 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); |
58 | else { | 59 | else { |
59 | name = info->fileName(); | 60 | name = info->fileName(); |
60 | if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) || | 61 | if( ( selector()->mode() == OFileSelector::Open && !info->isReadable() ) || |
61 | ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){ | 62 | ( selector()->mode() == OFileSelector::Save && !info->isWritable() ) ){ |
62 | 63 | ||
63 | locked = true; | 64 | locked = true; |
64 | } | 65 | } |
65 | } | 66 | } |
66 | new OFileSelectorItem( this, pix, name, | 67 | new OFileSelectorItem( this, pix, name, |
67 | info->lastModified().toString(), | 68 | info->lastModified().toString(), |
68 | QString::number( info->size() ), | 69 | QString::number( info->size() ), |
69 | dir, locked ); | 70 | dir, locked ); |
70 | } | 71 | } |
71 | void OFileListView::addFile( const QPixmap&, | 72 | void OFileListView::addFile( const QPixmap&, |
72 | const QString& /*mime*/, const QString& /*dir*/, | 73 | const QString& /*mime*/, const QString& /*dir*/, |
73 | const QString& /*file*/, bool /*isSyml*/ ) { | 74 | const QString& /*file*/, |
75 | const QString& /*extra*/, | ||
76 | bool /*isSyml*/ ) { | ||
74 | 77 | ||
75 | } | 78 | } |
76 | void OFileListView::addDir( const QPixmap& pix, const QString&, | 79 | void OFileListView::addDir( const QPixmap& pix, const QString&, |
77 | QFileInfo* info, bool symlink ) { | 80 | QFileInfo* info, |
81 | const QString& /*extra */, | ||
82 | bool symlink ) { | ||
78 | 83 | ||
79 | bool locked = false; | 84 | bool locked = false; |
80 | QString name; | 85 | QString name; |
81 | 86 | ||
82 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; | 87 | name = symlink ? info->fileName() + "->" + info->dirPath(true) + "/" +info->readLink() : info->fileName() ; |
83 | 88 | ||
84 | new OFileSelectorItem( this, pix, name, | 89 | new OFileSelectorItem( this, pix, name, |
85 | info->lastModified().toString(), | 90 | info->lastModified().toString(), |
86 | QString::number( info->size() ), | 91 | QString::number( info->size() ), |
87 | info->dirPath( true ), locked, | 92 | info->dirPath( true ), locked, |
88 | true ); | 93 | true ); |
89 | 94 | ||
90 | } | 95 | } |
91 | void OFileListView::addDir( const QPixmap&, | 96 | void OFileListView::addDir( const QPixmap&, |
92 | const QString& /*mime*/, const QString& /*dir*/, | 97 | const QString& /*mime*/, const QString& /*dir*/, |
93 | const QString& /*file*/, bool ) { | 98 | const QString& /*file*/, |
99 | const QString& /*extra*/, | ||
100 | bool ) { | ||
94 | 101 | ||
95 | } | 102 | } |
96 | void OFileListView::addSymlink( const QPixmap&, | 103 | void OFileListView::addSymlink( const QPixmap&, |
97 | const QString& /*mime*/, | 104 | const QString& /*mime*/, |
98 | QFileInfo* /*info*/, | 105 | QFileInfo* /*info*/, |
106 | const QString& /*extra*/, | ||
99 | bool /*isSym*/ ) { | 107 | bool /*isSym*/ ) { |
100 | 108 | ||
101 | } | 109 | } |
102 | void OFileListView::addSymlink(const QPixmap&, | 110 | void OFileListView::addSymlink(const QPixmap&, |
103 | const QString& /*m*/, const QString& /*path*/, | 111 | const QString& /*m*/, const QString& /*path*/, |
104 | const QString& /*file*/, bool /*isSym*/ ) { | 112 | const QString& /*file*/, |
113 | const QString& /*extra*/, | ||
114 | bool /*isSym*/ ) { | ||
105 | 115 | ||
106 | } | 116 | } |
107 | void OFileListView::cd( const QString& ) { | 117 | void OFileListView::cd( const QString& ) { |
108 | 118 | ||
109 | } | 119 | } |
110 | QWidget* OFileListView::widget() { | 120 | QWidget* OFileListView::widget() { |
111 | return this; | 121 | return this; |
112 | } | 122 | } |
113 | QString OFileListView::selectedName()const{ | 123 | QString OFileListView::selectedName()const{ |
114 | QListViewItem *item = currentItem(); | 124 | QListViewItem *item = currentItem(); |
115 | if (!item ) | 125 | if (!item ) |
116 | return QString::null; | 126 | return QString::null; |
117 | 127 | ||
118 | return item->text( 1 ); | 128 | return item->text( 1 ); |
119 | } | 129 | } |
120 | QStringList OFileListView::selectedNames()const { | 130 | QStringList OFileListView::selectedNames()const { |
121 | QStringList list; | 131 | QStringList list; |
122 | list << selectedName(); | 132 | list << selectedName(); |
123 | return list; | 133 | return list; |
124 | } | 134 | } |
125 | QString OFileListView::selectedPath()const { | 135 | QString OFileListView::selectedPath()const { |
126 | return QString::null; | 136 | return QString::null; |
127 | } | 137 | } |
128 | QStringList OFileListView::selectedPaths()const { | 138 | QStringList OFileListView::selectedPaths()const { |
129 | QStringList list; | 139 | QStringList list; |
130 | list << selectedPath(); | 140 | b list << selectedPath(); |
131 | return list; | 141 | return list; |
132 | } | 142 | } |
133 | int OFileListView::fileCount() { | 143 | int OFileListView::fileCount() { |
134 | return childCount(); | 144 | return childCount(); |
135 | } | 145 | } |
136 | void OFileListView::sort() { | 146 | void OFileListView::sort() { |
137 | QListView::sort(); | 147 | QListView::sort(); |
138 | } | 148 | } |
139 | void OFileListView::slotSelectionChanged() { | 149 | void OFileListView::slotSelectionChanged() { |
140 | 150 | ||
141 | } | 151 | } |
142 | void OFileListView::slotCurrentChanged( QListViewItem* item) { | 152 | void OFileListView::slotCurrentChanged( QListViewItem* item) { |
143 | if (!item ) | 153 | if (!item ) |
144 | return; | 154 | return; |
145 | 155 | ||
146 | OFileSelectorItem* sel = (OFileSelectorItem*) item; | 156 | OFileSelectorItem* sel = (OFileSelectorItem*) item; |
147 | 157 | ||
148 | qWarning("current changed"); | 158 | qWarning("current changed"); |
149 | if(!sel->isDir() ){ | 159 | if(!sel->isDir() ){ |
150 | updateLine( sel->text(1) ); | 160 | updateLine( sel->text(1) ); |
151 | 161 | ||
152 | if (selector()->mode() == OFileSelector::Fileselector ) { | 162 | if (selector()->mode() == OFileSelector::Fileselector ) { |
153 | QStringList str = QStringList::split("->", sel->text(1) ); | 163 | QStringList str = QStringList::split("->", sel->text(1) ); |
154 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | 164 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); |
155 | DocLnk lnk( path ); | 165 | DocLnk lnk( path ); |
156 | fileSelected(lnk ); | 166 | fileSelected(lnk ); |
157 | fileSelected( path ); | 167 | fileSelected( path ); |
158 | } | 168 | } |
159 | } | 169 | } |
160 | } | 170 | } |
161 | void OFileListView::slotClicked( int button, QListViewItem* item, | 171 | void OFileListView::slotClicked( int button, QListViewItem* item, |
162 | const QPoint&, int ) { | 172 | const QPoint&, int ) { |
163 | if ( !item ) | 173 | if ( !item ) |
164 | return; | 174 | return; |
165 | 175 | ||
166 | if( button != Qt::LeftButton ) | 176 | if( button != Qt::LeftButton ) |
167 | return; | 177 | return; |
168 | 178 | ||
169 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 179 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
170 | 180 | ||
171 | if(!sel->isLocked() ){ | 181 | if(!sel->isLocked() ){ |
172 | QStringList str = QStringList::split("->", sel->text(1) ); | 182 | QStringList str = QStringList::split("->", sel->text(1) ); |
173 | if( sel->isDir() ){ | 183 | if( sel->isDir() ){ |
174 | changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); | 184 | changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); |
175 | }else{ | 185 | }else{ |
176 | updateLine( str[0].stripWhiteSpace() ); | 186 | updateLine( str[0].stripWhiteSpace() ); |
177 | QString path = sel->directory(); | 187 | QString path = sel->directory(); |
178 | path += "/"; | 188 | path += "/"; |
179 | path += str[0].stripWhiteSpace(); | 189 | path += str[0].stripWhiteSpace(); |
180 | 190 | ||
181 | DocLnk lnk( path ); | 191 | DocLnk lnk( path ); |
182 | fileSelected( path ); | 192 | fileSelected( path ); |
183 | fileSelected( lnk ); | 193 | fileSelected( lnk ); |
184 | } | 194 | } |
185 | } | 195 | } |
186 | } | 196 | } |
187 | void OFileListView::slotRightButton( int button, QListViewItem* item, | 197 | void OFileListView::slotRightButton( int button, QListViewItem* item, |
188 | const QPoint&, int ) { | 198 | const QPoint&, int ) { |
189 | if (!item || (button != Qt::RightButton )) | 199 | if (!item || (button != Qt::RightButton )) |
190 | return; | 200 | return; |
191 | 201 | ||
192 | /* raise contextmenu */ | 202 | /* raise contextmenu */ |
193 | } | 203 | } |
diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h index c8cdfd1..0f625ec 100644 --- a/libopie/ofileselector/ofilelistview.h +++ b/libopie/ofileselector/ofilelistview.h | |||
@@ -1,58 +1,67 @@ | |||
1 | #ifndef OPIE_FILE_LIST_VIEW_H | 1 | #ifndef OPIE_FILE_LIST_VIEW_H |
2 | #define OPIE_FILE_LIST_VIEW_H | 2 | #define OPIE_FILE_LIST_VIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
6 | 6 | ||
7 | #include "ofileview.h" | 7 | #include "ofileview.h" |
8 | 8 | ||
9 | class OFileListView : public QListView, public OFileView { | 9 | class OFileListView : public QListView, public OFileView { |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | public: | 11 | public: |
12 | OFileListView( QWidget* parent, OFileSelector* ); | 12 | OFileListView( QWidget* parent, OFileSelector* ); |
13 | ~OFileListView(); | 13 | ~OFileListView(); |
14 | 14 | ||
15 | void clear(); | 15 | void clear(); |
16 | void addFile( const QPixmap&, | 16 | void addFile( const QPixmap&, |
17 | const QString& mine, | 17 | const QString& mine, |
18 | QFileInfo* info, | 18 | QFileInfo* info, |
19 | const QString& extra = QString::null, | ||
19 | bool isSymlink = FALSE ); | 20 | bool isSymlink = FALSE ); |
20 | 21 | ||
21 | void addFile( const QPixmap&, | 22 | void addFile( const QPixmap&, |
22 | const QString& mime, | 23 | const QString& mime, |
23 | const QString& dir, | 24 | const QString& dir, |
24 | const QString& file, | 25 | const QString& file, |
26 | const QString& extra = QString::null, | ||
25 | bool = false ); | 27 | bool = false ); |
26 | 28 | ||
27 | void addDir( const QPixmap&, | 29 | void addDir( const QPixmap&, |
28 | const QString& mime, | 30 | const QString& mime, |
31 | const QString& extra = QString::null, | ||
29 | QFileInfo* info, bool = FALSE ); | 32 | QFileInfo* info, bool = FALSE ); |
30 | 33 | ||
31 | void addDir( const QPixmap&, | 34 | void addDir( const QPixmap&, |
32 | const QString& mime, const QString& dir, | 35 | const QString& mime, const QString& dir, |
33 | const QString& file, bool = FALSE ); | 36 | const QString& file, |
37 | const QString& extra = QString::null, | ||
38 | bool = FALSE ); | ||
34 | 39 | ||
35 | void addSymlink( const QPixmap&, | 40 | void addSymlink( const QPixmap&, |
36 | const QString& mime, | 41 | const QString& mime, |
37 | QFileInfo* info, bool = FALSE ); | 42 | QFileInfo* info, |
43 | const QString& extra = QString::null, | ||
44 | bool = FALSE ); | ||
38 | void addSymlink( const QPixmap&, | 45 | void addSymlink( const QPixmap&, |
39 | const QString& mine, const QString& path, | 46 | const QString& mine, const QString& path, |
40 | const QString& file, bool isSymlink = FALSE ); | 47 | const QString& file, |
48 | const QString& extra, | ||
49 | bool isSymlink = FALSE ); | ||
41 | void cd( const QString& path ); | 50 | void cd( const QString& path ); |
42 | QWidget* widget(); | 51 | QWidget* widget(); |
43 | void sort(); | 52 | void sort(); |
44 | 53 | ||
45 | QString selectedName()const ; | 54 | QString selectedName()const ; |
46 | QStringList selectedNames()const; | 55 | QStringList selectedNames()const; |
47 | 56 | ||
48 | QString selectedPath()const; | 57 | QString selectedPath()const; |
49 | QStringList selectedPaths()const; | 58 | QStringList selectedPaths()const; |
50 | int fileCount(); | 59 | int fileCount(); |
51 | private slots: | 60 | private slots: |
52 | void slotSelectionChanged(); | 61 | void slotSelectionChanged(); |
53 | void slotCurrentChanged(QListViewItem* ); | 62 | void slotCurrentChanged(QListViewItem* ); |
54 | void slotClicked( int, QListViewItem*, const QPoint&, int ); | 63 | void slotClicked( int, QListViewItem*, const QPoint&, int ); |
55 | void slotRightButton(int, QListViewItem*, const QPoint&, int ); | 64 | void slotRightButton(int, QListViewItem*, const QPoint&, int ); |
56 | }; | 65 | }; |
57 | 66 | ||
58 | #endif | 67 | #endif |
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 4ab744c..0ccb3cb 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp | |||
@@ -12,783 +12,782 @@ | |||
12 | #include <qpainter.h> | 12 | #include <qpainter.h> |
13 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
14 | #include <qwidgetstack.h> | 14 | #include <qwidgetstack.h> |
15 | #include <qpopupmenu.h> | 15 | #include <qpopupmenu.h> |
16 | #include <qdir.h> | 16 | #include <qdir.h> |
17 | #include <qfile.h> | 17 | #include <qfile.h> |
18 | #include <qfileinfo.h> | 18 | #include <qfileinfo.h> |
19 | #include <qtimer.h> | 19 | #include <qtimer.h> |
20 | 20 | ||
21 | #include <qpe/qpeapplication.h> | 21 | #include <qpe/qpeapplication.h> |
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/mimetype.h> | 24 | #include <qpe/mimetype.h> |
25 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
26 | #include <qpe/storage.h> | 26 | #include <qpe/storage.h> |
27 | 27 | ||
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <stdlib.h> | 29 | #include <stdlib.h> |
30 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
31 | 31 | ||
32 | #include "ofileview.h" | 32 | #include "ofileview.h" |
33 | #include "ofileselectormain.h" | 33 | #include "ofileselectormain.h" |
34 | #include "ofileselector.h" | 34 | #include "ofileselector.h" |
35 | #include "olocallister.h" | 35 | #include "olocallister.h" |
36 | #include "olister.h" | 36 | #include "olister.h" |
37 | #include "odefaultfactories.h" | 37 | #include "odefaultfactories.h" |
38 | 38 | ||
39 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 39 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
40 | 40 | ||
41 | namespace { | 41 | namespace { |
42 | /* let's find the index for a specified string */ | 42 | /* let's find the index for a specified string */ |
43 | int indexByString( const QComboBox *box, const QString &str ){ | 43 | int indexByString( const QComboBox *box, const QString &str ){ |
44 | int index= 0; | 44 | int index= 0; |
45 | for(int i= 0; i < box->count(); i++ ){ | 45 | for(int i= 0; i < box->count(); i++ ){ |
46 | /* found */ | 46 | /* found */ |
47 | if( str == box->text(i ) ){ | 47 | if( str == box->text(i ) ){ |
48 | index= i; | 48 | index= i; |
49 | break; | 49 | break; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | return index; | 52 | return index; |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 56 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
57 | const QString &dirName, | 57 | const QString &dirName, |
58 | const QString &fileName, | 58 | const QString &fileName, |
59 | const QMap<QString,QStringList>& mimeTypes) | 59 | const QMap<QString,QStringList>& mimeTypes) |
60 | : QWidget( wid, "OFileSelector") | 60 | : QWidget( wid, "OFileSelector") |
61 | { | 61 | { |
62 | m_mimetypes = mimeTypes; | 62 | m_mimetypes = mimeTypes; |
63 | if (mode == Save ) | 63 | if (mode == Save ) |
64 | m_name = fileName; | 64 | m_name = fileName; |
65 | 65 | ||
66 | initVars(); | 66 | initVars(); |
67 | 67 | ||
68 | m_mode = mode; | 68 | m_mode = mode; |
69 | m_selector = selector; | 69 | m_selector = selector; |
70 | m_currentDir = dirName; | 70 | m_currentDir = dirName; |
71 | init(); | 71 | init(); |
72 | } | 72 | } |
73 | 73 | ||
74 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 74 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
75 | const char *name, bool newVisible, | 75 | const char *name, bool newVisible, |
76 | bool closeVisible ) | 76 | bool closeVisible ) |
77 | : QWidget( parent, name ) | 77 | : QWidget( parent, name ) |
78 | { | 78 | { |
79 | /* update the mimefilter */ | 79 | /* update the mimefilter */ |
80 | if (!mimeFilter.isEmpty() ) { | 80 | if (!mimeFilter.isEmpty() ) { |
81 | QStringList list = QStringList::split(";", mimeFilter ); | 81 | QStringList list = QStringList::split(";", mimeFilter ); |
82 | m_mimetypes.insert(mimeFilter, list ); | 82 | m_mimetypes.insert(mimeFilter, list ); |
83 | } | 83 | } |
84 | initVars(); | 84 | initVars(); |
85 | m_currentDir = QPEApplication::documentDir(); | 85 | m_currentDir = QPEApplication::documentDir(); |
86 | m_mode = Fileselector; | 86 | m_mode = Fileselector; |
87 | m_selector = Normal; | 87 | m_selector = Normal; |
88 | m_shClose = closeVisible; | 88 | m_shClose = closeVisible; |
89 | m_shNew = newVisible; | 89 | m_shNew = newVisible; |
90 | m_shLne = false; | 90 | m_shLne = false; |
91 | m_shPerm = false; | 91 | m_shPerm = false; |
92 | m_shYesNo = false; | 92 | m_shYesNo = false; |
93 | init(); | 93 | init(); |
94 | 94 | ||
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | OFileSelector::~OFileSelector() | 98 | OFileSelector::~OFileSelector() |
99 | { | 99 | { |
100 | 100 | ||
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | void OFileSelector::setNewVisible( bool visible ) | 104 | void OFileSelector::setNewVisible( bool visible ) |
105 | { | 105 | { |
106 | m_shNew = visible; | 106 | m_shNew = visible; |
107 | if (m_new ) | 107 | if (m_new ) |
108 | m_new->show(); | 108 | m_new->show(); |
109 | } | 109 | } |
110 | void OFileSelector::setCloseVisible( bool visible ) | 110 | void OFileSelector::setCloseVisible( bool visible ) |
111 | { | 111 | { |
112 | m_shClose = visible; | 112 | m_shClose = visible; |
113 | 113 | ||
114 | if( m_close ) | 114 | if( m_close ) |
115 | m_close->show(); | 115 | m_close->show(); |
116 | } | 116 | } |
117 | void OFileSelector::reread() | 117 | void OFileSelector::reread() |
118 | { | 118 | { |
119 | if( m_selector == Normal ) | 119 | if( m_selector == Normal ) |
120 | initializeOldSelector(); | 120 | initializeOldSelector(); |
121 | else | 121 | else |
122 | reparse(); | 122 | reparse(); |
123 | } | 123 | } |
124 | 124 | ||
125 | const DocLnk *OFileSelector::selected() | 125 | const DocLnk *OFileSelector::selected() |
126 | { | 126 | { |
127 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 127 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
128 | return lnk; | 128 | return lnk; |
129 | } | 129 | } |
130 | 130 | ||
131 | void OFileSelector::setYesCancelVisible( bool show ) | 131 | void OFileSelector::setYesCancelVisible( bool show ) |
132 | { | 132 | { |
133 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 133 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
134 | m_shYesNo = show; | 134 | m_shYesNo = show; |
135 | 135 | ||
136 | if( m_shYesNo ) | 136 | if( m_shYesNo ) |
137 | m_boxOk->show(); | 137 | m_boxOk->show(); |
138 | else | 138 | else |
139 | m_boxOk->hide(); | 139 | m_boxOk->hide(); |
140 | 140 | ||
141 | } | 141 | } |
142 | void OFileSelector::setToolbarVisible( bool show ) | 142 | void OFileSelector::setToolbarVisible( bool show ) |
143 | { | 143 | { |
144 | m_shTool = show; | 144 | m_shTool = show; |
145 | 145 | ||
146 | if(!m_shTool ){ | 146 | if(!m_shTool ){ |
147 | m_location->hide(); | 147 | m_location->hide(); |
148 | m_up->hide(); | 148 | m_up->hide(); |
149 | m_homeButton->hide(); | 149 | m_homeButton->hide(); |
150 | m_docButton->hide(); | 150 | m_docButton->hide(); |
151 | }else{ | 151 | }else{ |
152 | m_location->show(); | 152 | m_location->show(); |
153 | m_up->show(); | 153 | m_up->show(); |
154 | m_homeButton->show(); | 154 | m_homeButton->show(); |
155 | m_docButton->show(); | 155 | m_docButton->show(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | void OFileSelector::setPermissionBarVisible( bool show ) | 158 | void OFileSelector::setPermissionBarVisible( bool show ) |
159 | { | 159 | { |
160 | m_shPerm = show; | 160 | m_shPerm = show; |
161 | initializePerm(); | 161 | initializePerm(); |
162 | 162 | ||
163 | if( m_shPerm ) | 163 | if( m_shPerm ) |
164 | m_checkPerm->show(); | 164 | m_checkPerm->show(); |
165 | else | 165 | else |
166 | m_checkPerm->hide(); | 166 | m_checkPerm->hide(); |
167 | } | 167 | } |
168 | void OFileSelector::setLineEditVisible( bool show ) | 168 | void OFileSelector::setLineEditVisible( bool show ) |
169 | { | 169 | { |
170 | if( show ){ | 170 | if( show ){ |
171 | initializeName(); | 171 | initializeName(); |
172 | m_boxName->show(); | 172 | m_boxName->show(); |
173 | }else{ | 173 | }else{ |
174 | // check if we showed before this is the way to go | 174 | // check if we showed before this is the way to go |
175 | if( m_shLne && m_boxName != 0 ) | 175 | if( m_shLne && m_boxName != 0 ) |
176 | m_boxName->hide(); | 176 | m_boxName->hide(); |
177 | } | 177 | } |
178 | m_shLne = show; | 178 | m_shLne = show; |
179 | } | 179 | } |
180 | 180 | ||
181 | void OFileSelector::setChooserVisible( bool show ) | 181 | void OFileSelector::setChooserVisible( bool show ) |
182 | { | 182 | { |
183 | m_shChooser = show; | 183 | m_shChooser = show; |
184 | initializeChooser(); | 184 | initializeChooser(); |
185 | 185 | ||
186 | if( m_shChooser ) | 186 | if( m_shChooser ) |
187 | m_boxView->hide(); | 187 | m_boxView->hide(); |
188 | else | 188 | else |
189 | m_boxView->show(); | 189 | m_boxView->show(); |
190 | 190 | ||
191 | } | 191 | } |
192 | 192 | ||
193 | QCheckBox* OFileSelector::permissionCheckbox() | 193 | QCheckBox* OFileSelector::permissionCheckbox() |
194 | { | 194 | { |
195 | if( m_selector == Normal ) | 195 | if( m_selector == Normal ) |
196 | return 0l; | 196 | return 0l; |
197 | else | 197 | else |
198 | return m_checkPerm; | 198 | return m_checkPerm; |
199 | } | 199 | } |
200 | bool OFileSelector::setPermission()const | 200 | bool OFileSelector::setPermission()const |
201 | { | 201 | { |
202 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 202 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
203 | } | 203 | } |
204 | void OFileSelector::setPermissionChecked( bool check ) | 204 | void OFileSelector::setPermissionChecked( bool check ) |
205 | { | 205 | { |
206 | if( m_checkPerm ) | 206 | if( m_checkPerm ) |
207 | m_checkPerm->setChecked( check ); | 207 | m_checkPerm->setChecked( check ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 210 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
211 | { | 211 | { |
212 | m_mode = mode; | 212 | m_mode = mode; |
213 | if( m_selector == Normal ) | 213 | if( m_selector == Normal ) |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | void OFileSelector::setShowDirs(bool dir) | 216 | void OFileSelector::setShowDirs(bool dir) |
217 | { | 217 | { |
218 | m_dir = dir; | 218 | m_dir = dir; |
219 | if ( m_selector != Fileselector ) | 219 | if ( m_selector != Fileselector ) |
220 | reparse(); | 220 | reparse(); |
221 | } | 221 | } |
222 | void OFileSelector::setCaseSensetive(bool caSe ) | 222 | void OFileSelector::setCaseSensetive(bool caSe ) |
223 | { | 223 | { |
224 | m_case = caSe; | 224 | m_case = caSe; |
225 | 225 | ||
226 | if ( m_selector != Fileselector ) | 226 | if ( m_selector != Fileselector ) |
227 | reparse(); | 227 | reparse(); |
228 | } | 228 | } |
229 | void OFileSelector::setShowFiles(bool show ) | 229 | void OFileSelector::setShowFiles(bool show ) |
230 | { | 230 | { |
231 | m_files = show; | 231 | m_files = show; |
232 | reparse(); | 232 | reparse(); |
233 | } | 233 | } |
234 | /// | 234 | /// |
235 | bool OFileSelector::cd(const QString &path ) | 235 | bool OFileSelector::cd(const QString &path ) |
236 | { | 236 | { |
237 | m_currentDir = path; | 237 | m_currentDir = path; |
238 | reparse(); | 238 | reparse(); |
239 | return true; | 239 | return true; |
240 | } | 240 | } |
241 | void OFileSelector::setSelector(int mode ) | 241 | void OFileSelector::setSelector(int mode ) |
242 | { | 242 | { |
243 | QString text; | 243 | QString text; |
244 | switch( mode ){ | 244 | switch( mode ){ |
245 | case Normal: | 245 | case Normal: |
246 | text = tr("Documents"); | 246 | text = tr("Documents"); |
247 | break; | 247 | break; |
248 | case Extended: | 248 | case Extended: |
249 | text = tr("List View"); | 249 | text = tr("List View"); |
250 | break; | 250 | break; |
251 | case ExtendedAll: | 251 | case ExtendedAll: |
252 | text = tr("All List View"); | 252 | text = tr("All List View"); |
253 | break; | 253 | break; |
254 | } | 254 | } |
255 | slotViewCheck( text ); | 255 | slotViewCheck( text ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) | 258 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) |
259 | { | 259 | { |
260 | /* m_custom = popup; | 260 | /* m_custom = popup; |
261 | m_showPopup = true; | 261 | m_showPopup = true; |
262 | */ | 262 | */ |
263 | } | 263 | } |
264 | 264 | ||
265 | //void OFileSelector::updateL | 265 | //void OFileSelector::updateL |
266 | 266 | ||
267 | QString OFileSelector::selectedName() const | 267 | QString OFileSelector::selectedName() const |
268 | { | 268 | { |
269 | QString name; | 269 | QString name; |
270 | if( m_selector == Normal ){ | 270 | if( m_selector == Normal ){ |
271 | DocLnk lnk = m_select->selectedDocument(); | 271 | DocLnk lnk = m_select->selectedDocument(); |
272 | name = lnk.file(); | 272 | name = lnk.file(); |
273 | }else { | 273 | }else { |
274 | if ( m_shLne ) { | 274 | if ( m_shLne ) { |
275 | name = m_currentDir + "/" +m_edit->text(); | 275 | name = m_currentDir + "/" +m_edit->text(); |
276 | }else{ | 276 | }else{ |
277 | name = m_currentDir + "/" + currentView()->selectedName(); | 277 | name = m_currentDir + "/" + currentView()->selectedName(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | return name; | 280 | return name; |
281 | } | 281 | } |
282 | QStringList OFileSelector::selectedNames()const | 282 | QStringList OFileSelector::selectedNames()const |
283 | { | 283 | { |
284 | QStringList list; | 284 | QStringList list; |
285 | if( m_selector == Normal ){ | 285 | if( m_selector == Normal ){ |
286 | list << selectedName(); | 286 | list << selectedName(); |
287 | }else { | 287 | }else { |
288 | list << selectedName(); // FIXME implement multiple Selections | 288 | list << selectedName(); // FIXME implement multiple Selections |
289 | } | 289 | } |
290 | return list; | 290 | return list; |
291 | } | 291 | } |
292 | /** If mode is set to the Dir selection this will return the selected path. | 292 | /** If mode is set to the Dir selection this will return the selected path. |
293 | * | 293 | * |
294 | * | 294 | * |
295 | */ | 295 | */ |
296 | QString OFileSelector::selectedPath()const | 296 | QString OFileSelector::selectedPath()const |
297 | { | 297 | { |
298 | QString path; | 298 | QString path; |
299 | if( m_selector == Normal ){ | 299 | if( m_selector == Normal ){ |
300 | path = QPEApplication::documentDir(); | 300 | path = QPEApplication::documentDir(); |
301 | } /* normal case to do */ | 301 | } /* normal case to do */ |
302 | return path; | 302 | return path; |
303 | } | 303 | } |
304 | QStringList OFileSelector::selectedPaths() const | 304 | QStringList OFileSelector::selectedPaths() const |
305 | { | 305 | { |
306 | QStringList list; | 306 | QStringList list; |
307 | list << selectedPath(); | 307 | list << selectedPath(); |
308 | return list; | 308 | return list; |
309 | } | 309 | } |
310 | QString OFileSelector::directory()const | 310 | QString OFileSelector::directory()const |
311 | { | 311 | { |
312 | if( m_selector == Normal ) | 312 | if( m_selector == Normal ) |
313 | return QPEApplication::documentDir(); | 313 | return QPEApplication::documentDir(); |
314 | 314 | ||
315 | return QDir(m_currentDir).absPath(); | 315 | return QDir(m_currentDir).absPath(); |
316 | } | 316 | } |
317 | 317 | ||
318 | int OFileSelector::fileCount() | 318 | int OFileSelector::fileCount() |
319 | { | 319 | { |
320 | int count; | 320 | int count; |
321 | switch( m_selector ){ | 321 | switch( m_selector ){ |
322 | case Normal: | 322 | case Normal: |
323 | count = m_select->fileCount(); | 323 | count = m_select->fileCount(); |
324 | break; | 324 | break; |
325 | case Extended: | 325 | case Extended: |
326 | case ExtendedAll: | 326 | case ExtendedAll: |
327 | default: | 327 | default: |
328 | count = currentView()->fileCount(); | 328 | count = currentView()->fileCount(); |
329 | break; | 329 | break; |
330 | } | 330 | } |
331 | return count; | 331 | return count; |
332 | } | 332 | } |
333 | DocLnk OFileSelector::selectedDocument() const | 333 | DocLnk OFileSelector::selectedDocument() const |
334 | { | 334 | { |
335 | DocLnk lnk; | 335 | DocLnk lnk; |
336 | switch( m_selector ){ | 336 | switch( m_selector ){ |
337 | case Normal:{ | 337 | case Normal:{ |
338 | lnk = m_select->selectedDocument(); | 338 | lnk = m_select->selectedDocument(); |
339 | break; | 339 | break; |
340 | } | 340 | } |
341 | case Extended: | 341 | case Extended: |
342 | case ExtendedAll: | 342 | case ExtendedAll: |
343 | default: | 343 | default: |
344 | lnk = DocLnk( selectedName() ); | 344 | lnk = DocLnk( selectedName() ); |
345 | break; | 345 | break; |
346 | } | 346 | } |
347 | return lnk; | 347 | return lnk; |
348 | } | 348 | } |
349 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 349 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
350 | { | 350 | { |
351 | QValueList<DocLnk> docs; | 351 | QValueList<DocLnk> docs; |
352 | docs.append( selectedDocument() ); | 352 | docs.append( selectedDocument() ); |
353 | return docs; | 353 | return docs; |
354 | } | 354 | } |
355 | 355 | ||
356 | 356 | ||
357 | // slots internal | 357 | // slots internal |
358 | 358 | ||
359 | void OFileSelector::slotOk() | 359 | void OFileSelector::slotOk() |
360 | { | 360 | { |
361 | emit ok(); | 361 | emit ok(); |
362 | } | 362 | } |
363 | void OFileSelector::slotCancel() | 363 | void OFileSelector::slotCancel() |
364 | { | 364 | { |
365 | emit cancel(); | 365 | emit cancel(); |
366 | } | 366 | } |
367 | /* switch the views */ | 367 | /* switch the views */ |
368 | void OFileSelector::slotViewCheck(const QString &sel) | 368 | void OFileSelector::slotViewCheck(const QString &sel) |
369 | { | 369 | { |
370 | setView( sel ); | 370 | setView( sel ); |
371 | } | 371 | } |
372 | 372 | ||
373 | QString OFileSelector::currentMimeType() const{ | 373 | QString OFileSelector::currentMimeType() const{ |
374 | QString mime; | 374 | QString mime; |
375 | QString currentText; | 375 | QString currentText; |
376 | if (m_shChooser && m_mimeCheck ) | 376 | if (m_shChooser && m_mimeCheck ) |
377 | currentText = m_mimeCheck->currentText(); | 377 | currentText = m_mimeCheck->currentText(); |
378 | 378 | ||
379 | qWarning("CurrentText" + currentText ); | 379 | qWarning("CurrentText" + currentText ); |
380 | if (tr("All") == currentText ) return QString::null; | 380 | if (tr("All") == currentText ) return QString::null; |
381 | else if (currentText.isEmpty() ) { | 381 | else if (currentText.isEmpty() ) { |
382 | ; | 382 | ; |
383 | }else { | 383 | }else { |
384 | QMap<QString, QStringList>::ConstIterator it; | 384 | QMap<QString, QStringList>::ConstIterator it; |
385 | it = m_mimetypes.find( currentText ); | 385 | it = m_mimetypes.find( currentText ); |
386 | if ( it != m_mimetypes.end() ) { | 386 | if ( it != m_mimetypes.end() ) { |
387 | mime = it.data().join(";"); | 387 | mime = it.data().join(";"); |
388 | }else{ | 388 | }else{ |
389 | mime = currentText; | 389 | mime = currentText; |
390 | } | 390 | } |
391 | } | 391 | } |
392 | return mime; | 392 | return mime; |
393 | } | 393 | } |
394 | void OFileSelector::slotMimeCheck(const QString &mime) | 394 | void OFileSelector::slotMimeCheck(const QString &mime) |
395 | { | 395 | { |
396 | if( m_selector == Normal ){ | 396 | if( m_selector == Normal ){ |
397 | initializeOldSelector(); | 397 | initializeOldSelector(); |
398 | 398 | ||
399 | updateMimes(); | 399 | updateMimes(); |
400 | updateMimeCheck(); | 400 | updateMimeCheck(); |
401 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 401 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
402 | }else{ // others | 402 | }else{ // others |
403 | qWarning("Mime %s", mime.latin1() ); | 403 | qWarning("Mime %s", mime.latin1() ); |
404 | if(m_shChooser ){ | 404 | if(m_shChooser ){ |
405 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 405 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
406 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 406 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
407 | } | ||
408 | reparse(); | ||
407 | } | 409 | } |
408 | reparse(); | ||
409 | } | ||
410 | |||
411 | } | 410 | } |
412 | /* | 411 | /* |
413 | * Ok if a non dir gets inserted into this combobox | 412 | * Ok if a non dir gets inserted into this combobox |
414 | * we need to change it | 413 | * we need to change it |
415 | * QFileInfo and dirPath will give us the right Dir | 414 | * QFileInfo and dirPath will give us the right Dir |
416 | */ | 415 | */ |
417 | void OFileSelector::slotLocationActivated(const QString &file) | 416 | void OFileSelector::slotLocationActivated(const QString &file) |
418 | { | 417 | { |
419 | qWarning("slotLocationActivated"); | 418 | qWarning("slotLocationActivated"); |
420 | QString name = file.left( file.find("<-", 0, TRUE ) ); | 419 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
421 | QFileInfo info( name ); | 420 | QFileInfo info( name ); |
422 | if ( info.isFile() ) | 421 | if ( info.isFile() ) |
423 | cd(info.dirPath( TRUE ) ); //absolute | 422 | cd(info.dirPath( TRUE ) ); //absolute |
424 | else | 423 | else |
425 | cd(name ); | 424 | cd(name ); |
426 | reparse(); | 425 | reparse(); |
427 | } | 426 | } |
428 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 427 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
429 | { | 428 | { |
430 | QStringList pathList; | 429 | QStringList pathList; |
431 | bool underDog = FALSE; | 430 | bool underDog = FALSE; |
432 | for(int i=0;i<count;i++) { | 431 | for(int i=0;i<count;i++) { |
433 | pathList << m_location->text(i); | 432 | pathList << m_location->text(i); |
434 | if( m_location->text(i) == currentPath) | 433 | if( m_location->text(i) == currentPath) |
435 | underDog = TRUE; | 434 | underDog = TRUE; |
436 | } | 435 | } |
437 | if( !underDog) { | 436 | if( !underDog) { |
438 | m_location->clear(); | 437 | m_location->clear(); |
439 | if( currentPath.left(2)=="//") | 438 | if( currentPath.left(2)=="//") |
440 | pathList.append( currentPath.right(currentPath.length()-1) ); | 439 | pathList.append( currentPath.right(currentPath.length()-1) ); |
441 | else | 440 | else |
442 | pathList.append( currentPath ); | 441 | pathList.append( currentPath ); |
443 | m_location->insertStringList( pathList,-1); | 442 | m_location->insertStringList( pathList,-1); |
444 | } | 443 | } |
445 | } | 444 | } |
446 | /* | 445 | /* |
447 | * Do not crash anymore | 446 | * Do not crash anymore |
448 | * don't try to change dir to a file | 447 | * don't try to change dir to a file |
449 | */ | 448 | */ |
450 | void OFileSelector::locationComboChanged() | 449 | void OFileSelector::locationComboChanged() |
451 | { | 450 | { |
452 | QFileInfo info( m_location->lineEdit()->text() ); | 451 | QFileInfo info( m_location->lineEdit()->text() ); |
453 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | 452 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
454 | if (info.isFile() ) | 453 | if (info.isFile() ) |
455 | cd(info.dirPath(TRUE) ); //absolute path | 454 | cd(info.dirPath(TRUE) ); //absolute path |
456 | else | 455 | else |
457 | cd( m_location->lineEdit()->text() ); | 456 | cd( m_location->lineEdit()->text() ); |
458 | 457 | ||
459 | reparse(); | 458 | reparse(); |
460 | } | 459 | } |
461 | void OFileSelector::init() | 460 | void OFileSelector::init() |
462 | { | 461 | { |
463 | initFactory(); | 462 | initFactory(); |
464 | m_lay = new QVBoxLayout( this ); | 463 | m_lay = new QVBoxLayout( this ); |
465 | m_lay->setSpacing(0 ); | 464 | m_lay->setSpacing(0 ); |
466 | 465 | ||
467 | /* take care of the main view... */ | 466 | /* take care of the main view... */ |
468 | initToolbar(); | 467 | initToolbar(); |
469 | //if( m_shChooser ) // the Chooser for the view and Mimetypes | 468 | //if( m_shChooser ) // the Chooser for the view and Mimetypes |
470 | initializeChooser(); | 469 | initializeChooser(); |
471 | 470 | ||
472 | /* initialize the file lister */ | 471 | /* initialize the file lister */ |
473 | if( m_selector == Normal ){ | 472 | if( m_selector == Normal ){ |
474 | QString mime; | 473 | QString mime; |
475 | if (!m_autoMime) { | 474 | if (!m_autoMime) { |
476 | if (!m_mimetypes.isEmpty() ) { | 475 | if (!m_mimetypes.isEmpty() ) { |
477 | QMap<QString, QStringList>::Iterator it; | 476 | QMap<QString, QStringList>::Iterator it; |
478 | it = m_mimetypes.begin(); // cause we're in the init | 477 | it = m_mimetypes.begin(); // cause we're in the init |
479 | mime = it.data().join(";"); | 478 | mime = it.data().join(";"); |
480 | } | 479 | } |
481 | } | 480 | } |
482 | initializeOldSelector(); | 481 | initializeOldSelector(); |
483 | }else{ | 482 | }else{ |
484 | initializeView(); | 483 | initializeView(); |
485 | } | 484 | } |
486 | 485 | ||
487 | if( m_shLne ) // the LineEdit with the current FileName | 486 | if( m_shLne ) // the LineEdit with the current FileName |
488 | initializeName(); | 487 | initializeName(); |
489 | 488 | ||
490 | if( m_shPerm ) // the Permission QCheckBox | 489 | if( m_shPerm ) // the Permission QCheckBox |
491 | initializePerm(); | 490 | initializePerm(); |
492 | 491 | ||
493 | if( m_shYesNo ) // the Yes No button row | 492 | if( m_shYesNo ) // the Yes No button row |
494 | initializeYes( ); | 493 | initializeYes( ); |
495 | 494 | ||
496 | if (m_selector != Normal ) | 495 | if (m_selector != Normal ) |
497 | reparse(); | 496 | reparse(); |
498 | } | 497 | } |
499 | void OFileSelector::updateMimes() | 498 | void OFileSelector::updateMimes() |
500 | { | 499 | { |
501 | if( m_autoMime ){ | 500 | if( m_autoMime ){ |
502 | m_mimetypes.clear(); | 501 | m_mimetypes.clear(); |
503 | m_mimetypes.insert( tr("All"), QString::null ); | 502 | m_mimetypes.insert( tr("All"), QString::null ); |
504 | if( m_selector == Normal ){ | 503 | if( m_selector == Normal ){ |
505 | DocLnkSet set; | 504 | DocLnkSet set; |
506 | Global::findDocuments(&set, QString::null ); | 505 | Global::findDocuments(&set, QString::null ); |
507 | QListIterator<DocLnk> dit( set.children() ); | 506 | QListIterator<DocLnk> dit( set.children() ); |
508 | for( ; dit.current(); ++dit ){ | 507 | for( ; dit.current(); ++dit ){ |
509 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 508 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
510 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 509 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
511 | } | 510 | } |
512 | }// else done in reparse | 511 | }// else done in reparse |
513 | } | 512 | } |
514 | } | 513 | } |
515 | void OFileSelector::initVars() | 514 | void OFileSelector::initVars() |
516 | { | 515 | { |
517 | if( m_mimetypes.isEmpty() ) | 516 | if( m_mimetypes.isEmpty() ) |
518 | m_autoMime = true; | 517 | m_autoMime = true; |
519 | else | 518 | else |
520 | m_autoMime = false; | 519 | m_autoMime = false; |
521 | 520 | ||
522 | m_shClose = false; | 521 | m_shClose = false; |
523 | m_shNew = false; | 522 | m_shNew = false; |
524 | m_shTool = true; | 523 | m_shTool = true; |
525 | m_shPerm = false; | 524 | m_shPerm = false; |
526 | m_shLne = true; | 525 | m_shLne = true; |
527 | m_shChooser = true; | 526 | m_shChooser = true; |
528 | m_shYesNo = true; | 527 | m_shYesNo = true; |
529 | m_case = false; | 528 | m_case = false; |
530 | m_dir = true; | 529 | m_dir = true; |
531 | m_files = true; | 530 | m_files = true; |
532 | m_showPopup = false; | 531 | m_showPopup = false; |
533 | m_mainView = 0l; | 532 | m_mainView = 0l; |
534 | m_fileView = 0l; | 533 | m_fileView = 0l; |
535 | m_lister = 0l; | 534 | m_lister = 0l; |
536 | 535 | ||
537 | if(m_pixmaps == 0 ) // init the pixmaps | 536 | if(m_pixmaps == 0 ) // init the pixmaps |
538 | initPics(); | 537 | initPics(); |
539 | 538 | ||
540 | // pointers | 539 | // pointers |
541 | m_location = 0; | 540 | m_location = 0; |
542 | m_mimeCheck = 0; | 541 | m_mimeCheck = 0; |
543 | m_viewCheck = 0; | 542 | m_viewCheck = 0; |
544 | m_homeButton = 0; | 543 | m_homeButton = 0; |
545 | m_docButton = 0; | 544 | m_docButton = 0; |
546 | m_hideButton = 0; | 545 | m_hideButton = 0; |
547 | m_ok = 0; | 546 | m_ok = 0; |
548 | m_cancel = 0; | 547 | m_cancel = 0; |
549 | m_reread = 0; | 548 | m_reread = 0; |
550 | m_up = 0; | 549 | m_up = 0; |
551 | m_View = 0; | 550 | m_View = 0; |
552 | m_checkPerm = 0; | 551 | m_checkPerm = 0; |
553 | m_pseudo = 0; | 552 | m_pseudo = 0; |
554 | m_pseudoLayout = 0; | 553 | m_pseudoLayout = 0; |
555 | m_select = 0; | 554 | m_select = 0; |
556 | m_lay = 0; | 555 | m_lay = 0; |
557 | m_Oselector = 0; | 556 | m_Oselector = 0; |
558 | m_boxToolbar = 0; | 557 | m_boxToolbar = 0; |
559 | m_boxOk = 0; | 558 | m_boxOk = 0; |
560 | m_boxName = 0; | 559 | m_boxName = 0; |
561 | m_boxView = 0; | 560 | m_boxView = 0; |
562 | m_edit = 0; | 561 | m_edit = 0; |
563 | m_fnLabel = 0; | 562 | m_fnLabel = 0; |
564 | m_new = 0; | 563 | m_new = 0; |
565 | m_close = 0; | 564 | m_close = 0; |
566 | } | 565 | } |
567 | void OFileSelector::initializeName() | 566 | void OFileSelector::initializeName() |
568 | { | 567 | { |
569 | /** Name Layout Line | 568 | /** Name Layout Line |
570 | * This is the Layout line arranged in | 569 | * This is the Layout line arranged in |
571 | * horizontal way each components | 570 | * horizontal way each components |
572 | * are next to each other | 571 | * are next to each other |
573 | * but we will only do this if | 572 | * but we will only do this if |
574 | * we didn't initialize a while ago. | 573 | * we didn't initialize a while ago. |
575 | */ | 574 | */ |
576 | if( m_boxName == 0 ){ | 575 | if( m_boxName == 0 ){ |
577 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 576 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
578 | m_fnLabel = new QLabel( m_boxName ); | 577 | m_fnLabel = new QLabel( m_boxName ); |
579 | m_fnLabel->setText( tr("Name:") ); | 578 | m_fnLabel->setText( tr("Name:") ); |
580 | m_edit = new QLineEdit( m_boxName ); | 579 | m_edit = new QLineEdit( m_boxName ); |
581 | m_edit->setText( m_name ); | 580 | m_edit->setText( m_name ); |
582 | //m_boxName->addWidget( m_fnLabel ); | 581 | //m_boxName->addWidget( m_fnLabel ); |
583 | m_boxName->setMargin( 5 ); | 582 | m_boxName->setMargin( 5 ); |
584 | m_boxName->setSpacing( 8 ); | 583 | m_boxName->setSpacing( 8 ); |
585 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | 584 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor |
586 | 585 | ||
587 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | 586 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout |
588 | }// else we already initialized | 587 | }// else we already initialized |
589 | // maybe show the components? | 588 | // maybe show the components? |
590 | // | 589 | // |
591 | } | 590 | } |
592 | void OFileSelector::initializeYes() | 591 | void OFileSelector::initializeYes() |
593 | { | 592 | { |
594 | /** The Save Cancel bar | 593 | /** The Save Cancel bar |
595 | * | 594 | * |
596 | */ | 595 | */ |
597 | if( m_boxOk == 0 ){ | 596 | if( m_boxOk == 0 ){ |
598 | m_boxOk = new QHBox( this ); | 597 | m_boxOk = new QHBox( this ); |
599 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | 598 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); |
600 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | 599 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); |
601 | 600 | ||
602 | //m_boxOk->addWidget( m_ok ); | 601 | //m_boxOk->addWidget( m_ok ); |
603 | //m_boxOk->addWidget( m_cancel ); | 602 | //m_boxOk->addWidget( m_cancel ); |
604 | m_boxOk->setMargin( 5 ); | 603 | m_boxOk->setMargin( 5 ); |
605 | m_boxOk->setSpacing( 10 ); | 604 | m_boxOk->setSpacing( 10 ); |
606 | m_lay->addWidget( m_boxOk, 0 ); | 605 | m_lay->addWidget( m_boxOk, 0 ); |
607 | 606 | ||
608 | connect( m_ok, SIGNAL( clicked() ), | 607 | connect( m_ok, SIGNAL( clicked() ), |
609 | this, SLOT(slotOk() ) ); | 608 | this, SLOT(slotOk() ) ); |
610 | connect( m_cancel, SIGNAL( clicked() ), | 609 | connect( m_cancel, SIGNAL( clicked() ), |
611 | this, SLOT( slotCancel() ) ); | 610 | this, SLOT( slotCancel() ) ); |
612 | } | 611 | } |
613 | } | 612 | } |
614 | /* | 613 | /* |
615 | * OK m_mimeCheck is a QComboBox we now want to fill | 614 | * OK m_mimeCheck is a QComboBox we now want to fill |
616 | * out that combobox | 615 | * out that combobox |
617 | * if automime we need to update the mimetypes | 616 | * if automime we need to update the mimetypes |
618 | */ | 617 | */ |
619 | void OFileSelector::updateMimeCheck() { | 618 | void OFileSelector::updateMimeCheck() { |
620 | m_mimeCheck->clear(); | 619 | m_mimeCheck->clear(); |
621 | if (m_autoMime ) { | 620 | if (m_autoMime ) { |
622 | //m_mimeCheck->insertItem( tr("All") ); | 621 | //m_mimeCheck->insertItem( tr("All") ); |
623 | updateMimes(); | 622 | updateMimes(); |
624 | } | 623 | } |
625 | 624 | ||
626 | QMap<QString, QStringList>::Iterator it; | 625 | QMap<QString, QStringList>::Iterator it; |
627 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | 626 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { |
628 | m_mimeCheck->insertItem( it.key() ); | 627 | m_mimeCheck->insertItem( it.key() ); |
629 | } | 628 | } |
630 | } | 629 | } |
631 | 630 | ||
632 | void OFileSelector::initializeChooser() | 631 | void OFileSelector::initializeChooser() |
633 | { | 632 | { |
634 | if( m_boxView == 0 ){ | 633 | if( m_boxView == 0 ){ |
635 | m_boxView = new QHBox( this ); | 634 | m_boxView = new QHBox( this ); |
636 | m_viewCheck = new QComboBox( m_boxView, "view check"); | 635 | m_viewCheck = new QComboBox( m_boxView, "view check"); |
637 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | 636 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); |
638 | m_boxView->setSpacing( 8 ); | 637 | m_boxView->setSpacing( 8 ); |
639 | m_lay->addWidget(m_boxView, 0 ); | 638 | m_lay->addWidget(m_boxView, 0 ); |
640 | 639 | ||
641 | 640 | ||
642 | updateMimeCheck(); | 641 | updateMimeCheck(); |
643 | fillList(); | 642 | fillList(); |
644 | 643 | ||
645 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 644 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
646 | this, SLOT( slotViewCheck(const QString & ) ) ); | 645 | this, SLOT( slotViewCheck(const QString & ) ) ); |
647 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 646 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
648 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 647 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
649 | } | 648 | } |
650 | } | 649 | } |
651 | /* generate the buttons for the toolbar */ | 650 | /* generate the buttons for the toolbar */ |
652 | void OFileSelector::initToolbar() { | 651 | void OFileSelector::initToolbar() { |
653 | m_mainView = new OFileSelectorMain( this ); | 652 | m_mainView = new OFileSelectorMain( this ); |
654 | 653 | ||
655 | /* now generate the tool bar */ | 654 | /* now generate the tool bar */ |
656 | qWarning( "toolbar" ); | 655 | qWarning( "toolbar" ); |
657 | m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); | 656 | m_pseudo = new QWidget( m_mainView, "Pseudo Widget" ); |
658 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); | 657 | m_pseudoLayout = new QVBoxLayout( m_pseudo ); |
659 | 658 | ||
660 | m_boxToolbar = new QHBox( m_pseudo ); | 659 | m_boxToolbar = new QHBox( m_pseudo ); |
661 | m_boxToolbar->setSpacing( 0 ); | 660 | m_boxToolbar->setSpacing( 0 ); |
662 | 661 | ||
663 | // tool bar members now | 662 | // tool bar members now |
664 | m_location = new QComboBox( m_boxToolbar ); | 663 | m_location = new QComboBox( m_boxToolbar ); |
665 | m_location->setEditable( TRUE ); | 664 | m_location->setEditable( TRUE ); |
666 | m_location->setDuplicatesEnabled( FALSE ); | 665 | m_location->setDuplicatesEnabled( FALSE ); |
667 | connect( m_location, SIGNAL(activated(const QString& ) ), | 666 | connect( m_location, SIGNAL(activated(const QString& ) ), |
668 | this, SLOT(slotLocationActivated(const QString& )) ); | 667 | this, SLOT(slotLocationActivated(const QString& )) ); |
669 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , | 668 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , |
670 | this, SLOT(locationComboChanged() ) ); | 669 | this, SLOT(locationComboChanged() ) ); |
671 | 670 | ||
672 | // UP Button | 671 | // UP Button |
673 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, | 672 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, |
674 | m_boxToolbar, "cdUpButton" ); | 673 | m_boxToolbar, "cdUpButton" ); |
675 | m_up->setFixedSize( QSize(20, 20 ) ); | 674 | m_up->setFixedSize( QSize(20, 20 ) ); |
676 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); | 675 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); |
677 | m_up->setFlat( TRUE ); | 676 | m_up->setFlat( TRUE ); |
678 | 677 | ||
679 | // Home Button | 678 | // Home Button |
680 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), | 679 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), |
681 | QString::null, m_boxToolbar ); | 680 | QString::null, m_boxToolbar ); |
682 | m_homeButton->setFixedSize( QSize(20, 20 ) ); | 681 | m_homeButton->setFixedSize( QSize(20, 20 ) ); |
683 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); | 682 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); |
684 | m_homeButton->setFlat( TRUE ); | 683 | m_homeButton->setFlat( TRUE ); |
685 | 684 | ||
686 | // Documents Button | 685 | // Documents Button |
687 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), | 686 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), |
688 | QString::null, m_boxToolbar, | 687 | QString::null, m_boxToolbar, |
689 | "docsButton" ); | 688 | "docsButton" ); |
690 | m_docButton->setFixedSize( QSize(20, 20 ) ); | 689 | m_docButton->setFixedSize( QSize(20, 20 ) ); |
691 | m_docButton->setFlat( true ); | 690 | m_docButton->setFlat( true ); |
692 | connect( m_docButton, SIGNAL(clicked() ), | 691 | connect( m_docButton, SIGNAL(clicked() ), |
693 | this, SLOT(slotDoc() ) ); | 692 | this, SLOT(slotDoc() ) ); |
694 | 693 | ||
695 | // close button | 694 | // close button |
696 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 695 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
697 | m_boxToolbar ); | 696 | m_boxToolbar ); |
698 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 697 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
699 | m_close->setFixedSize( 20, 20 ); | 698 | m_close->setFixedSize( 20, 20 ); |
700 | 699 | ||
701 | m_boxToolbar->setFixedHeight( 20 ); | 700 | m_boxToolbar->setFixedHeight( 20 ); |
702 | m_pseudoLayout->addWidget(m_boxToolbar ); | 701 | m_pseudoLayout->addWidget(m_boxToolbar ); |
703 | 702 | ||
704 | /* init the locations */ | 703 | /* init the locations */ |
705 | initLocations(); | 704 | initLocations(); |
706 | 705 | ||
707 | if( !m_shTool ){ | 706 | if( !m_shTool ){ |
708 | m_location->hide( ); | 707 | m_location->hide( ); |
709 | m_up->hide( ); | 708 | m_up->hide( ); |
710 | m_homeButton->hide( ); | 709 | m_homeButton->hide( ); |
711 | m_docButton->hide( ); | 710 | m_docButton->hide( ); |
712 | } | 711 | } |
713 | if(!m_shClose ) | 712 | if(!m_shClose ) |
714 | m_close->hide(); | 713 | m_close->hide(); |
715 | 714 | ||
716 | m_mainView->setToolbar( m_pseudo ); | 715 | m_mainView->setToolbar( m_pseudo ); |
717 | m_lay->addWidget( m_mainView, 100 ); | 716 | m_lay->addWidget( m_mainView, 100 ); |
718 | } | 717 | } |
719 | /* put default locations into the bar */ | 718 | /* put default locations into the bar */ |
720 | void OFileSelector::initLocations () { | 719 | void OFileSelector::initLocations () { |
721 | 720 | ||
722 | // let;s fill the Location ComboBox | 721 | // let;s fill the Location ComboBox |
723 | StorageInfo storage; | 722 | StorageInfo storage; |
724 | const QList<FileSystem> &fs = storage.fileSystems(); | 723 | const QList<FileSystem> &fs = storage.fileSystems(); |
725 | QListIterator<FileSystem> it ( fs ); | 724 | QListIterator<FileSystem> it ( fs ); |
726 | for( ; it.current(); ++it ){ | 725 | for( ; it.current(); ++it ){ |
727 | const QString disk = (*it)->name(); | 726 | const QString disk = (*it)->name(); |
728 | const QString path = (*it)->path(); | 727 | const QString path = (*it)->path(); |
729 | m_location->insertItem(path+ "<-"+disk ); | 728 | m_location->insertItem(path+ "<-"+disk ); |
730 | } | 729 | } |
731 | int count = m_location->count(); | 730 | int count = m_location->count(); |
732 | m_location->insertItem( m_currentDir ); | 731 | m_location->insertItem( m_currentDir ); |
733 | m_location->setCurrentItem( count ); | 732 | m_location->setCurrentItem( count ); |
734 | 733 | ||
735 | } | 734 | } |
736 | void OFileSelector::initializePerm() | 735 | void OFileSelector::initializePerm() |
737 | { | 736 | { |
738 | if( m_checkPerm == 0 ){ | 737 | if( m_checkPerm == 0 ){ |
739 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); | 738 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); |
740 | m_checkPerm->setChecked( false ); | 739 | m_checkPerm->setChecked( false ); |
741 | m_lay->addWidget( m_checkPerm ); | 740 | m_lay->addWidget( m_checkPerm ); |
742 | } | 741 | } |
743 | } | 742 | } |
744 | void OFileSelector::initPics() | 743 | void OFileSelector::initPics() |
745 | { | 744 | { |
746 | m_pixmaps = new QMap<QString,QPixmap>; | 745 | m_pixmaps = new QMap<QString,QPixmap>; |
747 | QPixmap pm = Resource::loadPixmap( "folder" ); | 746 | QPixmap pm = Resource::loadPixmap( "folder" ); |
748 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 747 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
749 | 748 | ||
750 | QPainter painter( &pm ); | 749 | QPainter painter( &pm ); |
751 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 750 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
752 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 751 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
753 | m_pixmaps->insert("dirsymlink", pm ); | 752 | m_pixmaps->insert("dirsymlink", pm ); |
754 | 753 | ||
755 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 754 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
756 | QPainter pen(&pm2 ); | 755 | QPainter pen(&pm2 ); |
757 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 756 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
758 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 757 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
759 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 758 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
760 | } | 759 | } |
761 | // if a mime complies with the m_mimeCheck->currentItem | 760 | // if a mime complies with the m_mimeCheck->currentItem |
762 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 761 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
763 | { | 762 | { |
764 | if( mime == "All" ) | 763 | if( mime == "All" ) |
765 | return true; | 764 | return true; |
766 | MimeType type( path ); | 765 | MimeType type( path ); |
767 | if( type.id() == mime ) | 766 | if( type.id() == mime ) |
768 | return true; | 767 | return true; |
769 | return false; | 768 | return false; |
770 | } | 769 | } |
771 | /* check if the mimetype in mime | 770 | /* check if the mimetype in mime |
772 | * complies with the one which is current | 771 | * complies with the one which is current |
773 | */ | 772 | */ |
774 | /* | 773 | /* |
775 | * We've the mimetype of the file | 774 | * We've the mimetype of the file |
776 | * We need to get the stringlist of the current mimetype | 775 | * We need to get the stringlist of the current mimetype |
777 | * | 776 | * |
778 | * mime = image/jpeg | 777 | * mime = image/jpeg |
779 | * QStringList = 'image/*' | 778 | * QStringList = 'image/*' |
780 | * or QStringList = image/jpeg;image/png;application/x-ogg | 779 | * or QStringList = image/jpeg;image/png;application/x-ogg |
781 | * or QStringList = application/x-ogg;image/*; | 780 | * or QStringList = application/x-ogg;image/*; |
782 | * with all these mime filters it should get acceptes | 781 | * with all these mime filters it should get acceptes |
783 | * to do so we need to look if mime is contained inside | 782 | * to do so we need to look if mime is contained inside |
784 | * the stringlist | 783 | * the stringlist |
785 | * if it's contained return true | 784 | * if it's contained return true |
786 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | 785 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' |
787 | * is contained in the mimefilter and then we will | 786 | * is contained in the mimefilter and then we will |
788 | * look if both are equal until the '/' | 787 | * look if both are equal until the '/' |
789 | */ | 788 | */ |
790 | bool OFileSelector::compliesMime( const QString& mime ) { | 789 | bool OFileSelector::compliesMime( const QString& mime ) { |
791 | qWarning("mimetype is %s", mime.latin1() ); | 790 | qWarning("mimetype is %s", mime.latin1() ); |
792 | QString currentText; | 791 | QString currentText; |
793 | if (m_shChooser ) | 792 | if (m_shChooser ) |
794 | currentText = m_mimeCheck->currentText(); | 793 | currentText = m_mimeCheck->currentText(); |
diff --git a/libopie/ofileselector/ofileselectoritem.cpp b/libopie/ofileselector/ofileselectoritem.cpp index 1e745a1..d31046b 100644 --- a/libopie/ofileselector/ofileselectoritem.cpp +++ b/libopie/ofileselector/ofileselectoritem.cpp | |||
@@ -1,53 +1,58 @@ | |||
1 | #include "ofileselectoritem.h" | 1 | #include "ofileselectoritem.h" |
2 | 2 | ||
3 | OFileSelectorItem::OFileSelectorItem( QListView*view, | 3 | OFileSelectorItem::OFileSelectorItem( QListView*view, |
4 | const QPixmap& pix, | 4 | const QPixmap& pix, |
5 | const QString& path, | 5 | const QString& path, |
6 | const QString& date, | 6 | const QString& date, |
7 | const QString& size, | 7 | const QString& size, |
8 | const QString& dir, | 8 | const QString& dir, |
9 | const QString& extra, | ||
9 | bool isLocked, | 10 | bool isLocked, |
10 | bool isDir ) | 11 | bool isDir ) |
11 | : QListViewItem( view ) | 12 | : QListViewItem( view ) |
12 | { | 13 | { |
13 | setPixmap( 0, pix ); | 14 | setPixmap( 0, pix ); |
14 | setText( 1, path ); | 15 | setText( 1, path ); |
15 | setText( 2, size ); | 16 | setText( 2, size ); |
16 | setText( 3, date ); | 17 | setText( 3, date ); |
17 | m_dir = isDir; | 18 | m_dir = isDir; |
18 | m_locked = isLocked; | 19 | m_locked = isLocked; |
19 | m_dirStr = dir; | 20 | m_dirStr = dir; |
21 | m_extra = extra; | ||
20 | } | 22 | } |
21 | OFileSelectorItem::~OFileSelectorItem() { | 23 | OFileSelectorItem::~OFileSelectorItem() { |
22 | } | 24 | } |
23 | bool OFileSelectorItem::isLocked()const { | 25 | bool OFileSelectorItem::isLocked()const { |
24 | return m_locked; | 26 | return m_locked; |
25 | } | 27 | } |
26 | QString OFileSelectorItem::directory()const { | 28 | QString OFileSelectorItem::directory()const { |
27 | return m_dirStr; | 29 | return m_dirStr; |
28 | } | 30 | } |
29 | bool OFileSelectorItem::isDir()const { | 31 | bool OFileSelectorItem::isDir()const { |
30 | return m_dir; | 32 | return m_dir; |
31 | } | 33 | } |
32 | QString OFileSelectorItem::path() const { | 34 | QString OFileSelectorItem::path() const { |
33 | return text(1); | 35 | return text(1); |
34 | } | 36 | } |
35 | QString OFileSelectorItem::key( int id, bool ) { | 37 | QString OFileSelectorItem::key( int id, bool ) { |
36 | QString ke; | 38 | QString ke; |
37 | 39 | ||
38 | if( id == 0 || id == 1 ){ // name | 40 | if( id == 0 || id == 1 ){ // name |
39 | if( m_dir ){ | 41 | if( m_dir ){ |
40 | ke.append("0" ); | 42 | ke.append("0" ); |
41 | ke.append( text(1) ); | 43 | ke.append( text(1) ); |
42 | }else{ | 44 | }else{ |
43 | ke.append("1" ); | 45 | ke.append("1" ); |
44 | ke.append( text(1) ); | 46 | ke.append( text(1) ); |
45 | } | 47 | } |
46 | }else if( id == 2 ){ // size | 48 | }else if( id == 2 ){ // size |
47 | return text(2); | 49 | return text(2); |
48 | }else if( id == 3 ){ // date | 50 | }else if( id == 3 ){ // date |
49 | return text(3); | 51 | return text(3); |
50 | } | 52 | } |
51 | 53 | ||
52 | return ke; | 54 | return ke; |
53 | } | 55 | } |
56 | QString OFileSelector::extra()const { | ||
57 | return m_extra; | ||
58 | } | ||
diff --git a/libopie/ofileselector/ofileselectoritem.h b/libopie/ofileselector/ofileselectoritem.h index 21460c4..81966ae 100644 --- a/libopie/ofileselector/ofileselectoritem.h +++ b/libopie/ofileselector/ofileselectoritem.h | |||
@@ -1,30 +1,35 @@ | |||
1 | #ifndef OPIE_FILE_SELECTOR_ITEM_H | 1 | #ifndef OPIE_FILE_SELECTOR_ITEM_H |
2 | #define OPIE_FILE_SELECTOR_ITEM_H | 2 | #define OPIE_FILE_SELECTOR_ITEM_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | 5 | ||
6 | class OFileSelectorItem : public QListViewItem { | 6 | class OFileSelectorItem : public QListViewItem { |
7 | public: | 7 | public: |
8 | OFileSelectorItem( QListView* view, | 8 | OFileSelectorItem( QListView* view, |
9 | const QPixmap&, | 9 | const QPixmap&, |
10 | const QString& path, | 10 | const QString& path, |
11 | const QString& date, | 11 | const QString& date, |
12 | const QString& size, | 12 | const QString& size, |
13 | const QString& dir, | 13 | const QString& dir, |
14 | bool isLocked, | 14 | bool isLocked, |
15 | const QString& extra, | ||
15 | bool isDir = false); | 16 | bool isDir = false); |
16 | ~OFileSelectorItem(); | 17 | ~OFileSelectorItem(); |
17 | bool isLocked() const; | 18 | bool isLocked() const; |
18 | QString directory()const; | 19 | QString directory()const; |
19 | bool isDir()const; | 20 | bool isDir()const; |
20 | QString path()const; | 21 | QString path()const; |
21 | QString key(int id, bool ); | 22 | QString key(int id, bool ); |
23 | QString extra()const; | ||
22 | 24 | ||
23 | private: | 25 | private: |
24 | bool m_locked : 1; | 26 | bool m_locked : 1; |
25 | bool m_dir : 1; | 27 | bool m_dir : 1; |
26 | QString m_dirStr; | 28 | QString m_dirStr; |
29 | QString m_extra; | ||
27 | 30 | ||
31 | class Private; | ||
32 | Private* d; | ||
28 | }; | 33 | }; |
29 | 34 | ||
30 | #endif | 35 | #endif |
diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp index 38f722c..72d2f60 100644 --- a/libopie/ofileselector/ofileview.cpp +++ b/libopie/ofileselector/ofileview.cpp | |||
@@ -1,36 +1,30 @@ | |||
1 | #include <qlineedit.h> | 1 | #include <qlineedit.h> |
2 | 2 | ||
3 | #include <qpe/applnk.h> | 3 | #include <qpe/applnk.h> |
4 | 4 | ||
5 | #include "ofileselector.h" | 5 | #include "ofileselector.h" |
6 | #include "ofileview.h" | 6 | #include "ofileview.h" |
7 | 7 | ||
8 | 8 | ||
9 | OFileView::OFileView( OFileSelector* sel) | 9 | OFileView::OFileView( OFileSelector* sel) |
10 | : m_sel( sel ) | 10 | : m_sel( sel ) |
11 | { | 11 | { |
12 | } | 12 | } |
13 | OFileView::~OFileView() { | 13 | OFileView::~OFileView() { |
14 | } | 14 | } |
15 | void OFileView::fileSelected( const QString& s ) { | 15 | void OFileView::fileSelected( const QString& dir,const QString& file,const QString& extra ) { |
16 | m_sel->internFileSelected( s ); | 16 | m_sel->currentLister()->fileSelected( dir,file,extra ); |
17 | } | ||
18 | void OFileView::fileSelected( const DocLnk& s) { | ||
19 | m_sel->internFileSelected( s ); | ||
20 | } | 17 | } |
21 | void OFileView::contextMenu() { | 18 | void OFileView::contextMenu() { |
22 | m_sel->internContextMenu(); | 19 | m_sel->internContextMenu(); |
23 | } | 20 | } |
24 | void OFileView::changedDir( const QString& s) { | 21 | void OFileView::changedDir( const QString& s, const QString& file, const QString& extra) { |
25 | m_sel->internChangedDir( s ); | 22 | m_sel->currentLister()->changedDir( s, file,extra ); |
26 | } | ||
27 | void OFileView::changedDir( const QDir& d ) { | ||
28 | m_sel->internChangedDir( d ); | ||
29 | } | 23 | } |
30 | OFileSelector* OFileView::selector() const { | 24 | OFileSelector* OFileView::selector() const { |
31 | return m_sel; | 25 | return m_sel; |
32 | } | 26 | } |
33 | void OFileView::updateLine( const QString& str ) { | 27 | void OFileView::updateLine( const QString& str ) { |
34 | if (m_sel->m_shLne ) | 28 | if (m_sel->m_shLne ) |
35 | m_sel->m_edit->setText( str ); | 29 | m_sel->m_edit->setText( str ); |
36 | } | 30 | } |
diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h index d7ea4a2..808587f 100644 --- a/libopie/ofileselector/ofileview.h +++ b/libopie/ofileselector/ofileview.h | |||
@@ -1,121 +1,140 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> | 3 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef ofileview_h | 29 | #ifndef ofileview_h |
30 | #define ofileview_h | 30 | #define ofileview_h |
31 | 31 | ||
32 | #include <qobject.h> | 32 | #include <qobject.h> |
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | 35 | ||
36 | class QFileInfo; | 36 | class QFileInfo; |
37 | class QDir; | 37 | class QDir; |
38 | class DocLnk; | 38 | class DocLnk; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * A OFileView is a specialised View for the | 41 | * A OFileView is a specialised View for the |
42 | * OFileSelector | 42 | * OFileSelector |
43 | * With a View you can chage the user visible | 43 | * With a View you can chage the user visible |
44 | * representation of a OFileLister | 44 | * representation of a OFileLister |
45 | * OFileView is just a basic interface which helps you to | 45 | * OFileView is just a basic interface which helps you to |
46 | * write new views | 46 | * write new views |
47 | */ | 47 | */ |
48 | class OFileSelector; | 48 | class OFileSelector; |
49 | class OFileView { | 49 | class OFileView { |
50 | public: | 50 | public: |
51 | OFileView( OFileSelector* ); | 51 | OFileView( OFileSelector* ); |
52 | OFileView(); | 52 | OFileView(); |
53 | virtual ~OFileView(); | 53 | virtual ~OFileView(); |
54 | 54 | ||
55 | virtual void clear() = 0; | 55 | virtual void clear() = 0; |
56 | virtual void addFile(const QPixmap&, | 56 | virtual void addFile(const QPixmap&, |
57 | const QString &mine, | 57 | const QString &mine, |
58 | QFileInfo *info, | 58 | QFileInfo *info, |
59 | const QString& extra = QString::null, | ||
59 | bool isSymlink = FALSE ) = 0; | 60 | bool isSymlink = FALSE ) = 0; |
60 | 61 | ||
61 | virtual void addFile(const QPixmap&, | 62 | virtual void addFile(const QPixmap&, |
62 | const QString& mine, const QString& dir, | 63 | const QString& mine, const QString& dir, |
63 | const QString& file, bool = FALSE ) = 0; | 64 | const QString& file, |
65 | const QString& extra = QString::null, | ||
66 | bool = FALSE ) = 0; | ||
64 | 67 | ||
65 | virtual void addDir (const QPixmap&, | 68 | virtual void addDir (const QPixmap&, |
66 | const QString &mine, | 69 | const QString &mine, |
67 | QFileInfo *info, | 70 | QFileInfo *info, |
71 | const QString& extra = QString::null, | ||
68 | bool isSymlink = FALSE ) = 0; | 72 | bool isSymlink = FALSE ) = 0; |
69 | virtual void addDir (const QPixmap&, | 73 | virtual void addDir (const QPixmap&, |
70 | const QString& mine, const QString& dir, | 74 | const QString& mine, const QString& dir, |
71 | const QString& file, bool = FALSE) = 0; | 75 | const QString& file, |
76 | const QString& extra = QString::null, | ||
77 | bool = FALSE) = 0; | ||
72 | 78 | ||
73 | virtual void addSymlink(const QPixmap&, | 79 | virtual void addSymlink(const QPixmap&, |
74 | const QString &mime, | 80 | const QString &mime, |
75 | QFileInfo *info, | 81 | QFileInfo *info, |
82 | const QString& extra = QString::null, | ||
76 | bool isSymlink = FALSE ) = 0; | 83 | bool isSymlink = FALSE ) = 0; |
77 | 84 | ||
78 | virtual void addSymlink(const QPixmap&, | 85 | virtual void addSymlink(const QPixmap&, |
79 | const QString& mine, | 86 | const QString& mine, |
80 | const QString& path, | 87 | const QString& path, |
81 | const QString& file, | 88 | const QString& file, |
89 | const QString& extra = QString::null, | ||
82 | bool isSymlink = FALSE ) = 0; | 90 | bool isSymlink = FALSE ) = 0; |
83 | 91 | ||
84 | virtual void cd(const QString &path ) = 0; | 92 | virtual void cd(const QString &path ) = 0; |
85 | virtual QWidget* widget() = 0; | 93 | virtual QWidget* widget() = 0; |
86 | 94 | ||
87 | virtual QString selectedName()const = 0; | 95 | virtual QString selectedName()const = 0; |
88 | virtual QStringList selectedNames()const = 0; | 96 | virtual QStringList selectedNames()const = 0; |
89 | virtual QString selectedPath()const = 0; | 97 | virtual QString selectedPath()const = 0; |
90 | virtual QStringList selectedPaths()const = 0; | 98 | virtual QStringList selectedPaths()const = 0; |
91 | virtual int fileCount() = 0; | 99 | virtual int fileCount() = 0; |
92 | virtual void sort() =0; | 100 | virtual void sort() =0; |
93 | 101 | ||
94 | /*signals:*/ | 102 | /*signals:*/ |
95 | protected: | 103 | protected: |
96 | 104 | ||
97 | void fileSelected(const QString &); | 105 | /** |
98 | void fileSelected(const DocLnk & ); | 106 | * @param dir The dir name |
99 | void contextMenu(); | 107 | * @param file The file name |
100 | void changedDir(const QString &); | 108 | * @param extra The extra information |
101 | void changedDir(const QDir & ); | 109 | */ |
110 | void fileSelected(const QString &dir, const QString& file, const QString& extra = QString::nulll); | ||
111 | void contextMenu(); | ||
112 | |||
113 | /** | ||
114 | * | ||
115 | * @param dir The dir name | ||
116 | * @param file The file name | ||
117 | * @param extra The extra informations | ||
118 | */ | ||
119 | void changedDir(const QString &dir, const QString& file, const QString& extra = QString::null); | ||
120 | void changedDir(const QDir & ); | ||
102 | 121 | ||
103 | /* updates the file name line of the FileSelector */ | 122 | /* updates the file name line of the FileSelector */ |
104 | void updateLine( const QString& ); | 123 | void updateLine( const QString& ); |
105 | OFileSelector* selector()const; | 124 | OFileSelector* selector()const; |
106 | 125 | ||
107 | private: | 126 | private: |
108 | OFileSelector* m_sel; | 127 | OFileSelector* m_sel; |
109 | }; | 128 | }; |
110 | 129 | ||
111 | class OFileViewFactory { | 130 | class OFileViewFactory { |
112 | public: | 131 | public: |
113 | OFileViewFactory() {} ; | 132 | OFileViewFactory() {} ; |
114 | virtual ~OFileViewFactory() = 0; | 133 | virtual ~OFileViewFactory() = 0; |
115 | 134 | ||
116 | OFileView* newView(QWidget *parent, const char *name ); | 135 | OFileView* newView(QWidget *parent, const char *name ); |
117 | QString name()const; | 136 | QString name()const; |
118 | }; | 137 | }; |
119 | 138 | ||
120 | 139 | ||
121 | #endif | 140 | #endif |
diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp index b6b03cd..378c69d 100644 --- a/libopie/ofileselector/olister.cpp +++ b/libopie/ofileselector/olister.cpp | |||
@@ -1,106 +1,162 @@ | |||
1 | #include <qcombobox.h> | ||
2 | |||
1 | #include "olister.h" | 3 | #include "olister.h" |
2 | #include "ofileview.h" | 4 | #include "ofileview.h" |
3 | #include "opixmapprovider.h" | 5 | #include "opixmapprovider.h" |
4 | #include "ofileselector.h" | 6 | #include "ofileselector.h" |
5 | 7 | ||
6 | 8 | ||
7 | OLister::OLister( OFileSelector* view) | 9 | OLister::OLister( OFileSelector* view) |
8 | : m_view( view ) | 10 | : m_view( view ), m_acc( 0l ) |
9 | { | 11 | { |
10 | m_prov = new OPixmapProvider( view ); | 12 | m_prov = new OPixmapProvider( view ); |
11 | } | 13 | } |
12 | OLister::~OLister() { | 14 | OLister::~OLister() { |
13 | delete m_prov; | 15 | delete m_prov; |
14 | } | 16 | } |
15 | void OLister::setPixmapProvider( OPixmapProvider* prov ) { | 17 | void OLister::setPixmapProvider( OPixmapProvider* prov ) { |
16 | delete m_prov; | 18 | delete m_prov; |
17 | m_prov = prov; | 19 | m_prov = prov; |
18 | } | 20 | } |
19 | bool OLister::showFiles()const { | 21 | bool OLister::showFiles()const { |
20 | return m_view->showFiles(); | 22 | return m_view->showFiles(); |
21 | } | 23 | } |
22 | bool OLister::showDirs()const { | 24 | bool OLister::showDirs()const { |
23 | return m_view->showDirs(); | 25 | return m_view->showDirs(); |
24 | } | 26 | } |
25 | void OLister::addFile( const QString& mine, | 27 | void OLister::addFile( const QString& mine, |
26 | QFileInfo* info, | 28 | QFileInfo* info, |
29 | const QString& extra, | ||
27 | bool isSymlink ) { | 30 | bool isSymlink ) { |
28 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : | 31 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : |
29 | OPixmapProvider::File; | 32 | OPixmapProvider::File; |
30 | QPixmap pix = provider()->pixmap(t, mine, | 33 | QPixmap pix = provider()->pixmap(t, mine, |
31 | info); | 34 | info); |
32 | view()->currentView()->addFile( pix, | 35 | view()->currentView()->addFile( pix, |
33 | mine, | 36 | mine, |
34 | info, | 37 | info, |
38 | extra, | ||
35 | isSymlink ); | 39 | isSymlink ); |
36 | } | 40 | } |
37 | void OLister::addFile( const QString& mine, | 41 | void OLister::addFile( const QString& mine, |
38 | const QString& path, | 42 | const QString& path, |
39 | const QString& file, | 43 | const QString& file, |
44 | const QString& extra, | ||
40 | bool isSymlink ) { | 45 | bool isSymlink ) { |
41 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : | 46 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : |
42 | OPixmapProvider::File; | 47 | OPixmapProvider::File; |
43 | 48 | ||
44 | QPixmap pix = provider()->pixmap(t, mine, path, file ); | 49 | QPixmap pix = provider()->pixmap(t, mine, path, file ); |
45 | view()->currentView()->addFile( pix, | 50 | view()->currentView()->addFile( pix, |
46 | mine, | 51 | mine, |
47 | path, | 52 | path, |
48 | file, | 53 | file, |
54 | extra, | ||
49 | isSymlink ); | 55 | isSymlink ); |
50 | } | 56 | } |
51 | void OLister::addDir( const QString& mine, | 57 | void OLister::addDir( const QString& mine, |
52 | QFileInfo* info, | 58 | QFileInfo* info, |
59 | const QString& extra, | ||
53 | bool isSymlink ) { | 60 | bool isSymlink ) { |
54 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : | 61 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : |
55 | OPixmapProvider::Dir; | 62 | OPixmapProvider::Dir; |
56 | QPixmap pix = provider()->pixmap(t, mine, info ); | 63 | QPixmap pix = provider()->pixmap(t, mine, info ); |
57 | view()->currentView()->addDir( pix, | 64 | view()->currentView()->addDir( pix, |
58 | mine, | 65 | mine, |
59 | info, | 66 | info, |
67 | extra, | ||
60 | isSymlink ); | 68 | isSymlink ); |
61 | } | 69 | } |
62 | void OLister::addDir( const QString& mine, | 70 | void OLister::addDir( const QString& mine, |
63 | const QString& path, | 71 | const QString& path, |
64 | const QString& dir, | 72 | const QString& dir, |
73 | const QString& extra, | ||
65 | bool isSymlink ) { | 74 | bool isSymlink ) { |
66 | 75 | ||
67 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : | 76 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : |
68 | OPixmapProvider::Dir; | 77 | OPixmapProvider::Dir; |
69 | QPixmap pix = provider()->pixmap(t, mine, path, dir ); | 78 | QPixmap pix = provider()->pixmap(t, mine, path, dir ); |
70 | 79 | ||
71 | view()->currentView()->addDir( pix, | 80 | view()->currentView()->addDir( pix, |
72 | mine, | 81 | mine, |
73 | path, | 82 | path, |
74 | dir, | 83 | dir, |
84 | extra, | ||
75 | isSymlink ); | 85 | isSymlink ); |
76 | } | 86 | } |
77 | void OLister::addSymlink( const QString& mine, | 87 | void OLister::addSymlink( const QString& mine, |
78 | QFileInfo* info, | 88 | QFileInfo* info, |
89 | const QString& extra, | ||
79 | bool isSymlink ) { | 90 | bool isSymlink ) { |
80 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info ); | 91 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info ); |
81 | view()->currentView()->addSymlink( pix, | 92 | view()->currentView()->addSymlink( pix, |
82 | mine, | 93 | mine, |
83 | info, | 94 | info, |
95 | extra, | ||
84 | isSymlink ); | 96 | isSymlink ); |
85 | } | 97 | } |
86 | void OLister::addSymlink( const QString& mine, | 98 | void OLister::addSymlink( const QString& mine, |
87 | const QString& path, | 99 | const QString& path, |
88 | const QString& name, | 100 | const QString& name, |
101 | const QString& extra, | ||
89 | bool isSymlink ) { | 102 | bool isSymlink ) { |
90 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, | 103 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, |
91 | path, name ); | 104 | path, name ); |
92 | view()->currentView()->addSymlink( pix, | 105 | view()->currentView()->addSymlink( pix, |
93 | mine, | 106 | mine, |
94 | path, | 107 | path, |
95 | name, | 108 | name, |
109 | extra, | ||
96 | isSymlink ); | 110 | isSymlink ); |
97 | } | 111 | } |
98 | OFileSelector* OLister::view() { | 112 | OFileSelector* OLister::view() { |
99 | return m_view; | 113 | return m_view; |
100 | } | 114 | } |
101 | OPixmapProvider* OLister::provider() { | 115 | OPixmapProvider* OLister::provider() { |
102 | return m_prov; | 116 | return m_prov; |
103 | } | 117 | } |
104 | bool OLister::compliesMime( const QString& mime ) { | 118 | bool OLister::compliesMime( const QString& mime ) { |
105 | return view()->compliesMime( mime ); | 119 | return view()->compliesMime( mime ); |
106 | } | 120 | } |
121 | OListerCmbAccess* OLister::comboBox() { | ||
122 | if (!m_acc ) | ||
123 | m_acc = new OListerCmbAccess( view()->m_location ); | ||
124 | |||
125 | return m_acc; | ||
126 | } | ||
127 | |||
128 | |||
129 | OListerCmbAccess::OListerCmbAccess(QComboBox* box ) | ||
130 | : m_cmb( cmb ) | ||
131 | {} | ||
132 | OListerCmbAccess::~OListerCmbAccess() { | ||
133 | } | ||
134 | void OListerCmbAccess::clear() { | ||
135 | if ( m_cmb ) | ||
136 | m_cmb->clear(); | ||
137 | } | ||
138 | void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) { | ||
139 | if ( !m_cmb ) return; | ||
140 | |||
141 | |||
142 | int c = m_cmb->count(); | ||
143 | for ( int i = 0; i < m_cmb->count(); i++ ) { | ||
144 | if ( m_cmb->text(i) == add ) { | ||
145 | bo->setCurrentItem( i ); | ||
146 | return; | ||
147 | } | ||
148 | } | ||
149 | m_cmb->insertItem(add ); | ||
150 | m_cmb->setCurrentItem( c ); | ||
151 | } | ||
152 | void OListerCmbAccess::insert( const QString& str ) { | ||
153 | if ( m_cmb ) | ||
154 | m_cmb->insertItem( str ); | ||
155 | } | ||
156 | QString OListerCmbAccess::currentText()const { | ||
157 | QString str; | ||
158 | if (m_cmb ) | ||
159 | str = m_cmb->currentText(); | ||
160 | |||
161 | return str; | ||
162 | } | ||
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h index 0885525..79d5409 100644 --- a/libopie/ofileselector/olister.h +++ b/libopie/ofileselector/olister.h | |||
@@ -1,64 +1,125 @@ | |||
1 | #ifndef OPIE_FILE_LISTER_H | 1 | #ifndef OPIE_FILE_LISTER_H |
2 | #define OPIE_FILE_LISTER_H | 2 | #define OPIE_FILE_LISTER_H |
3 | 3 | ||
4 | #include <qfileinfo.h> | 4 | #include <qfileinfo.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | 8 | ||
9 | class QComboBox; | ||
9 | class OPixmapProvider; | 10 | class OPixmapProvider; |
10 | class OFileSelector; | 11 | class OFileSelector; |
12 | |||
13 | class OListerCmbAccess; | ||
11 | /** | 14 | /** |
12 | * lister is something like KIO but very | 15 | * lister is something like KIO but very |
13 | * very basic and currently only for | 16 | * very basic and currently only for |
14 | * populating our views. | 17 | * populating our views. |
15 | * This is a base class which needs to be implemented. | 18 | * This is a base class which needs to be implemented. |
16 | * @see OLocalLister for a filesystem based implementation | 19 | * @see OLocalLister for a filesystem based implementation |
17 | */ | 20 | */ |
21 | |||
18 | class OLister { | 22 | class OLister { |
19 | public: | 23 | public: |
20 | OLister( OFileSelector* ); | 24 | OLister( OFileSelector* ); |
21 | virtual ~OLister(); | 25 | virtual ~OLister(); |
22 | virtual void reparse(const QString& path) = 0; | 26 | virtual void reparse(const QString& path) = 0; |
23 | 27 | ||
24 | /** | 28 | /** |
25 | * return a list of available mimetypes | 29 | * return a list of available mimetypes |
26 | */ | 30 | */ |
27 | virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; | 31 | virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; |
28 | void setPixmapProvider( OPixmapProvider* ); | 32 | void setPixmapProvider( OPixmapProvider* ); |
29 | 33 | ||
34 | |||
35 | /* some way a slot */ | ||
36 | void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0; | ||
37 | void changeDir( const QString& dir, const QString& file, const QString& extra ) = 0; | ||
30 | protected: | 38 | protected: |
39 | /** | ||
40 | * I hate too big classes | ||
41 | * this is a way to group | ||
42 | * access to a ComboBox | ||
43 | * which might exist or | ||
44 | * not in a secure way | ||
45 | */ | ||
46 | OListerCmbAccess* comboBox(); | ||
47 | |||
31 | bool showFiles()const; | 48 | bool showFiles()const; |
32 | bool showDirs()const; | 49 | bool showDirs()const; |
33 | bool compliesMime( const QString& mime ); | 50 | bool compliesMime( const QString& mime ); |
34 | void addFile( const QString& mine, | 51 | void addFile( const QString& mine, |
35 | QFileInfo*, | 52 | QFileInfo*, |
53 | const QString& extra = QString::null, | ||
36 | bool isSymlink = FALSE ); | 54 | bool isSymlink = FALSE ); |
55 | |||
37 | void addFile( const QString& mine, | 56 | void addFile( const QString& mine, |
38 | const QString& path, | 57 | const QString& path, |
39 | const QString& file, | 58 | const QString& file, |
59 | const QString& extra = QString::null, | ||
40 | bool isSymlink = FALSE ); | 60 | bool isSymlink = FALSE ); |
41 | void addDir( const QString& mine, | 61 | void addDir( const QString& mine, |
42 | QFileInfo*, | 62 | QFileInfo*, |
43 | bool isSymlink = FALSE ); | 63 | bool isSymlink = FALSE ); |
44 | void addDir( const QString& mine, | 64 | void addDir( const QString& mine, |
45 | const QString& path, | 65 | const QString& path, |
46 | const QString& dir, | 66 | const QString& dir, |
67 | const QString& extra = QString::null, | ||
47 | bool isSymlink = FALSE ); | 68 | bool isSymlink = FALSE ); |
48 | void addSymlink( const QString& mine, | 69 | void addSymlink( const QString& mine, |
49 | QFileInfo* info, | 70 | QFileInfo* info, |
71 | const QString& extra = QString::null, | ||
50 | bool isSymlink = FALSE); | 72 | bool isSymlink = FALSE); |
51 | void addSymlink( const QString& mine, | 73 | void addSymlink( const QString& mine, |
52 | const QString& path, | 74 | const QString& path, |
53 | const QString& name, | 75 | const QString& name, |
76 | const QString& extra = QString::null, | ||
54 | bool isSymlink = FALSE ); | 77 | bool isSymlink = FALSE ); |
55 | OFileSelector* view(); | 78 | OFileSelector* view(); |
56 | OPixmapProvider* provider(); | 79 | OPixmapProvider* provider(); |
57 | private: | 80 | private: |
58 | OFileSelector* m_view; | 81 | OFileSelector* m_view; |
59 | OPixmapProvider* m_prov; | 82 | OPixmapProvider* m_prov; |
83 | OListerCmbAccess* m_acc; | ||
84 | |||
85 | class Private; | ||
86 | Private *d; | ||
87 | }; | ||
88 | |||
89 | class OListerCmbAccess { | ||
90 | friend class OLister; | ||
91 | public: | ||
92 | OListerCmbAccess( QComboBox* = 0l); | ||
93 | ~OListerCmbAccess(); | ||
94 | |||
95 | /** | ||
96 | * clears the combobox | ||
97 | */ | ||
98 | void clear(); | ||
99 | |||
100 | /** | ||
101 | * set's @param add to be the current Item | ||
102 | * if the item is not present it'll be removed | ||
103 | */ | ||
104 | void setCurrentItem( const QString& add, bool FORECE_ADD = TRUE ); | ||
105 | |||
106 | /** | ||
107 | * inserts the the String at | ||
108 | * a non predictable position... The position is determined | ||
109 | * by the QComboBox code | ||
110 | */ | ||
111 | void insert( const QString& ); | ||
112 | |||
113 | /** | ||
114 | * | ||
115 | */ | ||
116 | QString currentText()const; | ||
60 | 117 | ||
118 | private: | ||
119 | class Private; | ||
120 | Private* d; | ||
121 | QComboBox* m_cmb; | ||
61 | 122 | ||
62 | }; | 123 | }; |
63 | 124 | ||
64 | #endif | 125 | #endif |
diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp index 6ffcf1e..2306b14 100644 --- a/libopie/ofileselector/olocallister.cpp +++ b/libopie/ofileselector/olocallister.cpp | |||
@@ -1,118 +1,119 @@ | |||
1 | #include <qdir.h> | 1 | #include <qdir.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qmap.h> | 3 | #include <qmap.h> |
4 | 4 | ||
5 | #include <qpe/mimetype.h> | 5 | #include <qpe/mimetype.h> |
6 | 6 | ||
7 | #include "ofileselector.h" | 7 | #include "ofileselector.h" |
8 | #include "olocallister.h" | 8 | #include "olocallister.h" |
9 | 9 | ||
10 | OLocalLister::OLocalLister( OFileSelector* file ) | 10 | OLocalLister::OLocalLister( OFileSelector* file ) |
11 | : OLister( file ) | 11 | : OLister( file ) |
12 | { | 12 | { |
13 | } | 13 | } |
14 | OLocalLister::~OLocalLister() { | 14 | OLocalLister::~OLocalLister() { |
15 | } | 15 | } |
16 | 16 | ||
17 | QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) { | 17 | QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) { |
18 | QMap<QString, QStringList> mimes; | 18 | QMap<QString, QStringList> mimes; |
19 | 19 | ||
20 | // let's find possible mimetypes | 20 | // let's find possible mimetypes |
21 | QDir dir( curDir ); | 21 | QDir dir( curDir ); |
22 | dir.setFilter( QDir::Files | QDir::Readable ); | 22 | dir.setFilter( QDir::Files | QDir::Readable ); |
23 | dir.setSorting( QDir::Size ); | 23 | dir.setSorting( QDir::Size ); |
24 | 24 | ||
25 | const QFileInfoList *list = dir.entryInfoList(); | 25 | const QFileInfoList *list = dir.entryInfoList(); |
26 | QFileInfoListIterator it( *list ); | 26 | QFileInfoListIterator it( *list ); |
27 | QFileInfo *fi; | 27 | QFileInfo *fi; |
28 | 28 | ||
29 | while( (fi=it.current() ) ) { | 29 | while( (fi=it.current() ) ) { |
30 | /* skip .desktop */ | 30 | /* skip .desktop */ |
31 | if( fi->extension() == QString::fromLatin1("desktop") ){ | 31 | if( fi->extension() == QString::fromLatin1("desktop") ){ |
32 | ++it; | 32 | ++it; |
33 | continue; | 33 | continue; |
34 | } | 34 | } |
35 | MimeType type( fi->absFilePath() ); | 35 | MimeType type( fi->absFilePath() ); |
36 | 36 | ||
37 | if( !mimes.contains( type.id() ) ){ | 37 | if( !mimes.contains( type.id() ) ){ |
38 | mimes.insert( type.id(), type.id() ); | 38 | mimes.insert( type.id(), type.id() ); |
39 | } | 39 | } |
40 | 40 | ||
41 | ++it; | 41 | ++it; |
42 | } | 42 | } |
43 | 43 | ||
44 | return mimes; | 44 | return mimes; |
45 | } | 45 | } |
46 | /* FIXME mimecheck | 46 | /** |
47 | * FIXME mimecheck | ||
47 | * use mime check for that | 48 | * use mime check for that |
48 | * filter dirs | 49 | * filter dirs |
49 | * filter filters | 50 | * filter filters |
50 | * filter files | 51 | * filter files |
51 | * filter mimetypes | 52 | * filter mimetypes |
52 | */ | 53 | */ |
53 | void OLocalLister::reparse( const QString& path ) { | 54 | void OLocalLister::reparse( const QString& path ) { |
54 | QString currentMimeType; | 55 | QString currentMimeType; |
55 | QDir dir( path ); | 56 | QDir dir( path ); |
56 | 57 | ||
57 | dir.setSorting( view()->sorting() ); | 58 | dir.setSorting( view()->sorting() ); |
58 | dir.setFilter( view()->filter() ); | 59 | dir.setFilter( view()->filter() ); |
59 | 60 | ||
60 | 61 | ||
61 | const QFileInfoList *list = dir.entryInfoList(); | 62 | const QFileInfoList *list = dir.entryInfoList(); |
62 | QFileInfoListIterator it( *list ); | 63 | QFileInfoListIterator it( *list ); |
63 | QFileInfo *fi; | 64 | QFileInfo *fi; |
64 | 65 | ||
65 | while( (fi=it.current() ) ){ | 66 | while( (fi=it.current() ) ){ |
66 | 67 | ||
67 | if( fi->fileName() == QString::fromLatin1("..") || | 68 | if( fi->fileName() == QString::fromLatin1("..") || |
68 | fi->fileName() == QString::fromLatin1(".") ){ | 69 | fi->fileName() == QString::fromLatin1(".") ){ |
69 | ++it; | 70 | ++it; |
70 | continue; | 71 | continue; |
71 | } | 72 | } |
72 | if( fi->isSymLink() ){ | 73 | if( fi->isSymLink() ){ |
73 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 74 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
74 | /* | 75 | /* |
75 | * 5 tries to prevent dos attack | 76 | * 5 tries to prevent dos attack |
76 | */ | 77 | */ |
77 | for( int i = 0; i<=4; i++) { | 78 | for( int i = 0; i<=4; i++) { |
78 | QFileInfo info( file ); | 79 | QFileInfo info( file ); |
79 | if( !info.exists() ){ | 80 | if( !info.exists() ){ |
80 | addSymlink( currentMimeType, fi, TRUE ); | 81 | addSymlink( currentMimeType, fi, TRUE ); |
81 | break; | 82 | break; |
82 | }else if( info.isDir() ){ | 83 | }else if( info.isDir() ){ |
83 | if (!showDirs() ) | 84 | if (!showDirs() ) |
84 | break; | 85 | break; |
85 | 86 | ||
86 | addDir( currentMimeType, fi, | 87 | addDir( currentMimeType, fi, |
87 | TRUE ); | 88 | TRUE ); |
88 | break; | 89 | break; |
89 | }else if( info.isFile() ){ | 90 | }else if( info.isFile() ){ |
90 | /* if not show files skip it */ | 91 | /* if not show files skip it */ |
91 | if (!showFiles() ) | 92 | if (!showFiles() ) |
92 | break; | 93 | break; |
93 | 94 | ||
94 | /* check if we comply to the mimetype */ | 95 | /* check if we comply to the mimetype */ |
95 | MimeType type( info.absFilePath() ); | 96 | MimeType type( info.absFilePath() ); |
96 | if (compliesMime( type.id() ) ) | 97 | if (compliesMime( type.id() ) ) |
97 | addFile( currentMimeType, fi, TRUE ); | 98 | addFile( currentMimeType, fi, TRUE ); |
98 | 99 | ||
99 | break; | 100 | break; |
100 | }else if( info.isSymLink() ){ | 101 | }else if( info.isSymLink() ){ |
101 | file = info.dirPath(true ) + "/" + info.readLink() ; | 102 | file = info.dirPath(true ) + "/" + info.readLink() ; |
102 | break; | 103 | break; |
103 | }else if( i == 4){ | 104 | }else if( i == 4){ |
104 | addSymlink( currentMimeType, fi ); | 105 | addSymlink( currentMimeType, fi ); |
105 | } | 106 | } |
106 | } | 107 | } |
107 | 108 | ||
108 | }else if( fi->isDir() ){ | 109 | }else if( fi->isDir() ){ |
109 | if (showDirs() ) | 110 | if (showDirs() ) |
110 | addDir( currentMimeType, fi ); | 111 | addDir( currentMimeType, fi ); |
111 | }else if( fi->isFile() ){ | 112 | }else if( fi->isFile() ){ |
112 | if ( showFiles() ) | 113 | if ( showFiles() ) |
113 | addFile( currentMimeType, fi ); | 114 | addFile( currentMimeType, fi ); |
114 | } | 115 | } |
115 | ++it; | 116 | ++it; |
116 | } // of while loop | 117 | } // of while loop |
117 | } | 118 | } |
118 | 119 | ||