! \class ColorMapsWidget \brief Widget for importing data from a dataset. \ingroup frontend */
| 32 | \ingroup frontend |
| 33 | */ |
| 34 | ColorMapsWidget::ColorMapsWidget(QWidget* parent) |
| 35 | : QWidget(parent) { |
| 36 | ui.setupUi(this); |
| 37 | ui.bInfo->setIcon(QIcon::fromTheme(QLatin1String("help-about"))); |
| 38 | ui.bViewMode->setIcon(QIcon::fromTheme(QLatin1String("view-list-icons"))); |
| 39 | ui.bViewMode->setToolTip(i18n("Switch between icon and list views")); |
| 40 | |
| 41 | ui.lvColorMaps->setViewMode(QListView::IconMode); |
| 42 | ui.lvColorMaps->setSelectionMode(QAbstractItemView::SingleSelection); |
| 43 | ui.lvColorMaps->setWordWrap(true); |
| 44 | ui.lvColorMaps->setResizeMode(QListWidget::Adjust); |
| 45 | ui.lvColorMaps->setDragDropMode(QListView::NoDragDrop); |
| 46 | ui.lvColorMaps->setEditTriggers(QAbstractItemView::NoEditTriggers); |
| 47 | ui.lvColorMaps->setIconSize(QSize(128, 128)); |
| 48 | connect(ui.lvColorMaps, &QAbstractItemView::doubleClicked, this, &ColorMapsWidget::doubleClicked); |
| 49 | |
| 50 | const int size = ui.leSearch->height(); |
| 51 | ui.lSearch->setPixmap(QIcon::fromTheme(QLatin1String("edit-find")).pixmap(size, size)); |
| 52 | |
| 53 | QString info = i18n("Enter the keyword you want to search for"); |
| 54 | ui.lSearch->setToolTip(info); |
| 55 | ui.leSearch->setToolTip(info); |
| 56 | ui.leSearch->setPlaceholderText(i18n("Search...")); |
| 57 | ui.leSearch->setFocus(); |
| 58 | |
| 59 | m_manager = ColorMapsManager::instance(); |
| 60 | ui.cbCollections->addItems(m_manager->collectionNames()); |
| 61 | |
| 62 | connect(ui.cbCollections, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ColorMapsWidget::collectionChanged); |
| 63 | connect(ui.bInfo, &QPushButton::clicked, this, &ColorMapsWidget::showInfo); |
| 64 | connect(ui.bViewMode, &QPushButton::clicked, this, &ColorMapsWidget::showViewModeMenu); |
| 65 | connect(ui.lwColorMaps, &QListWidget::itemSelectionChanged, this, &ColorMapsWidget::colorMapChanged); |
| 66 | connect(ui.lwColorMapsDetails, &QListWidget::itemSelectionChanged, this, &ColorMapsWidget::colorMapDetailsChanged); |
| 67 | |
| 68 | ui.twColorMapDetails->setEditTriggers(QAbstractItemView::NoEditTriggers); |
| 69 | ui.twColorMapDetails->setContextMenuPolicy(Qt::CustomContextMenu); |
| 70 | connect(ui.twColorMapDetails, &QTableWidget::customContextMenuRequested, this, &ColorMapsWidget::detailsContextMenuRequest); |
| 71 | |
| 72 | // CTRL+C copies only the last cell in the selection, we want to copy the whole selection. |
| 73 | // install event filters to handle CTRL+C key events. |
| 74 | ui.twColorMapDetails->installEventFilter(this); |
| 75 | |
| 76 | // select the last used collection |
| 77 | KConfigGroup conf = Settings::group(QStringLiteral("ColorMapsWidget")); |
| 78 | const QString& collection = conf.readEntry("Collection", QString()); |
| 79 | if (collection.isEmpty()) |
| 80 | ui.cbCollections->setCurrentIndex(0); |
| 81 | else { |
| 82 | for (int i = 0; i < ui.cbCollections->count(); ++i) { |
| 83 | if (ui.cbCollections->itemText(i) == collection) { |
| 84 | ui.cbCollections->setCurrentIndex(i); |
| 85 | break; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | collectionChanged(ui.cbCollections->currentIndex()); |
| 90 | |
| 91 | // select the last selected color map in the current view |
nothing calls this directly
no test coverage detected