void Configuration::ConfigFile::show() { debugOutput(DEBUG_LEVEL_NORMAL, " config file: %s\n", getName().c_str()); Setting &root = getRoot(); if(root.getLength()) { showSetting(root, ""); } else { debugOutput(DEBUG_LEVEL_NORMAL, " Empty\n"); } }
Scanner::Scanner(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) , _model(this) , _delegate(this) , _dynamicButtons(Qt::Vertical, this) , _thread(this) , _setting(this) { _ui.setupUi(this); _ui.horizontalLayout->addWidget(&_dynamicButtons); _ui.vehicleList->setModel(&_model); _ui.vehicleList->setItemDelegate(&_delegate); _dynamicButtons.addBtn(trUtf8("Enter")); _dynamicButtons.addBtn(trUtf8("Quit")); connect(&_dynamicButtons, SIGNAL(sendBtnClkByInx(int)), this, SLOT(btnClked(int))); connect(_ui.actionSettings, SIGNAL(triggered()), this, SLOT(showSetting())); connect(_ui.actionRegister, SIGNAL(triggered()), this, SLOT(showRegister())); showSetting(); scanVehicles(); }
int main() { union view font = {{1,12,RIGHT,OFF,OFF,OFF}};//初始化联合的第一个成员,结构体 FONT * pf = &font.st_view; char ch; //init /*font.st_view.font_id = 1; font.st_view.font_size = 12; font.st_view.alignment = LEFT; font.st_view.font_bold = OFF; font.st_view.font_italic = OFF; font.st_view.font_underline = OFF;*/ showSetting(pf); while((ch = menu()) != 'q') { puts("Enter your mode:"); puts("f)bit field mode\tb)bit mode"); switch(ch) { case 'f': ch = getchar(); delMore(); switch(ch) { case 'f':fontId(pf);break; case 'b':bitId(&font.ui_view);break; } break; case 's': ch = getchar(); delMore(); switch(ch) { case 'f':fontSize(pf);break; case 'b':bitSize(&font.ui_view);break; } break; case 'a': ch = getchar(); delMore(); switch(ch) { case 'f':fontAlignment(pf);break; case 'b':bitAlign(&font.ui_view);break; } break; case 'b': ch = getchar(); delMore(); switch(ch) { case 'f':fontBold(pf);break; case 'b':bitBold(&font.ui_view);break; } break; case 'i': ch = getchar(); delMore(); switch(ch) { case 'f':fontItalic(pf);break; case 'b':bitItalic(&font.ui_view);break; } break; case 'u': ch = getchar(); delMore(); switch(ch) { case 'f':fontUnderline(pf);break; case 'b':bitUnderline(&font.ui_view);break; } break; default: puts("Error input,Please type in an character such as f s a b i u or q:"); break; } showSetting(pf); } itobs(font.ui_view); return 0; }
void Configuration::ConfigFile::showSetting(libconfig::Setting &s, std::string prefix) { unsigned int children = s.getLength(); Setting::Type t = s.getType(); switch(t) { case Setting::TypeGroup: debugOutput(DEBUG_LEVEL_NORMAL, " %sGroup: %s\n", prefix.c_str(), s.getName()); for(unsigned int i = 0; i < children; i++) { showSetting(s[i], prefix + " "); } break; case Setting::TypeList: debugOutput(DEBUG_LEVEL_NORMAL, " %sList: %s\n", prefix.c_str(), s.getName()); for(unsigned int i = 0; i < children; i++) { showSetting(s[i], prefix + " "); } break; case Setting::TypeArray: debugOutput(DEBUG_LEVEL_NORMAL, " %sArray: %s\n", prefix.c_str(), s.getName()); for(unsigned int i = 0; i < children; i++) { showSetting(s[i], prefix + " "); } break; case Setting::TypeInt: { int32_t i = s; debugOutput(DEBUG_LEVEL_NORMAL, " %s%s = %d (0x%08X)\n", prefix.c_str(), s.getName(), i, i); } break; case Setting::TypeInt64: { int64_t i = s; debugOutput(DEBUG_LEVEL_NORMAL, " %s%s = %"PRId64" (0x%016"PRIX64")\n", prefix.c_str(), s.getName(), i, i); } break; case Setting::TypeFloat: { float f = s; debugOutput(DEBUG_LEVEL_NORMAL, " %s%s = %f\n", prefix.c_str(), s.getName(), f); } break; case Setting::TypeString: { std::string str = s; debugOutput(DEBUG_LEVEL_NORMAL, " %s%s = %s\n", prefix.c_str(), s.getName(), str.c_str()); } break; case Setting::TypeBoolean: { bool b = s; std::string str = (b?"true":"false"); debugOutput(DEBUG_LEVEL_NORMAL, " %s%s = %s\n", prefix.c_str(), s.getName(), str.c_str()); } break; default: { debugOutput(DEBUG_LEVEL_NORMAL, " %s%s = Unsupported Type\n", prefix.c_str(), s.getName()); } break; } }