QPhotoRec: automatically select the image disk after addiing it
This commit is contained in:
parent
ce52d72852
commit
bd8b9ef3ae
@ -102,37 +102,42 @@ void dup_partition_t(partition_t *dst, const partition_t *src)
|
||||
#endif
|
||||
}
|
||||
|
||||
list_disk_t *insert_new_disk(list_disk_t *list_disk, disk_t *disk_car)
|
||||
list_disk_t *insert_new_disk_aux(list_disk_t *list_disk, disk_t *disk, disk_t **the_disk)
|
||||
{
|
||||
if(disk_car==NULL)
|
||||
list_disk_t *tmp;
|
||||
list_disk_t *prev=NULL;
|
||||
list_disk_t *new_disk;
|
||||
if(disk==NULL)
|
||||
return list_disk;
|
||||
/* Add it at the end if it doesn't already exist */
|
||||
for(tmp=list_disk;tmp!=NULL;tmp=tmp->next)
|
||||
{
|
||||
list_disk_t *cur;
|
||||
list_disk_t *prev=NULL;
|
||||
list_disk_t *new_disk;
|
||||
/* Add it at the end if it doesn't already exist */
|
||||
for(cur=list_disk;cur!=NULL;cur=cur->next)
|
||||
if(tmp->disk->device!=NULL && disk->device!=NULL &&
|
||||
strcmp(tmp->disk->device, disk->device)==0)
|
||||
{
|
||||
if(cur->disk->device!=NULL && disk_car->device!=NULL)
|
||||
{
|
||||
if(strcmp(cur->disk->device,disk_car->device)==0)
|
||||
{
|
||||
disk_car->clean(disk_car);
|
||||
return list_disk;
|
||||
}
|
||||
}
|
||||
prev=cur;
|
||||
disk->clean(disk);
|
||||
if(the_disk!=NULL)
|
||||
*the_disk=tmp->disk;
|
||||
return list_disk;
|
||||
}
|
||||
new_disk=(list_disk_t *)MALLOC(sizeof(*new_disk));
|
||||
new_disk->disk=disk_car;
|
||||
if(prev!=NULL)
|
||||
{
|
||||
prev->next=new_disk;
|
||||
}
|
||||
new_disk->prev=prev;
|
||||
new_disk->next=NULL;
|
||||
return (list_disk!=NULL?list_disk:new_disk);
|
||||
prev=tmp;
|
||||
}
|
||||
new_disk=(list_disk_t *)MALLOC(sizeof(*new_disk));
|
||||
new_disk->disk=disk;
|
||||
if(prev!=NULL)
|
||||
{
|
||||
prev->next=new_disk;
|
||||
}
|
||||
new_disk->prev=prev;
|
||||
new_disk->next=NULL;
|
||||
if(the_disk!=NULL)
|
||||
*the_disk=disk;
|
||||
return (list_disk!=NULL?list_disk:new_disk);
|
||||
}
|
||||
|
||||
list_disk_t *insert_new_disk(list_disk_t *list_disk, disk_t *disk)
|
||||
{
|
||||
return insert_new_disk_aux(list_disk, disk, NULL);
|
||||
}
|
||||
|
||||
list_part_t *insert_new_partition(list_part_t *list_part, partition_t *part, const int force_insert, int *insert_error)
|
||||
|
@ -30,6 +30,7 @@ unsigned int offset2head(const disk_t *disk_car, const uint64_t offset);
|
||||
unsigned int offset2cylinder(const disk_t *disk_car, const uint64_t offset);
|
||||
void offset2CHS(const disk_t *disk_car,const uint64_t offset, CHS_t*CHS);
|
||||
|
||||
list_disk_t *insert_new_disk_aux(list_disk_t *list_disk, disk_t *disk, disk_t **the_disk);
|
||||
list_disk_t *insert_new_disk(list_disk_t *list_disk, disk_t *disk_car);
|
||||
list_part_t *insert_new_partition(list_part_t *list_part, partition_t *part, const int force_insert, int *insert_error);
|
||||
list_part_t *sort_partition_list(list_part_t *list_part);
|
||||
|
@ -113,6 +113,8 @@ QPhotorec::QPhotorec(QWidget *my_parent) : QWidget(my_parent)
|
||||
{
|
||||
no_disk_warning();
|
||||
}
|
||||
else
|
||||
select_disk(list_disk->disk);
|
||||
setupUI();
|
||||
}
|
||||
|
||||
@ -147,12 +149,15 @@ void QPhotorec::newSourceFile()
|
||||
"Raw Files (*.dd *.raw *.img)");
|
||||
if(!filename.isEmpty())
|
||||
{
|
||||
disk_t *new_disk=NULL;
|
||||
QByteArray filenameArray= (filename).toUtf8();
|
||||
list_disk=insert_new_disk(list_disk, file_test_availability(filenameArray.constData(), options->verbose, testdisk_mode));
|
||||
if(list_disk!=NULL)
|
||||
select_disk(list_disk->disk);
|
||||
HDDlistWidget_updateUI();
|
||||
PartListWidget_updateUI();
|
||||
list_disk=insert_new_disk_aux(list_disk, file_test_availability(filenameArray.constData(), options->verbose, testdisk_mode), &new_disk);
|
||||
if(new_disk!=NULL)
|
||||
{
|
||||
select_disk(new_disk);
|
||||
HDDlistWidget_updateUI();
|
||||
PartListWidget_updateUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,6 +247,9 @@ void QPhotorec::PartListWidget_updateUI()
|
||||
item=new QTableWidgetItem(QString(sizeinfo));
|
||||
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
PartListWidget->setItem(currentRow, 4, item);
|
||||
/* Select the partition if it's already known */
|
||||
if(selected_partition == partition)
|
||||
PartListWidget->setCurrentItem(item);
|
||||
}
|
||||
{
|
||||
QString partname="";
|
||||
@ -274,6 +282,15 @@ void QPhotorec::select_disk(disk_t *disk)
|
||||
log_info("%s\n", selected_disk->description_short(selected_disk));
|
||||
part_free_list(list_part);
|
||||
list_part=init_list_part(selected_disk, NULL);
|
||||
/* If only whole disk is listed, select it */
|
||||
/* If there is the whole disk and only one partition, select the partition */
|
||||
if(list_part!=NULL)
|
||||
{
|
||||
if(list_part->next==NULL)
|
||||
selected_partition=list_part->part;
|
||||
else if(list_part->next->next==NULL)
|
||||
selected_partition=list_part->next->part;
|
||||
}
|
||||
log_all_partitions(selected_disk, list_part);
|
||||
}
|
||||
|
||||
@ -386,13 +403,18 @@ void QPhotorec::buttons_updateUI()
|
||||
void QPhotorec::HDDlistWidget_updateUI()
|
||||
{
|
||||
list_disk_t *element_disk;
|
||||
int i;
|
||||
HDDlistWidget->clear();
|
||||
for(element_disk=list_disk;element_disk!=NULL;element_disk=element_disk->next)
|
||||
for(element_disk=list_disk, i=0;
|
||||
element_disk!=NULL;
|
||||
element_disk=element_disk->next, i++)
|
||||
{
|
||||
disk_t *disk=element_disk->disk;
|
||||
HDDlistWidget->addItem(
|
||||
QIcon::fromTheme("drive-harddisk", QIcon(":res/gnome/drive-harddisk.png")),
|
||||
disk->description_short(disk));
|
||||
if(disk==selected_disk)
|
||||
HDDlistWidget->setCurrentIndex(i);
|
||||
}
|
||||
HDDlistWidget->addItem(
|
||||
QIcon::fromTheme("application-x-cd-image", QIcon(":res/gnome/application-x-cd-image.png")),
|
||||
|
Loading…
x
Reference in New Issue
Block a user