src/settingseditor/librarieseditor.cpp

changeset 265
b2b7af293c46
parent 264
76a025db4948
child 300
3a4b132b8353
equal deleted inserted replaced
264:76a025db4948 265:b2b7af293c46
69 } 69 }
70 } 70 }
71 71
72 void LibrariesEditor::showContextMenu(const QPoint position) 72 void LibrariesEditor::showContextMenu(const QPoint position)
73 { 73 {
74 const std::size_t libraryIndex = this->currentLibraryIndex(); 74 const qsizetype 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 std::size_t libraryIndex = currentLibraryIndex(); 121 const qsizetype 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 std::size_t libraryIndex = this->currentLibraryIndex(); 139 const qsizetype 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 std::size_t libraryIndex = this->currentLibraryIndex(); 147 const qsizetype 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 std::size_t LibrariesEditor::currentLibraryIndex() const 157 qsizetype LibrariesEditor::currentLibraryIndex() const
158 { 158 {
159 const int row = this->ui.librariesTable->selectionModel()->currentIndex().row(); 159 return this->ui.librariesTable->selectionModel()->currentIndex().row();
160 return static_cast<std::size_t>(row);
161 } 160 }
162 161
163 void LibrariesEditor::saveSettings() 162 void LibrariesEditor::saveSettings()
164 { 163 {
165 if (LibrariesModel* model = this->currentModel()) { 164 if (LibrariesModel* model = this->currentModel()) {

mercurial