void PartitionModel::reload() { beginResetModel(); m_partitionList.clear(); if ( m_device ) { fillPartitionList( m_device->partitionTable() ); } endResetModel(); }
void PartitionModel::fillPartitionList( PartitionNode* parent ) { if ( !parent ) { return; } for ( auto partition : parent->children() ) { m_partitionList << partition; fillPartitionList( partition ); } }
// ======================================================= int CInterfaceNewt::guiInitMainWindow(char *szDevice, char *szImageFile, char *szNetworkIP, DWORD *dwServerPort, bool *bSsl) { newtComponent formMain, btnContinue, btnExit, btnAbout; newtComponent labelPartition, labelImage, editPartition, editImage, btnImage; newtComponent widgetTemp, labelAction, radioSave, radioRestore, radioMbr; newtComponent checkNetwork, labelNetwork, labelPort, editNetwork, editPort, checkSsl; newtExitStruct event; char szTemp[1024]; int nAction; int nRes; showDebug(8, "guiInitMainWindow\n"); SNPRINTF(szTemp, "Partition Image %s", PACKAGE_VERSION); newtCenteredWindow(67, 20, szTemp); labelPartition = newtLabel(1, 0, i18n("* Partition to save/restore")); editPartition = newtListbox(3, 1, 7, NEWT_FLAG_SCROLL); labelImage = newtLabel(1, 9, i18n("* Image file to create/use")); editImage = newtEntry(3, 10, szImageFile, 59, NULL, NEWT_FLAG_SCROLL); btnImage = newtCompactButton(62, 10, "*"); labelAction = newtLabel(1, 12, i18n("Action to be done:")); radioSave = newtRadiobutton(1, 13, i18n("Save partition into a new image file"), true, NULL); radioRestore = newtRadiobutton(1, 14, i18n("Restore partition from an image file"), false, radioSave); radioMbr = newtRadiobutton(1, 15, i18n("Restore an MBR from the image file"), false, radioRestore); checkNetwork = newtCheckbox(1, 17, i18n("Connect to server"), (!!(*szNetworkIP) ? 'X' : ' '), " X", NULL); #ifdef HAVE_SSL checkSsl = newtCheckbox(5, 19, i18n("Encrypt data on the network with SSL"), (*bSsl ? 'X' : ' '), " X", NULL); #else #ifdef MUST_LOGIN checkSsl = newtLabel(5, 19,i18n("SSL disabled at compile time")); #else checkSsl = newtLabel(5, 19,i18n("SSL&login disabled at compile time")); #endif #endif labelNetwork = newtLabel(5, 18, i18n("IP/name of the server:")); editNetwork = newtEntry(28, 18, szNetworkIP, 25, NULL, 0); labelPort = newtLabel(54, 18, i18n("Port:")); SNPRINTF(szTemp, "%u", *dwServerPort); editPort = newtEntry(60, 18, szTemp, 6, NULL, 0); btnContinue = newtCompactButton(50, 12, i18n("Next (F5)")); btnAbout = newtCompactButton(50, 14, i18n("About")); btnExit = newtCompactButton(50, 16, i18n("Exit (F6)")); nRes = fillPartitionList(editPartition); if (nRes == -1) RETURN_int(-1); formMain = newtForm(NULL, NULL, 0); newtFormAddComponents(formMain, labelPartition, labelImage, editPartition, editImage, btnImage, labelAction, radioSave, radioRestore, radioMbr, checkNetwork, labelNetwork, editNetwork, labelPort, editPort, checkSsl, btnContinue, btnAbout, btnExit, NULL); newtFormAddHotKey(formMain, KEY_EXIT); // Exit newtFormAddHotKey(formMain, KEY_OKAY); // Okay begin: /*widgetTemp = */newtFormRun(formMain, &event); widgetTemp = newtFormGetCurrent(formMain); if (((event.reason == event.NEWT_EXIT_HOTKEY) && (event.u.key == KEY_EXIT)) || ((event.reason == event.NEWT_EXIT_COMPONENT) && (widgetTemp == btnExit))) //if(widgetTemp == btnExit) return OPERATION_EXIT; if ((event.reason == event.NEWT_EXIT_COMPONENT) && (widgetTemp == btnAbout)) { showAboutDialog(); goto begin; } if ((event.reason == event.NEWT_EXIT_COMPONENT) && (widgetTemp == btnImage)) { char *fs_; fs_=filesel(newtEntryGetValue(editImage)); if(fs_) { newtEntrySet(editImage, fs_, 1); // free(fs_); } goto begin; } if (strcmp(newtEntryGetValue(editImage), "") == 0) // if "image" field empty { msgBoxError(i18n("The \"Image\" field is empty. Cannot continue")); goto begin; } if (newtCheckboxGetValue(checkNetwork) == 'X') { if (!(*newtEntryGetValue(editNetwork))) { msgBoxError(i18n("The \"Server IP/Name\" field is empty. Cannot continue")); goto begin; } if (!atoi((char*)newtEntryGetValue(editPort))) { msgBoxError(i18n("The \"Server Port\" field is not a valid integer. Cannot continue")); goto begin; } } // get device strcpy(szDevice, (char*)newtListboxGetCurrent(editPartition)); // image file strcpy(szImageFile, newtEntryGetValue(editImage)); // network if (newtCheckboxGetValue(checkNetwork) == 'X') // If network is activated { strcpy(szNetworkIP, (char*)newtEntryGetValue(editNetwork)); *dwServerPort = atoi((char*)newtEntryGetValue(editPort)); #ifdef HAVE_SSL *bSsl = (newtCheckboxGetValue(checkSsl) == 'X'); #endif } else // no network { *szNetworkIP = 0; *dwServerPort = OPTIONS_DEFAULT_SERVERPORT; } nAction = 0; if (newtRadioGetCurrent(radioRestore) == radioSave) { nAction = OPERATION_SAVE; } else if (newtRadioGetCurrent(radioRestore) == radioRestore) { nAction = OPERATION_RESTORE; } else if (newtRadioGetCurrent(radioRestore) == radioMbr) { nAction = OPERATION_RESTMBR; } newtFormDestroy(formMain); newtPopWindow(); return nAction; }