window: getNextFreeCell(): reimplement without refering to grid
Does not work that way since when we search, the grid has changed. So we cannot check inside the grid which ones are free. This would give wrong results.
Этот коммит содержится в:
родитель
7bae1183c6
Коммит
47c0358a25
43
window.cpp
43
window.cpp
@ -136,7 +136,7 @@ void Window::addToFavourites(const EntryPushButton &button)
|
||||
QString entryName = fi.completeBaseName() + ".qsrun";
|
||||
userConfig.entryPath = this->settingsProvider->userEntriesPaths()[0] + "/" + entryName;
|
||||
entryProvider->saveUserEntry(userConfig);
|
||||
initFromConfig();
|
||||
userEntryButtons.append(createEntryButton(userConfig));
|
||||
}
|
||||
|
||||
void Window::closeWindow()
|
||||
@ -154,23 +154,44 @@ void Window::closeWindow()
|
||||
|
||||
std::pair<int, int> Window::getNextFreeCell()
|
||||
{
|
||||
int maxRow = 0;
|
||||
for(EntryPushButton *button : userEntryButtons)
|
||||
{
|
||||
if(button->getRow() > maxRow)
|
||||
/* Not the most efficient way perhaps but for now it'll do */
|
||||
std::sort(userEntryButtons.begin(), userEntryButtons.end(), [](EntryPushButton *a, EntryPushButton *b) {
|
||||
const EntryConfig &config_a = a->getEntryConfig();
|
||||
const EntryConfig &config_b = b->getEntryConfig();
|
||||
if(config_a.row < config_b.row)
|
||||
{
|
||||
maxRow = button->getRow();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(config_a.row > config_b.row)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return config_a.col < config_b.col;
|
||||
});
|
||||
|
||||
int expectedRow = 1;
|
||||
int expectedCol = 1;
|
||||
int maxCols = this->settingsProvider->getMaxCols();
|
||||
for(int i = 1; i < maxCols; i++)
|
||||
for(EntryPushButton *current : userEntryButtons)
|
||||
{
|
||||
if(grid->itemAtPosition(maxRow, i) == 0)
|
||||
int currentRow = current->getEntryConfig().row;
|
||||
int currentCol = current->getEntryConfig().col;
|
||||
|
||||
if(currentRow != expectedRow || currentCol != expectedCol)
|
||||
{
|
||||
return {maxRow, i + 1};
|
||||
return {expectedRow, expectedCol};
|
||||
}
|
||||
if(expectedCol == maxCols)
|
||||
{
|
||||
expectedCol = 1;
|
||||
++expectedRow;
|
||||
}
|
||||
else
|
||||
{
|
||||
++expectedCol;
|
||||
}
|
||||
}
|
||||
return {maxRow + 1, 0};
|
||||
return {expectedRow, expectedCol};
|
||||
}
|
||||
|
||||
QStringList Window::generatePATHSuggestions(const QString &text)
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user