Diffstat (limited to 'noncore/settings/mediummount/mediumwidget.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/mediummount/mediumwidget.cc | 49 |
1 files changed, 45 insertions, 4 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 | |||
@@ -8,12 +8,13 @@ | |||
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" |
@@ -104,21 +105,31 @@ void MediumMountWidget::initGUI() | |||
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, |
@@ -151,12 +162,16 @@ void MediumMountWidget::readConfig( ) | |||
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() ); |
@@ -167,22 +182,48 @@ void MediumMountWidget::writeConfig() | |||
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 ); |