Deletion from library is more stable.

Imported to library pictures has unique names.
preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 6c5dcd6696
commit 828ae2272f
  1. 18
      src/board/UBFeaturesController.cpp
  2. 15
      src/gui/UBFeaturesWidget.cpp

@ -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 ) void UBFeaturesController::importImage( const QImage &image, const UBFeature &destination, const QString &fileName )
{ {
QString mFileName = fileName; QString mFileName = fileName;
QString filePath;
UBFeature dest = destination;
if (mFileName.isNull()) { if (mFileName.isNull()) {
QDateTime now = QDateTime::currentDateTime(); 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 ) ) if ( !destination.getFullVirtualPath().startsWith( picturesElement.getFullVirtualPath(), Qt::CaseInsensitive ) )
{ {
dest = picturesElement; dest = picturesElement;
} }
QString filePath = dest.getFullPath().toLocalFile() + "/" + mFileName; filePath = dest.getFullPath().toLocalFile() + "/" + mFileName;
image.save(filePath); image.save(filePath);
QImage thumb = createThumbnail( filePath ); QImage thumb = createThumbnail( filePath );

@ -169,9 +169,15 @@ void UBFeaturesWidget::deleteElements( const UBFeaturesMimeData * mimeData )
void UBFeaturesWidget::deleteSelectedElements() void UBFeaturesWidget::deleteSelectedElements()
{ {
QModelIndexList selected = centralWidget->listView()->selectionModel()->selectedIndexes(); 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.isDeletable()) {
if (feature.inTrash()) { if (feature.inTrash()) {
controller->deleteItem(feature); controller->deleteItem(feature);
@ -179,10 +185,7 @@ void UBFeaturesWidget::deleteSelectedElements()
controller->moveToTrash(feature, true); 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(); controller->refreshModels();
} }

Loading…
Cancel
Save