File indexing completed on 2025-01-19 03:59:41
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2003-02-10 0007 * Description : Camera type selection dialog 0008 * 0009 * SPDX-FileCopyrightText: 2003-2005 by Renchi Raju <renchi dot raju at gmail dot com> 0010 * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "cameraselection.h" 0017 0018 // Qt includes 0019 0020 #include <QButtonGroup> 0021 #include <QGridLayout> 0022 #include <QGroupBox> 0023 #include <QLabel> 0024 #include <QRadioButton> 0025 #include <QTreeWidget> 0026 #include <QUrl> 0027 #include <QApplication> 0028 #include <QStyle> 0029 #include <QComboBox> 0030 #include <QLineEdit> 0031 #include <QStandardPaths> 0032 #include <QDialogButtonBox> 0033 #include <QVBoxLayout> 0034 #include <QPushButton> 0035 0036 // KDE includes 0037 0038 #include <klocalizedstring.h> 0039 0040 // Local includes 0041 0042 #include "digikam_config.h" 0043 #include "digikam_globals.h" 0044 #include "dlayoutbox.h" 0045 #include "dfileselector.h" 0046 #include "gpcamera.h" 0047 #include "dtextedit.h" 0048 0049 namespace Digikam 0050 { 0051 0052 class Q_DECL_HIDDEN CameraSelection::Private 0053 { 0054 public: 0055 0056 explicit Private() 0057 : buttons (nullptr), 0058 portButtonGroup (nullptr), 0059 usbButton (nullptr), 0060 serialButton (nullptr), 0061 networkButton (nullptr), 0062 portPathComboBox(nullptr), 0063 listView (nullptr), 0064 titleEdit (nullptr), 0065 networkEdit (nullptr), 0066 umsMountURL (nullptr), 0067 searchBar (nullptr) 0068 { 0069 } 0070 0071 QDialogButtonBox* buttons; 0072 0073 QButtonGroup* portButtonGroup; 0074 0075 QRadioButton* usbButton; 0076 QRadioButton* serialButton; 0077 QRadioButton* networkButton; 0078 0079 QComboBox* portPathComboBox; 0080 0081 QString UMSCameraNameActual; 0082 QString UMSCameraNameShown; 0083 QString PTPCameraNameShown; 0084 QString PTPIPCameraNameShown; 0085 0086 QStringList serialPortList; 0087 0088 QTreeWidget* listView; 0089 0090 DTextEdit* titleEdit; 0091 QLineEdit* networkEdit; 0092 0093 DFileSelector* umsMountURL; 0094 0095 SearchTextBar* searchBar; 0096 }; 0097 0098 CameraSelection::CameraSelection(QWidget* const parent) 0099 : QDialog(parent), 0100 d (new Private) 0101 { 0102 qApp->setOverrideCursor(Qt::WaitCursor); 0103 0104 setWindowTitle(i18nc("@title:window", "Camera Configuration")); 0105 setModal(true); 0106 0107 const int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0108 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0109 0110 d->buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); 0111 d->buttons->button(QDialogButtonBox::Ok)->setDefault(true); 0112 0113 d->UMSCameraNameActual = QLatin1String("Directory Browse"); // Don't be i18n! 0114 d->UMSCameraNameShown = i18n("Mounted Camera"); 0115 d->PTPCameraNameShown = QLatin1String("USB PTP Class Camera"); 0116 d->PTPIPCameraNameShown = QLatin1String("PTP/IP Camera"); 0117 0118 QWidget* const page = new QWidget(this); 0119 QGridLayout* mainBoxLayout = new QGridLayout(page); 0120 0121 // -------------------------------------------------------------- 0122 0123 d->listView = new QTreeWidget(page); 0124 d->listView->setRootIsDecorated(false); 0125 d->listView->setSelectionMode(QAbstractItemView::SingleSelection); 0126 d->listView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 0127 d->listView->setMinimumWidth(350); 0128 d->listView->setAllColumnsShowFocus(true); 0129 d->listView->setColumnCount(1); 0130 d->listView->setHeaderLabels(QStringList() << i18n("Camera List")); 0131 d->listView->setWhatsThis(i18n("<p>Select the camera name that you want to use here. All " 0132 "default settings on the right panel " 0133 "will be set automatically.</p><p>This list has been generated " 0134 "using the gphoto2 library installed on your computer.</p>")); 0135 0136 d->searchBar = new SearchTextBar(page, QLatin1String("CameraSelectionSearchBar")); 0137 0138 // -------------------------------------------------------------- 0139 0140 QGroupBox* const titleBox = new QGroupBox(i18n("Camera Title"), page); 0141 QVBoxLayout* const gLayout1 = new QVBoxLayout(titleBox); 0142 d->titleEdit = new DTextEdit(titleBox); 0143 d->titleEdit->setLinesVisible(1); 0144 d->titleEdit->setWhatsThis(i18n("<p>Set here the name used in digiKam interface to " 0145 "identify this camera.</p>")); 0146 0147 gLayout1->addWidget(d->titleEdit); 0148 gLayout1->setContentsMargins(spacing, spacing, spacing, spacing); 0149 gLayout1->setSpacing(spacing); 0150 0151 // -------------------------------------------------------------- 0152 0153 QGroupBox* const portPathBox = new QGroupBox(i18n("Camera Port Type"), page); 0154 QGridLayout* const gLayout2 = new QGridLayout(portPathBox); 0155 d->portButtonGroup = new QButtonGroup(portPathBox); 0156 d->portButtonGroup->setExclusive(true); 0157 0158 d->usbButton = new QRadioButton(i18n("USB"), portPathBox); 0159 d->usbButton->setWhatsThis(i18n("<p>Select this option if your camera is connected to your " 0160 "computer using a USB cable.</p>")); 0161 0162 d->serialButton = new QRadioButton(i18nc("@item: serail port based camera", "Serial"), portPathBox); 0163 d->serialButton->setWhatsThis(i18n("<p>Select this option if your camera is connected to your " 0164 "computer using a serial cable.</p>")); 0165 0166 d->networkButton = new QRadioButton(i18n("Network"), portPathBox); 0167 d->networkButton->setWhatsThis(i18n("<p>Select this option if your camera is connected to your " 0168 "computer network.</p>")); 0169 0170 d->portPathComboBox = new QComboBox(portPathBox); 0171 d->portPathComboBox->setDuplicatesEnabled(false); 0172 d->portPathComboBox->setWhatsThis(i18n("<p>Select the serial port to use on your computer here. " 0173 "This option is only required if you use a serial camera.</p>")); 0174 0175 d->networkEdit = new QLineEdit(portPathBox); 0176 d->networkEdit->setWhatsThis(i18n("<p>Enter here the network address of your camera.</p>")); 0177 d->networkEdit->setInputMask(QLatin1String("000.000.000.000")); 0178 d->networkEdit->setText(QLatin1String("192.168.001.001")); 0179 0180 d->portButtonGroup->addButton(d->usbButton); 0181 d->portButtonGroup->addButton(d->serialButton); 0182 d->portButtonGroup->addButton(d->networkButton); 0183 0184 gLayout2->addWidget(d->usbButton, 0, 0, 1, 2); 0185 gLayout2->addWidget(d->serialButton, 1, 0, 1, 2); 0186 gLayout2->addWidget(d->portPathComboBox, 1, 1, 1, 2); 0187 gLayout2->addWidget(d->networkButton, 2, 0, 1, 2); 0188 gLayout2->addWidget(d->networkEdit, 2, 1, 1, 2); 0189 gLayout2->setContentsMargins(spacing, spacing, spacing, spacing); 0190 gLayout2->setSpacing(spacing); 0191 0192 // -------------------------------------------------------------- 0193 0194 QGroupBox* const umsMountBox = new QGroupBox(i18n("Camera Mount Path"), page); 0195 QVBoxLayout* const gLayout3 = new QVBoxLayout(umsMountBox); 0196 0197 QLabel* const umsMountLabel = new QLabel(umsMountBox); 0198 umsMountLabel->setText(i18n("Note: only for USB/IEEE mass storage cameras.")); 0199 0200 d->umsMountURL = new DFileSelector(umsMountBox); 0201 d->umsMountURL->setFileDlgPath(QLatin1String("/mnt/camera")); 0202 d->umsMountURL->setFileDlgMode(QFileDialog::Directory); 0203 d->umsMountURL->setFileDlgOptions(QFileDialog::ShowDirsOnly); 0204 d->umsMountURL->setWhatsThis(i18n("<p>Set here the mount path to use on your computer. This " 0205 "option is only required if you use a <b>USB Mass Storage</b> " 0206 "camera.</p>")); 0207 0208 gLayout3->addWidget(umsMountLabel); 0209 gLayout3->addWidget(d->umsMountURL); 0210 gLayout3->setContentsMargins(spacing, spacing, spacing, spacing); 0211 gLayout3->setSpacing(spacing); 0212 0213 // -------------------------------------------------------------- 0214 0215 QWidget* const box2 = new QWidget(page); 0216 QGridLayout* const gLayout4 = new QGridLayout(box2); 0217 0218 QLabel* const logo = new QLabel(box2); 0219 logo->setPixmap(QIcon::fromTheme(QLatin1String("digikam")).pixmap(QSize(48,48))); 0220 0221 QLabel* const link = new QLabel(box2); 0222 link->setText(i18n("<p>To set a <b>USB Mass Storage</b> camera<br/>" 0223 "(which looks like a removable drive when mounted<br/>" 0224 "on your desktop), please use<br/>" 0225 "<a href=\"umscamera\">%1</a> from the camera list.</p>", 0226 d->UMSCameraNameShown)); 0227 0228 QLabel* const link2 = new QLabel(box2); 0229 link2->setText(i18n("<p>To set a <b>Generic PTP USB Device</b><br/>" 0230 "(which uses Picture Transfer Protocol), please<br/>" 0231 "use <a href=\"ptpcamera\">%1</a> from the camera list.</p>", 0232 d->PTPCameraNameShown)); 0233 0234 QLabel* const link3 = new QLabel(box2); 0235 link3->setText(i18n("<p>To set a <b>Generic PTP/IP Network Device</b><br/>" 0236 "(which uses Picture Transfer Protocol), please<br/>" 0237 "use <a href=\"ptpipcamera\">%1</a> from the camera list.</p>", 0238 d->PTPIPCameraNameShown)); 0239 0240 QLabel* const explanation = new QLabel(box2); 0241 explanation->setOpenExternalLinks(true); 0242 explanation->setText(i18n("<p>A complete list of camera settings to use is<br/>" 0243 "available at <a href='https://www.figuiere.net/digicam/'>" 0244 "this URL</a>.</p>")); 0245 0246 gLayout4->setContentsMargins(spacing, spacing, spacing, spacing); 0247 gLayout4->setSpacing(spacing); 0248 gLayout4->addWidget(logo, 0, 0, 1, 1); 0249 gLayout4->addWidget(link, 0, 1, 2, 1); 0250 gLayout4->addWidget(link2, 2, 1, 2, 1); 0251 gLayout4->addWidget(link3, 4, 1, 2, 1); 0252 gLayout4->addWidget(explanation, 6, 1, 2, 1); 0253 0254 // -------------------------------------------------------------- 0255 0256 mainBoxLayout->addWidget(d->listView, 0, 0, 6, 1); 0257 mainBoxLayout->addWidget(d->searchBar, 7, 0, 1, 1); 0258 mainBoxLayout->addWidget(titleBox, 0, 1, 1, 1); 0259 mainBoxLayout->addWidget(portPathBox, 1, 1, 1, 1); 0260 mainBoxLayout->addWidget(umsMountBox, 2, 1, 1, 1); 0261 mainBoxLayout->addWidget(box2, 3, 1, 2, 1); 0262 mainBoxLayout->setColumnStretch(0, 10); 0263 mainBoxLayout->setRowStretch(6, 10); 0264 mainBoxLayout->setContentsMargins(QMargins()); 0265 mainBoxLayout->setSpacing(spacing); 0266 0267 QVBoxLayout* const vbx = new QVBoxLayout(this); 0268 vbx->addWidget(page); 0269 vbx->addWidget(d->buttons); 0270 setLayout(vbx); 0271 0272 // Connections -------------------------------------------------- 0273 0274 connect(link, SIGNAL(linkActivated(QString)), 0275 this, SLOT(slotUMSCameraLinkUsed())); 0276 0277 connect(link2, SIGNAL(linkActivated(QString)), 0278 this, SLOT(slotPTPCameraLinkUsed())); 0279 0280 connect(link3, SIGNAL(linkActivated(QString)), 0281 this, SLOT(slotPTPIPCameraLinkUsed())); 0282 0283 connect(d->networkEdit, SIGNAL(textChanged(QString)), 0284 this, SLOT(slotNetworkEditChanged(QString))); 0285 0286 connect(d->listView, SIGNAL(itemClicked(QTreeWidgetItem*,int)), 0287 this, SLOT(slotSelectionChanged(QTreeWidgetItem*,int))); 0288 0289 #if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) 0290 0291 connect(d->portButtonGroup, SIGNAL(idClicked(int)), 0292 this, SLOT(slotPortChanged())); 0293 0294 #else 0295 0296 connect(d->portButtonGroup, SIGNAL(buttonClicked(int)), 0297 this, SLOT(slotPortChanged())); 0298 0299 #endif 0300 0301 connect(d->searchBar, SIGNAL(signalSearchTextSettings(SearchTextSettings)), 0302 this, SLOT(slotSearchTextChanged(SearchTextSettings))); 0303 0304 connect(d->buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), 0305 this, SLOT(slotOkClicked())); 0306 0307 connect(d->buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), 0308 this, SLOT(reject())); 0309 0310 connect(d->buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()), 0311 this, SLOT(slotHelp())); 0312 0313 // Initialize -------------------------------------------------- 0314 0315 #ifndef HAVE_GPHOTO2 0316 0317 // If digiKam is compiled without Gphoto2 support, we hide widgets relevant. 0318 0319 d->listView->hide(); 0320 d->searchBar->hide(); 0321 box2->hide(); 0322 slotUMSCameraLinkUsed(); 0323 0324 #else 0325 0326 getCameraList(); 0327 getSerialPortList(); 0328 0329 #endif // HAVE_GPHOTO2 0330 0331 qApp->restoreOverrideCursor(); 0332 } 0333 0334 CameraSelection::~CameraSelection() 0335 { 0336 delete d; 0337 } 0338 0339 void CameraSelection::slotUMSCameraLinkUsed() 0340 { 0341 QList<QTreeWidgetItem*> list = d->listView->findItems(d->UMSCameraNameShown, Qt::MatchExactly, 0); 0342 0343 if (!list.isEmpty()) 0344 { 0345 QTreeWidgetItem* const item = list.first(); 0346 0347 if (item) 0348 { 0349 d->listView->setCurrentItem(item); 0350 d->listView->scrollToItem(item); 0351 } 0352 } 0353 } 0354 0355 void CameraSelection::slotPTPCameraLinkUsed() 0356 { 0357 QList<QTreeWidgetItem*> list = d->listView->findItems(d->PTPCameraNameShown, Qt::MatchExactly, 0); 0358 0359 if (!list.isEmpty()) 0360 { 0361 QTreeWidgetItem* const item = list.first(); 0362 0363 if (item) 0364 { 0365 d->listView->setCurrentItem(item); 0366 d->listView->scrollToItem(item); 0367 } 0368 } 0369 } 0370 0371 void CameraSelection::slotPTPIPCameraLinkUsed() 0372 { 0373 QList<QTreeWidgetItem*> list = d->listView->findItems(d->PTPIPCameraNameShown, Qt::MatchExactly, 0); 0374 0375 if (!list.isEmpty()) 0376 { 0377 QTreeWidgetItem* const item = list.first(); 0378 0379 if (item) 0380 { 0381 d->listView->setCurrentItem(item); 0382 d->listView->scrollToItem(item); 0383 } 0384 } 0385 } 0386 0387 void CameraSelection::slotNetworkEditChanged(const QString& text) 0388 { 0389 int cursorPosition = d->networkEdit->cursorPosition(); 0390 QStringList ipRanges = text.split(QLatin1Char('.')); 0391 0392 for (int i = 0 ; i < ipRanges.count() ; ++i) 0393 { 0394 bool ok; 0395 0396 for (int a = ipRanges.at(i).count() ; a < 3 ; ++a) 0397 { 0398 ipRanges[i].append(QLatin1Char('0')); 0399 } 0400 0401 if (ipRanges.at(i).toInt(&ok) > 255) 0402 { 0403 ipRanges[i] = QLatin1String("255"); 0404 } 0405 0406 if (!ok) 0407 { 0408 ipRanges[i] = QLatin1String("000"); 0409 } 0410 } 0411 0412 d->networkEdit->setText(ipRanges.join(QLatin1Char('.'))); 0413 d->networkEdit->setCursorPosition(cursorPosition); 0414 } 0415 0416 void CameraSelection::setCamera(const QString& title, const QString& model, 0417 const QString& port, const QString& path) 0418 { 0419 QString camModel(model); 0420 0421 if (camModel == d->UMSCameraNameActual) 0422 { 0423 camModel = d->UMSCameraNameShown; 0424 } 0425 0426 QList<QTreeWidgetItem*> list = d->listView->findItems(camModel, Qt::MatchExactly, 0); 0427 0428 if (!list.isEmpty()) 0429 { 0430 QTreeWidgetItem* const item = list.first(); 0431 0432 if (!item) 0433 { 0434 return; 0435 } 0436 0437 d->listView->setCurrentItem(item); 0438 d->listView->scrollToItem(item); 0439 0440 d->titleEdit->setText(title); 0441 0442 if (port.contains(QLatin1String("usb"))) 0443 { 0444 d->usbButton->setChecked(true); 0445 slotPortChanged(); 0446 } 0447 else if (port.contains(QLatin1String("serial"))) 0448 { 0449 d->serialButton->setChecked(true); 0450 0451 for (int i = 0 ; i < d->portPathComboBox->count() ; ++i) 0452 { 0453 if (port == d->portPathComboBox->itemText(i)) 0454 { 0455 d->portPathComboBox->setCurrentIndex(i); 0456 break; 0457 } 0458 } 0459 0460 slotPortChanged(); 0461 } 0462 else if (port.contains(QLatin1String("ptpip"))) 0463 { 0464 d->networkButton->setChecked(true); 0465 d->networkEdit->setText(port); 0466 slotPortChanged(); 0467 } 0468 0469 d->umsMountURL->setFileDlgPath(path); 0470 } 0471 } 0472 0473 void CameraSelection::getCameraList() 0474 { 0475 int count = 0; 0476 QStringList clist; 0477 QString cname; 0478 0479 GPCamera::getSupportedCameras(count, clist); 0480 0481 for (int i = 0 ; i < count ; ++i) 0482 { 0483 cname = clist.at(i); 0484 0485 if (cname == d->UMSCameraNameActual) 0486 { 0487 new QTreeWidgetItem(d->listView, QStringList() << d->UMSCameraNameShown); 0488 } 0489 else 0490 { 0491 new QTreeWidgetItem(d->listView, QStringList() << cname); 0492 } 0493 } 0494 } 0495 0496 void CameraSelection::getSerialPortList() 0497 { 0498 QStringList plist; 0499 0500 GPCamera::getSupportedPorts(plist); 0501 0502 d->serialPortList.clear(); 0503 0504 for (int i = 0; i < plist.count() ; ++i) 0505 { 0506 if ((plist.at(i)).startsWith(QLatin1String("serial:"))) 0507 { 0508 d->serialPortList.append(plist.at(i)); 0509 } 0510 } 0511 } 0512 0513 void CameraSelection::slotSelectionChanged(QTreeWidgetItem* item, int) 0514 { 0515 if (!item) 0516 { 0517 return; 0518 } 0519 0520 QString model(item->text(0)); 0521 0522 if (model == d->UMSCameraNameShown) 0523 { 0524 model = d->UMSCameraNameActual; 0525 0526 d->titleEdit->setText(model); 0527 0528 d->usbButton->setEnabled(true); 0529 d->usbButton->setChecked(false); 0530 d->usbButton->setEnabled(false); 0531 d->serialButton->setEnabled(true); 0532 d->serialButton->setChecked(false); 0533 d->serialButton->setEnabled(false); 0534 d->networkButton->setEnabled(true); 0535 d->networkButton->setChecked(false); 0536 d->networkButton->setEnabled(false); 0537 d->portPathComboBox->setEnabled(true); 0538 d->portPathComboBox->clear(); 0539 d->portPathComboBox->insertItem(0, QLatin1String("NONE")); 0540 d->portPathComboBox->setEnabled(false); 0541 d->networkEdit->setEnabled(true); 0542 d->networkEdit->setText(QLatin1String("192.168.001.001")); 0543 d->networkEdit->setEnabled(false); 0544 0545 d->umsMountURL->setEnabled(true); 0546 d->umsMountURL->setFileDlgPath(QLatin1String("/mnt/camera")); 0547 0548 return; 0549 } 0550 else 0551 { 0552 d->umsMountURL->setEnabled(true); 0553 d->umsMountURL->setFileDlgPath(QLatin1String("/")); 0554 d->umsMountURL->setEnabled(false); 0555 } 0556 0557 d->titleEdit->setText(model); 0558 0559 QStringList plist; 0560 GPCamera::getCameraSupportedPorts(model, plist); 0561 0562 if (plist.contains(QLatin1String("serial"))) 0563 { 0564 d->serialButton->setEnabled(true); 0565 d->serialButton->setChecked(true); 0566 } 0567 else 0568 { 0569 d->serialButton->setEnabled(true); 0570 d->serialButton->setChecked(false); 0571 d->serialButton->setEnabled(false); 0572 } 0573 0574 if (plist.contains(QLatin1String("ptpip"))) 0575 { 0576 d->networkButton->setEnabled(true); 0577 d->networkButton->setChecked(true); 0578 } 0579 else 0580 { 0581 d->networkButton->setEnabled(true); 0582 d->networkButton->setChecked(false); 0583 d->networkButton->setEnabled(false); 0584 } 0585 0586 if (plist.contains(QLatin1String("usb"))) 0587 { 0588 d->usbButton->setEnabled(true); 0589 d->usbButton->setChecked(true); 0590 } 0591 else 0592 { 0593 d->usbButton->setEnabled(true); 0594 d->usbButton->setChecked(false); 0595 d->usbButton->setEnabled(false); 0596 } 0597 0598 slotPortChanged(); 0599 } 0600 0601 void CameraSelection::slotPortChanged() 0602 { 0603 if (d->usbButton->isChecked()) 0604 { 0605 d->portPathComboBox->setEnabled(true); 0606 d->portPathComboBox->clear(); 0607 d->portPathComboBox->insertItem(0, QLatin1String("usb:")); 0608 d->portPathComboBox->setEnabled(false); 0609 d->networkEdit->setEnabled(false); 0610 0611 return; 0612 } 0613 0614 if (d->networkButton->isChecked()) 0615 { 0616 d->portPathComboBox->setEnabled(true); 0617 d->portPathComboBox->clear(); 0618 d->portPathComboBox->insertItem(0, QLatin1String("ptpip:")); 0619 d->portPathComboBox->setEnabled(false); 0620 d->networkEdit->setEnabled(true); 0621 0622 return; 0623 } 0624 0625 if (d->serialButton->isChecked()) 0626 { 0627 d->portPathComboBox->setEnabled(true); 0628 d->portPathComboBox->clear(); 0629 d->portPathComboBox->insertItems(0, d->serialPortList); 0630 d->networkEdit->setEnabled(false); 0631 } 0632 } 0633 0634 QString CameraSelection::currentTitle() const 0635 { 0636 return d->titleEdit->text(); 0637 } 0638 0639 QString CameraSelection::currentModel() const 0640 { 0641 QTreeWidgetItem* const item = d->listView->currentItem(); 0642 0643 if (!item) 0644 { 0645 return QString(); 0646 } 0647 0648 QString model(item->text(0)); 0649 0650 if (model == d->UMSCameraNameShown) 0651 { 0652 model = d->UMSCameraNameActual; 0653 } 0654 0655 return model; 0656 } 0657 0658 QString CameraSelection::currentPortPath() const 0659 { 0660 if (d->networkButton->isChecked()) 0661 { 0662 return (d->portPathComboBox->currentText() + 0663 d->networkEdit->text()); 0664 } 0665 else 0666 { 0667 return d->portPathComboBox->currentText(); 0668 } 0669 } 0670 0671 QString CameraSelection::currentCameraPath() const 0672 { 0673 return d->umsMountURL->fileDlgPath(); 0674 } 0675 0676 void CameraSelection::slotOkClicked() 0677 { 0678 Q_EMIT signalOkClicked(currentTitle(), currentModel(), 0679 currentPortPath(), currentCameraPath()); 0680 accept(); 0681 } 0682 0683 void CameraSelection::slotSearchTextChanged(const SearchTextSettings& settings) 0684 { 0685 bool query = false; 0686 QString search = settings.text; 0687 0688 QTreeWidgetItemIterator it(d->listView); 0689 0690 while (*it) 0691 { 0692 QTreeWidgetItem* const item = *it; 0693 0694 if (item->text(0).contains(search, settings.caseSensitive)) 0695 { 0696 query = true; 0697 item->setHidden(false); 0698 } 0699 else 0700 { 0701 item->setHidden(true); 0702 } 0703 0704 ++it; 0705 } 0706 0707 d->searchBar->slotSearchResult(query); 0708 } 0709 0710 void CameraSelection::slotHelp() 0711 { 0712 openOnlineDocumentation(QLatin1String("setup_application"), QLatin1String("camera_settings")); 0713 } 0714 0715 } // namespace Digikam 0716 0717 #include "moc_cameraselection.cpp"