22 QList<KbProfile*> newProfiles;
24 for(
int i = 0; i < count; i++){
27 if(profile && !newProfiles.contains(profile))
28 newProfiles.
append(profile);
29 item->setFlags(item->flags() | Qt::ItemIsEditable);
33 if(!newProfiles.contains(profile))
34 newProfiles.append(profile);
52 QListWidgetItem* item =
new QListWidgetItem(QIcon((profile ==
device->
hwProfile()) ?
":/img/icon_profile_hardware.png" :
":/img/icon_profile.png"), profile->
name(),
ui->
profileList);
54 item->setFlags(item->flags() | Qt::ItemIsEditable);
56 item->setSelected(
true);
68 QListWidgetItem* item =
new QListWidgetItem(
"New profile...",
ui->
profileList);
69 item->setFlags((item->flags() | Qt::ItemIsEditable) & ~Qt::ItemIsDragEnabled & ~Qt::ItemIsDropEnabled);
71 QFont font = item->font();
74 item->setIcon(QIcon(
":/img/icon_plus.png"));
79 QUuid guid = item->data(
GUID).toUuid();
80 if(guid.isNull() && item->data(
NEW_FLAG).toInt() == 1){
84 item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
85 QFont font = item->font();
86 font.setItalic(
false);
88 item->setIcon(QIcon(
":/img/icon_profile.png"));
102 if(!item || !currentProfile || item->data(
GUID).toUuid() != currentProfile->
id().
guid)
104 currentProfile->
name(item->text());
106 item->setText(currentProfile->
name());
112 if(!item || !currentProfile || item->data(
GUID).toUuid() != currentProfile->
id().
guid)
118 QAction* rename =
new QAction(
"Rename...",
this);
119 QAction* duplicate =
new QAction(
"Duplicate",
this);
120 QAction* del =
new QAction(
"Delete",
this);
121 bool canDelete = (profiles.count() > 1);
124 del->setEnabled(
false);
125 QAction* hwsave =
new QAction(
"Save to Hardware",
this);
126 QAction* moveup =
new QAction(
"Move Up",
this);
128 moveup->setEnabled(
false);
129 QAction* movedown =
new QAction(
"Move Down",
this);
130 if(index >= profiles.count() - 1)
131 movedown->setEnabled(
false);
132 menu.addAction(rename);
133 menu.addAction(duplicate);
136 menu.addAction(hwsave);
138 menu.addAction(moveup);
139 menu.addAction(movedown);
140 QAction* result = menu.exec(QCursor::pos());
141 if(result == rename){
143 }
else if(result == duplicate){
146 profiles.insert(index + 1, newProfile);
149 }
else if(result == del){
152 profiles.removeAll(currentProfile);
154 currentProfile->deleteLater();
156 if(index < profiles.count())
160 }
else if(result == hwsave){
164 for(
int i = 0; i < count; i++){
166 if(item->data(
NEW_FLAG).toUInt() == 1)
169 item->setIcon(QIcon((profile ==
device->
hwProfile()) ?
":/img/icon_profile_hardware.png" :
":/img/icon_profile.png"));
171 }
else if(result == moveup){
173 profiles.insert(index - 1, currentProfile);
175 }
else if(result == movedown){
176 profiles.removeAll(currentProfile);
177 profiles.insert(index + 1, currentProfile);
void on_profileList_customContextMenuRequested(const QPoint &pos)
RListWidget * profileList
void on_profileList_itemChanged(QListWidgetItem *item)
static const int NEW_FLAG
KbProfile * currentProfile()
void profileList_reordered()
KbProfileDialog(KbWidget *parent=0)
int indexOf(KbProfile *profile)
void on_profileList_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
void setCurrentProfile(KbProfile *profile, bool spontaneous=true)
void append(KbMode *newMode)
const QList< KbProfile * > & profiles() const
void on_profileList_itemClicked(QListWidgetItem *item)
void appendProfile(KbProfile *newProfile)
void removeAll(KbMode *mode)
void setupUi(QDialog *KbProfileDialog)
KbProfile * find(const QUuid &id)