+
+
+void ControllerTab::UpdateProfileKeys(int mapPosition, uint32_t key)
+{
+ profile[profileNum].map[mapPosition] = key;
+}
+
+
+void ControllerTab::UpdateProfileConnections(int selection)
+{
+ profile[profileNum].preferredSlot = mapToList->itemData(selection).toInt();
+}
+
+
+void ControllerTab::ChangeDevice(int selection)
+{
+ int deviceNum = deviceList->itemData(selection).toInt();
+ mapNameList->clear();
+ int numberOfMappings = FindMappingsForDevice(deviceNum, mapNameList);
+ // Make sure to disable the "-" button is there's only one mapping for this
+ // device...
+ deleteMapName->setDisabled(numberOfMappings == 1 ? true : false);
+ // Set up new profile #...
+ ChangeMapName(0);
+}
+
+
+void ControllerTab::ChangeMapName(int selection)
+{
+ profileNum = mapNameList->itemData(selection).toInt();
+
+ for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
+ controllerWidget->keys[i] = profile[profileNum].map[i];
+
+ controllerWidget->update();
+ mapToList->setCurrentIndex(mapToList->findData(profile[profileNum].preferredSlot));
+}
+
+
+void ControllerTab::AddMapName(void)
+{
+ int freeProfile = GetFreeProfile();
+
+ if (freeProfile == -1)
+ {
+ // Oh crap, we're out of room! Alert the media!
+ QMessageBox::warning(this, tr("Houston, we have a problem..."), tr("Can't create any more profiles!"));
+
+ return;
+ }
+
+ QString text = QInputDialog::getText(this, tr("Add Map Name"), tr("Map name:"), QLineEdit::Normal);
+
+ if (text.isEmpty())
+ return;
+
+ // Add mapping...
+ profileNum = freeProfile;
+ profile[profileNum].device = deviceList->itemData(deviceList->currentIndex()).toInt();
+ strncpy(profile[profileNum].mapName, text.toAscii().data(), 31);
+ profile[profileNum].mapName[31] = 0;
+ profile[profileNum].preferredSlot = CONTROLLER1;
+
+ for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
+ profile[profileNum].map[i] = '*';
+
+ mapNameList->addItem(text, profileNum);
+#if 0
+ mapNameList->setCurrentIndex(mapNameList->count() - 1);
+#else
+ int selection = mapNameList->count() - 1;
+ mapNameList->setCurrentIndex(selection);
+ ChangeMapName(selection);
+ // We just added a new mapping, so enable the delete button!
+ deleteMapName->setDisabled(false);
+#endif
+}
+
+
+void ControllerTab::DeleteMapName(void)
+{
+ QString msg = QString("Map name: %1\n\nAre you sure you want to remove this mapping?").arg(profile[profileNum].mapName);
+
+// QMessageBox::StandardButton retVal = QMessageBox::question(this, tr("Remove Mapping"), tr("Are you sure you want to remove this mapping?"), QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
+ QMessageBox::StandardButton retVal = QMessageBox::question(this, tr("Remove Mapping"), msg, QMessageBox::No | QMessageBox::Yes, QMessageBox::No);
+
+ if (retVal == QMessageBox::No)
+ return;
+
+ int index = mapNameList->currentIndex();
+ int profileToRemove = profileNum;
+ mapNameList->removeItem(index);
+ DeleteProfile(profileToRemove);
+ // We need to reload the profile that we move to after deleting the current
+ // one...
+ ChangeMapName(mapNameList->currentIndex());
+ // If we get down to one profile left for the device, we need to make sure
+ // that the user can't delete it!
+ deleteMapName->setDisabled(mapNameList->count() == 1 ? true : false);
+}
+