/** * Adds the key/value pair to the HashMap. * @param object The key/value pair to add. * @return `true` if the insertion occurred. `false` otherwise. */ bool insert(ValueType const &object) override { if (shouldResize()) { resize(); } auto newHash = hash(object.first); // check if this key already exists. for (auto &v : _values[newHash]) { if (_keyEqual(v.first, object.first)) { v.second = object.second; return true; } } return _values[newHash].enqueue(object); }
DoubleVector DoubleVector::operator-(DoubleVector& rightVec) { shouldResize(rightVec); return make(rightVec, '-'); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { //initialize attributes this->clickController = new libTheClick::ClickController(); //create elements for drumkitPathStaticList //Q_OS_??? for operating system (e.g. DARWIN == MAC, WIN32, LINUX); Q_WS_??? for window system (e.g. X11, WIN32, MACX) #ifdef Q_OS_MAC this->drumkitPathStaticList.push_back( QCoreApplication::applicationDirPath() + "/../Resources/drumkits" ); this->drumkitPathStaticList.push_back( QDir::homePath() + "/Library/Application Support/Hydrogen/drumkits" ); #endif #ifdef Q_OS_LINUX this->drumkitPathStaticList.push_back( QCoreApplication::applicationDirPath() + "/drumkits" ); this->drumkitPathStaticList.push_back( "/usr/share/hydrogen/data/drumkits" ); #endif #ifdef Q_OS_WIN32 this->drumkitPathStaticList.push_back( QCoreApplication::applicationDirPath() + "/drumkits" ); #endif //load all drumkits for(QList<QString>::iterator it1 = this->drumkitPathStaticList.begin(); it1 != this->drumkitPathStaticList.end(); it1++) { QDir pathDir = QDir(*it1); QStringList dirsOfPath = pathDir.entryList(QDir::AllDirs); std::cout << "check directory: " << (*it1).toUtf8().constData() << std::endl; for (QStringList::const_iterator it2 = dirsOfPath.constBegin(); it2 != dirsOfPath.constEnd(); it2++) { if(*it2 != "." && *it2 != "..") { std::cout << "load: " << QDir::fromNativeSeparators(*it1 + "/" + *it2).toUtf8().constData() << std::endl; this->clickController->getSoundBase()->loadDrumKit( QDir::fromNativeSeparators(*it1 + "/" + *it2).toUtf8().constData() ); } } } //create form this->theClickForm = new Ui::TheClickForm(); this->theClickForm->setupUi( this ); //create Widgets this->speedWidget = new SpeedWidget( this->clickController, this->theClickForm->speedGroupBox ); this->speedWidget->speedDial->setMinimum(20); this->speedWidget->speedDial->setMaximum(300); this->speedWidget->setObjectName( QString::fromUtf8("speedWidget") ); this->speedWidget->setGeometry( QRect(10,10,170,620) ); // this->speedWidget->setGeometry( QRect(10,10,this->theClickForm->speedGroupBox->width()-20,this->theClickForm->speedGroupBox->height()-20) ); this->speedWidget->show(); this->clickGeneratorScrollListOfWidgets = new ScrollListOfWidgets( this->theClickForm->tabWidget ); this->theClickForm->tabWidget->addTab(this->clickGeneratorScrollListOfWidgets, QString::fromUtf8("ClickGenerators")); this->clickGeneratorScrollListOfWidgets->setGeometry( QRect(0,20,this->theClickForm->tabWidget->width(),this->theClickForm->tabWidget->height()-40) ); this->clickGeneratorDivisionWidget = new ClickGeneratorDivisionWidget(this->clickController); this->clickGeneratorScrollListOfWidgets->addWidget( this->clickGeneratorDivisionWidget); connect(this->clickGeneratorDivisionWidget, SIGNAL(shouldResize()), this, SLOT(shouldResize()) ); this->clickGeneratorXoYWidget = new ClickGeneratorXoYWidget(this->clickController); this->clickGeneratorScrollListOfWidgets->addWidget( this->clickGeneratorXoYWidget ); connect(this->clickGeneratorXoYWidget, SIGNAL(shouldResize()), this, SLOT(shouldResize()) ); this->clickGeneratorPASWidget = new ClickGeneratorPASWidget(this->clickController); this->clickGeneratorScrollListOfWidgets->addWidget( this->clickGeneratorPASWidget ); connect(this->clickGeneratorPASWidget, SIGNAL(shouldResize()), this, SLOT(shouldResize()) ); this->m_XToXAssociationWidget = new XToXAssociationWidget( XToXAssociationWidget::N_TO_ONE, this->theClickForm->tabWidget ); this->theClickForm->tabWidget->addTab(this->m_XToXAssociationWidget, QString::fromUtf8("Sound Configuration")); connect(this->m_XToXAssociationWidget, SIGNAL(associationChanged()), this, SLOT(soundConfigurationChanged())); //generate widgets for XToXAssociationWidge { QList<XToXAssociationAbstractWidget*>* widgetList = this->clickGeneratorDivisionWidget->XToXAssociationWidgetFactory(); for(QList<XToXAssociationAbstractWidget*>::iterator it = widgetList->begin(); it != widgetList->end(); it++) this->m_XToXAssociationWidget->pushBackLeftWidget( *it ); delete widgetList; } { QList<XToXAssociationAbstractWidget*>* widgetList = this->clickGeneratorXoYWidget->XToXAssociationWidgetFactory(); for(QList<XToXAssociationAbstractWidget*>::iterator it = widgetList->begin(); it != widgetList->end(); it++) this->m_XToXAssociationWidget->pushBackLeftWidget( *it ); delete widgetList; } { QList<XToXAssociationAbstractWidget*>* widgetList = this->clickGeneratorPASWidget->XToXAssociationWidgetFactory(); for(QList<XToXAssociationAbstractWidget*>::iterator it = widgetList->begin(); it != widgetList->end(); it++) this->m_XToXAssociationWidget->pushBackLeftWidget( *it ); delete widgetList; } { std::list<SoundInformation>* sil = this->clickController->getSoundBase()->getListOfAllSoundInformations(); for(std::list<SoundInformation>::iterator it = sil->begin(); it != sil->end(); it++) { SoundElementWidget* newSoundElementWidget = new SoundElementWidget( (*it).drumkitID, (*it).instrumentID ); newSoundElementWidget->setText( QString::fromStdString( (*it).name ) ); this->m_XToXAssociationWidget->pushBackRightWidget( newSoundElementWidget ); } delete sil; } //set sounds in click generators for(int i = 0; i < DIVSUBDIV__MAX_DIVISIONS; i++) { ClickGeneratorAbstractWidget::clickgensound_strings cgss; cgss.drumkitName = QString::fromUtf8("The Black Pearl 1.0 subset for TheClick"); cgss.instrumentName = QString::fromUtf8("Pearl Kick"); this->clickGeneratorDivisionWidget->setClickGenSoundStrings(i, cgss); } for(int i = 0; i < DIVSUBDIV__MAX_SUBDIVISIONS; i++) { ClickGeneratorAbstractWidget::clickgensound_strings cgss; cgss.drumkitName = QString::fromUtf8("The Black Pearl 1.0 subset for TheClick"); cgss.instrumentName = QString::fromUtf8("Sabian Hat Pedal"); this->clickGeneratorDivisionWidget->setClickGenSoundStrings(i + DIVSUBDIV__MAX_DIVISIONS, cgss); } { ClickGeneratorAbstractWidget::clickgensound_strings cgss; cgss.drumkitName = QString::fromUtf8("Gimme A Hand 1.0"); cgss.instrumentName = QString::fromUtf8("Bongo Hi"); this->clickGeneratorPASWidget->setClickGenSoundStrings(PAS_SOUNDID_LEFT_ACCENT, cgss); this->clickGeneratorPASWidget->setClickGenSoundStrings(PAS_SOUNDID_LEFT_NORMAL, cgss); this->clickGeneratorPASWidget->setClickGenSoundStrings(PAS_SOUNDID_LEFT_GHOST, cgss); cgss.instrumentName = QString::fromUtf8("Bongo Lo"); this->clickGeneratorPASWidget->setClickGenSoundStrings(PAS_SOUNDID_RIGHT_ACCENT, cgss); this->clickGeneratorPASWidget->setClickGenSoundStrings(PAS_SOUNDID_RIGHT_NORMAL, cgss); this->clickGeneratorPASWidget->setClickGenSoundStrings(PAS_SOUNDID_RIGHT_GHOST, cgss); } { ClickGeneratorAbstractWidget::clickgensound_strings cgss; cgss.drumkitName = QString::fromUtf8("The Black Pearl 1.0 subset for TheClick"); cgss.instrumentName = QString::fromUtf8("Pearl Snare"); this->clickGeneratorXoYWidget->setClickGenSoundStrings(XOY_SOUNDID_Y, cgss); cgss.instrumentName = QString::fromUtf8("Pearl Snare Rimshot"); this->clickGeneratorXoYWidget->setClickGenSoundStrings(XOY_SOUNDID_X, cgss); } //bring MainWindow to appropriate size QResizeEvent re(this->size(), this->size()); this->resizeEvent(&re); }