mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
renombrado eficiente de bibliotecas
This commit is contained in:
parent
8b00e649b8
commit
8e3df875ae
@ -1247,11 +1247,11 @@ void LibraryWindow::rename(QString newName)
|
||||
QString currentLibrary = selectedLibrary->currentText();
|
||||
QString path = libraries.value(currentLibrary);
|
||||
libraries.remove(currentLibrary);
|
||||
selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||
//selectedLibrary->removeItem(selectedLibrary->currentIndex());
|
||||
libraries.insert(newName,path);
|
||||
selectedLibrary->addItem(newName,path);
|
||||
selectedLibrary->renameCurrentLibrary(newName);
|
||||
saveLibraries();
|
||||
selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName));
|
||||
//selectedLibrary->setCurrentIndex(selectedLibrary->findText(newName));
|
||||
}
|
||||
|
||||
void LibraryWindow::cancelCreating()
|
||||
|
@ -147,3 +147,9 @@ void YACReaderLibraryItemWidget::select()
|
||||
|
||||
isSelected = true;
|
||||
}
|
||||
|
||||
void YACReaderLibraryItemWidget::setName(const QString & name)
|
||||
{
|
||||
this->name = name;
|
||||
nameLabel->setText(name);
|
||||
}
|
@ -20,12 +20,14 @@ public:
|
||||
signals:
|
||||
void selected(QString,QString);
|
||||
void showOptions();
|
||||
|
||||
public slots:
|
||||
void showUpDownButtons(bool show);
|
||||
|
||||
//bool eventFilter(QObject *object, QEvent *event);
|
||||
void select();
|
||||
void deselect();
|
||||
void setName(const QString & name);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -101,4 +101,27 @@ void YACReaderLibraryListWidget::showContextMenu()
|
||||
{
|
||||
YACReaderLibraryItemWidget * itemWidget = librariesList.at(currentLibraryIndex);
|
||||
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();
|
||||
void removeItem(int index);
|
||||
void showContextMenu();
|
||||
void renameCurrentLibrary(QString newName);
|
||||
protected:
|
||||
void mousePressEvent ( QMouseEvent * event );
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user