MCPcopy Create free account
hub / github.com/KDE/labplot / ColorMapsWidget

Method ColorMapsWidget

src/frontend/colormaps/ColorMapsWidget.cpp:34–109  ·  view source on GitHub ↗

! \class ColorMapsWidget \brief Widget for importing data from a dataset. \ingroup frontend */

Source from the content-addressed store, hash-verified

32 \ingroup frontend
33 */
34ColorMapsWidget::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

Callers

nothing calls this directly

Calls 14

groupFunction · 0.85
setToolTipMethod · 0.80
setIconSizeMethod · 0.80
heightMethod · 0.80
setPlaceholderTextMethod · 0.80
QStringClass · 0.50
setIconMethod · 0.45
pixmapMethod · 0.45
setFocusMethod · 0.45
collectionNamesMethod · 0.45
isEmptyMethod · 0.45
setCurrentIndexMethod · 0.45

Tested by

no test coverage detected