mirror of
https://github.com/YACReader/yacreader
synced 2025-11-14 14:02:45 -05:00
renombrado eficiente de bibliotecas
This commit is contained in:
@ -1247,11 +1247,11 @@ void LibraryWindow::rename(QString newName)
|
|||||||
QString currentLibrary = selectedLibrary->currentText();
|
QString currentLibrary = selectedLibrary->currentText();
|
||||||
QString path = libraries.value(currentLibrary);
|
QString path = libraries.value(currentLibrary);
|
||||||
libraries.remove(currentLibrary);
|
libraries.remove(currentLibrary);
|
||||||
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
//selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||||
libraries.insert(newName,path);
|
libraries.insert(newName,path);
|
||||||
selectedLibrary->addItem(newName,path);
|
selectedLibrary->renameCurrentLibrary(newName);
|
||||||
saveLibraries();
|
saveLibraries();
|
||||||
selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName));
|
//selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryWindow::cancelCreating()
|
void LibraryWindow::cancelCreating()
|
||||||
|
|||||||
@ -147,3 +147,9 @@ void YACReaderLibraryItemWidget::select()
|
|||||||
|
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YACReaderLibraryItemWidget::setName(const QString & name)
|
||||||
|
{
|
||||||
|
this->name = name;
|
||||||
|
nameLabel->setText(name);
|
||||||
|
}
|
||||||
@ -20,12 +20,14 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void selected(QString,QString);
|
void selected(QString,QString);
|
||||||
void showOptions();
|
void showOptions();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showUpDownButtons(bool show);
|
void showUpDownButtons(bool show);
|
||||||
|
|
||||||
//bool eventFilter(QObject *object, QEvent *event);
|
//bool eventFilter(QObject *object, QEvent *event);
|
||||||
void select();
|
void select();
|
||||||
void deselect();
|
void deselect();
|
||||||
|
void setName(const QString & name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@ -101,4 +101,27 @@ void YACReaderLibraryListWidget::showContextMenu()
|
|||||||
{
|
{
|
||||||
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
|
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
|
||||||
QMenu::exec(actions(),itemWidget->mapToGlobal(QPoint(itemWidget->width()-8,itemWidget->height()/2)));
|
QMenu::exec(actions(),itemWidget->mapToGlobal(QPoint(itemWidget->width()-8,itemWidget->height()/2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLibraryListWidget::renameCurrentLibrary(QString newName)
|
||||||
|
{
|
||||||
|
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
|
||||||
|
|
||||||
|
|
||||||
|
this->layout()->removeWidget(itemWidget);
|
||||||
|
librariesList.removeOne(itemWidget);
|
||||||
|
|
||||||
|
itemWidget->setName(newName);
|
||||||
|
|
||||||
|
QList<YACReaderLibraryItemWidget *>::iterator itr;
|
||||||
|
int i = 0;
|
||||||
|
for(itr = librariesList.begin(); itr!=librariesList.end() && !naturalSortLessThanCI(newName,(*itr)->name);itr++)
|
||||||
|
i++;
|
||||||
|
|
||||||
|
librariesList.insert(itr,itemWidget);
|
||||||
|
|
||||||
|
QVBoxLayout * mainLayout = dynamic_cast<QVBoxLayout *>(layout());
|
||||||
|
mainLayout->insertWidget(i,itemWidget);
|
||||||
|
|
||||||
|
currentLibraryIndex = i;
|
||||||
}
|
}
|
||||||
@ -23,6 +23,7 @@ public slots:
|
|||||||
int currentIndex();
|
int currentIndex();
|
||||||
void removeItem(int index);
|
void removeItem(int index);
|
||||||
void showContextMenu();
|
void showContextMenu();
|
||||||
|
void renameCurrentLibrary(QString newName);
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent ( QMouseEvent * event );
|
void mousePressEvent ( QMouseEvent * event );
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user