Make double-clicking on a partition item in the list trigger edit/create
This commit is contained in:
parent
cd99f64344
commit
bf72672cce
@ -67,6 +67,7 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
|||||||
|
|
||||||
connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );
|
connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );
|
||||||
|
|
||||||
|
connect( m_ui->partitionTreeView, &QAbstractItemView::activated, this, &PartitionPage::onPartitionViewActivated );
|
||||||
connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
|
connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
|
||||||
connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
|
connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
|
||||||
connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
|
connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
|
||||||
@ -185,6 +186,29 @@ PartitionPage::onRevertClicked()
|
|||||||
updateFromCurrentDevice();
|
updateFromCurrentDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PartitionPage::onPartitionViewActivated()
|
||||||
|
{
|
||||||
|
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
||||||
|
if ( !index.isValid() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
|
||||||
|
Q_ASSERT( model );
|
||||||
|
Partition* partition = model->partitionForIndex( index );
|
||||||
|
Q_ASSERT( partition );
|
||||||
|
|
||||||
|
// Use the buttons to trigger the actions so that they do nothing if they
|
||||||
|
// are disabled. Alternatively, the code could use QAction to centralize,
|
||||||
|
// but I don't expect there will be other occurences of triggering the same
|
||||||
|
// action from multiple UI elements in this page, so it does not feel worth
|
||||||
|
// the price.
|
||||||
|
if ( PMUtils::isPartitionFreeSpace( partition ) )
|
||||||
|
m_ui->createButton->click();
|
||||||
|
else
|
||||||
|
m_ui->editButton->click();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ private:
|
|||||||
void onCreateClicked();
|
void onCreateClicked();
|
||||||
void onEditClicked();
|
void onEditClicked();
|
||||||
void onDeleteClicked();
|
void onDeleteClicked();
|
||||||
|
void onPartitionViewActivated();
|
||||||
|
|
||||||
void updatePartitionToCreate( Device*, Partition* );
|
void updatePartitionToCreate( Device*, Partition* );
|
||||||
void editExistingPartition( Device*, Partition* );
|
void editExistingPartition( Device*, Partition* );
|
||||||
|
@ -63,6 +63,9 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="partitionTreeView">
|
<widget class="QTreeView" name="partitionTreeView">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
<property name="rootIsDecorated">
|
<property name="rootIsDecorated">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user