示例#1
0
void NewRecordUser::check()
{
	textRead();
	if (emptyLine())
	{
		if (Site::checkUrl(m_url))
		{
			addMessage();
		}
		else 
		{
			ui->lineError->setText(Scale::coded("URL не работает."));
		}
	}
	else
	{
		ui->lineError->setText(Scale::coded("Заполни все поля, товарищ!"));
	}
}
示例#2
0
void ConsoleWidget::prompt(QString text)
{
    QString text2 = text;

    moveCursor(QTextCursor::End);

    handleColor(); // change to default color

    // add space because it looks better
    text2 += " ";

    // go to new line if line isn't empty
    emptyLine();
    insertPlainText(text2);
    m_lastLine = "";
    // if we have trouble keeping viewport
    QScrollBar *sb = verticalScrollBar();
    sb->setSliderPosition(sb->maximum());

    m_prompt = text2;
}
示例#3
0
void ConsoleWidget::print(QString text, QColor color)
{
    emptyLine();
    moveCursor(QTextCursor::End);
    handleColor(color);
    m_mutexPrint.lock();
    if (text==m_lastLine)
    {
        if (!m_suppress)
        {
            insertPlainText("...\n");
            m_suppress = true;
        }
    }
    else
    {
        insertPlainText(text);
        m_suppress = false;
    }
    m_lastLine = text;
    m_waitPrint.wakeAll();
    m_mutexPrint.unlock();
}
void AdDisplayMenu::print() {
	//first line, only borderChar
	for (unsigned int i = 0; i < width; i++)
		cout << borderChar;

	cout << endl;

	//includes top margin with is a line full of spaces, with borderChar on either side
	for (unsigned int i = 0; i < topMargin; i++)
		emptyLine();

	cout << borderChar << " ";
	string adType;
	if (ad->getType() == 'P')
		adType = "Purchase";
	else
		adType = "Sale";
	adType += " Ad";

	cout << adType << string(width - 3 - adType.length(), ' ') << borderChar << endl;
	emptyLine();

	//display title
	string title = ad->getTitle();
	cout << borderChar << " Title: " << title
			<< string(width - 2 - 8 - title.length(), ' ') << borderChar << endl;

	//a white line between title and description
	emptyLine();

	cout << borderChar << " Category: " << categoryToString(ad->getCategory())
			<< string(
					width - 2 - 11
							- categoryToString(ad->getCategory()).length(), ' ')
			<< borderChar << endl;

	emptyLine();

	//used to add menu options correctly
	string description = ad->getDescription();

	cout << borderChar << " Description: " << description
			<< string(width - 2 - 14 - description.length(), ' ') << borderChar
			<< endl;

	if(ad->getType() == 'S'){
		emptyLine();
		Sale* sale = static_cast<Sale*> (ad);
		string cond = conditionToString(sale->getCondition());
		cout << borderChar << " Product Condition: " << cond << string(width-2-20- cond.length(), ' ') << borderChar << endl;
	}


	//a white line between description and contacts
	emptyLine();

	cout << borderChar << " Creation Date: " << ad->getCreationDate()
			<< string(width - 2 - 16 - ad->getCreationDate().length(), ' ')
			<< borderChar << endl;

	bool showEmail = ad->getOwner()->getShowEmail();
	bool showName = ad->getOwner()->getShowName();
	bool showPhoneNumber = ad->getOwner()->getShowPhoneNumber();

	if (showEmail || showName || showPhoneNumber) {
		if (showEmail) {
			string email = ad->getOwner()->getEmail();
			cout << borderChar << " Email: " << email
					<< string(width - 2 - 8 - email.length(), ' ') << borderChar
					<< endl;
		}

		if (showName) {
			string name = ad->getOwner()->getName();
			cout << borderChar << " Name: " << name
					<< string(width - 2 - 7 - name.length(), ' ') << borderChar
					<< endl;
		}

		if (showPhoneNumber) {
			string phoneNumber = ad->getOwner()->getPhoneNumber();
			cout << borderChar << " Phone Number: " << phoneNumber
					<< string(width - 2 - 15 - phoneNumber.length(), ' ')
					<< borderChar << endl;
		}
		emptyLine();
	}
	stringstream ss;
	ss << ad->getViews();
	cout << borderChar << " Views: " << ss.str()
			<< string(width - 2 - 8 - ss.str().length(), ' ') << borderChar
			<< endl;
	emptyLine();

	ss.str("");
	ss << ad->getPrice() << "  ";
	if (!ad->isPriceNegotiable())
		ss << "Non-";
	ss << "Negotiable";
	cout << borderChar << " Price: " << ss.str()
			<< string(width - 2 - 8 - ss.str().length(), ' ') << borderChar
			<< endl;
	emptyLine();

	unsigned int i = 1;
	if (data->getSignedInUser() == ad->getOwner()) {
		string editTitle = "1 - Edit title";
		cout << borderChar << " " << editTitle
				<< string(width - 3 - editTitle.length(), ' ') << borderChar
				<< endl;
		string editDescription = "2 - Edit description";
		cout << borderChar << " " << editDescription
				<< string(width - 3 - editDescription.length(), ' ')
				<< borderChar << endl;
		string editCategory = "3 - Edit category";
		cout << borderChar << " " << editCategory
				<< string(width - 3 - editCategory.length(), ' ') << borderChar
				<< endl;
		string editPrice = "4 - Edit price";
		cout << borderChar << " " << editPrice
				<< string(width - 3 - editPrice.length(), ' ') << borderChar
				<< endl;
		string removeAd = "5 - Remove advertisement";
		cout << borderChar << " " << removeAd
				<< string(width - 3 - removeAd.length(), ' ') << borderChar
				<< endl;
		i = 6;
	} else {
		string imInterested = " 1 - I'm interested";
		i = 2;
		cout << borderChar << imInterested
				<< string(width - imInterested.length() - 2, ' ') << borderChar
				<< endl;
	}
	ss.str("");
	ss << " " << i << " - Exit";
	cout << borderChar << ss.str() << string(width - ss.str().length() - 2, ' ')
			<< borderChar << endl;

	emptyLine();

	//last line
	for (unsigned int i = 0; i < width; i++)
		cout << borderChar;

	cout << endl;
}
示例#5
0
void ConsoleWidget::error(QString text)
{
    emptyLine();
    print("error: " + text, Qt::red);
}