-rw-r--r-- | libopie/libopie.pro | 19 | ||||
-rw-r--r-- | libopie/odevice.h | 2 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 13 | ||||
-rw-r--r-- | libopie/ofileview.h | 28 | ||||
-rw-r--r-- | libopie/ofontmenu.h | 2 |
5 files changed, 39 insertions, 25 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro index 891c03e..6c47e86 100644 --- a/libopie/libopie.pro +++ b/libopie/libopie.pro | |||
@@ -1,25 +1,40 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h ofileselector.h ofiledialog.h ofileview.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h oclickablelabel.h oprocctrl.h oprocess.h odevice.h otimepicker.h otabwidget.h otabbar.h otabinfo.h | 3 | HEADERS = ofontmenu.h ofileselector.h \ |
4 | SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp oclickablelabel.cpp oprocctrl.cpp oprocess.cpp odevice.cpp otimepicker.cpp otabwidget.cpp otabbar.cpp | 4 | ofiledialog.h tododb.h \ |
5 | todoevent.h todoresource.h \ | ||
6 | todovcalresource.h xmltree.h \ | ||
7 | colordialog.h colorpopupmenu.h \ | ||
8 | oclickablelabel.h oprocctrl.h \ | ||
9 | oprocess.h odevice.h \ | ||
10 | otimepicker.h otabwidget.h \ | ||
11 | otabbar.h otabinfo.h | ||
12 | SOURCES = ofontmenu.cc ofileselector.cc \ | ||
13 | ofiledialog.cc xmltree.cc \ | ||
14 | tododb.cpp todoevent.cpp \ | ||
15 | todovcalresource.cpp colordialog.cpp \ | ||
16 | colorpopupmenu.cpp oclickablelabel.cpp \ | ||
17 | oprocctrl.cpp oprocess.cpp \ | ||
18 | odevice.cpp otimepicker.cpp \ | ||
19 | otabwidget.cpp otabbar.cpp | ||
5 | TARGET = opie | 20 | TARGET = opie |
6 | INCLUDEPATH += $(OPIEDIR)/include | 21 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 22 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
8 | #VERSION = 1.0.0 | 23 | #VERSION = 1.0.0 |
9 | 24 | ||
10 | INTERFACES = otimepickerbase.ui | 25 | INTERFACES = otimepickerbase.ui |
11 | 26 | ||
12 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 27 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
13 | ../i18n/en/libopie.ts \ | 28 | ../i18n/en/libopie.ts \ |
14 | ../i18n/es/libopie.ts \ | 29 | ../i18n/es/libopie.ts \ |
15 | ../i18n/fr/libopie.ts \ | 30 | ../i18n/fr/libopie.ts \ |
16 | ../i18n/hu/libopie.ts \ | 31 | ../i18n/hu/libopie.ts \ |
17 | ../i18n/ja/libopie.ts \ | 32 | ../i18n/ja/libopie.ts \ |
18 | ../i18n/ko/libopie.ts \ | 33 | ../i18n/ko/libopie.ts \ |
19 | ../i18n/no/libopie.ts \ | 34 | ../i18n/no/libopie.ts \ |
20 | ../i18n/pl/libopie.ts \ | 35 | ../i18n/pl/libopie.ts \ |
21 | ../i18n/pt/libopie.ts \ | 36 | ../i18n/pt/libopie.ts \ |
22 | ../i18n/pt_BR/libopie.ts \ | 37 | ../i18n/pt_BR/libopie.ts \ |
23 | ../i18n/sl/libopie.ts \ | 38 | ../i18n/sl/libopie.ts \ |
24 | ../i18n/zh_CN/libopie.ts \ | 39 | ../i18n/zh_CN/libopie.ts \ |
25 | ../i18n/zh_TW/libopie.ts | 40 | ../i18n/zh_TW/libopie.ts |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 9dda68e..2f676ff 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,119 +1,117 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _LIBOPIE_ODEVICE_H_ | 20 | #ifndef _LIBOPIE_ODEVICE_H_ |
21 | #define _LIBOPIE_ODEVICE_H_ | 21 | #define _LIBOPIE_ODEVICE_H_ |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | 24 | ||
25 | 25 | ||
26 | class ODeviceData; | 26 | class ODeviceData; |
27 | 27 | ||
28 | enum OModel { | 28 | enum OModel { |
29 | OMODEL_Unknown, | 29 | OMODEL_Unknown, |
30 | 30 | ||
31 | OMODEL_iPAQ_H31xx, | 31 | OMODEL_iPAQ_H31xx, |
32 | OMODEL_iPAQ_H36xx, | 32 | OMODEL_iPAQ_H36xx, |
33 | OMODEL_iPAQ_H37xx, | 33 | OMODEL_iPAQ_H37xx, |
34 | OMODEL_iPAQ_H38xx, | 34 | OMODEL_iPAQ_H38xx, |
35 | 35 | ||
36 | OMODEL_Zaurus_SL5000 | 36 | OMODEL_Zaurus_SL5000 |
37 | }; | 37 | }; |
38 | 38 | ||
39 | enum OVendor { | 39 | enum OVendor { |
40 | OVENDOR_Unknown, | 40 | OVENDOR_Unknown, |
41 | 41 | ||
42 | OVENDOR_HP, | 42 | OVENDOR_HP, |
43 | OVENDOR_Sharp | 43 | OVENDOR_Sharp |
44 | }; | 44 | }; |
45 | 45 | ||
46 | enum OSystem { | 46 | enum OSystem { |
47 | OSYSTEM_Unknown, | 47 | OSYSTEM_Unknown, |
48 | 48 | ||
49 | OSYSTEM_Familiar, | 49 | OSYSTEM_Familiar, |
50 | OSYSTEM_Zaurus, | 50 | OSYSTEM_Zaurus, |
51 | OSYSTEM_OpenZaurus | 51 | OSYSTEM_OpenZaurus |
52 | }; | 52 | }; |
53 | 53 | ||
54 | enum OLedState { | 54 | enum OLedState { |
55 | OLED_Off, | 55 | OLED_Off, |
56 | OLED_On, | 56 | OLED_On, |
57 | OLED_BlinkSlow, | 57 | OLED_BlinkSlow, |
58 | OLED_BlinkFast | 58 | OLED_BlinkFast |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | class ODevice | 62 | class ODevice |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | |||
66 | public: | ||
67 | static ODevice *inst ( ); | 65 | static ODevice *inst ( ); |
68 | 66 | ||
69 | // system | 67 | // system |
70 | enum PowerButtonHandler { | 68 | enum PowerButtonHandler { |
71 | KERNEL, | 69 | KERNEL, |
72 | OPIE | 70 | OPIE |
73 | }; | 71 | }; |
74 | 72 | ||
75 | virtual bool setPowerButtonHandler ( PowerButtonHandler h ); | 73 | virtual bool setPowerButtonHandler ( PowerButtonHandler h ); |
76 | virtual bool suspend ( ); | 74 | virtual bool suspend ( ); |
77 | 75 | ||
78 | virtual bool setDisplayStatus ( bool on ); | 76 | virtual bool setDisplayStatus ( bool on ); |
79 | virtual bool setDisplayBrightness ( int brightness ); | 77 | virtual bool setDisplayBrightness ( int brightness ); |
80 | virtual int displayBrightnessResolution ( ) const; | 78 | virtual int displayBrightnessResolution ( ) const; |
81 | 79 | ||
82 | // information | 80 | // information |
83 | 81 | ||
84 | QString modelString ( ); | 82 | QString modelString ( ); |
85 | OModel model ( ); | 83 | OModel model ( ); |
86 | 84 | ||
87 | QString vendorString ( ); | 85 | QString vendorString ( ); |
88 | OVendor vendor ( ); | 86 | OVendor vendor ( ); |
89 | 87 | ||
90 | QString systemString ( ); | 88 | QString systemString ( ); |
91 | OSystem system ( ); | 89 | OSystem system ( ); |
92 | 90 | ||
93 | QString systemVersionString ( ); | 91 | QString systemVersionString ( ); |
94 | 92 | ||
95 | // input / output | 93 | // input / output |
96 | 94 | ||
97 | virtual void alarmSound ( ); | 95 | virtual void alarmSound ( ); |
98 | virtual void keySound ( ); | 96 | virtual void keySound ( ); |
99 | virtual void touchSound ( ); | 97 | virtual void touchSound ( ); |
100 | 98 | ||
101 | virtual uint hasLeds ( ) const; | 99 | virtual uint hasLeds ( ) const; |
102 | virtual OLedState led ( uint which ) const; | 100 | virtual OLedState led ( uint which ) const; |
103 | virtual bool setLed ( uint which, OLedState st ); | 101 | virtual bool setLed ( uint which, OLedState st ); |
104 | 102 | ||
105 | virtual ~ODevice ( ); | 103 | virtual ~ODevice ( ); |
106 | 104 | ||
107 | protected: | 105 | protected: |
108 | ODevice ( ); | 106 | ODevice ( ); |
109 | virtual void init ( ); | 107 | virtual void init ( ); |
110 | 108 | ||
111 | ODeviceData *d; | 109 | ODeviceData *d; |
112 | 110 | ||
113 | private: | 111 | private: |
114 | ODevice ( const ODevice & ); | 112 | ODevice ( const ODevice & ); |
115 | }; | 113 | }; |
116 | 114 | ||
117 | #endif | 115 | #endif |
118 | 116 | ||
119 | 117 | ||
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 3c3a6c4..b3aacd6 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -1,598 +1,591 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qheader.h> | 5 | #include <qheader.h> |
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qabstractlayout.h> | 7 | #include <qabstractlayout.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
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/fileselector.h> | 23 | #include <qpe/fileselector.h> |
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/mimetype.h> | 25 | #include <qpe/mimetype.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/storage.h> | 27 | #include <qpe/storage.h> |
28 | 28 | ||
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | 32 | ||
33 | #include "ofileselector.h" | 33 | #include "ofileselector.h" |
34 | 34 | ||
35 | 35 | ||
36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
37 | 37 | ||
38 | namespace { | 38 | namespace { |
39 | int indexByString( const QComboBox *box, const QString &str ){ | 39 | int indexByString( const QComboBox *box, const QString &str ){ |
40 | int index= 0; | 40 | int index= 0; |
41 | for(int i= 0; i < box->count(); i++ ){ | 41 | for(int i= 0; i < box->count(); i++ ){ |
42 | if( str == box->text(i ) ){ | 42 | if( str == box->text(i ) ){ |
43 | index= i; | 43 | index= i; |
44 | break; | 44 | break; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | return index; | 47 | return index; |
48 | } | 48 | } |
49 | class OFileSelectorItem : public QListViewItem { | 49 | class OFileSelectorItem : public QListViewItem { |
50 | public: | 50 | public: |
51 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 51 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
52 | const QString &date, const QString &size, const QString &mDir, | 52 | const QString &date, const QString &size, const QString &mDir, |
53 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 53 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
54 | setPixmap(0, pixmap ); | 54 | setPixmap(0, pixmap ); |
55 | setText(1, path ); | 55 | setText(1, path ); |
56 | setText(2, size ); | 56 | setText(2, size ); |
57 | setText(3, date ); | 57 | setText(3, date ); |
58 | //setText(4, mDir ); | 58 | //setText(4, mDir ); |
59 | m_dir = mDir; | 59 | m_dir = mDir; |
60 | dir = isDir; | 60 | dir = isDir; |
61 | mLocked = isLocked; | 61 | mLocked = isLocked; |
62 | } | 62 | } |
63 | bool isLocked() const{ | 63 | bool isLocked() const{ |
64 | return mLocked; | 64 | return mLocked; |
65 | } | 65 | } |
66 | QString directory()const{ | 66 | QString directory()const{ |
67 | return m_dir; | 67 | return m_dir; |
68 | } | 68 | } |
69 | bool isDir()const{ | 69 | bool isDir()const{ |
70 | return dir; | 70 | return dir; |
71 | } | 71 | } |
72 | QString path()const{ | 72 | QString path()const{ |
73 | return text(1 ); | 73 | return text(1 ); |
74 | } | 74 | } |
75 | QString key(int id, bool )const { | 75 | QString key(int id, bool )const { |
76 | QString ke; | 76 | QString ke; |
77 | if( id == 0 || id == 1 ){ // name | 77 | if( id == 0 || id == 1 ){ // name |
78 | if( dir ){ | 78 | if( dir ){ |
79 | ke.append("0" ); | 79 | ke.append("0" ); |
80 | ke.append( text(1) ); | 80 | ke.append( text(1) ); |
81 | }else{ | 81 | }else{ |
82 | ke.append("1" ); | 82 | ke.append("1" ); |
83 | ke.append( text(1) ); | 83 | ke.append( text(1) ); |
84 | } | 84 | } |
85 | }else if( id == 2 ){ // size | 85 | }else if( id == 2 ){ // size |
86 | return text(2); | 86 | return text(2); |
87 | }else if( id == 3 ){ // date | 87 | }else if( id == 3 ){ // date |
88 | return text(3); | 88 | return text(3); |
89 | } | 89 | } |
90 | return ke; | 90 | return ke; |
91 | }; | 91 | }; |
92 | private: | 92 | private: |
93 | bool mLocked:1; | 93 | bool mLocked:1; |
94 | bool dir:1; | 94 | bool dir:1; |
95 | QString m_dir; | 95 | QString m_dir; |
96 | }; | 96 | }; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | 99 | ||
100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 100 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
101 | const QString &dirName, | 101 | const QString &dirName, |
102 | const QString &fileName, | 102 | const QString &fileName, |
103 | const QMap<QString,QStringList>& mimeTypes) | 103 | const QMap<QString,QStringList>& mimeTypes) |
104 | : QWidget( wid, "OFileSelector") | 104 | : QWidget( wid, "OFileSelector") |
105 | { | 105 | { |
106 | m_mimetypes = mimeTypes; | 106 | m_mimetypes = mimeTypes; |
107 | if (mode == SAVE ) | 107 | if (mode == SAVE ) |
108 | m_name = fileName; | 108 | m_name = fileName; |
109 | initVars(); | 109 | initVars(); |
110 | m_mode = mode; | 110 | m_mode = mode; |
111 | m_selector = selector; | 111 | m_selector = selector; |
112 | m_currentDir = dirName; | 112 | m_currentDir = dirName; |
113 | init(); | 113 | init(); |
114 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | 114 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); |
115 | } | 115 | } |
116 | 116 | ||
117 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 117 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
118 | const char *name, bool newVisible, | 118 | const char *name, bool newVisible, |
119 | bool closeVisible ) | 119 | bool closeVisible ) |
120 | : QWidget( parent, name ) | 120 | : QWidget( parent, name ) |
121 | { | 121 | { |
122 | if (!mimeFilter.isEmpty() ) { | 122 | if (!mimeFilter.isEmpty() ) { |
123 | QStringList list = QStringList::split(";", mimeFilter ); | 123 | QStringList list = QStringList::split(";", mimeFilter ); |
124 | m_mimetypes.insert(mimeFilter, list ); | 124 | m_mimetypes.insert(mimeFilter, list ); |
125 | } | 125 | } |
126 | initVars(); | 126 | initVars(); |
127 | m_currentDir = QPEApplication::documentDir(); | 127 | m_currentDir = QPEApplication::documentDir(); |
128 | m_mode = FILESELECTOR; | 128 | m_mode = FILESELECTOR; |
129 | m_selector = NORMAL; | 129 | m_selector = NORMAL; |
130 | m_shClose = closeVisible; | 130 | m_shClose = closeVisible; |
131 | m_shNew = newVisible; | 131 | m_shNew = newVisible; |
132 | m_shLne = false; | 132 | m_shLne = false; |
133 | m_shPerm = false; | 133 | m_shPerm = false; |
134 | m_shYesNo = false; | 134 | m_shYesNo = false; |
135 | init(); | 135 | init(); |
136 | 136 | ||
137 | 137 | ||
138 | } | 138 | } |
139 | 139 | ||
140 | OFileSelector::~OFileSelector() | 140 | OFileSelector::~OFileSelector() |
141 | { | 141 | { |
142 | 142 | ||
143 | 143 | ||
144 | } | 144 | } |
145 | 145 | ||
146 | void OFileSelector::setNewVisible( bool visible ) | 146 | void OFileSelector::setNewVisible( bool visible ) |
147 | { | 147 | { |
148 | m_shNew = visible; | 148 | m_shNew = visible; |
149 | if( m_selector == NORMAL ){ | 149 | if( m_selector == NORMAL ){ |
150 | delete m_select; | 150 | delete m_select; |
151 | // we need to initialize but keep the selected mimetype | 151 | // we need to initialize but keep the selected mimetype |
152 | QString mime = currentMimeType(); | 152 | QString mime = currentMimeType(); |
153 | m_select = new FileSelector( mime , | 153 | m_select = new FileSelector( mime , |
154 | m_stack, "fileselector", | 154 | m_stack, "fileselector", |
155 | m_shNew, m_shClose); | 155 | m_shNew, m_shClose); |
156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 156 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 157 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
158 | connect(m_select, SIGNAL(closeMe() ), | 158 | connect(m_select, SIGNAL(closeMe() ), |
159 | this, SIGNAL(closeMe() ) ); | 159 | this, SIGNAL(closeMe() ) ); |
160 | //connect to close me and other signals as well | 160 | //connect to close me and other signals as well |
161 | m_stack->addWidget( m_select, NORMAL ); | 161 | m_stack->addWidget( m_select, NORMAL ); |
162 | }else{ | 162 | }else{ |
163 | m_new->show(); | 163 | m_new->show(); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | void OFileSelector::setCloseVisible( bool visible ) | 166 | void OFileSelector::setCloseVisible( bool visible ) |
167 | { | 167 | { |
168 | m_shClose = visible; | 168 | m_shClose = visible; |
169 | if( m_selector == NORMAL ){ | 169 | if( m_selector == NORMAL ){ |
170 | setNewVisible( m_shNew ); // yeah baby | 170 | setNewVisible( m_shNew ); // yeah baby |
171 | }else{ | 171 | }else{ |
172 | m_close->show(); | 172 | m_close->show(); |
173 | } | 173 | } |
174 | } | 174 | } |
175 | void OFileSelector::reread() | 175 | void OFileSelector::reread() |
176 | { | 176 | { |
177 | if( m_selector == NORMAL ){ | 177 | if( m_selector == NORMAL ){ |
178 | setNewVisible( m_shNew ); // make it a initializeSelector | 178 | setNewVisible( m_shNew ); // make it a initializeSelector |
179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 179 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
180 | reparse(); | 180 | reparse(); |
181 | //}else{ | 181 | //}else{ |
182 | //; | 182 | //; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | const DocLnk *OFileSelector::selected() | 186 | const DocLnk *OFileSelector::selected() |
187 | { | 187 | { |
188 | if( m_selector == NORMAL ){ | ||
189 | return m_select->selected(); | ||
190 | }else{ | ||
191 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 188 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
192 | return lnk; | 189 | return lnk; |
193 | } | ||
194 | } | 190 | } |
195 | 191 | ||
196 | void OFileSelector::setYesCancelVisible( bool show ) | 192 | void OFileSelector::setYesCancelVisible( bool show ) |
197 | { | 193 | { |
198 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 194 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
199 | m_shYesNo = show; | 195 | m_shYesNo = show; |
200 | if( m_shYesNo ) | 196 | if( m_shYesNo ) |
201 | m_boxOk->show(); | 197 | m_boxOk->show(); |
202 | else | 198 | else |
203 | m_boxOk->hide(); | 199 | m_boxOk->hide(); |
204 | 200 | ||
205 | } | 201 | } |
206 | void OFileSelector::setToolbarVisible( bool show ) | 202 | void OFileSelector::setToolbarVisible( bool show ) |
207 | { | 203 | { |
208 | m_shTool = show; | 204 | m_shTool = show; |
209 | initializeListView(); // FIXME see above waste of memory | 205 | initializeListView(); // FIXME see above waste of memory |
210 | if(!m_shTool ){ | 206 | if(!m_shTool ){ |
211 | m_location->hide(); | 207 | m_location->hide(); |
212 | m_up->hide(); | 208 | m_up->hide(); |
213 | m_homeButton->hide(); | 209 | m_homeButton->hide(); |
214 | m_docButton->hide(); | 210 | m_docButton->hide(); |
215 | }else{ | 211 | }else{ |
216 | m_location->show(); | 212 | m_location->show(); |
217 | m_up->show(); | 213 | m_up->show(); |
218 | m_homeButton->show(); | 214 | m_homeButton->show(); |
219 | m_docButton->show(); | 215 | m_docButton->show(); |
220 | } | 216 | } |
221 | } | 217 | } |
222 | void OFileSelector::setPermissionBarVisible( bool show ) | 218 | void OFileSelector::setPermissionBarVisible( bool show ) |
223 | { | 219 | { |
224 | m_shPerm = show; | 220 | m_shPerm = show; |
225 | initializePerm(); | 221 | initializePerm(); |
226 | if( m_shPerm ) | 222 | if( m_shPerm ) |
227 | m_checkPerm->show(); | 223 | m_checkPerm->show(); |
228 | else | 224 | else |
229 | m_checkPerm->hide(); | 225 | m_checkPerm->hide(); |
230 | } | 226 | } |
231 | void OFileSelector::setLineEditVisible( bool show ) | 227 | void OFileSelector::setLineEditVisible( bool show ) |
232 | { | 228 | { |
233 | if( show ){ | 229 | if( show ){ |
234 | initializeName(); | 230 | initializeName(); |
235 | m_boxName->show(); | 231 | m_boxName->show(); |
236 | }else{ | 232 | }else{ |
237 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go | 233 | if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go |
238 | m_boxName->hide(); | 234 | m_boxName->hide(); |
239 | } | 235 | } |
240 | } | 236 | } |
241 | m_shLne = show; | 237 | m_shLne = show; |
242 | } | 238 | } |
243 | 239 | ||
244 | void OFileSelector::setChooserVisible( bool show ) | 240 | void OFileSelector::setChooserVisible( bool show ) |
245 | { | 241 | { |
246 | m_shChooser = show; | 242 | m_shChooser = show; |
247 | initializeChooser(); | 243 | initializeChooser(); |
248 | if( m_shChooser ){ | 244 | if( m_shChooser ){ |
249 | m_boxView->hide(); | 245 | m_boxView->hide(); |
250 | }else{ | 246 | }else{ |
251 | m_boxView->show(); | 247 | m_boxView->show(); |
252 | } | 248 | } |
253 | } | 249 | } |
254 | 250 | ||
255 | QCheckBox* OFileSelector::permissionCheckbox() | 251 | QCheckBox* OFileSelector::permissionCheckbox() |
256 | { | 252 | { |
257 | if( m_selector == NORMAL ) | 253 | if( m_selector == NORMAL ) |
258 | return 0l; | 254 | return 0l; |
259 | else | 255 | else |
260 | return m_checkPerm; | 256 | return m_checkPerm; |
261 | } | 257 | } |
262 | bool OFileSelector::setPermission()const | 258 | bool OFileSelector::setPermission()const |
263 | { | 259 | { |
264 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 260 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
265 | } | 261 | } |
266 | void OFileSelector::setPermissionChecked( bool check ) | 262 | void OFileSelector::setPermissionChecked( bool check ) |
267 | { | 263 | { |
268 | if( m_checkPerm ) | 264 | if( m_checkPerm ) |
269 | m_checkPerm->setChecked( check ); | 265 | m_checkPerm->setChecked( check ); |
270 | } | 266 | } |
271 | 267 | ||
272 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 268 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
273 | { | 269 | { |
274 | m_mode = mode; | 270 | m_mode = mode; |
275 | if( m_selector == NORMAL ) | 271 | if( m_selector == NORMAL ) |
276 | return; | 272 | return; |
277 | } | 273 | } |
278 | void OFileSelector::setShowDirs(bool ) | 274 | void OFileSelector::setShowDirs(bool ) |
279 | { | 275 | { |
280 | m_dir = true; | 276 | m_dir = true; |
281 | reparse(); | 277 | reparse(); |
282 | } | 278 | } |
283 | void OFileSelector::setCaseSensetive(bool caSe ) | 279 | void OFileSelector::setCaseSensetive(bool caSe ) |
284 | { | 280 | { |
285 | m_case = caSe; | 281 | m_case = caSe; |
286 | reparse(); | 282 | reparse(); |
287 | } | 283 | } |
288 | void OFileSelector::setShowFiles(bool show ) | 284 | void OFileSelector::setShowFiles(bool show ) |
289 | { | 285 | { |
290 | m_files = show; | 286 | m_files = show; |
291 | reparse(); | 287 | reparse(); |
292 | } | 288 | } |
293 | /// | 289 | /// |
294 | bool OFileSelector::cd(const QString &path ) | 290 | bool OFileSelector::cd(const QString &path ) |
295 | { | 291 | { |
296 | m_currentDir = path; | 292 | m_currentDir = path; |
297 | reparse(); | 293 | reparse(); |
298 | return true; | 294 | return true; |
299 | } | 295 | } |
300 | void OFileSelector::setSelector(int mode ) | 296 | void OFileSelector::setSelector(int mode ) |
301 | { | 297 | { |
302 | QString text; | 298 | QString text; |
303 | switch( mode ){ | 299 | switch( mode ){ |
304 | case NORMAL: | 300 | case NORMAL: |
305 | text = tr("Documents"); | 301 | text = tr("Documents"); |
306 | break; | 302 | break; |
307 | case EXTENDED: | 303 | case EXTENDED: |
308 | text = tr("Files"); | 304 | text = tr("Files"); |
309 | break; | 305 | break; |
310 | case EXTENDED_ALL: | 306 | case EXTENDED_ALL: |
311 | text = tr("All Files"); | 307 | text = tr("All Files"); |
312 | break; | 308 | break; |
313 | } | 309 | } |
314 | slotViewCheck( text ); | 310 | slotViewCheck( text ); |
315 | } | 311 | } |
316 | 312 | ||
317 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) | 313 | void OFileSelector::setPopupMenu(QPopupMenu *popup ) |
318 | { | 314 | { |
319 | m_custom = popup; | 315 | m_custom = popup; |
320 | m_showPopup = true; | 316 | m_showPopup = true; |
321 | } | 317 | } |
322 | 318 | ||
323 | //void OFileSelector::updateL | 319 | //void OFileSelector::updateL |
324 | 320 | ||
325 | QString OFileSelector::selectedName() const | 321 | QString OFileSelector::selectedName() const |
326 | { | 322 | { |
327 | QString name; | 323 | QString name; |
328 | if( m_selector == NORMAL ){ | 324 | if( m_selector == NORMAL ){ |
329 | const DocLnk *lnk = m_select->selected(); | 325 | DocLnk lnk = m_select->selectedDocument(); |
330 | name = lnk->file(); | 326 | name = lnk.file(); |
331 | delete lnk; | ||
332 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 327 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
333 | if ( m_shLne ) { | 328 | if ( m_shLne ) { |
334 | name = m_currentDir + "/" +m_edit->text(); | 329 | name = m_currentDir + "/" +m_edit->text(); |
335 | }else{ | 330 | }else{ |
336 | QListViewItem *item = m_View->currentItem(); | 331 | QListViewItem *item = m_View->currentItem(); |
337 | if( item != 0 ) | 332 | if( item != 0 ) |
338 | name = m_currentDir + "/" + item->text( 1 ); | 333 | name = m_currentDir + "/" + item->text( 1 ); |
339 | } | 334 | } |
340 | }else { // installed view | 335 | }else { // installed view |
341 | ; | 336 | ; |
342 | } | 337 | } |
343 | return name; | 338 | return name; |
344 | } | 339 | } |
345 | QStringList OFileSelector::selectedNames()const | 340 | QStringList OFileSelector::selectedNames()const |
346 | { | 341 | { |
347 | QStringList list; | 342 | QStringList list; |
348 | if( m_selector == NORMAL ){ | 343 | if( m_selector == NORMAL ){ |
349 | list << selectedName(); | 344 | list << selectedName(); |
350 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 345 | }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
351 | list << selectedName(); // FIXME implement multiple Selections | 346 | list << selectedName(); // FIXME implement multiple Selections |
352 | } | 347 | } |
353 | return list; | 348 | return list; |
354 | } | 349 | } |
355 | /** If mode is set to the Dir selection this will return the selected path. | 350 | /** If mode is set to the Dir selection this will return the selected path. |
356 | * | 351 | * |
357 | * | 352 | * |
358 | */ | 353 | */ |
359 | QString OFileSelector::selectedPath()const | 354 | QString OFileSelector::selectedPath()const |
360 | { | 355 | { |
361 | QString path; | 356 | QString path; |
362 | if( m_selector == NORMAL ){ | 357 | if( m_selector == NORMAL ){ |
363 | path = QPEApplication::documentDir(); | 358 | path = QPEApplication::documentDir(); |
364 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 359 | }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
365 | ; | 360 | ; |
366 | } | 361 | } |
367 | return path; | 362 | return path; |
368 | } | 363 | } |
369 | QStringList OFileSelector::selectedPaths() const | 364 | QStringList OFileSelector::selectedPaths() const |
370 | { | 365 | { |
371 | QStringList list; | 366 | QStringList list; |
372 | list << selectedPath(); | 367 | list << selectedPath(); |
373 | return list; | 368 | return list; |
374 | } | 369 | } |
375 | QString OFileSelector::directory()const | 370 | QString OFileSelector::directory()const |
376 | { | 371 | { |
377 | if( m_selector == NORMAL ) | 372 | if( m_selector == NORMAL ) |
378 | return QPEApplication::documentDir(); | 373 | return QPEApplication::documentDir(); |
379 | 374 | ||
380 | return QDir(m_currentDir).absPath(); | 375 | return QDir(m_currentDir).absPath(); |
381 | } | 376 | } |
382 | 377 | ||
383 | int OFileSelector::fileCount() | 378 | int OFileSelector::fileCount() |
384 | { | 379 | { |
385 | int count; | 380 | int count; |
386 | switch( m_selector ){ | 381 | switch( m_selector ){ |
387 | case NORMAL: | 382 | case NORMAL: |
388 | count = m_select->fileCount(); | 383 | count = m_select->fileCount(); |
389 | break; | 384 | break; |
390 | //case CUSTOM: | 385 | //case CUSTOM: |
391 | case EXTENDED: | 386 | case EXTENDED: |
392 | case EXTENDED_ALL: | 387 | case EXTENDED_ALL: |
393 | default: | 388 | default: |
394 | count = m_View->childCount(); | 389 | count = m_View->childCount(); |
395 | break; | 390 | break; |
396 | } | 391 | } |
397 | return count; | 392 | return count; |
398 | } | 393 | } |
399 | DocLnk OFileSelector::selectedDocument() const | 394 | DocLnk OFileSelector::selectedDocument() const |
400 | { | 395 | { |
401 | DocLnk lnk; | 396 | DocLnk lnk; |
402 | switch( m_selector ){ | 397 | switch( m_selector ){ |
403 | case NORMAL:{ | 398 | case NORMAL:{ |
404 | const DocLnk *lnk2 = m_select->selected(); | 399 | lnk = m_select->selectedDocument(); |
405 | lnk = DocLnk(*lnk2 ); // copy | ||
406 | delete lnk2; | ||
407 | break; | 400 | break; |
408 | } | 401 | } |
409 | case EXTENDED: | 402 | case EXTENDED: |
410 | case EXTENDED_ALL: | 403 | case EXTENDED_ALL: |
411 | default: | 404 | default: |
412 | lnk = DocLnk( selectedName() ); // new DocLnk | 405 | lnk = DocLnk( selectedName() ); // new DocLnk |
413 | break; | 406 | break; |
414 | } | 407 | } |
415 | return lnk; | 408 | return lnk; |
416 | } | 409 | } |
417 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 410 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
418 | { | 411 | { |
419 | QValueList<DocLnk> docs; | 412 | QValueList<DocLnk> docs; |
420 | docs.append( selectedDocument() ); | 413 | docs.append( selectedDocument() ); |
421 | return docs; | 414 | return docs; |
422 | } | 415 | } |
423 | 416 | ||
424 | 417 | ||
425 | // slots internal | 418 | // slots internal |
426 | 419 | ||
427 | void OFileSelector::slotOk() | 420 | void OFileSelector::slotOk() |
428 | { | 421 | { |
429 | emit ok(); | 422 | emit ok(); |
430 | } | 423 | } |
431 | void OFileSelector::slotCancel() | 424 | void OFileSelector::slotCancel() |
432 | { | 425 | { |
433 | emit cancel(); | 426 | emit cancel(); |
434 | } | 427 | } |
435 | void OFileSelector::slotViewCheck(const QString &sel) | 428 | void OFileSelector::slotViewCheck(const QString &sel) |
436 | { | 429 | { |
437 | if( sel == tr("Documents" ) ){ | 430 | if( sel == tr("Documents" ) ){ |
438 | if( m_select == 0 ){ | 431 | if( m_select == 0 ){ |
439 | // autMime? fix cause now we use All and not the current | 432 | // autMime? fix cause now we use All and not the current |
440 | // yes currentMime fixes that for us | 433 | // yes currentMime fixes that for us |
441 | QString mime = currentMimeType(); | 434 | QString mime = currentMimeType(); |
442 | m_select = new FileSelector(mime, | 435 | m_select = new FileSelector(mime, |
443 | m_stack, "fileselector", | 436 | m_stack, "fileselector", |
444 | m_shNew, m_shClose); | 437 | m_shNew, m_shClose); |
445 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 438 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
446 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 439 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
447 | connect(m_select, SIGNAL(closeMe() ), | 440 | connect(m_select, SIGNAL(closeMe() ), |
448 | this, SIGNAL(closeMe() ) ); | 441 | this, SIGNAL(closeMe() ) ); |
449 | //connect to close me and other signals as well | 442 | //connect to close me and other signals as well |
450 | 443 | ||
451 | m_stack->addWidget( m_select, NORMAL ); | 444 | m_stack->addWidget( m_select, NORMAL ); |
452 | } | 445 | } |
453 | m_stack->raiseWidget( NORMAL ); | 446 | m_stack->raiseWidget( NORMAL ); |
454 | m_selector = NORMAL; | 447 | m_selector = NORMAL; |
455 | }else if( sel == tr("Files") ){ | 448 | }else if( sel == tr("Files") ){ |
456 | m_selector = EXTENDED; | 449 | m_selector = EXTENDED; |
457 | initializeListView(); | 450 | initializeListView(); |
458 | reparse(); | 451 | reparse(); |
459 | m_stack->raiseWidget( EXTENDED ); | 452 | m_stack->raiseWidget( EXTENDED ); |
460 | }else if( sel == tr("All Files") ){ | 453 | }else if( sel == tr("All Files") ){ |
461 | m_selector = EXTENDED_ALL; | 454 | m_selector = EXTENDED_ALL; |
462 | initializeListView(); | 455 | initializeListView(); |
463 | reparse(); | 456 | reparse(); |
464 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter | 457 | m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter |
465 | } | 458 | } |
466 | } | 459 | } |
467 | // not yet finished..... | 460 | // not yet finished..... |
468 | QString OFileSelector::currentMimeType() const{ | 461 | QString OFileSelector::currentMimeType() const{ |
469 | QString mime; | 462 | QString mime; |
470 | QString currentText; | 463 | QString currentText; |
471 | if (m_shChooser ) | 464 | if (m_shChooser ) |
472 | currentText = m_mimeCheck->currentText(); | 465 | currentText = m_mimeCheck->currentText(); |
473 | 466 | ||
474 | if (tr("All") == currentText ) return QString::null; | 467 | if (tr("All") == currentText ) return QString::null; |
475 | else if (currentText.isEmpty() ) { | 468 | else if (currentText.isEmpty() ) { |
476 | ; | 469 | ; |
477 | }else { | 470 | }else { |
478 | QMap<QString, QStringList>::ConstIterator it; | 471 | QMap<QString, QStringList>::ConstIterator it; |
479 | it = m_mimetypes.find( currentText ); | 472 | it = m_mimetypes.find( currentText ); |
480 | if ( it == m_mimetypes.end() ) { | 473 | if ( it == m_mimetypes.end() ) { |
481 | mime = it.data().join(";"); | 474 | mime = it.data().join(";"); |
482 | }else{ | 475 | }else{ |
483 | mime = currentText; | 476 | mime = currentText; |
484 | } | 477 | } |
485 | } | 478 | } |
486 | return mime; | 479 | return mime; |
487 | } | 480 | } |
488 | void OFileSelector::slotMimeCheck(const QString &mime) | 481 | void OFileSelector::slotMimeCheck(const QString &mime) |
489 | { | 482 | { |
490 | if( m_selector == NORMAL ){ | 483 | if( m_selector == NORMAL ){ |
491 | //if( m_autoMime ){ | 484 | //if( m_autoMime ){ |
492 | QString newMimeType; | 485 | QString newMimeType; |
493 | if (mime != tr("All") ) { | 486 | if (mime != tr("All") ) { |
494 | QMap<QString, QStringList>::Iterator it; | 487 | QMap<QString, QStringList>::Iterator it; |
495 | it = m_mimetypes.find(mime); | 488 | it = m_mimetypes.find(mime); |
496 | if ( it != m_mimetypes.end() ) { | 489 | if ( it != m_mimetypes.end() ) { |
497 | newMimeType = it.data().join(";"); | 490 | newMimeType = it.data().join(";"); |
498 | }else{ | 491 | }else{ |
499 | newMimeType = mime; | 492 | newMimeType = mime; |
500 | } | 493 | } |
501 | } | 494 | } |
502 | delete m_select; | 495 | delete m_select; |
503 | m_select = new FileSelector( newMimeType, | 496 | m_select = new FileSelector( newMimeType, |
504 | m_stack, "fileselector", | 497 | m_stack, "fileselector", |
505 | m_shNew, m_shClose); | 498 | m_shNew, m_shClose); |
506 | 499 | ||
507 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 500 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
508 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 501 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
509 | connect(m_select, SIGNAL(closeMe() ), | 502 | connect(m_select, SIGNAL(closeMe() ), |
510 | this, SIGNAL(closeMe() ) ); | 503 | this, SIGNAL(closeMe() ) ); |
511 | //connect to close me and other signals as well | 504 | //connect to close me and other signals as well |
512 | m_stack->addWidget( m_select, NORMAL ); | 505 | m_stack->addWidget( m_select, NORMAL ); |
513 | m_stack->raiseWidget( NORMAL ); | 506 | m_stack->raiseWidget( NORMAL ); |
514 | updateMimes(); | 507 | updateMimes(); |
515 | updateMimeCheck(); | 508 | updateMimeCheck(); |
516 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 509 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
517 | //} | 510 | //} |
518 | }else{ // others | 511 | }else{ // others |
519 | qWarning("Mime %s", mime.latin1() ); | 512 | qWarning("Mime %s", mime.latin1() ); |
520 | if(m_shChooser ){ | 513 | if(m_shChooser ){ |
521 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 514 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
522 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 515 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
523 | } | 516 | } |
524 | reparse(); | 517 | reparse(); |
525 | } | 518 | } |
526 | 519 | ||
527 | } | 520 | } |
528 | /* | 521 | /* |
529 | * Ok if a non dir gets inserted into this combobox | 522 | * Ok if a non dir gets inserted into this combobox |
530 | * we need to change it | 523 | * we need to change it |
531 | * QFileInfo and dirPath will give us the right Dir | 524 | * QFileInfo and dirPath will give us the right Dir |
532 | */ | 525 | */ |
533 | void OFileSelector::slotLocationActivated(const QString &file) | 526 | void OFileSelector::slotLocationActivated(const QString &file) |
534 | { | 527 | { |
535 | qWarning("slotLocationActivated"); | 528 | qWarning("slotLocationActivated"); |
536 | QString name = file.left( file.find("<-", 0, TRUE ) ); | 529 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
537 | QFileInfo info( name ); | 530 | QFileInfo info( name ); |
538 | if ( info.isFile() ) | 531 | if ( info.isFile() ) |
539 | cd(info.dirPath( TRUE ) ); //absolute | 532 | cd(info.dirPath( TRUE ) ); //absolute |
540 | else | 533 | else |
541 | cd(name ); | 534 | cd(name ); |
542 | reparse(); | 535 | reparse(); |
543 | } | 536 | } |
544 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 537 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
545 | { | 538 | { |
546 | QStringList pathList; | 539 | QStringList pathList; |
547 | bool underDog = FALSE; | 540 | bool underDog = FALSE; |
548 | for(int i=0;i<count;i++) { | 541 | for(int i=0;i<count;i++) { |
549 | pathList << m_location->text(i); | 542 | pathList << m_location->text(i); |
550 | if( m_location->text(i) == currentPath) | 543 | if( m_location->text(i) == currentPath) |
551 | underDog = TRUE; | 544 | underDog = TRUE; |
552 | } | 545 | } |
553 | if( !underDog) { | 546 | if( !underDog) { |
554 | m_location->clear(); | 547 | m_location->clear(); |
555 | if( currentPath.left(2)=="//") | 548 | if( currentPath.left(2)=="//") |
556 | pathList.append( currentPath.right(currentPath.length()-1) ); | 549 | pathList.append( currentPath.right(currentPath.length()-1) ); |
557 | else | 550 | else |
558 | pathList.append( currentPath ); | 551 | pathList.append( currentPath ); |
559 | m_location->insertStringList( pathList,-1); | 552 | m_location->insertStringList( pathList,-1); |
560 | } | 553 | } |
561 | } | 554 | } |
562 | /* | 555 | /* |
563 | * Do not crash anymore | 556 | * Do not crash anymore |
564 | * don't try to change dir to a file | 557 | * don't try to change dir to a file |
565 | */ | 558 | */ |
566 | void OFileSelector::locationComboChanged() | 559 | void OFileSelector::locationComboChanged() |
567 | { | 560 | { |
568 | QFileInfo info( m_location->lineEdit()->text() ); | 561 | QFileInfo info( m_location->lineEdit()->text() ); |
569 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | 562 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
570 | if (info.isFile() ) | 563 | if (info.isFile() ) |
571 | cd(info.dirPath(TRUE) ); //absolute path | 564 | cd(info.dirPath(TRUE) ); //absolute path |
572 | else | 565 | else |
573 | cd( m_location->lineEdit()->text() ); | 566 | cd( m_location->lineEdit()->text() ); |
574 | 567 | ||
575 | reparse(); | 568 | reparse(); |
576 | } | 569 | } |
577 | void OFileSelector::init() | 570 | void OFileSelector::init() |
578 | { | 571 | { |
579 | m_lay = new QVBoxLayout( this ); | 572 | m_lay = new QVBoxLayout( this ); |
580 | m_lay->setSpacing(0 ); | 573 | m_lay->setSpacing(0 ); |
581 | 574 | ||
582 | m_stack = new QWidgetStack( this ); | 575 | m_stack = new QWidgetStack( this ); |
583 | if( m_selector == NORMAL ){ | 576 | if( m_selector == NORMAL ){ |
584 | QString mime; | 577 | QString mime; |
585 | if (!m_autoMime) { | 578 | if (!m_autoMime) { |
586 | if (!m_mimetypes.isEmpty() ) { | 579 | if (!m_mimetypes.isEmpty() ) { |
587 | QMap<QString, QStringList>::Iterator it; | 580 | QMap<QString, QStringList>::Iterator it; |
588 | it = m_mimetypes.begin(); // cause we're in the init | 581 | it = m_mimetypes.begin(); // cause we're in the init |
589 | mime = it.data().join(";"); | 582 | mime = it.data().join(";"); |
590 | } | 583 | } |
591 | } | 584 | } |
592 | m_select = new FileSelector(mime, | 585 | m_select = new FileSelector(mime, |
593 | m_stack, "fileselector", | 586 | m_stack, "fileselector", |
594 | m_shNew, m_shClose); | 587 | m_shNew, m_shClose); |
595 | 588 | ||
596 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), | 589 | connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), |
597 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); | 590 | this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); |
598 | connect(m_select, SIGNAL(closeMe() ), | 591 | connect(m_select, SIGNAL(closeMe() ), |
diff --git a/libopie/ofileview.h b/libopie/ofileview.h index ed256f1..e072477 100644 --- a/libopie/ofileview.h +++ b/libopie/ofileview.h | |||
@@ -1,79 +1,87 @@ | |||
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 | 34 | ||
35 | class QFileInfo; | 35 | class QFileInfo; |
36 | class QDir; | 36 | class QDir; |
37 | class DocLnk; | 37 | class DocLnk; |
38 | class OFileSelectorView : public QWidget { | 38 | |
39 | /** | ||
40 | * A OFileView is a specialised View for the | ||
41 | * OFileSelector | ||
42 | * With a View you can chage the user visible | ||
43 | * representation of a OFileLister | ||
44 | * OFileView is just a basic interface which helps you to | ||
45 | * write new views | ||
46 | */ | ||
47 | class OFileView { | ||
39 | Q_OBJECT | 48 | Q_OBJECT |
40 | public: | 49 | public: |
41 | OFileSelectorView(QWidget *widget, | 50 | OFileView(QWidget *widget, |
42 | const char *name ) | 51 | const char *name ); |
43 | : QWidget(widget, name ) | 52 | virtual OFileView(); |
44 | { }; | ||
45 | virtual ~OFileSelectorView() = 0; | 53 | virtual ~OFileSelectorView() = 0; |
46 | 54 | ||
47 | virtual void addFile(const QString &mine, | 55 | virtual void addFile(const QString &mine, |
48 | QFileInfo *info, | 56 | QFileInfo *info, |
49 | bool isSymlink = FALSE ) = 0; | 57 | bool isSymlink = FALSE ) = 0; |
50 | 58 | ||
51 | virtual void addDir (const QString &mine, | 59 | virtual void addDir (const QString &mine, |
52 | QFileInfo *info, | 60 | QFileInfo *info, |
53 | bool isSymlink = FALSE ) = 0; | 61 | bool isSymlink = FALSE ) = 0; |
54 | 62 | ||
55 | virtual void addSymlink(const QString &mime, | 63 | virtual void addSymlink(const QString &mime, |
56 | QFileInfo *info, | 64 | QFileInfo *info, |
57 | bool isSymlink = FALSE ) = 0; | 65 | bool isSymlink = FALSE ) = 0; |
58 | 66 | ||
59 | virtual void cd(const QString &path ) = 0; | 67 | virtual void cd(const QString &path ) = 0; |
60 | signals: | 68 | signals: |
61 | void fileSelected(const QString &); | 69 | void fileSelected(const QString &); |
62 | void fileSelected(const DocLnk & ); | 70 | void fileSelected(const DocLnk & ); |
63 | void contextMenu(); | 71 | void contextMenu(); |
64 | void changedDir(const QString &); | 72 | void changedDir(const QString &); |
65 | void changedDir(const QDir & ); | 73 | void changedDir(const QDir & ); |
66 | }; | 74 | }; |
67 | 75 | ||
68 | class OFileViewFactory { | 76 | class OFileViewFactory { |
69 | // Q_OBJECT | 77 | // Q_OBJECT |
70 | public: | 78 | public: |
71 | OFileViewFactory() {} ; | 79 | OFileViewFactory() {} ; |
72 | virtual ~OFileViewFactory() = 0; | 80 | virtual ~OFileViewFactory() = 0; |
73 | 81 | ||
74 | OFileSelectorView* newView(QWidget *parent, const char *name ); | 82 | OFileSelectorView* newView(QWidget *parent, const char *name ); |
75 | QString name()const; | 83 | QString name()const; |
76 | }; | 84 | }; |
77 | 85 | ||
78 | 86 | ||
79 | #endif | 87 | #endif |
diff --git a/libopie/ofontmenu.h b/libopie/ofontmenu.h index 609f240..5fd515f 100644 --- a/libopie/ofontmenu.h +++ b/libopie/ofontmenu.h | |||
@@ -1,83 +1,83 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | 3 | ||
4 | =. This file is part of the OPIE Project | 4 | =. This file is part of the OPIE Project |
5 | .=l. Copyright (c) 2002 zekce <zecke@handhelds.org> | 5 | .=l. Copyright (c) 2002 zecke <zecke@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This library is free software; you can | 7 | _;:, .> :=|. This library is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This library is distributed in the hope that | 14 | .i_,=:_. -<s. This library is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | 28 | ||
29 | */ | 29 | */ |
30 | 30 | ||
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | #ifndef ofontmenu_h | 34 | #ifndef ofontmenu_h |
35 | #define ofontmenu_h | 35 | #define ofontmenu_h |
36 | 36 | ||
37 | #include <qpopupmenu.h> | 37 | #include <qpopupmenu.h> |
38 | #include <qlist.h> | 38 | #include <qlist.h> |
39 | 39 | ||
40 | 40 | ||
41 | namespace { | 41 | namespace { |
42 | struct WidSize { | 42 | struct WidSize { |
43 | QWidget *wid; | 43 | QWidget *wid; |
44 | int size; | 44 | int size; |
45 | }; | 45 | }; |
46 | 46 | ||
47 | }; | 47 | }; |
48 | 48 | ||
49 | // if i would be on kde this would be a KActionMenu... | 49 | // if i would be on kde this would be a KActionMenu... |
50 | class Config; | 50 | class Config; |
51 | class OFontMenu : public QPopupMenu { | 51 | class OFontMenu : public QPopupMenu { |
52 | Q_OBJECT | 52 | Q_OBJECT |
53 | public: | 53 | public: |
54 | OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); | 54 | OFontMenu(QWidget *parent, const char* name, const QList<QWidget> &list ); |
55 | void save(Config *cfg ); | 55 | void save(Config *cfg ); |
56 | void restore(Config *cfg ); | 56 | void restore(Config *cfg ); |
57 | void setWidgets(const QList<QWidget> &list ); | 57 | void setWidgets(const QList<QWidget> &list ); |
58 | void addWidget(QWidget *wid ); | 58 | void addWidget(QWidget *wid ); |
59 | void forceSize(QWidget *wid, int size ); | 59 | void forceSize(QWidget *wid, int size ); |
60 | void removeWidget(QWidget *wid ); | 60 | void removeWidget(QWidget *wid ); |
61 | const QList<QWidget> &widgets()const; | 61 | const QList<QWidget> &widgets()const; |
62 | 62 | ||
63 | signals: | 63 | signals: |
64 | void fontChanged(int size ); | 64 | void fontChanged(int size ); |
65 | private: | 65 | private: |
66 | QList<QWidget> m_list; | 66 | QList<QWidget> m_list; |
67 | QList<WidSize> m_wids; | 67 | QList<WidSize> m_wids; |
68 | int m_size; | 68 | int m_size; |
69 | class OFontMenuPrivate; | 69 | class OFontMenuPrivate; |
70 | OFontMenuPrivate *d; | 70 | OFontMenuPrivate *d; |
71 | private slots: | 71 | private slots: |
72 | virtual void slotSmall(); | 72 | virtual void slotSmall(); |
73 | virtual void slotMedium(); | 73 | virtual void slotMedium(); |
74 | virtual void slotLarge(); | 74 | virtual void slotLarge(); |
75 | void setFontSize(int size ); | 75 | void setFontSize(int size ); |
76 | }; | 76 | }; |
77 | 77 | ||
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | 80 | ||
81 | 81 | ||
82 | 82 | ||
83 | 83 | ||