-rw-r--r-- | libopie/ofileselector.cc | 49 | ||||
-rw-r--r-- | libopie/ofileselector.h | 49 |
2 files changed, 49 insertions, 49 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 3a11032..0a6e595 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -52,49 +52,96 @@ | |||
52 | #include <qpe/mimetype.h> | 52 | #include <qpe/mimetype.h> |
53 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
54 | #include <qpe/storage.h> | 54 | #include <qpe/storage.h> |
55 | 55 | ||
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <sys/stat.h> | 58 | #include <sys/stat.h> |
59 | 59 | ||
60 | #include "ofileselector.h" | 60 | #include "ofileselector.h" |
61 | 61 | ||
62 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 62 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
63 | 63 | ||
64 | namespace { | 64 | namespace { |
65 | 65 | ||
66 | int indexByString( const QComboBox *box, const QString &str ){ | 66 | int indexByString( const QComboBox *box, const QString &str ){ |
67 | int index= -1; | 67 | int index= -1; |
68 | for(int i= 0; i < box->count(); i++ ){ | 68 | for(int i= 0; i < box->count(); i++ ){ |
69 | if( str == box->text(i ) ){ | 69 | if( str == box->text(i ) ){ |
70 | index= i; | 70 | index= i; |
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | } | 73 | } |
74 | return index; | 74 | return index; |
75 | } | 75 | } |
76 | 76 | class OFileSelectorItem : public QListViewItem { | |
77 | public: | ||
78 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | ||
79 | const QString &date, const QString &size, const QString &mDir, | ||
80 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | ||
81 | setPixmap(0, pixmap ); | ||
82 | setText(1, path ); | ||
83 | setText(2, size ); | ||
84 | setText(3, date ); | ||
85 | //setText(4, mDir ); | ||
86 | m_dir = mDir; | ||
87 | dir = isDir; | ||
88 | mLocked = isLocked; | ||
89 | } | ||
90 | bool isLocked() const{ | ||
91 | return mLocked; | ||
92 | } | ||
93 | QString directory()const{ | ||
94 | return m_dir; | ||
95 | } | ||
96 | bool isDir()const{ | ||
97 | return dir; | ||
98 | } | ||
99 | QString path()const{ | ||
100 | return text(1 ); | ||
101 | } | ||
102 | QString key(int id, bool )const { | ||
103 | QString ke; | ||
104 | if( id == 0 || id == 1 ){ // name | ||
105 | if( dir ){ | ||
106 | ke.append("0" ); | ||
107 | ke.append( text(1) ); | ||
108 | }else{ | ||
109 | ke.append("1" ); | ||
110 | ke.append( text(1) ); | ||
111 | } | ||
112 | }else if( id == 2 ){ // size | ||
113 | return text(2); | ||
114 | }else if( id == 3 ){ // date | ||
115 | return text(3); | ||
116 | } | ||
117 | return ke; | ||
118 | }; | ||
119 | private: | ||
120 | bool mLocked:1; | ||
121 | bool dir:1; | ||
122 | QString m_dir; | ||
123 | }; | ||
77 | }; | 124 | }; |
78 | 125 | ||
79 | 126 | ||
80 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, | 127 | OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, |
81 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) | 128 | const QString &fileName, const QStringList &mimetypes ) : QWidget( wid ) |
82 | { | 129 | { |
83 | if(wid!=0) | 130 | if(wid!=0) |
84 | resize(wid->width(),wid->height()); | 131 | resize(wid->width(),wid->height()); |
85 | m_selector = selector; | 132 | m_selector = selector; |
86 | m_currentDir = dirName; | 133 | m_currentDir = dirName; |
87 | m_name = fileName; | 134 | m_name = fileName; |
88 | m_mimetypes = mimetypes; | 135 | m_mimetypes = mimetypes; |
89 | 136 | ||
90 | if( mimetypes.isEmpty() ) | 137 | if( mimetypes.isEmpty() ) |
91 | m_autoMime = true; | 138 | m_autoMime = true; |
92 | 139 | ||
93 | qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); | 140 | qWarning("OFileSelector mimetypes %s", mimetypes.join(" ").latin1() ); |
94 | m_mode = mode; | 141 | m_mode = mode; |
95 | m_shTool = true; | 142 | m_shTool = true; |
96 | m_shPerm = true; | 143 | m_shPerm = true; |
97 | m_shLne = true; | 144 | m_shLne = true; |
98 | m_shChooser = true; | 145 | m_shChooser = true; |
99 | m_shYesNo = true; | 146 | m_shYesNo = true; |
100 | 147 | ||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index babe09f..8173d76 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -43,96 +43,49 @@ | |||
43 | 43 | ||
44 | #include <qpe/applnk.h> | 44 | #include <qpe/applnk.h> |
45 | #include <qlistview.h> | 45 | #include <qlistview.h> |
46 | /** This is OPIEs FileDialog Widget. You can use it | 46 | /** This is OPIEs FileDialog Widget. You can use it |
47 | * as a dropin replacement of the fileselector and | 47 | * as a dropin replacement of the fileselector and |
48 | * or use any of the new features. | 48 | * or use any of the new features. |
49 | * This is also a complete FileSave and FileLoad widget | 49 | * This is also a complete FileSave and FileLoad widget |
50 | * If you look for a Dialog check OFileDialog | 50 | * If you look for a Dialog check OFileDialog |
51 | * | 51 | * |
52 | */ | 52 | */ |
53 | class DocLnk; | 53 | class DocLnk; |
54 | class QCheckBox; | 54 | class QCheckBox; |
55 | class QComboBox; | 55 | class QComboBox; |
56 | class QPushButton; | 56 | class QPushButton; |
57 | class FileSelector; | 57 | class FileSelector; |
58 | class QGridLayout; | 58 | class QGridLayout; |
59 | class QLineEdit; | 59 | class QLineEdit; |
60 | class QLabel; | 60 | class QLabel; |
61 | class QWidgetStack; | 61 | class QWidgetStack; |
62 | class QHBoxLayout; | 62 | class QHBoxLayout; |
63 | class QVBoxLayout; | 63 | class QVBoxLayout; |
64 | class QPopupMenu; | 64 | class QPopupMenu; |
65 | class QFileInfo; | 65 | class QFileInfo; |
66 | // | 66 | // |
67 | class OFileSelectorItem : public QListViewItem { | 67 | |
68 | public: | ||
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | ||
70 | const QString &date, const QString &size, const QString &mDir, | ||
71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | ||
72 | setPixmap(0, pixmap ); | ||
73 | setText(1, path ); | ||
74 | setText(2, size ); | ||
75 | setText(3, date ); | ||
76 | //setText(4, mDir ); | ||
77 | m_dir = mDir; | ||
78 | dir = isDir; | ||
79 | mLocked = isLocked; | ||
80 | } | ||
81 | bool isLocked() const{ | ||
82 | return mLocked; | ||
83 | } | ||
84 | QString directory()const{ | ||
85 | return m_dir; | ||
86 | } | ||
87 | bool isDir()const{ | ||
88 | return dir; | ||
89 | } | ||
90 | QString path()const{ | ||
91 | return text(1 ); | ||
92 | } | ||
93 | QString key(int id, bool )const { | ||
94 | QString ke; | ||
95 | if( id == 0 || id == 1 ){ // name | ||
96 | if( dir ){ | ||
97 | ke.append("0" ); | ||
98 | ke.append( text(1) ); | ||
99 | }else{ | ||
100 | ke.append("1" ); | ||
101 | ke.append( text(1) ); | ||
102 | } | ||
103 | }else if( id == 2 ){ // size | ||
104 | return text(2); | ||
105 | }else if( id == 3 ){ // date | ||
106 | return text(3); | ||
107 | } | ||
108 | return ke; | ||
109 | }; | ||
110 | private: | ||
111 | bool mLocked:1; | ||
112 | bool dir:1; | ||
113 | QString m_dir; | ||
114 | }; | ||
115 | 68 | ||
116 | class OFileSelector : public QWidget { | 69 | class OFileSelector : public QWidget { |
117 | Q_OBJECT | 70 | Q_OBJECT |
118 | public: | 71 | public: |
119 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; | 72 | enum Mode {OPEN=1, SAVE=2, FILESELECTOR=4, DIR=8 }; |
120 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; | 73 | enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 }; |
121 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; | 74 | enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 }; |
122 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList &mimetypes = QStringList() ); | 75 | OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList &mimetypes = QStringList() ); |
123 | ~OFileSelector() {}; | 76 | ~OFileSelector() {}; |
124 | bool isToolbarVisible() const { return m_shTool; }; | 77 | bool isToolbarVisible() const { return m_shTool; }; |
125 | bool isPermissionBarVisible() const { return m_shPerm; }; | 78 | bool isPermissionBarVisible() const { return m_shPerm; }; |
126 | bool isLineEditVisible()const { return m_shLne; }; | 79 | bool isLineEditVisible()const { return m_shLne; }; |
127 | bool isChooserVisible( )const { return m_shChooser; }; | 80 | bool isChooserVisible( )const { return m_shChooser; }; |
128 | bool isYesCancelVisible()const { return m_shYesNo; }; | 81 | bool isYesCancelVisible()const { return m_shYesNo; }; |
129 | void setYesCancelVisible( bool show ); | 82 | void setYesCancelVisible( bool show ); |
130 | void setToolbarVisible( bool show ); | 83 | void setToolbarVisible( bool show ); |
131 | void setPermissionBarVisible( bool show ); | 84 | void setPermissionBarVisible( bool show ); |
132 | void setLineEditVisible(bool show) ; | 85 | void setLineEditVisible(bool show) ; |
133 | void setChooserVisible( bool chooser ); | 86 | void setChooserVisible( bool chooser ); |
134 | 87 | ||
135 | QCheckBox* permissionCheckbox(); | 88 | QCheckBox* permissionCheckbox(); |
136 | bool setPermission() const; | 89 | bool setPermission() const; |
137 | void setPermissionChecked( bool check ); | 90 | void setPermissionChecked( bool check ); |
138 | 91 | ||