author | alwin <alwin> | 2004-02-22 01:07:49 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-22 01:07:49 (UTC) |
commit | 3d3972ee1de2fe930dd32bcfe13a3a4f486f6ac5 (patch) (unidiff) | |
tree | 90f90bc883434cbd08ffc6c1777681609063398c | |
parent | a1b94ec1962ddb3fb699c81bf88da58b53c94375 (diff) | |
download | opie-3d3972ee1de2fe930dd32bcfe13a3a4f486f6ac5.zip opie-3d3972ee1de2fe930dd32bcfe13a3a4f486f6ac5.tar.gz opie-3d3972ee1de2fe930dd32bcfe13a3a4f486f6ac5.tar.bz2 |
now we can edit subdirs in .opiestorage.cf as used in launcher
or Global for searching for documents.
ToDo: Where to (re-)implement the stuff where the dialogs apears if a
media is inserted first time???? eg, no .opiestorage.cf exists on this
media? I didn't found any usefull :(
-rw-r--r-- | noncore/settings/mediummount/mediumwidget.cc | 49 | ||||
-rw-r--r-- | noncore/settings/mediummount/mediumwidget.h | 5 |
2 files changed, 49 insertions, 5 deletions
diff --git a/noncore/settings/mediummount/mediumwidget.cc b/noncore/settings/mediummount/mediumwidget.cc index 981e1dd..caa9559 100644 --- a/noncore/settings/mediummount/mediumwidget.cc +++ b/noncore/settings/mediummount/mediumwidget.cc | |||
@@ -1,192 +1,233 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qgroupbox.h> | 4 | #include <qgroupbox.h> |
5 | #include <qhbox.h> | 5 | #include <qhbox.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 <qpixmap.h> | 10 | #include <qpixmap.h> |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | #include <qvbox.h> | 12 | #include <qvbox.h> |
13 | #include <qwhatsthis.h> | 13 | #include <qwhatsthis.h> |
14 | #include <qcombobox.h> | ||
14 | 15 | ||
15 | 16 | ||
16 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
17 | #include <qpe/qpeapplication.h> | 18 | #include <qpe/qpeapplication.h> |
18 | 19 | ||
19 | #include "mediumwidget.h" | 20 | #include "mediumwidget.h" |
20 | 21 | ||
21 | 22 | ||
22 | 23 | ||
23 | using namespace MediumMountSetting; | 24 | using namespace MediumMountSetting; |
24 | 25 | ||
25 | /* TRANSLATOR MediumMountSetting::MediumMountWidget */ | 26 | /* TRANSLATOR MediumMountSetting::MediumMountWidget */ |
26 | 27 | ||
27 | MediumMountWidget::MediumMountWidget(const QString &path, | 28 | MediumMountWidget::MediumMountWidget(const QString &path, |
28 | const QPixmap &pix, | 29 | const QPixmap &pix, |
29 | QWidget *parent, | 30 | QWidget *parent, |
30 | const char *name ) | 31 | const char *name ) |
31 | : QWidget( parent, name ) | 32 | : QWidget( parent, name ) |
32 | { | 33 | { |
33 | if(parent == 0){ | 34 | if(parent == 0){ |
34 | resize(QApplication::desktop()->width(), QApplication::desktop()->height() ); | 35 | resize(QApplication::desktop()->width(), QApplication::desktop()->height() ); |
35 | }else{ | 36 | }else{ |
36 | resize(parent->width(), parent->height() ); | 37 | resize(parent->width(), parent->height() ); |
37 | } | 38 | } |
38 | m_path = path; | 39 | m_path = path; |
39 | initGUI(); | 40 | initGUI(); |
40 | m_label->setPixmap(pix ); | 41 | m_label->setPixmap(pix ); |
41 | m_config = 0; | 42 | m_config = 0; |
42 | 43 | ||
43 | readConfig(); | 44 | readConfig(); |
44 | } | 45 | } |
45 | // now we fire up the GUI | 46 | // now we fire up the GUI |
46 | // if I would know what I'm doing ;) | 47 | // if I would know what I'm doing ;) |
47 | void MediumMountWidget::initGUI() | 48 | void MediumMountWidget::initGUI() |
48 | { | 49 | { |
49 | //main layout | 50 | //main layout |
50 | m_box = new QVBoxLayout( this , 5, 5 ); | 51 | m_box = new QVBoxLayout( this , 5, 5 ); |
51 | //m_box->setSpacing( 5 ); | 52 | //m_box->setSpacing( 5 ); |
52 | //m_box->addStretch( -1 ); | 53 | //m_box->addStretch( -1 ); |
53 | 54 | ||
54 | // picture + text | 55 | // picture + text |
55 | m_infoBox = new QHBox(this, "infobox" ); | 56 | m_infoBox = new QHBox(this, "infobox" ); |
56 | //m_infoBox->setSpacing( 4 ); | 57 | //m_infoBox->setSpacing( 4 ); |
57 | m_label = new QLabel(m_infoBox ); | 58 | m_label = new QLabel(m_infoBox ); |
58 | m_desc = new QLabel(m_infoBox ); | 59 | m_desc = new QLabel(m_infoBox ); |
59 | m_desc->setTextFormat( Qt::RichText ); | 60 | m_desc->setTextFormat( Qt::RichText ); |
60 | QWhatsThis::add( this, tr("Configure this medium. The changes will" | 61 | QWhatsThis::add( this, tr("Configure this medium. The changes will" |
61 | " go into effect when the application gets" | 62 | " go into effect when the application gets" |
62 | " closed. To update the Document Tab you need" | 63 | " closed. To update the Document Tab you need" |
63 | " to remove and insert this medium.")); | 64 | " to remove and insert this medium.")); |
64 | m_desc->setText("" ); | 65 | m_desc->setText("" ); |
65 | m_box->addWidget( m_infoBox ); // add the widget to the layout | 66 | m_box->addWidget( m_infoBox ); // add the widget to the layout |
66 | 67 | ||
67 | 68 | ||
68 | // groupbox | 69 | // groupbox |
69 | m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" ); | 70 | m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" ); |
70 | m_checks = new QGridLayout( m_group, 4, 3 ); | 71 | m_checks = new QGridLayout( m_group, 4, 3 ); |
71 | //m_checks->setMargin( 12 ); | 72 | //m_checks->setMargin( 12 ); |
72 | 73 | ||
73 | 74 | ||
74 | 75 | ||
75 | QSpacerItem *item2 = new QSpacerItem(5, 8, | 76 | QSpacerItem *item2 = new QSpacerItem(5, 8, |
76 | QSizePolicy::Fixed, | 77 | QSizePolicy::Fixed, |
77 | QSizePolicy::Fixed); | 78 | QSizePolicy::Fixed); |
78 | m_box->addItem( item2 ); | 79 | m_box->addItem( item2 ); |
79 | 80 | ||
80 | m_audio = new QCheckBox( tr("Audio"), m_group ); | 81 | m_audio = new QCheckBox( tr("Audio"), m_group ); |
81 | m_all = new QCheckBox( tr("All") , m_group ); | 82 | m_all = new QCheckBox( tr("All") , m_group ); |
82 | m_image = new QCheckBox( tr("Image"), m_group ); | 83 | m_image = new QCheckBox( tr("Image"), m_group ); |
83 | m_text = new QCheckBox( tr("Text") , m_group ); | 84 | m_text = new QCheckBox( tr("Text") , m_group ); |
84 | m_video = new QCheckBox( tr("Video"), m_group ); | 85 | m_video = new QCheckBox( tr("Video"), m_group ); |
85 | 86 | ||
86 | QSpacerItem *iti1b = new QSpacerItem(2, 10, QSizePolicy::Fixed, | 87 | QSpacerItem *iti1b = new QSpacerItem(2, 10, QSizePolicy::Fixed, |
87 | QSizePolicy::Fixed ); | 88 | QSizePolicy::Fixed ); |
88 | m_checks->addItem( iti1b, 0, 0 ); | 89 | m_checks->addItem( iti1b, 0, 0 ); |
89 | 90 | ||
90 | m_checks->addWidget(m_audio, 1, 0 ); | 91 | m_checks->addWidget(m_audio, 1, 0 ); |
91 | m_checks->addWidget(m_image, 2, 0 ); | 92 | m_checks->addWidget(m_image, 2, 0 ); |
92 | m_checks->addWidget(m_all , 3, 0 ); | 93 | m_checks->addWidget(m_all , 3, 0 ); |
93 | 94 | ||
94 | m_checks->addWidget(m_text, 1, 2 ); | 95 | m_checks->addWidget(m_text, 1, 2 ); |
95 | m_checks->addWidget(m_video, 2, 2 ); | 96 | m_checks->addWidget(m_video, 2, 2 ); |
96 | 97 | ||
97 | m_checks->addRowSpacing(0, 8 ); | 98 | m_checks->addRowSpacing(0, 8 ); |
98 | m_checks->addColSpacing(1, 2 ); | 99 | m_checks->addColSpacing(1, 2 ); |
99 | m_checks->setColStretch(1, -2 ); | 100 | m_checks->setColStretch(1, -2 ); |
100 | 101 | ||
101 | connect(m_all, SIGNAL(stateChanged(int) ), | 102 | connect(m_all, SIGNAL(stateChanged(int) ), |
102 | this, SLOT(slotStateChanged() ) ); | 103 | this, SLOT(slotStateChanged() ) ); |
103 | 104 | ||
104 | m_box->addWidget( m_group ); | 105 | m_box->addWidget( m_group ); |
105 | 106 | ||
106 | // label | 107 | // label |
107 | m_lblPath = new QLabel(tr("Limit search to:"), this ); | 108 | m_lblPath = new QLabel(tr("Limit search to:"), this ); |
108 | m_box->addWidget( m_lblPath ); | 109 | m_box->addWidget( m_lblPath ); |
109 | 110 | ||
110 | // add to | 111 | |
112 | m_subList = new QComboBox(FALSE,this,"docFolderList"); | ||
113 | m_subList->setDuplicatesEnabled(FALSE); | ||
114 | m_subList->setEditable(TRUE); | ||
115 | m_box->addWidget(m_subList); | ||
116 | |||
111 | m_hboxAdd = new QHBox( this ); | 117 | m_hboxAdd = new QHBox( this ); |
112 | //m_hboxAdd->setSpacing( 10 ); | ||
113 | m_edit = new QLineEdit(m_hboxAdd ); | ||
114 | m_add = new QPushButton(m_hboxAdd ); | 118 | m_add = new QPushButton(m_hboxAdd ); |
115 | m_add->setText( tr("Add") ); | 119 | m_add->setText( tr("Add") ); |
120 | m_del = new QPushButton(m_hboxAdd); | ||
121 | m_del->setText(tr("Remove")); | ||
122 | |||
123 | connect(m_add, SIGNAL(clicked() ), | ||
124 | this, SLOT(slotAdd() ) ); | ||
125 | connect(m_del, SIGNAL(clicked() ), | ||
126 | this, SLOT(slotRemove() ) ); | ||
116 | 127 | ||
117 | m_box->addWidget(m_hboxAdd ); | 128 | m_box->addWidget(m_hboxAdd ); |
118 | 129 | ||
119 | m_always = new QCheckBox( tr("Always check this medium"), this ); | 130 | m_always = new QCheckBox( tr("Always check this medium"), this ); |
120 | 131 | ||
121 | m_box->addWidget( m_always ); | 132 | m_box->addWidget( m_always ); |
122 | 133 | ||
123 | QSpacerItem *item = new QSpacerItem(5, 50, | 134 | QSpacerItem *item = new QSpacerItem(5, 50, |
124 | QSizePolicy::Fixed, | 135 | QSizePolicy::Fixed, |
125 | QSizePolicy::Expanding ); | 136 | QSizePolicy::Expanding ); |
126 | m_box->addItem(item ); | 137 | m_box->addItem(item ); |
127 | } | 138 | } |
128 | 139 | ||
129 | void MediumMountWidget::readConfig( ) | 140 | void MediumMountWidget::readConfig( ) |
130 | { | 141 | { |
131 | if( m_config == 0 ) | 142 | if( m_config == 0 ) |
132 | m_config = new Config(m_path + "/.opiestorage.cf", Config::File ); | 143 | m_config = new Config(m_path + "/.opiestorage.cf", Config::File ); |
133 | m_config->setGroup( "main" ); | 144 | m_config->setGroup( "main" ); |
134 | 145 | ||
135 | m_always->setChecked( m_config->readBoolEntry("check", false) ); | 146 | m_always->setChecked( m_config->readBoolEntry("check", false) ); |
136 | 147 | ||
137 | m_config->setGroup( "mimetypes" ); | 148 | m_config->setGroup( "mimetypes" ); |
138 | if( m_config->readBoolEntry("all", false ) ){ | 149 | if( m_config->readBoolEntry("all", false ) ){ |
139 | m_audio->setEnabled( false ); | 150 | m_audio->setEnabled( false ); |
140 | m_image->setEnabled( false ); | 151 | m_image->setEnabled( false ); |
141 | m_text->setEnabled ( false ); | 152 | m_text->setEnabled ( false ); |
142 | m_video->setEnabled( false ); | 153 | m_video->setEnabled( false ); |
143 | m_all->setChecked( true ); | 154 | m_all->setChecked( true ); |
144 | }else{ | 155 | }else{ |
145 | m_audio->setEnabled( true ); | 156 | m_audio->setEnabled( true ); |
146 | m_image->setEnabled( true ); | 157 | m_image->setEnabled( true ); |
147 | m_text->setEnabled ( true ); | 158 | m_text->setEnabled ( true ); |
148 | m_all->setEnabled ( true ); | 159 | m_all->setEnabled ( true ); |
149 | 160 | ||
150 | m_all->setChecked( false ); | 161 | m_all->setChecked( false ); |
151 | 162 | ||
152 | m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); | 163 | m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); |
153 | m_image->setChecked( m_config->readBoolEntry("image", true ) ); | 164 | m_image->setChecked( m_config->readBoolEntry("image", true ) ); |
154 | m_text->setChecked ( m_config->readBoolEntry("text" , true ) ); | 165 | m_text->setChecked ( m_config->readBoolEntry("text" , true ) ); |
155 | m_video->setChecked( m_config->readBoolEntry("video", true ) ); | 166 | m_video->setChecked( m_config->readBoolEntry("video", true ) ); |
156 | }; | 167 | }; |
168 | m_config->setGroup("subdirs"); | ||
169 | QStringList entries = m_config->readListEntry("subdirs",':'); | ||
170 | m_subList->clear(); | ||
171 | m_subList->insertStringList(entries); | ||
157 | } | 172 | } |
158 | 173 | ||
159 | void MediumMountWidget::writeConfig() | 174 | void MediumMountWidget::writeConfig() |
160 | { | 175 | { |
161 | m_config->setGroup("main"); | 176 | m_config->setGroup("main"); |
162 | m_config->writeEntry("check", m_always->isChecked() ); | 177 | m_config->writeEntry("check", m_always->isChecked() ); |
163 | 178 | ||
164 | m_config->setGroup("mimetypes" ); | 179 | m_config->setGroup("mimetypes" ); |
165 | if(m_all->isChecked() ){ | 180 | if(m_all->isChecked() ){ |
166 | m_config->writeEntry("all", true ); | 181 | m_config->writeEntry("all", true ); |
167 | }else{ | 182 | }else{ |
168 | m_config->writeEntry("audio", m_audio->isChecked() ); | 183 | m_config->writeEntry("audio", m_audio->isChecked() ); |
169 | m_config->writeEntry("image", m_image->isChecked() ); | 184 | m_config->writeEntry("image", m_image->isChecked() ); |
170 | m_config->writeEntry("text" , m_text->isChecked() ); | 185 | m_config->writeEntry("text" , m_text->isChecked() ); |
171 | m_config->writeEntry("video", m_video->isChecked() ); | 186 | m_config->writeEntry("video", m_video->isChecked() ); |
172 | } | 187 | } |
188 | m_config->setGroup("subdirs"); | ||
189 | QStringList entries; | ||
190 | QString ctext; | ||
191 | for (int i = 0; i < m_subList->count();++i) { | ||
192 | ctext = m_subList->text(i); | ||
193 | if (ctext.isEmpty()) | ||
194 | continue; | ||
195 | if (ctext.startsWith("/")&&ctext.length()>1) { | ||
196 | ctext = ctext.right(ctext.length()-1); | ||
197 | } | ||
198 | entries.append(ctext); | ||
199 | } | ||
200 | m_config->writeEntry("subdirs",entries,':'); | ||
173 | } | 201 | } |
174 | MediumMountWidget::~MediumMountWidget() | 202 | MediumMountWidget::~MediumMountWidget() |
175 | { | 203 | { |
176 | delete m_config; | 204 | delete m_config; |
177 | } | 205 | } |
178 | 206 | ||
179 | void MediumMountWidget::slotAdd() | 207 | void MediumMountWidget::slotAdd() |
180 | { | 208 | { |
209 | if (m_subList->currentText()==m_subList->text(m_subList->currentItem())) | ||
210 | return; | ||
211 | m_subList->insertItem(m_subList->currentText()); | ||
212 | } | ||
181 | 213 | ||
214 | void MediumMountWidget::slotRemove() | ||
215 | { | ||
216 | QString text = m_subList->currentText(); | ||
217 | if (text != m_subList->text(m_subList->currentItem())) { | ||
218 | m_subList->clearEdit (); | ||
219 | } else { | ||
220 | m_subList->removeItem(m_subList->currentItem()); | ||
221 | } | ||
182 | } | 222 | } |
223 | |||
183 | void MediumMountWidget::slotStateChanged() | 224 | void MediumMountWidget::slotStateChanged() |
184 | { | 225 | { |
185 | bool state = !(m_all->isChecked()); | 226 | bool state = !(m_all->isChecked()); |
186 | 227 | ||
187 | m_audio->setEnabled( state ); | 228 | m_audio->setEnabled( state ); |
188 | m_text->setEnabled ( state ); | 229 | m_text->setEnabled ( state ); |
189 | m_video->setEnabled( state ); | 230 | m_video->setEnabled( state ); |
190 | m_image->setEnabled( state ); | 231 | m_image->setEnabled( state ); |
191 | 232 | ||
192 | } | 233 | } |
diff --git a/noncore/settings/mediummount/mediumwidget.h b/noncore/settings/mediummount/mediumwidget.h index 0f27117..28ae369 100644 --- a/noncore/settings/mediummount/mediumwidget.h +++ b/noncore/settings/mediummount/mediumwidget.h | |||
@@ -1,79 +1,82 @@ | |||
1 | 1 | ||
2 | #ifndef MediumMountWidget_H | 2 | #ifndef MediumMountWidget_H |
3 | #define MediumMountWidget_H | 3 | #define MediumMountWidget_H |
4 | 4 | ||
5 | //#include <qpixmap.h> | 5 | //#include <qpixmap.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | 7 | ||
8 | 8 | ||
9 | class QLabel; | 9 | class QLabel; |
10 | class QPixmap; | 10 | class QPixmap; |
11 | class Config; | 11 | class Config; |
12 | class QGridLayout; | 12 | class QGridLayout; |
13 | class QCheckBox; | 13 | class QCheckBox; |
14 | class QPushButton; | 14 | class QPushButton; |
15 | class QVBoxLayout; | 15 | class QVBoxLayout; |
16 | class QHBoxLayout; | 16 | class QHBoxLayout; |
17 | class QGroupBox; | 17 | class QGroupBox; |
18 | class QVBox; | 18 | class QVBox; |
19 | class QHBox; | 19 | class QHBox; |
20 | class QLineEdit; | 20 | class QLineEdit; |
21 | class QComboBox; | ||
21 | 22 | ||
22 | namespace MediumMountSetting { | 23 | namespace MediumMountSetting { |
23 | 24 | ||
24 | class MediumMountWidget : public QWidget { | 25 | class MediumMountWidget : public QWidget { |
25 | Q_OBJECT | 26 | Q_OBJECT |
26 | public: | 27 | public: |
27 | MediumMountWidget(const QString&, const QPixmap &, QWidget *parent, const char *name = 0 ); | 28 | MediumMountWidget(const QString&, const QPixmap &, QWidget *parent, const char *name = 0 ); |
28 | ~MediumMountWidget(); | 29 | ~MediumMountWidget(); |
29 | 30 | ||
30 | 31 | ||
31 | void writeConfig(); | 32 | void writeConfig(); |
32 | 33 | ||
33 | private slots: | 34 | private slots: |
34 | void slotAdd(); | 35 | void slotAdd(); |
36 | void slotRemove(); | ||
35 | void slotStateChanged(); | 37 | void slotStateChanged(); |
36 | 38 | ||
37 | private: | 39 | private: |
38 | void readConfig(); | 40 | void readConfig(); |
39 | void initGUI(); | 41 | void initGUI(); |
40 | 42 | ||
41 | bool m_dirty : 1; | 43 | bool m_dirty : 1; |
42 | 44 | ||
43 | class MediumMountWidgetPrivate; | 45 | class MediumMountWidgetPrivate; |
44 | MediumMountWidgetPrivate *d; | 46 | MediumMountWidgetPrivate *d; |
45 | 47 | ||
46 | QString m_path; | 48 | QString m_path; |
47 | 49 | ||
48 | Config *m_config; | 50 | Config *m_config; |
49 | 51 | ||
50 | QHBox *m_infoBox; | 52 | QHBox *m_infoBox; |
51 | QLabel *m_label; | 53 | QLabel *m_label; |
52 | QLabel *m_desc; | 54 | QLabel *m_desc; |
53 | 55 | ||
54 | QLineEdit *m_edit; | ||
55 | QPushButton *m_add; | 56 | QPushButton *m_add; |
57 | QComboBox *m_subList; | ||
58 | QPushButton *m_del; | ||
56 | 59 | ||
57 | QVBoxLayout *m_box; | 60 | QVBoxLayout *m_box; |
58 | QGridLayout *m_checks; | 61 | QGridLayout *m_checks; |
59 | 62 | ||
60 | QGroupBox *m_group; | 63 | QGroupBox *m_group; |
61 | QCheckBox *m_all; | 64 | QCheckBox *m_all; |
62 | QCheckBox *m_audio; | 65 | QCheckBox *m_audio; |
63 | QCheckBox *m_image; | 66 | QCheckBox *m_image; |
64 | QCheckBox *m_text; | 67 | QCheckBox *m_text; |
65 | QCheckBox *m_video; | 68 | QCheckBox *m_video; |
66 | 69 | ||
67 | QCheckBox *m_always; | 70 | QCheckBox *m_always; |
68 | //QCheckBox *m_yesNo; | 71 | //QCheckBox *m_yesNo; |
69 | 72 | ||
70 | QHBox *m_hboxAdd; | 73 | QHBox *m_hboxAdd; |
71 | 74 | ||
72 | QLabel *m_lblPath; | 75 | QLabel *m_lblPath; |
73 | //////////////// | 76 | //////////////// |
74 | 77 | ||
75 | 78 | ||
76 | 79 | ||
77 | }; | 80 | }; |
78 | }; | 81 | }; |
79 | #endif | 82 | #endif |