Diffstat (limited to 'noncore/settings/mediummount/mediumwidget.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/mediummount/mediumwidget.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/noncore/settings/mediummount/mediumwidget.cc b/noncore/settings/mediummount/mediumwidget.cc index caa9559..f39a6ed 100644 --- a/noncore/settings/mediummount/mediumwidget.cc +++ b/noncore/settings/mediummount/mediumwidget.cc | |||
@@ -105,129 +105,146 @@ void MediumMountWidget::initGUI() | |||
105 | m_box->addWidget( m_group ); | 105 | m_box->addWidget( m_group ); |
106 | 106 | ||
107 | // label | 107 | // label |
108 | m_lblPath = new QLabel(tr("Limit search to:"), this ); | 108 | m_lblPath = new QLabel(tr("Limit search to:"), this ); |
109 | m_box->addWidget( m_lblPath ); | 109 | m_box->addWidget( m_lblPath ); |
110 | 110 | ||
111 | 111 | ||
112 | m_subList = new QComboBox(FALSE,this,"docFolderList"); | 112 | m_subList = new QComboBox(FALSE,this,"docFolderList"); |
113 | m_subList->setDuplicatesEnabled(FALSE); | 113 | m_subList->setDuplicatesEnabled(FALSE); |
114 | m_subList->setEditable(TRUE); | 114 | m_subList->setEditable(TRUE); |
115 | m_box->addWidget(m_subList); | 115 | m_box->addWidget(m_subList); |
116 | 116 | ||
117 | m_hboxAdd = new QHBox( this ); | 117 | m_hboxAdd = new QHBox( this ); |
118 | m_add = new QPushButton(m_hboxAdd ); | 118 | m_add = new QPushButton(m_hboxAdd ); |
119 | m_add->setText( tr("Add") ); | 119 | m_add->setText( tr("Add") ); |
120 | m_del = new QPushButton(m_hboxAdd); | 120 | m_del = new QPushButton(m_hboxAdd); |
121 | m_del->setText(tr("Remove")); | 121 | m_del->setText(tr("Remove")); |
122 | 122 | ||
123 | connect(m_add, SIGNAL(clicked() ), | 123 | connect(m_add, SIGNAL(clicked() ), |
124 | this, SLOT(slotAdd() ) ); | 124 | this, SLOT(slotAdd() ) ); |
125 | connect(m_del, SIGNAL(clicked() ), | 125 | connect(m_del, SIGNAL(clicked() ), |
126 | this, SLOT(slotRemove() ) ); | 126 | this, SLOT(slotRemove() ) ); |
127 | 127 | ||
128 | m_box->addWidget(m_hboxAdd ); | 128 | m_box->addWidget(m_hboxAdd ); |
129 | 129 | m_scan_all_check = new QCheckBox( tr("Scan whole media"), this ); | |
130 | connect(m_scan_all_check,SIGNAL(stateChanged(int)),this,SLOT(slotScanAllChanged(int))); | ||
131 | |||
132 | m_box->addWidget(m_scan_all_check); | ||
133 | |||
130 | m_always = new QCheckBox( tr("Always check this medium"), this ); | 134 | m_always = new QCheckBox( tr("Always check this medium"), this ); |
131 | 135 | ||
132 | m_box->addWidget( m_always ); | 136 | m_box->addWidget( m_always ); |
133 | 137 | ||
134 | QSpacerItem *item = new QSpacerItem(5, 50, | 138 | QSpacerItem *item = new QSpacerItem(5, 50, |
135 | QSizePolicy::Fixed, | 139 | QSizePolicy::Fixed, |
136 | QSizePolicy::Expanding ); | 140 | QSizePolicy::Expanding ); |
137 | m_box->addItem(item ); | 141 | m_box->addItem(item ); |
138 | } | 142 | } |
139 | 143 | ||
140 | void MediumMountWidget::readConfig( ) | 144 | void MediumMountWidget::readConfig( ) |
141 | { | 145 | { |
142 | if( m_config == 0 ) | 146 | if( m_config == 0 ) |
143 | m_config = new Config(m_path + "/.opiestorage.cf", Config::File ); | 147 | m_config = new Config(m_path + "/.opiestorage.cf", Config::File ); |
144 | m_config->setGroup( "main" ); | 148 | m_config->setGroup( "main" ); |
145 | 149 | ||
146 | m_always->setChecked( m_config->readBoolEntry("check", false) ); | 150 | m_always->setChecked( m_config->readBoolEntry("check", false) ); |
147 | 151 | ||
148 | m_config->setGroup( "mimetypes" ); | 152 | m_config->setGroup( "mimetypes" ); |
149 | if( m_config->readBoolEntry("all", false ) ){ | 153 | if( m_config->readBoolEntry("all", false ) ){ |
150 | m_audio->setEnabled( false ); | 154 | m_audio->setEnabled( false ); |
151 | m_image->setEnabled( false ); | 155 | m_image->setEnabled( false ); |
152 | m_text->setEnabled ( false ); | 156 | m_text->setEnabled ( false ); |
153 | m_video->setEnabled( false ); | 157 | m_video->setEnabled( false ); |
154 | m_all->setChecked( true ); | 158 | m_all->setChecked( true ); |
155 | }else{ | 159 | }else{ |
156 | m_audio->setEnabled( true ); | 160 | m_audio->setEnabled( true ); |
157 | m_image->setEnabled( true ); | 161 | m_image->setEnabled( true ); |
158 | m_text->setEnabled ( true ); | 162 | m_text->setEnabled ( true ); |
159 | m_all->setEnabled ( true ); | 163 | m_all->setEnabled ( true ); |
160 | 164 | ||
161 | m_all->setChecked( false ); | 165 | m_all->setChecked( false ); |
162 | 166 | ||
163 | m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); | 167 | m_audio->setChecked( m_config->readBoolEntry("audio", true ) ); |
164 | m_image->setChecked( m_config->readBoolEntry("image", true ) ); | 168 | m_image->setChecked( m_config->readBoolEntry("image", true ) ); |
165 | m_text->setChecked ( m_config->readBoolEntry("text" , true ) ); | 169 | m_text->setChecked ( m_config->readBoolEntry("text" , true ) ); |
166 | m_video->setChecked( m_config->readBoolEntry("video", true ) ); | 170 | m_video->setChecked( m_config->readBoolEntry("video", true ) ); |
167 | }; | 171 | }; |
168 | m_config->setGroup("subdirs"); | 172 | m_config->setGroup("subdirs"); |
169 | QStringList entries = m_config->readListEntry("subdirs",':'); | 173 | QStringList entries = m_config->readListEntry("subdirs",':'); |
170 | m_subList->clear(); | 174 | m_subList->clear(); |
171 | m_subList->insertStringList(entries); | 175 | m_subList->insertStringList(entries); |
176 | m_scan_all_check->setChecked(m_config->readBoolEntry("wholemedia",true)); | ||
172 | } | 177 | } |
173 | 178 | ||
174 | void MediumMountWidget::writeConfig() | 179 | void MediumMountWidget::writeConfig() |
175 | { | 180 | { |
176 | m_config->setGroup("main"); | 181 | m_config->setGroup("main"); |
177 | m_config->writeEntry("check", m_always->isChecked() ); | 182 | m_config->writeEntry("check", m_always->isChecked() ); |
178 | 183 | ||
179 | m_config->setGroup("mimetypes" ); | 184 | m_config->setGroup("mimetypes" ); |
180 | if(m_all->isChecked() ){ | 185 | if(m_all->isChecked() ){ |
181 | m_config->writeEntry("all", true ); | 186 | m_config->writeEntry("all", true ); |
182 | }else{ | 187 | }else{ |
183 | m_config->writeEntry("audio", m_audio->isChecked() ); | 188 | m_config->writeEntry("audio", m_audio->isChecked() ); |
184 | m_config->writeEntry("image", m_image->isChecked() ); | 189 | m_config->writeEntry("image", m_image->isChecked() ); |
185 | m_config->writeEntry("text" , m_text->isChecked() ); | 190 | m_config->writeEntry("text" , m_text->isChecked() ); |
186 | m_config->writeEntry("video", m_video->isChecked() ); | 191 | m_config->writeEntry("video", m_video->isChecked() ); |
187 | } | 192 | } |
188 | m_config->setGroup("subdirs"); | 193 | m_config->setGroup("subdirs"); |
189 | QStringList entries; | 194 | QStringList entries; |
190 | QString ctext; | 195 | QString ctext; |
191 | for (int i = 0; i < m_subList->count();++i) { | 196 | for (int i = 0; i < m_subList->count();++i) { |
192 | ctext = m_subList->text(i); | 197 | ctext = m_subList->text(i); |
193 | if (ctext.isEmpty()) | 198 | if (ctext.isEmpty()) |
194 | continue; | 199 | continue; |
195 | if (ctext.startsWith("/")&&ctext.length()>1) { | 200 | if (ctext.startsWith("/")) { |
196 | ctext = ctext.right(ctext.length()-1); | 201 | ctext = ctext.right(ctext.length()-1); |
197 | } | 202 | } |
198 | entries.append(ctext); | 203 | if (!ctext.isEmpty()) { |
204 | entries.append(ctext); | ||
205 | } | ||
199 | } | 206 | } |
200 | m_config->writeEntry("subdirs",entries,':'); | 207 | m_config->writeEntry("subdirs",entries,':'); |
208 | m_config->writeEntry("wholemedia",m_scan_all_check->isChecked()); | ||
201 | } | 209 | } |
210 | |||
202 | MediumMountWidget::~MediumMountWidget() | 211 | MediumMountWidget::~MediumMountWidget() |
203 | { | 212 | { |
204 | delete m_config; | 213 | delete m_config; |
205 | } | 214 | } |
206 | 215 | ||
207 | void MediumMountWidget::slotAdd() | 216 | void MediumMountWidget::slotAdd() |
208 | { | 217 | { |
209 | if (m_subList->currentText()==m_subList->text(m_subList->currentItem())) | 218 | if (m_subList->currentText()==m_subList->text(m_subList->currentItem())) |
210 | return; | 219 | return; |
211 | m_subList->insertItem(m_subList->currentText()); | 220 | m_subList->insertItem(m_subList->currentText()); |
212 | } | 221 | } |
213 | 222 | ||
214 | void MediumMountWidget::slotRemove() | 223 | void MediumMountWidget::slotRemove() |
215 | { | 224 | { |
216 | QString text = m_subList->currentText(); | 225 | QString text = m_subList->currentText(); |
217 | if (text != m_subList->text(m_subList->currentItem())) { | 226 | if (text != m_subList->text(m_subList->currentItem())) { |
218 | m_subList->clearEdit (); | 227 | m_subList->clearEdit (); |
219 | } else { | 228 | } else { |
220 | m_subList->removeItem(m_subList->currentItem()); | 229 | m_subList->removeItem(m_subList->currentItem()); |
221 | } | 230 | } |
222 | } | 231 | } |
223 | 232 | ||
224 | void MediumMountWidget::slotStateChanged() | 233 | void MediumMountWidget::slotStateChanged() |
225 | { | 234 | { |
226 | bool state = !(m_all->isChecked()); | 235 | bool state = !(m_all->isChecked()); |
227 | 236 | ||
228 | m_audio->setEnabled( state ); | 237 | m_audio->setEnabled( state ); |
229 | m_text->setEnabled ( state ); | 238 | m_text->setEnabled ( state ); |
230 | m_video->setEnabled( state ); | 239 | m_video->setEnabled( state ); |
231 | m_image->setEnabled( state ); | 240 | m_image->setEnabled( state ); |
232 | 241 | ||
233 | } | 242 | } |
243 | |||
244 | void MediumMountWidget::slotScanAllChanged(int) | ||
245 | { | ||
246 | bool state = !(m_scan_all_check->isChecked()); | ||
247 | m_add->setEnabled(state); | ||
248 | m_del->setEnabled(state); | ||
249 | m_subList->setEnabled(state); | ||
250 | } | ||