Commit e1e9e6aa authored by Alexandre Lision's avatar Alexandre Lision

codecs: add ability to reorder codecs

Refs #67077

Change-Id: I226907c42b3d04999603ccb752cfdea519f88b6d
parent 91d11e52
......@@ -36,7 +36,7 @@
#import "QNSTreeController.h"
@interface AccAudioVC : NSViewController <NSOutlineViewDelegate, NSPathControlDelegate> {
@interface AccAudioVC : NSViewController <NSOutlineViewDelegate> {
}
......
......@@ -67,15 +67,28 @@
[codecsView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[codecsView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[codecsView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
}
- (IBAction)moveUp:(id)sender {
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
if(!qIdx.isValid())
return;
QMimeData* mime = privateAccount->codecModel()->audioCodecs()->mimeData(QModelIndexList() << qIdx);
privateAccount->codecModel()->audioCodecs()->dropMimeData(mime, Qt::MoveAction, qIdx.row() - 1, 0, QModelIndex());
}
}
- (IBAction)moveDown:(id)sender {
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
if(!qIdx.isValid())
return;
QMimeData* mime = privateAccount->codecModel()->audioCodecs()->mimeData(QModelIndexList() << qIdx);
privateAccount->codecModel()->audioCodecs()->dropMimeData(mime, Qt::MoveAction, qIdx.row() + 1, 0, QModelIndex());
}
}
- (IBAction)toggleCodec:(NSOutlineView*)sender {
......@@ -83,8 +96,7 @@
NSTableColumn *col = [sender tableColumnWithIdentifier:COLUMNID_STATE];
NSButtonCell *cell = [col dataCellForRow:row];
QModelIndex qIdx = privateAccount->codecModel()->audioCodecs()->index(row, 0, QModelIndex());
privateAccount->codecModel()->audioCodecs()->setData(
qIdx, cell.state == NSOnState ? Qt::Unchecked : Qt::Checked, Qt::CheckStateRole);
privateAccount->codecModel()->audioCodecs()->setData(qIdx, cell.state == NSOnState ? Qt::Unchecked : Qt::Checked, Qt::CheckStateRole);
}
#pragma mark - NSOutlineViewDelegate methods
......
......@@ -39,7 +39,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" headerView="bYO-LR-nVo" indentationPerLevel="16" outlineTableColumn="DSk-Vi-l91" id="H2b-i2-whr">
<rect key="frame" x="0.0" y="0.0" width="380" height="19"/>
<rect key="frame" x="0.0" y="0.0" width="366" height="19"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
......@@ -126,6 +126,9 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="moveDown:" target="-2" id="Eew-cq-oSJ"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8M7-MC-vJE">
<rect key="frame" x="-6" y="13" width="58" height="32"/>
......@@ -133,6 +136,9 @@
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="moveUp:" target="-2" id="y2e-P5-leK"/>
</connections>
</button>
</subviews>
</customView>
......
......@@ -90,6 +90,29 @@
cell.state == NSOnState ? Qt::Unchecked : Qt::Checked, Qt::CheckStateRole);
}
- (IBAction)moveUp:(id)sender {
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
if(!qIdx.isValid())
return;
QMimeData* mime = privateAccount->codecModel()->mimeData(QModelIndexList() << qIdx);
privateAccount->codecModel()->dropMimeData(mime, Qt::MoveAction, qIdx.row() - 1, 0, QModelIndex());
}
}
- (IBAction)moveDown:(id)sender {
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
if(!qIdx.isValid())
return;
QMimeData* mime = privateAccount->codecModel()->mimeData(QModelIndexList() << qIdx);
privateAccount->codecModel()->dropMimeData(mime, Qt::MoveAction, qIdx.row() + 1, 0, QModelIndex());
}
}
#pragma mark - NSOutlineViewDelegate methods
// -------------------------------------------------------------------------------
......
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