void MSOptionPopupMenu::update(const MSIndexVector& index_) { if (MSView::model()!=0) { if (index_.length()==0) { if (optionsModel().length()==itemCount()) { MSMenuItem *mi; int i,n=itemCount(); for(i=0;i<n;i++) { mi=(MSMenuItem *)itemVector()(i); mi->label(optionsModel()(i)); } computeSize(); optionMenu()->setSelectedItem(0); optionMenu()->computeSize(); } else rebuildMenu(); } else { MSIndexVector iv(index_); iv.sortUp(); if (iv(0)==itemCount()) { for (unsigned i=0,j=itemCount();i<iv.length();i++,j++) { MSMenuItem *pMenuItem=new MSMenuItem(this,optionsModel()(j),0,j); setItem(pMenuItem,j); } } else { for (unsigned i=0;i<iv.length();i++) { unsigned index=iv(i); MSMenuItem *mi=menuItem(index); if (mi!=0) mi->label(optionsModel()(index)); } } } computeSize(); optionMenu()->computeSize(); } }
void MSOptionMenu::setSelectedItem(int item_) { _selectedItem=item_; if(hasModel()==MSTrue) { if(optionMenu()!=0) { _internalEvent=MSTrue; if(_selectedItem<optionsModel().length()) { viewModel()=optionsModel()(_selectedItem); } else viewModel().removeAll(); _internalEvent=MSFalse; } } }
MSOptionMenu::MSOptionMenu(MSWidget *owner_,MSString& model_, MSStringVector& options_,const char *label_) : MSCompositeField(owner_,label_) { init(); optionsModel(options_); model(model_); }
void MSOptionPopupMenu::rebuildMenu(void) { removeAllItems(); if (MSView::model()!=0) { unsigned n=optionsModel().length(); if (n>0) { for (unsigned i=0;i<n;i++) { MSMenuItem *pMenuItem=new MSMenuItem(this,optionsModel()(i),0,i); setItem(pMenuItem,i); } } } computeSize(); optionMenu()->setSelectedItem(0); optionMenu()->computeSize(); }
void MSOptionMenu::updateData(void) { if(hasModel() == MSTrue && _internalEvent == MSFalse) { _internalEvent=MSTrue; unsigned index; if(optionMenu()==0) { if(viewModel().length()!=0) { MSStringVector sv(viewModel()); options(sv); _selectedItem=0; } } else { if(viewModel().length()!=0) { index = optionsModel().indexOf(viewModel()); if(index == optionsModel().length()) { //append the new value to the list. optionsModel().appendSingle(viewModel()); } _selectedItem=index; drawFieldValue(); } else { if(_selectedItem<optionsModel().length()) { viewModel()=optionsModel()(_selectedItem); } else viewModel().removeAll(); } } _internalEvent=MSFalse; } }
int main(int argc, char *argv[]) { // Do this early as we don't want to bother initializing if we are just calling IPC for (int i = 1; i < argc; i++) { if (strlen(argv[i]) > 7 && strncasecmp(argv[i], "bitcoin:", 8) == 0) { const char *strURL = argv[i]; try { boost::interprocess::message_queue mq(boost::interprocess::open_only, "BitcoinURL"); if(mq.try_send(strURL, strlen(strURL), 0)) exit(0); else break; } catch (boost::interprocess::interprocess_exception &ex) { break; } } } // Internal string conversion is all UTF-8 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForTr()); Q_INIT_RESOURCE(bitcoin); QApplication app(argc, argv); ParseParameters(argc, argv); // Get desired locale ("en_US") from command line or system locale QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString())); // Load language files for configured locale: // - First load the translator for the base language, without territory // - Then load the more specific locale translator QString lang = lang_territory; lang.truncate(lang_territory.lastIndexOf('_')); // "en" QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator; qtTranslatorBase.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang); if (!qtTranslatorBase.isEmpty()) app.installTranslator(&qtTranslatorBase); qtTranslator.load(QLibraryInfo::location(QLibraryInfo::TranslationsPath) + "/qt_" + lang_territory); if (!qtTranslator.isEmpty()) app.installTranslator(&qtTranslator); translatorBase.load(":/translations/"+lang); if (!translatorBase.isEmpty()) app.installTranslator(&translatorBase); translator.load(":/translations/"+lang_territory); if (!translator.isEmpty()) app.installTranslator(&translator); app.setApplicationName(QApplication::translate("main", "Bitcoin-Qt")); QSplashScreen splash(QPixmap(":/images/splash"), 0); splash.show(); splash.setAutoFillBackground(true); splashref = &splash; app.processEvents(); app.setQuitOnLastWindowClosed(false); try { if(AppInit2(argc, argv)) { { // Put this in a block, so that BitcoinGUI is cleaned up properly before // calling Shutdown() in case of exceptions. BitcoinGUI window; splash.finish(&window); OptionsModel optionsModel(pwalletMain); ClientModel clientModel(&optionsModel); WalletModel walletModel(pwalletMain, &optionsModel); guiref = &window; window.setClientModel(&clientModel); window.setWalletModel(&walletModel); // If -min option passed, start window minimized. if(GetBoolArg("-min")) { window.showMinimized(); } else { window.show(); } // Place this here as guiref has to be defined if we dont want to lose URLs ipcInit(); // Check for URL in argv for (int i = 1; i < argc; i++) { if (strlen(argv[i]) > 7 && strncasecmp(argv[i], "bitcoin:", 8) == 0) { const char *strURL = argv[i]; try { boost::interprocess::message_queue mq(boost::interprocess::open_only, "BitcoinURL"); mq.try_send(strURL, strlen(strURL), 0); } catch (boost::interprocess::interprocess_exception &ex) { } } } app.exec(); guiref = 0; } Shutdown(NULL); } else { return 1; } } catch (std::exception& e) { PrintException(&e, "Runaway exception"); } catch (...) { PrintException(NULL, "Runaway exception"); } return 0; }