Пример #1
0
void Modules::populateRow(bool fixed, int rType, string prompt) {
    char answer;
    bool valid; //input valid check

    do {
        valid = true;
        cout << endl << "Would you like to use a randomly-generated twelve-tone row? (y/n): ";
        cin >> answer;
        if (!cin)
            inputInvalid(valid);
        else {
            switch (answer) {
                case 'y':
                    setRowSize(12, rType);
                    generateTwelve(rType);
                    break;
                case 'n':
                    cout << endl << prompt << endl;
                    if(fixed == false)	// if the array size is not fixed, prompt user to input size
                        inputRowLength(rType);
                    inputRow(rType);
                    break;
                default:
                    inputInvalid(valid);
            }
        }
    } while (valid == false);
}
Пример #2
0
void Modules::outputting(char &f, ofstream &outFile) {
    string fName;
    bool valid;

    do {
        valid = true;
        cout << "Would you like to write to a file? (y/n): ";
        cin >> f;
        if (!cin)
            inputInvalid(valid);
        else {
            switch (f) {
                case 'y':
                    cout << "Enter a file name (to append, enter the name of an existing file): ";
                    cin >> fName;
                    outFile.open(fName.c_str(), ios::app);
                    break;
                case 'n':
                    break;
                default:
                    inputInvalid(valid);
            }
        }
    } while (valid == false);
}
Пример #3
0
int Modules::rotationDirection() {
    char direction;
    bool valid;

    do {
        valid = true;
        cout << endl << "Would you like to rotate to the left instead of to the right? (y/n): ";
        cin >> direction;
        if (!cin)
            inputInvalid(valid);	// back to loop if input is invalid
        else {
            switch (direction) {
                case 'y': return -1;    // rotate to left
                case 'n': return 1; // rotate to right
                default: inputInvalid(valid);
            }
        }
    } while (valid == false);
    return 1;
}
Пример #4
0
void Modules::inputRowLength(int rType, int lim, string num) {
    bool valid;	// input valid check
    int input;	// size of row

    do {
        valid = true;
        cout << "How many pitches would you like in your " << num << "row (1-" << lim << ")? ";
        cin >> input;
        if (input < 1 || input > lim || !cin) {
            inputInvalid(valid);
            continue;
        }
        setRowSize(input, rType);
    } while (valid == false);
}
Пример #5
0
void Modules::inputRow(int rType, string num) {
    bool valid;	// input valid check
    string input;

    for (int i = 0; i < getRowSize(rType); i++) {
        cout << "Enter your " << num << "row in pitches or numbers (" << i + 1 << "): ";
        do {
            valid = true;
            cin >> input;
            if (pitchToNum(input) == -1) {
                inputInvalid(valid);
                continue;
            }
            setRow(i, pitchToNum(input), rType);
        } while (valid == false);
    }
}
Пример #6
0
void Modules::inputRowNor() {
    bool valid;	// input valid check
    int input;

    for (int i = 0; i < getRowSize(1); i++) {
        cout << "Enter your row in any integers between -" << MAXINT
            << " and " << MAXINT << " (" << i + 1 << "): ";
        do {
            valid = true;
            cin >> input;
            if (getRow(i, 1) < -MAXINT || getRow(i, 1) > MAXINT || !cin) {
                inputInvalid(valid);
                continue;
            }
            setRow(i, input, 1);
        } while (valid == false);
    }
}
Пример #7
0
/*!
 * \en	Validate value and paint LineEdit frame. \_en
 * \ru	Проверяет значение и рисует рамку поля ввода.\_ru
 */
void
wField::Validate(const QString &test)
{
	
	int p = 0;
	QString s = test;
	// restore LineEdit color state
	lineEdit->setPalette( defaultLineEditPalette );
	lineEdit->setMargin( defaultLineEditFrameMargin );
	lineEdit->setFrameStyle( defaultLineEditFrameStyle );

	if ( test.isNull()  || test.isEmpty() ) return;

	QPalette pal = lineEdit->palette();
	switch ( v->validate(s, p) )
	{
		case QValidator::Invalid:
			lineEdit->setFrameStyle(QFrame::Box);
			lineEdit->setMargin(2);
			pal.setColor(QPalette::Active, QColorGroup::Light, Qt::red);
			lineEdit->setPalette(pal);
			emit inputInvalid();
			break;
		case QValidator::Intermediate:
			lineEdit->setFrameStyle(QFrame::Box);
			lineEdit->setMargin(2);
			if (two_state == 0) {
				pal.setColor(QPalette::Active, QColorGroup::Light, Qt::yellow);
			}else{
				pal.setColor(QPalette::Active, QColorGroup::Light, Qt::red);
			}
			lineEdit->setPalette(pal);
			setValue( test );
			break;
		case QValidator::Acceptable:
			lineEdit->setFrameStyle(QFrame::Box);
			lineEdit->setMargin(2);
			pal.setColor(QPalette::Active, QColorGroup::Light, Qt::green);
			lineEdit->setPalette(pal);
			setValue( test );
			break;
	}
}