src/settingseditor/librarieseditor.cpp

changeset 300
3a4b132b8353
parent 265
b2b7af293c46
child 381
80bea7a6e84f
equal deleted inserted replaced
299:cf9a854b56a9 300:3a4b132b8353
69 } 69 }
70 } 70 }
71 71
72 void LibrariesEditor::showContextMenu(const QPoint position) 72 void LibrariesEditor::showContextMenu(const QPoint position)
73 { 73 {
74 const qsizetype libraryIndex = this->currentLibraryIndex(); 74 const index_t libraryIndex = this->currentLibraryIndex();
75 LibrariesModel* model = this->currentModel(); 75 LibrariesModel* model = this->currentModel();
76 if (model != nullptr and model->isValidIndex(libraryIndex)) 76 if (model != nullptr and model->isValidIndex(libraryIndex))
77 { 77 {
78 QMenu* contextMenu = new QMenu{this}; 78 QMenu* contextMenu = new QMenu{this};
79 QAction* removeAction = new QAction{tr("Remove library")}; 79 QAction* removeAction = new QAction{tr("Remove library")};
116 } 116 }
117 117
118 void LibrariesEditor::setCurrentLibraryRole() 118 void LibrariesEditor::setCurrentLibraryRole()
119 { 119 {
120 if (LibrariesModel* model = this->currentModel()) { 120 if (LibrariesModel* model = this->currentModel()) {
121 const qsizetype libraryIndex = currentLibraryIndex(); 121 const index_t libraryIndex = currentLibraryIndex();
122 QObject* senderObject = sender(); 122 QObject* senderObject = sender();
123 QAction* senderAction = qobject_cast<QAction*>(senderObject); 123 QAction* senderAction = qobject_cast<QAction*>(senderObject);
124 const Library::Role role = senderAction->data().value<Library::Role>(); 124 const Library::Role role = senderAction->data().value<Library::Role>();
125 model->setLibraryRole(libraryIndex, role); 125 model->setLibraryRole(libraryIndex, role);
126 } 126 }
134 } 134 }
135 135
136 void LibrariesEditor::moveCurrentLibraryUp() 136 void LibrariesEditor::moveCurrentLibraryUp()
137 { 137 {
138 if (LibrariesModel* model = this->currentModel()) { 138 if (LibrariesModel* model = this->currentModel()) {
139 const qsizetype libraryIndex = this->currentLibraryIndex(); 139 const index_t libraryIndex = this->currentLibraryIndex();
140 model->moveLibrary(libraryIndex, libraryIndex - 1); 140 model->moveLibrary(libraryIndex, libraryIndex - 1);
141 } 141 }
142 } 142 }
143 143
144 void LibrariesEditor::moveCurrentLibraryDown() 144 void LibrariesEditor::moveCurrentLibraryDown()
145 { 145 {
146 if (LibrariesModel* model = this->currentModel()) { 146 if (LibrariesModel* model = this->currentModel()) {
147 const qsizetype libraryIndex = this->currentLibraryIndex(); 147 const index_t libraryIndex = this->currentLibraryIndex();
148 model->moveLibrary(libraryIndex + 1, libraryIndex); 148 model->moveLibrary(libraryIndex + 1, libraryIndex);
149 } 149 }
150 } 150 }
151 151
152 LibrariesModel *LibrariesEditor::currentModel() 152 LibrariesModel *LibrariesEditor::currentModel()
153 { 153 {
154 return qobject_cast<LibrariesModel*>(this->ui.librariesTable->model()); 154 return qobject_cast<LibrariesModel*>(this->ui.librariesTable->model());
155 } 155 }
156 156
157 qsizetype LibrariesEditor::currentLibraryIndex() const 157 index_t LibrariesEditor::currentLibraryIndex() const
158 { 158 {
159 return this->ui.librariesTable->selectionModel()->currentIndex().row(); 159 return this->ui.librariesTable->selectionModel()->currentIndex().row();
160 } 160 }
161 161
162 void LibrariesEditor::saveSettings() 162 void LibrariesEditor::saveSettings()

mercurial