Example #1
0
void UserActionDlg::InsertCONTACTData(
	const std::wstring& name,
	const std::wstring& phone,
	const std::wstring& remark)
{
	QTableWidget* table = ui.tbAddressBook;
	QTableWidgetItem* nameItem = new QTableWidgetItem;
	QTableWidgetItem* phoneItem = new QTableWidgetItem;
	QTableWidgetItem* locationItem = new QTableWidgetItem;
	QTableWidgetItem* networkItem = new QTableWidgetItem;
	QTableWidgetItem* remarkItem = new QTableWidgetItem;
	QTableWidgetItem* getTimeItem = new QTableWidgetItem;
	getTimeItem->setTextAlignment(Qt::AlignCenter);

	nameItem->setText(QString::fromStdWString(name));
	phoneItem->setText(QString::fromStdWString(phone));
	remarkItem->setText(QString::fromStdWString(remark));
	getTimeItem->setText(TGetCurrentTime().c_str());

	std::wstring location, netService;
	DM->GetLocationFromPhoneNumber(phone, location, netService);
	locationItem->setText(QString::fromStdWString(location));
	networkItem->setText(QString::fromStdWString(netService));

	nameItem->setIcon(QIcon(QPixmap("image/group.png")));

	table->insertRow(0);
	table->setItem(0, 0, nameItem);
	table->setItem(0, 1, phoneItem);
	table->setItem(0, 2, locationItem);
	table->setItem(0, 3, networkItem);
	table->setItem(0, 4, remarkItem);
	table->setItem(0, 5, getTimeItem);
}
void model_import_dlg::on_texture_dialog_done(bool add, QString path, QString type)
{
	QTableWidget * table = mesh_tab->findChild<QTableWidget*>("texturesTable");

	int row = 0;

	if (add)
	{
		row = table->rowCount();
		table->insertRow(row);
	}
	else
	{
		row = table->currentRow();
	}

	table->setItem(row, 0, new QTableWidgetItem(path));
	table->setItem(row, 1, new QTableWidgetItem(type));
	table->setColumnWidth(0, 350);
	table->setColumnWidth(1, 150);

	for (int i = 0; i < table->rowCount(); i++)
		for (int j = 0; j < table->columnCount(); j++)
			table->item(i, j)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
Example #3
0
static QTableWidget* createFilesTable(const QStringList &fileNames)
{
    QTableWidget *table = new QTableWidget(0, 2);
    table->setSelectionMode(QAbstractItemView::NoSelection);

    QStringList labels({
                           QCoreApplication::translate("AddImageToResources","Filename"),
                           QCoreApplication::translate("AddImageToResources","Size")
                       });
    table->setHorizontalHeaderLabels(labels);
    table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
    table->verticalHeader()->hide();
    table->setShowGrid(false);

    for (const QString &filePath : fileNames) {
           const QString toolTip = QDir::toNativeSeparators(filePath);
           const QString fileName = QFileInfo(filePath).fileName();
           const qint64 size = QFileInfo(filePath).size() / 1024;
           QTableWidgetItem *fileNameItem = new QTableWidgetItem(fileName);
           fileNameItem->setToolTip(toolTip);
           fileNameItem->setFlags(fileNameItem->flags() ^ Qt::ItemIsEditable);
           QTableWidgetItem *sizeItem = new QTableWidgetItem(QString::number(size) + " KB");
           sizeItem->setToolTip(toolTip);
           sizeItem->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
           sizeItem->setFlags(sizeItem->flags() ^ Qt::ItemIsEditable);

           int row = table->rowCount();
           table->insertRow(row);
           table->setItem(row, 0, fileNameItem);
           table->setItem(row, 1, sizeItem);
       }

    return table;
}
Example #4
0
void ShortcutsWidget::addShortcutRow(MenuAction &action)
{
    QTableWidget *table = ui->tableWidget;

    const int row = table->rowCount();
    table->insertRow(row);

    auto tableItem = new QTableWidgetItem();
    action.tableItem = tableItem;
    table->setItem(row, Columns::Icon, tableItem);
    tableItem->setFlags(Qt::ItemIsEnabled);

    tableItem = new QTableWidgetItem(uiText(action.text));
    table->setItem(row, Columns::Text, tableItem);
    tableItem->setFlags(Qt::ItemIsEnabled);

    tableItem = new QTableWidgetItem();
    table->setItem(row, Columns::Type, tableItem);
    tableItem->setFlags(Qt::ItemIsEnabled);
    if (action.command.type() & CommandType::GlobalShortcut) {
        tableItem->setIcon( getIcon("", IconExternalLinkSquareAlt) );
        tableItem->setToolTip( tr("Shortcut can be triggered from any application") );
    }

    action.shortcutButton = new ShortcutButton(table);
    table->setCellWidget(row, Columns::Shortcut, action.shortcutButton);

    m_actions.append(action);

    connect( action.shortcutButton, &ShortcutButton::shortcutAdded,
             this, &ShortcutsWidget::onShortcutAdded );
    connect( action.shortcutButton, &ShortcutButton::shortcutRemoved,
             this, &ShortcutsWidget::onShortcutRemoved );
}
Example #5
0
void ItemTagsLoader::addTagToSettingsTable(const ItemTagsLoader::Tag &tag)
{
    QTableWidget *t = ui->tableWidget;

    const int row = t->rowCount();

    t->insertRow(row);
    t->setItem( row, tagsTableColumns::name, new TagTableWidgetItem(tag.name) );
    t->setItem( row, tagsTableColumns::match, new QTableWidgetItem(tag.match) );
    t->setItem( row, tagsTableColumns::styleSheet, new QTableWidgetItem(tag.styleSheet) );
    t->setItem( row, tagsTableColumns::color, new QTableWidgetItem() );
    t->setItem( row, tagsTableColumns::icon, new QTableWidgetItem() );

    auto colorButton = new QPushButton(t);
    const QColor color = tag.color.isEmpty()
            ? QColor::fromRgb(50, 50, 50)
            : deserializeColor(tag.color);
    setColorIcon(colorButton, color);
    t->setCellWidget(row, tagsTableColumns::color, colorButton);
    connect(colorButton, &QAbstractButton::clicked, this, &ItemTagsLoader::onColorButtonClicked);

    auto iconButton = new IconSelectButton(t);
    iconButton->setCurrentIcon(tag.icon);
    t->setCellWidget(row, tagsTableColumns::icon, iconButton);
    connect(iconButton, &IconSelectButton::currentIconChanged, this, &ItemTagsLoader::onAllTableWidgetItemsChanged);

    onTableWidgetItemChanged(t->item(row, 0));
}
Example #6
0
void SkillEditFrame::onCurrentItemChanged(DataContainerItem *current) {
	if (current == 0)
		return;
	QTableWidget *skillTable = this->findChild<QTableWidget *>("skillTable");
	DataContainerItem *item = current;
	if (item->getStringData().size() > 0) {
		StatsContainer *skill = GenStatsReader::getContainer(*skillStats, item->getStringData());
		if (skill != 0) {
			typedef std::map<std::string, std::string> StringMap;
			StringMap dataMap = skill->getBaseDataMap();
			for (int i=0; i<skillTable->rowCount(); ++i) {
				for (int j=0; j<skillTable->columnCount(); ++j) {
					delete skillTable->item(i, j);
				}
			}
			
			skillTable->setRowCount(0);
			int row = 0;
			for (StringMap::iterator it = dataMap.begin(); it != dataMap.end(); ++it) {
				QTableWidgetItem *nameItem = new QTableWidgetItem();
				nameItem->setText(it->first.c_str());
				QTableWidgetItem *valueItem = new QTableWidgetItem();
				valueItem->setText(it->second.c_str());
				skillTable->insertRow(row);
				skillTable->setItem(row, 0, nameItem);
				skillTable->setItem(row, 1, valueItem);
				++row;
			}

			skillTable->resizeRowsToContents();
			skillTable->resizeColumnsToContents();
		}
	}
}
Example #7
0
void UserActionDlg::InsertSMSData(
	LONG type,
	const std::wstring& address,
	const std::wstring& msg,
	const std::wstring& date)
{
	QTableWidget* table = ui.tbMessageInfo;
	QTableWidgetItem* time = new QTableWidgetItem;
	time->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* typeItem = new QTableWidgetItem;
	typeItem->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* contact = new QTableWidgetItem;
	QTableWidgetItem* message = new QTableWidgetItem;
	QTableWidgetItem* getTime = new QTableWidgetItem;
	getTime->setTextAlignment(Qt::AlignCenter);

	time->setText(QString::fromStdWString(date));
	typeItem->setText(type == 1 ? 
		QString::fromLocal8Bit("发送") : QString::fromLocal8Bit("接收"));
	contact->setText(QString::fromStdWString(address));
	message->setText(QString::fromStdWString(msg));
	getTime->setText(QString::fromStdWString(AnsiToWide(TGetCurrentTime())));

	table->insertRow(0);
	table->setItem(0, 0, time);
	table->setItem(0, 1, typeItem);
	table->setItem(0, 2, contact);
	table->setItem(0, 3, message);
	table->setItem(0, 4, getTime);
}
Example #8
0
void CocktailDialog::initQTablaWidget()
{
    ui->lineEditNomeCocktail->setText (QString::fromStdString (c->getNomeCocktail ()));
    ui->lineEditMomCons->setText (QString::fromStdString (c->getMomentoConsumo ()));

    Drink* d  = c->getDrink ();


    QTableWidget* tw = ui->tableIngridientiWidget;

    int s = d->howManyElements ();

for (int i = 0; i < s; ++i)
{
    tw->insertRow (i);
    QTableWidgetItem* itemTipo  = new QTableWidgetItem;
    QTableWidgetItem* itemNome  = new QTableWidgetItem;
    QTableWidgetItem* itemQuantita  = new QTableWidgetItem;
    QTableWidgetItem* itemPalc  = new QTableWidgetItem;


    itemTipo->setData (0, QVariant(QString::fromStdString (d->getChild (i)->getTipo ())));
    itemNome->setData (0, QVariant(QString::fromStdString (d->getChild (i)->getNome ())));
    itemQuantita->setData(0, QVariant(QString::number (d->getChild (i)->volume ())));
    itemPalc->setData(0, QVariant(QString::number (d->getChild (i)->getPercentualeAlcolica ())));

    tw->setItem (i, 0, itemTipo);
    tw->setItem (i, 1, itemNome);
    tw->setItem (i, 2, itemQuantita);
    tw->setItem (i, 3, itemPalc);
 }
}
Example #9
0
QWidget *ItemSyncLoader::createSettingsWidget(QWidget *parent)
{
    ui.reset(new Ui::ItemSyncSettings);
    QWidget *w = new QWidget(parent);
    ui->setupUi(w);

    // Init tab sync path table.
    const QStringList tabPaths = m_settings.value(configSyncTabs).toStringList();
    QTableWidget *t = ui->tableWidgetSyncTabs;
    for (int row = 0, i = 0; i < tabPaths.size() + 20; ++row, i += 2) {
        t->insertRow(row);
        t->setItem( row, syncTabsTableColumns::tabName, new QTableWidgetItem(tabPaths.value(i)) );
        t->setItem( row, syncTabsTableColumns::path, new QTableWidgetItem(tabPaths.value(i + 1)) );

        QPushButton *button = createBrowseButton();
        t->setCellWidget(row, syncTabsTableColumns::browse, button);
        connect( button, &QAbstractButton::clicked,
                 this, &ItemSyncLoader::onBrowseButtonClicked );
    }
    setNormalStretchFixedColumns(t, syncTabsTableColumns::tabName, syncTabsTableColumns::path,
                                 syncTabsTableColumns::browse);

    // Init file format table.
    const QVariantList formatSettings = m_settings.value(configFormatSettings).toList();
    t = ui->tableWidgetFormatSettings;
    for (int row = 0; row < formatSettings.size() + 10; ++row) {
        const QVariantMap format = formatSettings.value(row).toMap();
        const QString formats = format.value("formats").toStringList().join(", ");
        t->insertRow(row);
        t->setItem( row, formatSettingsTableColumns::formats, new QTableWidgetItem(formats) );
        t->setItem( row, formatSettingsTableColumns::itemMime, new QTableWidgetItem(format.value("itemMime").toString()) );

        auto button = new IconSelectButton();
        button->setCurrentIcon( format.value("icon").toString() );
        t->setCellWidget(row, formatSettingsTableColumns::icon, button);
    }
    setNormalStretchFixedColumns(t, formatSettingsTableColumns::formats,
                                 formatSettingsTableColumns::itemMime,
                                 formatSettingsTableColumns::icon);

    return w;
}
Example #10
0
void ShortcutsWidget::loadShortcuts(QSettings &settings)
{
    MenuItems items = menuItems();
    ::loadShortcuts(&items, settings);

    m_actions.clear();
    m_shortcuts.clear();

    QTableWidget *table = ui->tableWidget;
    while (table->rowCount() > 0)
        table->removeRow(0);


    foreach (const MenuItem &item, items) {
        MenuAction action;
        action.iconName = item.iconName;
        action.iconId = item.iconId;
        action.text = item.text;
        action.settingsKey = item.settingsKey;

        const int row = table->rowCount();
        table->insertRow(row);

        QTableWidgetItem *tableItem = new QTableWidgetItem();
        table->setItem(row, Columns::Empty, tableItem);
        tableItem->setFlags(Qt::NoItemFlags);

        tableItem = new QTableWidgetItem();
        action.tableItem = tableItem;
        table->setItem(row, Columns::Icon, tableItem);
        tableItem->setFlags(Qt::ItemIsEnabled);

        tableItem = new QTableWidgetItem(uiText(action.text));
        table->setItem(row, Columns::Text, tableItem);
        tableItem->setFlags(Qt::ItemIsEnabled);

        action.shortcutButton = new ShortcutButton(table);
        table->setCellWidget(row, Columns::Shortcut, action.shortcutButton);
        action.shortcutButton->setDefaultShortcut(item.defaultShortcut);
        foreach (const QKeySequence &shortcut, item.shortcuts)
            action.shortcutButton->addShortcut(shortcut);

        action.iconId = item.iconId;
        m_actions.append(action);

        m_shortcuts << item.shortcuts;
        m_timerCheckAmbiguous.start();

        connect( action.shortcutButton, SIGNAL(shortcutAdded(QKeySequence)),
                 this, SLOT(onShortcutAdded(QKeySequence)) );
        connect( action.shortcutButton, SIGNAL(shortcutRemoved(QKeySequence)),
                 this, SLOT(onShortcutRemoved(QKeySequence)) );
    }
Example #11
0
QListViewItemExt::QListViewItemExt(QTableWidgetItem* item,QTableWidgetItem* after)
              :QTableWidgetItem()
{
  QTableWidget* parent = item->tableWidget();
  mParent = parent;
  mRow = parent->row(after);

  parent->insertRow(mRow);
  parent->setItem(mRow, 0, this);
  mIndex = -1;
  mHiddenText = QString::null;
}
Example #12
0
void DebugPanel::setVariableList(QVector<QVariantList> varList)
{
    QTableWidget *table = ui->stackTableWidget;
    table->setRowCount(0);
    int row = 0, column = 0;
    foreach(QVariantList var, varList) {
        table->insertRow(table->rowCount());
        column = 0;
        foreach(QVariant part, var) {
            QTableWidgetItem *item = new QTableWidgetItem(part.toString());
            table->setItem(row, column, item);
            column++;
        }
Example #13
0
void DataElementViewer::append(const Message &m, int index)
{
    bool filter = true;
    filter &= ui->filterIn->isChecked()             || m.direction != In;
    filter &= ui->filterOut->isChecked()            || m.direction != Out;

    filter &= ui->filterTcp->isChecked()            || m.protocol != Tcp;
    filter &= ui->filterUdpUnicast->isChecked()     || m.protocol != UdpUnicast;
    filter &= ui->filterUdpBroadcast->isChecked()   || m.protocol != UdpBroadcast;

    filter &= ui->filterClient->isChecked()         || m.clientServer != Client;
    filter &= ui->filterServer->isChecked()         || m.clientServer != Server;

    filter &= channelMatcher.exactMatch(m.channel);
    filter &= typeMatcher.exactMatch(m.type);
    filter &= subTypeMatcher.exactMatch(m.subType);
    filter &= senderMatcher.exactMatch(m.sender);
    filter &= receiverMatcher.exactMatch(m.receiver);
    filter &= addressMatcher.exactMatch(m.address);

    filter &= !ui->filterNullMessage->isChecked()   || !m.null;
    filter |= ui->filterInvalidType->isChecked()    && !m.validType;
    filter |= ui->filterInvalidMessage->isChecked() && !m.validMessage;

    if (filter)
    {
        QTableWidget * t = ui->outputTable;
        int row = t->rowCount();
        int col = 0;
        t->insertRow(row);

        t->setItem(row, col++, new QTableWidgetItem(QString::number(index)));
        t->setItem(row, col++, new QTableWidgetItem(m._time));
        t->setItem(row, col++, new QTableWidgetItem(m._address));
        t->setItem(row, col++, new QTableWidgetItem(m._serverClient));
        t->setItem(row, col++, new QTableWidgetItem(m._direction));
        t->setItem(row, col++, new QTableWidgetItem(m._protocol));
        t->setItem(row, col++, new QTableWidgetItem(m._channel));
        t->setItem(row, col++, new QTableWidgetItem(m._type));
        t->setItem(row, col++, new QTableWidgetItem(m._subType));
        t->setItem(row, col++, new QTableWidgetItem(m._sender));
        t->setItem(row, col++, new QTableWidgetItem(m._receiver));
        t->setItem(row, col++, new QTableWidgetItem(m._validType));
        t->setItem(row, col++, new QTableWidgetItem(m._validMessage));
        t->setItem(row, col++, new QTableWidgetItem(m._message));
    }
}
Example #14
0
void UserActionDlg::InsertCALData(
	LONG lType,
	const std::wstring& address,
	const std::wstring& date,
	int iDuration)
{
	QTableWidget* table = ui.tbCallInfo;

	QTableWidgetItem* time = new QTableWidgetItem;
	time->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* type = new QTableWidgetItem;
	type->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* contact = new QTableWidgetItem;
	contact->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* location = new QTableWidgetItem;
	location->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* network = new QTableWidgetItem;
	network->setTextAlignment(Qt::AlignCenter);
	QTableWidgetItem* duration = new QTableWidgetItem;
	duration->setTextAlignment(Qt::AlignCenter);

	QTableWidgetItem* getTime = new QTableWidgetItem;
	getTime->setTextAlignment(Qt::AlignCenter);

	time->setText(QString::fromStdWString(date));
	type->setText(lType ==  1 ? 
		QString::fromLocal8Bit("拨打") : QString::fromLocal8Bit("接听"));
	contact->setText(QString::fromStdWString(address));
	duration->setText(QString("%1").arg(iDuration) + QString::fromLocal8Bit(" 秒"));
	getTime->setText(TGetCurrentTime().c_str());

	std::wstring locationStr, netServiceStr;
	DM->GetLocationFromPhoneNumber(address, locationStr, netServiceStr);

	location->setText(QString::fromStdWString(locationStr));
	network->setText(QString::fromStdWString(netServiceStr));

	table->insertRow(0);
	table->setItem(0, 0, time);
	table->setItem(0, 1, type);
	table->setItem(0, 2, contact);
	table->setItem(0, 3, network);
	table->setItem(0, 4, location);
	table->setItem(0, 5, duration);
	table->setItem(0, 6, getTime);
}
Example #15
0
void MainWindow::fillMonthTable(QTableWidget& tableMonth)
{
    int j = 0;
    QTableWidgetItem *newItem;
    tableMonth.setColumnCount(1);
    for(int i = 1; i < MONTHS+1; i++)
    {
        tableMonth.insertRow(j);
        newItem = new QTableWidgetItem();
        newItem->setText(QString::number(i));
        tableMonth.setItem(j, 0, newItem);
        if(i == selDate_.month())
            tableMonth.item(j, 0)->setBackground(Qt::red);
        else
            tableMonth.item(j, 0)->setBackground(Qt::magenta);
        j++;
    }
    standartStuffForAllTables(*ui->twMonth);
}
Example #16
0
//Это нужно вынести в отдельный класс!
//--->
void MainWindow::fillYearTable(QTableWidget& tableYear)
{
    int j = 0;
    QTableWidgetItem *newItem;
    tableYear.setColumnCount(1);
    for(int i = PASTYEARS; i < FUTUREYEARS; i++)
    {
        tableYear.insertRow(j);
        newItem = new QTableWidgetItem();
        newItem->setText(QString::number(selDate_.year() + i));
        tableYear.setItem(j, 0, newItem);
        if((selDate_.year() + i) == selDate_.year())
            tableYear.item(j, 0)->setBackground(Qt::red);
        else
            tableYear.item(j, 0)->setBackground(Qt::cyan);
        j++;
    }
    standartStuffForAllTables(*ui->twYear);
}
Example #17
0
QListViewItemExt::QListViewItemExt(QTableWidgetItem* item,QString label1,
                                   QString label2,QString label3,
                                   QString label4,QString label5,
                                   QString label6,QString label7,
                                   QString label8)
{
    QTableWidget* parent = item->tableWidget();
    mParent = parent;
    mIndex = -1;
    mHiddenText = QString::null;
    mRow = parent->rowCount();

    parent->insertRow(mRow);
    parent->setColumnCount(8);
    addWidgets(parent, label1, label2, label3, label4, label5, label6,
               label7, label8);
  mIndex = -1;
  mHiddenText = QString::null;
}
Example #18
0
void MainWindow::refreshPizzas(void) {
	this->_ui->tableWaiting->setRowCount(0);
	this->_ui->tableProcessing->setRowCount(0);
	this->_ui->tableFinished->setRowCount(0);

	std::ostringstream stream;

	Kitchen *kitchen = this->_reception->getCurrentKitchen();
	if (kitchen != NULL and kitchen->getPizzas()->size() > 0) {
		QTableWidget *table;

		for (std::list<Pizza>::iterator it = kitchen->getPizzas()->begin(); it != kitchen->getPizzas()->end(); it++) {
			if (it->getState() == Awaiting) {
				table = this->_ui->tableWaiting;
			} else if (it->getState() == Processing) {
				table = this->_ui->tableProcessing;
			} else {
				table = this->_ui->tableFinished;
			}

			size_t i(table->rowCount());
			table->insertRow(i);

			stream.str("");
			stream.clear();
			stream << Misc::getPizzaTypeName(it->getType());

			QTableWidgetItem *item1 = new QTableWidgetItem();
			item1->setText(stream.str().c_str());
			table->setItem(i, 0, item1);

			stream.str("");
			stream.clear();
			stream << Misc::getPizzaSizeName(it->getSize());

			QTableWidgetItem *item2 = new QTableWidgetItem();
			item2->setText(stream.str().c_str());
			table->setItem(i, 1, item2);
		}
	}
}
Example #19
0
void MigraineMainWindow::buildColumnsItems(TableInfo *info, int type)
{
    QTableWidget *tableWidget;

    if (type == SOURCE_COLUMNS)
        tableWidget = srcColumnsTableWidget;
    else if(type == TARGET_COLUMNS)
        tableWidget = tgtColumnsTableWidget;

    while (tableWidget->rowCount() > 0)
        tableWidget->removeRow(0);

    for (int i = 0; i < info->fieldNames().count(); i++)
    {
        QTableWidgetItem *fieldName = new QTableWidgetItem(info->fieldName(i), QTableWidgetItem::Type);
        QTableWidgetItem *fieldType = new QTableWidgetItem(info->fieldType(i), QTableWidgetItem::Type);
        tableWidget->insertRow(i);
        tableWidget->setItem(i, 0, fieldName);
        tableWidget->setItem(i, 1, fieldType);
    }
}
Example #20
0
void MainWindow::fillDayTable(QTableWidget& tableDay, int daysInMonth)
{
    tableDay.clear();
    tableDay.setRowCount(0);

    int j = 0;
    QTableWidgetItem *newItem;
    tableDay.setColumnCount(1);
    for(int i = 1; i < daysInMonth+1; i++)
    {
        tableDay.insertRow(j);
        newItem = new QTableWidgetItem();
        newItem->setText(QString::number(i));
        tableDay.setItem(j, 0, newItem);
        if(i == selDate_.day())
            tableDay.item(j, 0)->setBackground(Qt::red);
        else
            tableDay.item(j, 0)->setBackground(Qt::yellow);
        j++;
    }
    standartStuffForAllTables(*ui->twDay);
}
Example #21
0
void MainWindow::agregarPersonaATable(Persona *p)
{
    QTableWidget *table = ui->tableWidget;

    table->insertRow(0);
    QTableWidgetItem *item = new QTableWidgetItem(QString().setNum(p->id()));
    table->setItem(0, 0, item);

    item = new QTableWidgetItem(p->nombre());
    table->setItem(0, 1, item);

    item = new QTableWidgetItem((p->direccion()));
    table->setItem(0, 2, item);
    item = new QTableWidgetItem(p->telefono());
    table->setItem(0, 3, item);

    item = new QTableWidgetItem(p->email());
    table->setItem(0, 4, item);


    ui->lcdNumber->display((int)++cdadPersonas);
}
Example #22
0
Recepcjonista::readClients()
{
    mSQL->get_result("SELECT * FROM klient");

    QTableWidget* tw = ui->klienci_tableWidget;
    tw->clear();
    while (tw->rowCount() > 0)
    {
        tw->removeRow(0);
    }
    tw->setHorizontalHeaderItem(0, new QTableWidgetItem("PESEL"));
    tw->setHorizontalHeaderItem(1, new QTableWidgetItem("Imię"));
    tw->setHorizontalHeaderItem(2, new QTableWidgetItem("Nazwisko"));
    tw->setHorizontalHeaderItem(3, new QTableWidgetItem("Adres"));
    tw->setHorizontalHeaderItem(4, new QTableWidgetItem("Nr telefonu"));
    tw->setHorizontalHeaderItem(5, new QTableWidgetItem("E-mail"));

    int row_count = 0;
    while(mSQL->get_row())
    {
        tw->insertRow(tw->rowCount());

        tw->setItem(row_count, 0, new QTableWidgetItem(QString::fromStdString(mSQL->el("PESEL"))));

        tw->setItem(row_count, 1, new QTableWidgetItem(QString::fromStdString(mSQL->el("Imię"))));

        tw->setItem(row_count, 2, new QTableWidgetItem(QString::fromStdString(mSQL->el("Nazwisko"))));

        string adres = mSQL->el("Miasto") + " " + mSQL->el("Ulica") + " " + mSQL->el("Nr budynku") + " " + mSQL->el("Kod pocztowy");
        tw->setItem(row_count, 3, new QTableWidgetItem(QString::fromStdString(adres)));

        tw->setItem(row_count, 4, new QTableWidgetItem(QString::fromStdString(mSQL->el("Nr telefonu"))));

        tw->setItem(row_count++, 5, new QTableWidgetItem(QString::fromStdString(mSQL->el("Email"))));
    }

}
Example #23
0
/***************************************************************************
  Updates list of servers in network page in proper QTableViews
***************************************************************************/
void fc_client::update_server_list(enum server_scan_type sstype,
                                   const struct server_list *list)
{
  QTableWidget* sel = NULL;
  QString host, portstr;
  int port;

  switch (sstype) {
  case SERVER_SCAN_LOCAL:
    sel = lan_widget;
    break;
  case SERVER_SCAN_GLOBAL:
    sel = wan_widget;
    break;
  default:
    break;
  }

  if (!sel) {
    return;
  }

  if (!list) {
    return;
  }

  host = connect_host_edit->text();
  portstr = connect_port_edit->text();
  port = portstr.toInt();
  sel->clearContents();
  sel->setRowCount(0);
  int row = 0;
  server_list_iterate(list, pserver) {
    char buf[20];
    sel->insertRow(row);

    if (pserver->humans >= 0) {
      fc_snprintf(buf, sizeof(buf), "%d", pserver->humans);
    } else {
      strncpy(buf, _("Unknown"), sizeof(buf));
    }

    int tmp = pserver->port;
    QString tstring = QString::number(tmp);

    for (int col = 0; col < 6; col++) {
      QTableWidgetItem *item;
      item = new QTableWidgetItem();

      switch (col) {
      case 0:
        item->setText(pserver->host);
        break;
      case 1:
        item->setText(tstring);
        break;
      case 2:
        item->setText(pserver->version);
        break;
      case 3:
        item->setText(_(pserver->state));
        break;
      case 4:
        item->setText(buf);
        break;
      case 5:
        item->setText(pserver->message);
        break;
      default:
        break;
      }

      sel->setItem(row, col, item);
    }

    if (host == pserver->host && port == pserver->port) {
      sel->selectRow(row);
    }

    row++;
  } server_list_iterate_end;
Example #24
0
KeyBinder::KeyBinder(QWidget * parent, const QString & helpText, const QString & defaultText, const QString & resetButtonText) : QWidget(parent)
{
    this->defaultText = defaultText;
    enableSignal = false;

    // Two-column tab layout
    QHBoxLayout * pageKeysLayout = new QHBoxLayout(this);
    pageKeysLayout->setSpacing(0);
    pageKeysLayout->setContentsMargins(0, 0, 0, 0);

    // Table for category list
    QVBoxLayout * catListContainer = new QVBoxLayout();
    catListContainer->setContentsMargins(10, 10, 10, 10);
    catList = new QListWidget();
    catList->setFixedWidth(180);
    catList->setStyleSheet("QListWidget::item { font-size: 14px; } QListWidget:hover { border-color: #F6CB1C; } QListWidget::item:selected { background: #150A61; color: yellow; }");
    catList->setFocusPolicy(Qt::NoFocus);
    connect(catList, SIGNAL(currentRowChanged(int)), this, SLOT(changeBindingsPage(int)));
    catListContainer->addWidget(catList);
    pageKeysLayout->addLayout(catListContainer);

    // Reset all binds button
    if (!resetButtonText.isEmpty())
    {
        QPushButton * btnResetAll = new QPushButton(resetButtonText);
        catListContainer->addWidget(btnResetAll);
        btnResetAll->setFixedHeight(40);
        catListContainer->setStretch(1, 0);
        catListContainer->setSpacing(10);
        connect(btnResetAll, SIGNAL(clicked()), this, SIGNAL(resetAllBinds()));
    }

    // Container for pages of key bindings
    QWidget * bindingsPagesContainer = new QWidget();
    QVBoxLayout * rightLayout = new QVBoxLayout(bindingsPagesContainer);

    // Scroll area for key bindings
    QScrollArea * scrollArea = new QScrollArea();
    scrollArea->setContentsMargins(0, 0, 0, 0);
    scrollArea->setWidget(bindingsPagesContainer);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    scrollArea->setWidgetResizable(true);
    scrollArea->setFrameShape(QFrame::NoFrame);
    scrollArea->setStyleSheet("background: #130F2A;");

    // Add key binding pages to bindings tab
    pageKeysLayout->addWidget(scrollArea);
    pageKeysLayout->setStretch(1, 1);

    // Custom help text
    QLabel * helpLabel = new QLabel();
    helpLabel->setText(helpText);
    helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;");
    helpLabel->setFixedHeight(24);
    rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter);

    // Category list and bind table row heights
    const int rowHeight = 20;
    QSize catSize, headerSize;
    catSize.setHeight(36);
    headerSize.setHeight(24);

    // Category list header
    QListWidgetItem * catListHeader = new QListWidgetItem(tr("Category"));
    catListHeader->setSizeHint(headerSize);
    catListHeader->setFlags(Qt::NoItemFlags);
    catListHeader->setForeground(QBrush(QColor("#130F2A")));
    catListHeader->setBackground(QBrush(QColor("#F6CB1C")));
    catListHeader->setTextAlignment(Qt::AlignCenter);
    catList->addItem(catListHeader);

    // Populate
    bindingsPages = new QHBoxLayout();
    bindingsPages->setContentsMargins(0, 0, 0, 0);
    rightLayout->addLayout(bindingsPages);
    QWidget * curPage = NULL;
    QVBoxLayout * curLayout = NULL;
    QTableWidget * curTable = NULL;
    bool bFirstPage = true;
    selectedBindTable = NULL;
    bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>();
    bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>();
    for (int i = 0; i < BINDS_NUMBER; i++)
    {
        if (cbinds[i].category != NULL)
        {
            // Add stretch at end of previous layout
            if (curLayout != NULL) curLayout->insertStretch(-1, 1);

            // Category list item
            QListWidgetItem * catItem = new QListWidgetItem(HWApplication::translate("binds (categories)", cbinds[i].category));
            catItem->setSizeHint(catSize);
            catList->addItem(catItem);

            // Create new page
            curPage = new QWidget();
            curLayout = new QVBoxLayout(curPage);
            curLayout->setSpacing(2);
            bindingsPages->addWidget(curPage);
            if (!bFirstPage) curPage->setVisible(false);
        }

        // Description
        if (cbinds[i].description != NULL)
        {
            QLabel * desc = new QLabel(HWApplication::translate("binds (descriptions)", cbinds[i].description));
            curLayout->addWidget(desc, 0);
            QFrame * divider = new QFrame();
            divider->setFrameShape(QFrame::HLine);
            divider->setFrameShadow(QFrame::Plain);
            curLayout->addWidget(divider, 0);
        }

        // New table
        if (cbinds[i].category != NULL || cbinds[i].description != NULL)
        {
            curTable = new QTableWidget(0, 2);
            curTable->verticalHeader()->setVisible(false);
            curTable->horizontalHeader()->setVisible(false);
            curTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
            curTable->verticalHeader()->setDefaultSectionSize(rowHeight);
            curTable->setShowGrid(false);
            curTable->setStyleSheet("QTableWidget { border: none; } ");
            curTable->setSelectionBehavior(QAbstractItemView::SelectRows);
            curTable->setSelectionMode(QAbstractItemView::SingleSelection);
            curTable->setFocusPolicy(Qt::NoFocus);
            connect(curTable, SIGNAL(itemSelectionChanged()), this, SLOT(bindSelectionChanged()));
            connect(curTable, SIGNAL(itemClicked(QTableWidgetItem *)), this, SLOT(bindCellClicked(QTableWidgetItem *)));
            curLayout->addWidget(curTable, 0);
        }

        // Hidden combo box
        QComboBox * comboBox = CBBind[i] = new QComboBox(curTable);
        comboBox->setModel((QAbstractItemModel*)DataManager::instance().bindsModel());
        comboBox->setVisible(false);
        comboBox->setFixedWidth(200);

        // Table row
        int row = curTable->rowCount();
        QTableWidgetItem * nameCell = new QTableWidgetItem(HWApplication::translate("binds", cbinds[i].name));
        nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        curTable->insertRow(row);
        curTable->setItem(row, 0, nameCell);
        QTableWidgetItem * bindCell = new QTableWidgetItem(comboBox->currentText());
        bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        curTable->setItem(row, 1, bindCell);
        curTable->resizeColumnsToContents();
        curTable->setFixedHeight(curTable->verticalHeader()->length() + 10);

        // Updates the text in the table cell
        connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(bindChanged(const QString &)));

        // Map combo box and that row's cells to each other
        bindComboBoxCellMappings->insert(comboBox, bindCell);
        bindCellComboBoxMappings->insert(nameCell, comboBox);
        bindCellComboBoxMappings->insert(bindCell, comboBox);
    }
Example #25
0
void SessionAnalysisWidget::update(bool repaintCharts)
{
    gatherData();

    int rows = 0;

    QTableWidget *table = ui.lapTimeTableWidget;
    if (EventData::getInstance().getEventType() == LTPackets::PRACTICE_EVENT)
        table = ui.lapTimeTableWidgetFP;

    if (EventData::getInstance().getEventType() == LTPackets::QUALI_EVENT)
    {
        switch (ui.qualiTabWidget->currentIndex())
        {
            case 0: table = ui.lapTimeTableWidgetQuali; break;
            case 1: table = ui.lapTimeTableWidgetQ1; break;
            case 2: table = ui.lapTimeTableWidgetQ2; break;
            case 3: table = ui.lapTimeTableWidgetQ3; break;
        }
    }

    int firstPlace = 0;
	for (int i = 0; i < lapDataArray.size(); ++i)
	{
        if (lapInWindow(i))
        {
            if (rows == 0)
                firstPlace = i;
            if (rows + 1 >= table->rowCount())
            {
                table->insertRow(rows+1);
                table->setRowHeight(rows+1, 22);
            }

            if (lapDataArray[i].getCarID() < 0)
                continue;

            ColorsManager &sd = ColorsManager::getInstance();
            setItem(table, rows+1, 0, QString::number(rows+1)+".", Qt::ItemIsEnabled | Qt::ItemIsSelectable, Qt::AlignRight | Qt::AlignVCenter, sd.getColor(LTPackets::CYAN));

            QString s = EventData::getInstance().getDriversData()[lapDataArray[i].getCarID()-1].getDriverName();
            QTableWidgetItem *item = setItem(table, rows+1, 1, s, Qt::ItemIsEnabled | Qt::ItemIsSelectable, Qt::AlignLeft | Qt::AlignVCenter, sd.getColor(LTPackets::WHITE));
            item->setIcon(getDriverIcon(EventData::getInstance().getDriversData()[lapDataArray[i].getCarID()-1].getNumber()));


            setItem(table, rows+1, 2, lapDataArray[i].getTime().toString(), Qt::ItemIsEnabled | Qt::ItemIsSelectable, Qt::AlignCenter, sd.getColor(LTPackets::WHITE));

            s = (rows == 0 || !lapDataArray[i].getTime().isValid()) ? "" : "+" + DriverData::calculateGap(lapDataArray[i].getTime(), lapDataArray[firstPlace].getTime());
            setItem(table, rows+1, 3, s, Qt::ItemIsEnabled | Qt::ItemIsSelectable, Qt::AlignRight | Qt::AlignVCenter, sd.getColor(LTPackets::YELLOW));

            s = QString::number(lapDataArray[i].getLapNumber());
            if (EventData::getInstance().getEventType() == LTPackets::PRACTICE_EVENT)
                s = SeasonData::getInstance().getSessionDefaults().correctFPTime(lapDataArray[i].getPracticeLapExtraData().getSessionTime()).toString("h:mm:ss");//lapDataArray[i].sessionTime.toString("h:mm:ss") + " (" + QString::number(LTPackets::currentEventFPLength()-LTPackets::timeToMins(lapDataArray[i].sessionTime))+")";

            else if (EventData::getInstance().getEventType() == LTPackets::QUALI_EVENT)
                s = SeasonData::getInstance().getSessionDefaults().correctQualiTime(lapDataArray[i].getQualiLapExtraData().getSessionTime(), lapDataArray[i].getQualiLapExtraData().getQualiPeriod()).toString("mm:ss");

            setItem(table, rows+1, 4, s, Qt::ItemIsEnabled | Qt::ItemIsSelectable, Qt::AlignRight | Qt::AlignVCenter, sd.getColor(LTPackets::WHITE));

            if (ui.qualiTabWidget->currentIndex() == 0)
                setItem(table, rows+1, 5, QString::number(lapDataArray[i].getQualiLapExtraData().getQualiPeriod()), Qt::ItemIsEnabled | Qt::ItemIsSelectable, Qt::AlignRight | Qt::AlignVCenter, sd.getColor(LTPackets::WHITE));

            ++rows;
        }
	}
    if (rows < table->rowCount()-1)
    {
        for (int i = table->rowCount()-1; i > rows; --i)
            table->removeRow(i);
    }

    if (repaintCharts)
    {
        if (EventData::getInstance().getEventType() == LTPackets::RACE_EVENT)
        {
            ui.sessionLapTimesChart->setData(lapDataArray);
            ui.sessionLapTimesChart->update();

            ui.sessionPositionsChart->setData(lapDataArray);
            ui.sessionPositionsChart->update();

            ui.sessionGapsChart->setData(lapDataArray);
            ui.sessionGapsChart->update();
        }
        if (EventData::getInstance().getEventType() == LTPackets::PRACTICE_EVENT)
        {
            ui.sessionLapTimesChartFP->setData(lapDataArray);
            ui.sessionLapTimesChartFP->update();
        }
        if (EventData::getInstance().getEventType() == LTPackets::QUALI_EVENT)
        {
            switch (ui.qualiTabWidget->currentIndex())
            {
                case 0:
                    ui.sessionLapTimesChartQuali->setData(lapDataArray);
                    ui.sessionLapTimesChartQuali->update();
                break;

                case 1:
                    ui.sessionLapTimesChartQ1->setData(lapDataArray);
                    ui.sessionLapTimesChartQ1->update();
                    break;

                case 2:
                    ui.sessionLapTimesChartQ2->setData(lapDataArray);
                    ui.sessionLapTimesChartQ2->update();
                    break;

                case 3:
                    ui.sessionLapTimesChartQ3->setData(lapDataArray);
                    ui.sessionLapTimesChartQ3->update();
                    break;
            }
        }
    }
}
Example #26
0
void AddEditBlog::fetchedBlogId(const QList< QMap < QString, QString > > &list)
{
    if (d->mFetchBlogIdTimer) {
        d->mFetchBlogIdTimer->deleteLater();
        d->mFetchBlogIdTimer = Q_NULLPTR;
    }
    hideWaitWidget();
    QString blogId, blogName, blogUrl, apiUrl;
    const int listCount(list.count());
    if (listCount > 1) {
        qCDebug(BLOGILO_LOG) << "User has more than ONE blog!";
        QDialog *blogsDialog = new QDialog(this);
        QTableWidget *blogsList = new QTableWidget(blogsDialog);
        blogsList->setSelectionBehavior(QAbstractItemView::SelectRows);
        QList< QMap<QString, QString> >::const_iterator it = list.constBegin();
        QList< QMap<QString, QString> >::const_iterator endIt = list.constEnd();
        int i = 0;
        blogsList->setColumnCount(4);
        QStringList headers;
        headers << i18n("Title") << i18n("URL");

        blogsList->setHorizontalHeaderLabels(headers);
        blogsList->setColumnHidden(2, true);
        blogsList->setColumnHidden(3, true);
        for (; it != endIt; ++it) {
            qCDebug(BLOGILO_LOG) << it->value(QStringLiteral("title"));
            blogsList->insertRow(i);
            blogsList->setCellWidget(i, 0, new QLabel(it->value(QStringLiteral("title"))));
            blogsList->setCellWidget(i, 1, new QLabel(it->value(QStringLiteral("url"))));
            blogsList->setCellWidget(i, 2, new QLabel(it->value(QStringLiteral("id"))));
            blogsList->setCellWidget(i, 3, new QLabel(it->value(QStringLiteral("apiUrl"))));
            ++i;
        }
        QVBoxLayout *mainLayout = new QVBoxLayout;
        blogsDialog->setLayout(mainLayout);
        mainLayout->addWidget(blogsList);
        blogsDialog->setWindowTitle(i18n("Which blog?"));
        if (blogsDialog->exec()) {
            int row = blogsList->currentRow();
            if (row == -1) {
                delete blogsDialog;
                return;
            }
            blogId = qobject_cast<QLabel *>(blogsList->cellWidget(row, 2))->text();
            blogName = qobject_cast<QLabel *>(blogsList->cellWidget(row, 0))->text();
            blogUrl = qobject_cast<QLabel *>(blogsList->cellWidget(row, 1))->text();
            apiUrl = qobject_cast<QLabel *>(blogsList->cellWidget(row, 3))->text();
        } else {
            delete blogsDialog;
            return;
        }
        delete blogsDialog;
    } else if (listCount > 0) {
        blogId = list.constBegin()->value(QStringLiteral("id"));
        blogName = list.constBegin()->value(QStringLiteral("title"));
        blogUrl = list.constBegin()->value(QStringLiteral("url"));
        apiUrl = list.constBegin()->value(QStringLiteral("apiUrl"));
    } else {
        KMessageBox::sorry(this, i18n("Sorry, No blog found with the specified account info."));
        return;
    }
    d->ui.txtId->setText(blogId);
    d->ui.txtTitle->setText(blogName);
    d->ui.txtId->setEnabled(true);
    d->ui.btnFetch->setEnabled(true);
    d->ui.btnAutoConf->setEnabled(true);

    if (!apiUrl.isEmpty()) {
        d->ui.txtUrl->setText(apiUrl);
    } else {
        apiUrl = d->ui.txtUrl->text();
    }
    if (!blogUrl.isEmpty()) {
        d->bBlog->setBlogUrl(blogUrl);
    } else {
        if (d->tmpBlogUrl.isEmpty()) {
            d->bBlog->setBlogUrl(apiUrl);
        } else {
            d->bBlog->setBlogUrl(d->tmpBlogUrl);
        }
    }

    d->bBlog->setUrl(QUrl(apiUrl));
    d->bBlog->setUsername(d->ui.txtUser->text());
    d->bBlog->setPassword(d->ui.txtPass->text());
    d->bBlog->setBlogId(blogId);
    d->bBlog->setTitle(blogName);
}
Example #27
0
void QuickStartWizard::loadShare()
{
	std::cerr << "ShareManager:: In load !!!!!" << std::endl ;

	std::list<SharedDirInfo>::const_iterator it;
	std::list<SharedDirInfo> dirs;
	rsFiles->getSharedDirectories(dirs);

	ui.shareIncomingDirectory->setChecked(rsFiles->getShareDownloadDirectory());

	/* get a link to the table */
	QTableWidget *listWidget = ui.shareddirList;

	/* remove old items ??? */
	listWidget->clearContents() ;
	listWidget->setRowCount(0) ;

	connect(this,SIGNAL(itemClicked(QTableWidgetItem*)),this,SLOT(updateFlags(QTableWidgetItem*))) ;

	int row=0 ;
	for(it = dirs.begin(); it != dirs.end(); ++it,++row)
	{
		listWidget->insertRow(row) ;
		listWidget->setItem(row,0,new QTableWidgetItem(QString::fromStdString((*it).filename)));
#ifdef USE_COMBOBOX
		QComboBox *cb = new QComboBox ;
		cb->addItem(tr("Network Wide")) ;
		cb->addItem(tr("Browsable")) ;
		cb->addItem(tr("Universal")) ;

		cb->setToolTip(tr("Please decide whether this directory is\n* Network Wide: \tanonymously shared over the network (including your friends)\n* Browsable: \tbrowsable by your friends\n* Universal: \t\tboth")) ;

		// TODO
		//  - set combobox current value depending on what rsFiles reports.
		//  - use a signal mapper to get the correct row that contains the combo box sending the signal:
		//  		mapper = new SignalMapper(this) ;
		//
		//  		for(all cb)
		//  		{
		//  			signalMapper->setMapping(cb,...)
		//  		}
		//
		int index = 0 ;
		index += ((*it).shareflags & RS_FILE_HINTS_NETWORK_WIDE) > 0 ;
		index += (((*it).shareflags & RS_FILE_HINTS_BROWSABLE) > 0) * 2 ;
		listWidget->setCellWidget(row,1,cb);

		if(index < 1 || index > 3)
			std::cerr << "******* ERROR IN FILE SHARING FLAGS. Flags = " << (*it).shareflags << " ***********" << std::endl ;
		else
			index-- ;

		cb->setCurrentIndex(index) ;
#else
		QCheckBox *cb1 = new QCheckBox ;
		QCheckBox *cb2 = new QCheckBox ;

		cb1->setChecked( (*it).shareflags & DIR_FLAGS_NETWORK_WIDE_OTHERS ) ;
		cb2->setChecked( (*it).shareflags & DIR_FLAGS_BROWSABLE_OTHERS ) ;

		cb1->setToolTip(tr("If checked, the share is anonymously shared to anybody.")) ;
		cb2->setToolTip(tr("If checked, the share is browsable by your friends.")) ;

		listWidget->setCellWidget(row,1,cb1);
		listWidget->setCellWidget(row,2,cb2);

		QObject::connect(cb1,SIGNAL(toggled(bool)),this,SLOT(updateFlags(bool))) ;
		QObject::connect(cb2,SIGNAL(toggled(bool)),this,SLOT(updateFlags(bool))) ;
#endif
	}

	//ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));

	listWidget->update(); /* update display */
	update();
}
Example #28
0
void MainWindow::on_actionShortcuts_triggered() {

	QTableWidget* scTable = new QTableWidget();

	scTable->setRowCount(0);
	scTable->setColumnCount(2);

	scTable->setHorizontalHeaderItem(0, new QTableWidgetItem("Shortcut"));
	scTable->setHorizontalHeaderItem(1, new QTableWidgetItem("Description"));
	scTable->verticalHeader()->hide();


	QLinkedList<QPair<QString, QString>> scList;

	//read from file in resources and add to linked list
	QFile shortcutFile(":Shortcuts/resources/shortcuts.txt");

	if (!shortcutFile.open(QIODevice::ReadOnly | QIODevice::Text))
		return;

	QString line;
	while (!shortcutFile.atEnd()) {
		QTextStream stream(&shortcutFile);
		while (!stream.atEnd()) {
			line = stream.readLine();
			QStringList shortCutAndDescription = line.split(':');
			if (shortCutAndDescription.size() == 2) {
				scList.append(QPair<QString, QString>(shortCutAndDescription[0], shortCutAndDescription[1]));
			}
		}

	}

	QLinkedList<QPair<QString, QString>>::const_iterator sc;
	for (sc = scList.constBegin(); sc != scList.constEnd(); ++sc) {
		scTable->insertRow(scTable->rowCount());


		QTableWidgetItem* scKey = new QTableWidgetItem(sc->first);
		QTableWidgetItem* scKeyInfo = new QTableWidgetItem(sc->second);
		scKey->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
		scKeyInfo->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable);

		scTable->setItem(scTable->rowCount() - 1, 0, scKey);
		scTable->setItem(scTable->rowCount() - 1, 1, scKeyInfo);
	}


	//scTable->horizontalHeader()->setStretchLastSection( true ); 
	scTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

	QWidget* outerWidget = new QWidget();
	outerWidget->setWindowTitle("Shortcuts");
	outerWidget->resize(scTable->size());
	QVBoxLayout* vLayout = new QVBoxLayout();

	vLayout->addWidget(scTable);

	outerWidget->setLayout(vLayout);


	outerWidget->show();
}
void
CLOAD_WORKSHEET::
LoadWorksheet( QTabWidget * tabWidget, QTextEdit * textEdit, QString fileName )
{
    if ( cCheckIfTabsExist->CheckIfTabsExist(tabWidget) )
    {
        QFile file(fileName);

        if (file.fileName().isEmpty())
                return;
        else
        {
            if (!file.open(QIODevice::ReadOnly))
            {
                QMessageBox::information(this, tr("Unable to open file"),file.errorString());
                return;
            }

            textEdit->clear();
            QTextStream textStream(&file);
            QString Section = textStream.readAll().trimmed();
            textEdit->setPlainText(Section);
            QTableWidget * table = new QTableWidget;
            int row = 0;

            for ( int i = 0; i < textEdit->document()->blockCount(); i++ )
            {
                QString line = textEdit->document()->findBlockByLineNumber(i).text();

                if ( line.contains("PM Model") )
                {
                    CreateTable(tabWidget, "PM Model", 0);      // create table headers
                    tabWidget->setCurrentIndex(0);              // tab select
                    QTableWidget * table0 = dynamic_cast<QTableWidget *>(tabWidget->currentWidget());
                    table = table0;                             // set table
                    row = 0;                                    // add row counter
                }


                else if ( line.contains("Model Serial") )
                {
                    CreateTable(tabWidget, "Model Serial", 0);
                    tabWidget->setCurrentIndex(1);
                    QTableWidget * table1 = dynamic_cast<QTableWidget *>(tabWidget->currentWidget());
                    table = table1;
                    row = 0;
                }


                else if ( line.contains("Unit Data") )
                {
                    CreateTable(tabWidget, "Unit Data", 0);
                    tabWidget->setCurrentIndex(2);
                    QTableWidget * table2 = dynamic_cast<QTableWidget *>(tabWidget->currentWidget());
                    table = table2;
                    row = 0;
                }

                else if ( line.contains("Master PM") )
                {
                    CreateTable(tabWidget, "Master PM", 0);
                    tabWidget->setCurrentIndex(3);
                    QTableWidget * table3 = dynamic_cast<QTableWidget *>(tabWidget->currentWidget());
                    table = table3;
                    row = 0;
                }

                else
                {
                    table->insertRow(row); // add a row to the table

                    for ( int col = 0; col < 12; col++ )
                    {
                        QTableWidgetItem * item = new QTableWidgetItem(line.split("|").at(col).trimmed());

                        if ( col == 0 )
                            item->setTextAlignment(Qt::AlignVCenter | Qt::AlignLeft);
                        else
                            item->setTextAlignment(Qt::AlignCenter);

                        item->setFlags(item->flags() & ~Qt::ItemIsEditable);
                        table->setItem(row,col,item);
                    }

                    row++;                 // prepare for next
                }
            }
        }
    }
}
void MultiInstancePanelPrivate::addTableRow(Node* node)
{
    int newRowIndex = table->rowCount();
    table->insertRow(newRowIndex);
    
    std::list<boost::shared_ptr<KnobI> > instanceSpecificKnobs;
    getInstanceSpecificKnobs(node, &instanceSpecificKnobs);
    
    ///first add the enabled column
    {
        QWidget* enabledContainer = createCheckBoxForTable(true);
        table->setCellWidget(newRowIndex, 0, enabledContainer);
    }
    
    int columnIndex = 1;
    for (std::list<boost::shared_ptr<KnobI> >::iterator it = instanceSpecificKnobs.begin();it!=instanceSpecificKnobs.end();++it) {
        Int_Knob* isInt = dynamic_cast<Int_Knob*>(it->get());
        Bool_Knob* isBool = dynamic_cast<Bool_Knob*>(it->get());
        Double_Knob* isDouble = dynamic_cast<Double_Knob*>(it->get());
        Color_Knob* isColor = dynamic_cast<Color_Knob*>(it->get());
        String_Knob* isString = dynamic_cast<String_Knob*>(it->get());
        
        if (!isInt || !isBool || !isDouble || !isColor || !isString) {
            continue;
        }
        
        bool createCheckBox = false;
        bool createSpinBox = false;
        if (isBool) {
            createCheckBox = true;
        } else if (isInt || isDouble || isColor) {
            createSpinBox = true;
        }
        
        for (int i = 0; i < (*it)->getDimension(); ++it) {
            if (createCheckBox) {
                assert(isBool);
                bool checked = isBool->getValue();
                QWidget* enabledContainer = createCheckBoxForTable(checked);
                table->setCellWidget(newRowIndex, columnIndex, enabledContainer);
            } else if (createSpinBox) {
                double mini = INT_MIN,maxi = INT_MAX;
                SpinBox::SPINBOX_TYPE type = SpinBox::DOUBLE_SPINBOX;
                if (isInt) {
                    mini = isInt->getMinimums()[i];
                    maxi = isInt->getMaximums()[i];
                    type = SpinBox::INT_SPINBOX;
                } else if (isDouble) {
                    mini = isDouble->getMinimums()[i];
                    maxi = isDouble->getMaximums()[i];
                }
                SpinBox* sb = new SpinBox(NULL,type);
                sb->setMinimum(mini);
                sb->setMaximum(maxi);
                table->setCellWidget(newRowIndex, columnIndex, sb);
            } else {
                assert(isString);
                std::string value = isString->getValue();
                LineEdit* le = new LineEdit(NULL);
                le->setText(value.c_str());
                table->setCellWidget(newRowIndex, columnIndex, le);
            }
            ++columnIndex;
        }
        
    }
}