Skip to content

Commit 900106e

Browse files
committed
Add combobox
1 parent 0f019c4 commit 900106e

File tree

2 files changed

+78
-4
lines changed

2 files changed

+78
-4
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { QComboBox, QIcon, QVariant } from '@nodegui/nodegui';
2+
import { NgComponent } from './component';
3+
import { RendererStyleFlags2 } from '@angular/core';
4+
5+
interface ComboBoxItem {
6+
text: string;
7+
icon?: QIcon;
8+
userData?: QVariant;
9+
}
10+
11+
export class NgCombobox extends QComboBox implements NgComponent {
12+
public static nodeName = 'combobox';
13+
public parent: any;
14+
15+
public appendChild(newChild: any): void {
16+
console.warn('combobox do not have append child');
17+
}
18+
19+
public insertBefore(newChild: any, refChild: any) {}
20+
21+
public setNgAttribute(
22+
name: string,
23+
value: string,
24+
namespace?: string | null
25+
): void {
26+
switch (name) {
27+
case 'id':
28+
this.setObjectName(value);
29+
break;
30+
31+
default:
32+
break;
33+
}
34+
}
35+
36+
public setNgProperty(name: string, value: ComboBoxItem[] | any): void {
37+
if (name === 'items') {
38+
this.clear();
39+
40+
value.forEach(item => {
41+
this.addItem(item.icon, item.text, item.userData);
42+
});
43+
}
44+
45+
this.setProperty(name, value);
46+
}
47+
48+
public setStyle(
49+
style: string,
50+
value: any,
51+
flags?: RendererStyleFlags2
52+
): void {
53+
this.setInlineStyle(`${style}:${value}`);
54+
}
55+
56+
public setValue(value: string): void {
57+
throw new Error('Method not implemented.');
58+
}
59+
60+
removeAttribute(name: string, namespace?: string): void {
61+
throw new Error('Method not implemented.');
62+
}
63+
removeChild(oldChild: any): void {
64+
throw new Error('Method not implemented.');
65+
}
66+
removeClass(name: string): void {
67+
throw new Error('Method not implemented.');
68+
}
69+
removeStyle(style: string, flags?: RendererStyleFlags2): void {
70+
throw new Error('Method not implemented.');
71+
}
72+
}

projects/angular-nodegui/src/lib/components/components-map.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { NgRadioButton } from './radiobutton';
1313
import { NgProgressBar } from './progress-bar';
1414
import { NgScrollArea } from './scroll-area';
1515
import { NgSpinnBox } from './spin-box';
16+
import { NgCombobox } from './combobox';
1617

1718
export type Constructable<T> = new () => T;
1819
export type NgComponentClass = Constructable<NgComponent>;
@@ -26,17 +27,18 @@ export class ComponentsMap {
2627

2728
constructor() {
2829
this.map.set(NgButton.nodeName, NgButton);
29-
this.map.set(NgWindow.nodeName, NgWindow);
30-
this.map.set(NgText.nodeName, NgText);
31-
this.map.set(NgView.nodeName, NgView);
3230
this.map.set(NgCheckbox.nodeName, NgCheckbox);
31+
this.map.set(NgCombobox.nodeName, NgCombobox);
3332
this.map.set(NgDial.nodeName, NgDial);
3433
this.map.set(NgImage.nodeName, NgImage);
3534
this.map.set(NgLineEdit.nodeName, NgLineEdit);
3635
this.map.set(NgPlainTextEdit.nodeName, NgPlainTextEdit);
37-
this.map.set(NgRadioButton.nodeName, NgRadioButton);
3836
this.map.set(NgProgressBar.nodeName, NgProgressBar);
37+
this.map.set(NgRadioButton.nodeName, NgRadioButton);
3938
this.map.set(NgScrollArea.nodeName, NgScrollArea);
4039
this.map.set(NgSpinnBox.nodeName, NgSpinnBox);
40+
this.map.set(NgText.nodeName, NgText);
41+
this.map.set(NgView.nodeName, NgView);
42+
this.map.set(NgWindow.nodeName, NgWindow);
4143
}
4244
}

0 commit comments

Comments
 (0)