Commit 828ae227 authored by Aleksei Kanash's avatar Aleksei Kanash

Deletion from library is more stable.

Imported to library pictures has unique names.
parent 6c5dcd66
......@@ -641,19 +641,31 @@ void UBFeaturesController::importImage(const QImage &image, const QString &fileN
void UBFeaturesController::importImage( const QImage &image, const UBFeature &destination, const QString &fileName )
{
QString mFileName = fileName;
QString filePath;
UBFeature dest = destination;
if (mFileName.isNull()) {
QDateTime now = QDateTime::currentDateTime();
mFileName = tr("ImportedImage") + "-" + now.toString("dd-MM-yyyy hh-mm-ss") + ".png";
static int imageCounter = 0;
mFileName = tr("ImportedImage") + "-" + now.toString("dd-MM-yyyy hh-mm-ss");
filePath = dest.getFullPath().toLocalFile() + "/" + mFileName;
if (QFile::exists(filePath+".png"))
mFileName += QString("-[%1]").arg(++imageCounter);
else
imageCounter = 0;
mFileName += ".png";
}
UBFeature dest = destination;
if ( !destination.getFullVirtualPath().startsWith( picturesElement.getFullVirtualPath(), Qt::CaseInsensitive ) )
{
dest = picturesElement;
}
QString filePath = dest.getFullPath().toLocalFile() + "/" + mFileName;
filePath = dest.getFullPath().toLocalFile() + "/" + mFileName;
image.save(filePath);
QImage thumb = createThumbnail( filePath );
......
......@@ -169,9 +169,15 @@ void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData )
void UBFeaturesWidget::deleteSelectedElements()
{
QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes();
do
QList<UBFeature> featureasToMove;
for (int i = 0; i < selected.count(); i++)
{
featureasToMove.append(controller->getFeature(selected.at(i), objNameFeatureList));
}
foreach (UBFeature feature, featureasToMove)
{
UBFeature feature = controller->getFeature(selected.at(0), objNameFeatureList);
if (feature.isDeletable()) {
if (feature.inTrash()) {
controller->deleteItem(feature);
......@@ -179,10 +185,7 @@ void UBFeaturesWidget::deleteSelectedElements()
controller->moveToTrash(feature, true);
}
}
selected = centralWidget->listView()->selectionModel()->selectedIndexes();
if (!selected.isEmpty())
centralWidget->listView()->selectionModel()->select(selected.at(0), QItemSelectionModel::Deselect);
}while (!selected.isEmpty());
}
controller->refreshModels();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment