src/settingseditor/librarieseditor.cpp

Sun, 09 Apr 2023 16:01:38 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sun, 09 Apr 2023 16:01:38 +0300
changeset 363
16f5dcfa7c9f
parent 300
3a4b132b8353
child 381
80bea7a6e84f
permissions
-rw-r--r--

Removed unused code

7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #include <QFileDialog>
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
2 #include <QMenu>
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 #include <QMessageBox>
264
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
4 #include <ui_librarieseditor.h>
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 259
diff changeset
5 #include "src/settingseditor/librarieseditor.h"
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 206
diff changeset
7 LibrariesEditor::LibrariesEditor(QWidget* parent) :
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 QWidget{parent},
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 ui{*new Ui_LibrariesEditor}
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 this->ui.setupUi(this);
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 connect(
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 this->ui.newLibrarySearch,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 &QPushButton::clicked,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 this,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 &LibrariesEditor::searchPathForNewLibrary);
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 connect(
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18 this->ui.newLibraryAdd,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 &QPushButton::clicked,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 this,
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 &LibrariesEditor::addNewLibrary);
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
22 this->ui.librariesTable->setContextMenuPolicy(Qt::CustomContextMenu);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
23 connect(
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
24 this->ui.librariesTable,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
25 &QWidget::customContextMenuRequested,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
26 this,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
27 &LibrariesEditor::showContextMenu);
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
28 this->setEnabled(false);
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 LibrariesEditor::~LibrariesEditor()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 delete &this->ui;
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
35
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36 void LibrariesEditor::searchPathForNewLibrary()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
38 const QString path = QFileDialog::getExistingDirectory(this, tr("Browse LDraw library"));
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
39 if (not path.isEmpty())
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 {
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
41 this->ui.newLibraryPath->setText(path);
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
42 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
43 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
44
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
45 void LibrariesEditor::addNewLibrary()
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
47 if (LibrariesModel* model = this->currentModel()) {
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
48 const QDir dir{this->ui.newLibraryPath->text()};
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
49 if (not dir.exists())
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
50 {
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
51 QMessageBox::critical(
206
654661eab7f3 More refactor, merged main.h, basics.h and utility.h into one header file basics.h and removed plenty of unused code
Teemu Piippo <teemu@hecknology.net>
parents: 201
diff changeset
52 this,
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
53 tr("Library does not exist"),
206
654661eab7f3 More refactor, merged main.h, basics.h and utility.h into one header file basics.h and removed plenty of unused code
Teemu Piippo <teemu@hecknology.net>
parents: 201
diff changeset
54 tr("The directory %1 does not exist.").arg(quoted(dir.path()))
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
55 );
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
56 }
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
57 else
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
58 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
59 if (not dir.isReadable())
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
60 {
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
61 QMessageBox::warning(this,
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
62 tr("Unreadable library"),
206
654661eab7f3 More refactor, merged main.h, basics.h and utility.h into one header file basics.h and removed plenty of unused code
Teemu Piippo <teemu@hecknology.net>
parents: 201
diff changeset
63 tr("The directory %1 cannot be read.").arg(quoted(dir.path()))
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
64 );
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
65 }
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
66 model->addLibrary({Library::OfficialLibrary, dir});
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
67 this->ui.newLibraryPath->clear();
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
68 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
69 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
70 }
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
71
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
72 void LibrariesEditor::showContextMenu(const QPoint position)
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
73 {
300
3a4b132b8353 Fix build warnings, size_type of QVector changes from Qt5 to Qt6 so we need an alias for it
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 265
diff changeset
74 const index_t libraryIndex = this->currentLibraryIndex();
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
75 LibrariesModel* model = this->currentModel();
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
76 if (model != nullptr and model->isValidIndex(libraryIndex))
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
77 {
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
78 QMenu* contextMenu = new QMenu{this};
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
79 QAction* removeAction = new QAction{tr("Remove library")};
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
80 connect(
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
81 removeAction,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
82 &QAction::triggered,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
83 this,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
84 &LibrariesEditor::removeCurrentLibrary);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
85 QMenu* roleMenu = new QMenu{tr("Set role"), contextMenu};
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
86 for (const Library::Role role : Library::allRoles)
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
87 {
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
88 QAction* setRoleAction = new QAction{Library::libraryRoleName(role)};
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
89 setRoleAction->setData(role);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
90 roleMenu->addAction(setRoleAction);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
91 connect(
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
92 setRoleAction,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
93 &QAction::triggered,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
94 this,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
95 &LibrariesEditor::setCurrentLibraryRole);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
96 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
97 QAction* moveUpAction = new QAction{tr("Move up")};
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
98 connect(
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
99 moveUpAction,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
100 &QAction::triggered,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
101 this,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
102 &LibrariesEditor::moveCurrentLibraryUp);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
103 QAction* moveDownAction = new QAction{tr("Move down")};
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
104 connect(
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
105 moveDownAction,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
106 &QAction::triggered,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
107 this,
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
108 &LibrariesEditor::moveCurrentLibraryDown);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
109 contextMenu->addMenu(roleMenu);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
110 contextMenu->addSeparator();
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
111 contextMenu->addAction(moveDownAction);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
112 contextMenu->addAction(moveUpAction);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
113 contextMenu->addAction(removeAction);
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
114 contextMenu->popup(this->ui.librariesTable->mapToGlobal(position));
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
115 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
116 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
117
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
118 void LibrariesEditor::setCurrentLibraryRole()
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
119 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
120 if (LibrariesModel* model = this->currentModel()) {
300
3a4b132b8353 Fix build warnings, size_type of QVector changes from Qt5 to Qt6 so we need an alias for it
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 265
diff changeset
121 const index_t libraryIndex = currentLibraryIndex();
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
122 QObject* senderObject = sender();
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
123 QAction* senderAction = qobject_cast<QAction*>(senderObject);
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
124 const Library::Role role = senderAction->data().value<Library::Role>();
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
125 model->setLibraryRole(libraryIndex, role);
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
126 }
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
127 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
128
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
129 void LibrariesEditor::removeCurrentLibrary()
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
130 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
131 if (LibrariesModel* model = this->currentModel()) {
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
132 model->removeLibrary(currentLibraryIndex());
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
133 }
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
134 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
135
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
136 void LibrariesEditor::moveCurrentLibraryUp()
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
137 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
138 if (LibrariesModel* model = this->currentModel()) {
300
3a4b132b8353 Fix build warnings, size_type of QVector changes from Qt5 to Qt6 so we need an alias for it
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 265
diff changeset
139 const index_t libraryIndex = this->currentLibraryIndex();
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
140 model->moveLibrary(libraryIndex, libraryIndex - 1);
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
141 }
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
142 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
143
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
144 void LibrariesEditor::moveCurrentLibraryDown()
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
145 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
146 if (LibrariesModel* model = this->currentModel()) {
300
3a4b132b8353 Fix build warnings, size_type of QVector changes from Qt5 to Qt6 so we need an alias for it
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 265
diff changeset
147 const index_t libraryIndex = this->currentLibraryIndex();
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
148 model->moveLibrary(libraryIndex + 1, libraryIndex);
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
149 }
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
150 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
151
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
152 LibrariesModel *LibrariesEditor::currentModel()
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
153 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
154 return qobject_cast<LibrariesModel*>(this->ui.librariesTable->model());
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
155 }
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
156
300
3a4b132b8353 Fix build warnings, size_type of QVector changes from Qt5 to Qt6 so we need an alias for it
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 265
diff changeset
157 index_t LibrariesEditor::currentLibraryIndex() const
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
158 {
265
b2b7af293c46 Fix build warnings
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 264
diff changeset
159 return this->ui.librariesTable->selectionModel()->currentIndex().row();
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
160 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 7
diff changeset
161
218
63125c36de73 Replace config collector with a simpler system
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 206
diff changeset
162 void LibrariesEditor::saveSettings()
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
163 {
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
164 if (LibrariesModel* model = this->currentModel()) {
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
165 model->storeToSettings();
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
166 }
7
68443f5be176 added the settings editor
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
167 }
259
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
168
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
169 void LibrariesEditor::setModel(LibrariesModel *model)
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
170 {
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
171 this->ui.librariesTable->setModel(model);
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
172 this->setEnabled(model != nullptr);
c27612f0eac0 - Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 218
diff changeset
173 }

mercurial