Ejemplo n.º 1
1
/**
* @brief ctor for main window
*
* @param parent
*/
MainWindow::MainWindow(QWidget *parent):
    QMainWindow(parent)
{	
	m_pCentral = new QFrame;
	setCentralWidget(m_pCentral);

	m_mainLayout = new QHBoxLayout;
	m_mainLayout->setContentsMargins(1,1,1,1);
	m_mainLayout->setSpacing(1);
	centralWidget()->setLayout(m_mainLayout);
	m_mainLayout->addWidget(&m_accordion);
	m_accordion.setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);

	QAccordionItem *item = new QAccordionItem("Item1");
	QTableWidget *table = new QTableWidget();
	QTableWidgetItem *table_item = new QTableWidgetItem("Test talbe item");
	table->setColumnCount(1);
	table->setRowCount(1);
	table->setItem(0,0,table_item);
	item->setWidget(table);

	m_accordion.addItem(item);		

	QAccordionItem *item2 = new QAccordionItem("Item2");
	QLineEdit *lineEdit = new QLineEdit();
	lineEdit->setText("Testing Text");
	item2->setWidget(lineEdit);
	m_accordion.addItem(item2);		
	createInnerAccordion();

}
Ejemplo n.º 2
0
// get speaker's themes by language
QTableWidget *PublicTalks::getSpeakerPublicTalks(int kieli_id, int personid, QString select) {
    QTableWidget *table = new QTableWidget(0,3);
    table->verticalHeader()->setVisible(false);

    //sitten vectoriin kaikki aiheet
    std::vector<sql_item> q;
//    q = sql.selectSql("SELECT * FROM Esitelmat, P_esitelmat WHERE Esitelmat.kieli_id = '"+ kielet[0].getValue("id") +"'"
//                      " AND Esitelmat.aihe_id = P_esitelmat.aihe_id"
//                      " AND P_esitelmat.puhuja_id = '" + QString::number(personid) + "'");
    q = sql.selectSql("SELECT Esitelmat.*, P_esitelmat.puhuja_id, yleisokokous.pvm FROM Esitelmat "
                      "LEFT JOIN yleisokokous ON Esitelmat.aihe_id = yleisokokous.aihe_id "
                      "LEFT JOIN P_esitelmat ON Esitelmat.aihe_id = P_esitelmat.aihe_id "
                      "WHERE P_esitelmat.puhuja_id = '" + QString::number(personid) + "' "
                      "AND Esitelmat.kieli_id = '"+ langId +"' "
                      "GROUP BY Esitelmat.aihe_id ORDER BY Esitelmat.aihe_id");
    table->setRowCount(q.size()+1);
    for(unsigned int i = 0; i < q.size(); i++) {

        int value = QVariant(q[i].getValue("aihe_id")).toInt();
        QTableWidgetItem *item = new QTableWidgetItem();
        item->setData(Qt::DisplayRole,value);
        table->setItem(i+1,0,item);
        //table->setItem(i+1,0,new QTableWidgetItem(q[i].getValue("aihe_id")));
        table->setItem(i+1,1,new QTableWidgetItem(q[i].getValue("aihe")));
        if(table->item(i+1,1)->text() == select) {
            QFont boldfont(table->item(i+1,1)->font().family(),
                           table->item(i+1,1)->font().pointSize(),
                           QFont::Bold);
            table->item(i+1,1)->setFont(boldfont);
        }
        table->setItem(i+1,2,new QTableWidgetItem(q[i].getValue("pvm")));
    }

    return table;
}
Ejemplo n.º 3
0
void MainWindow::on_spinAccount_valueChanged(int arg1)
{
    if (!root_set) return;
    const char addr_version = 0x00, wif_version = 0x80;
    const size_t buflen = 128;
    char buf[buflen + 1];
    HDNode node;
    // external chain
    for (int chain = 0; chain < 2; chain++) {
        QTableWidget *list = chain == 0 ? ui->listAddress : ui->listChange;
        node = root;
        hdnode_private_ckd(&node, 44 | 0x80000000);
        hdnode_private_ckd(&node, 0 | 0x80000000); // bitcoin
        hdnode_private_ckd(&node, (arg1 - 1) | 0x80000000);
        hdnode_serialize_private(&node, buf, buflen); QString xprv = QString(buf); ui->lineXprv->setText(xprv);
        hdnode_serialize_public(&node, buf, buflen); QString xpub = QString(buf); ui->lineXpub->setText(xpub);
        hdnode_private_ckd(&node, chain); // external / internal
        for (int i = 0; i < 100; i++) {
            HDNode node2 = node;
            hdnode_private_ckd(&node2, i);
            ecdsa_get_address(node2.public_key, addr_version, buf, buflen); QString address = QString(buf);
            ecdsa_get_wif(node2.private_key, wif_version, buf, buflen); QString wif = QString(buf);
            list->setItem(i, 0, new QTableWidgetItem(address));
            list->setItem(i, 1, new QTableWidgetItem(wif));
            list->setItem(i, 2, new QTableWidgetItem("0.0"));
        }
    }
}
Ejemplo n.º 4
0
void MainWindow::updateLevelPlistTable()
{
    noEmit = true;

    QTableWidget *table = ui->levelPlistTableWidget;

    int count = levelPlist.count();
    table->setRowCount(count);
    table->setColumnCount(2);

    QMap<QString, QVariant>::const_iterator i;
    int index = 0;

    for (i = levelPlist.constBegin(); i != levelPlist.constEnd(); ++i)
    {
        table->setItem(index, 0, new QTableWidgetItem(i.key()));

        if(i.value().type() == QVariant::String)
        {
            table->setItem(index, 1, new QTableWidgetItem(i.value().toString()));
        }
        else if(i.value().type() == QVariant::List)
        {
            table->setItem(index, 1, new QTableWidgetItem(QString("Click to edit")));
        }
        else
        {
            Q_ASSERT_X(false, "MainWindow::updateObjectTable", "Unknown QVariant type!");
        }
        index++;
    }

    noEmit = false;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMainWindow *w = new QMainWindow();

    w->setWindowTitle(QString::fromUtf8("QTableWidget Merge Cells Example"));
    w->resize(400, 250);

    QTableWidget* table = new QTableWidget();

    //Set table row count 1 and column count 3
    table->setRowCount(1);
    table->setColumnCount(3);
    table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //Set Header Label Texts Here
    table->setHorizontalHeaderLabels(QString("HEADER 1;HEADER 2;HEADER 3").split(";"));

    QTableWidgetItem* item = new QTableWidgetItem("ITEM 2");
    item->setTextAlignment(Qt::AlignCenter);

    //Add Table items here
    table->setItem(0,0,new QTableWidgetItem("ITEM 1"));
    table->setItem(0,1,item);
    table->setSpan(0,1,1,2);

    w->setCentralWidget(table);

    w->show();

    return a.exec();
}
Ejemplo n.º 6
0
void PageMemoryRights::RunAddrSize(duint addrin, duint sizein, QString pagetypein)
{
    addr = addrin;
    size = sizein;
    pagetype = pagetypein;

    QTableWidget* tableWidget = ui->pagetableWidget;
    tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    duint nr_pages = size / PAGE_SIZE;
    tableWidget->setColumnCount(2);
    tableWidget->setRowCount(nr_pages);
    tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(QString(tr("Address"))));
    tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(QString(tr("Rights"))));

    duint actual_addr;
    char rights[RIGHTS_STRING_SIZE];
    for(duint i = 0; i < nr_pages; i++)
    {
        actual_addr = addr + (i * PAGE_SIZE);
        tableWidget->setItem(i, 0, new QTableWidgetItem(ToPtrString(actual_addr)));
        if(DbgFunctions()->GetPageRights(actual_addr, rights))
            tableWidget->setItem(i, 1, new QTableWidgetItem(QString(rights)));
    }

    QModelIndex idx = (ui->pagetableWidget->model()->index(0, 0));
    ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);
    idx = (ui->pagetableWidget->model()->index(0, 1));
    ui->pagetableWidget->selectionModel()->select(idx, QItemSelectionModel::Select);

    ui->radioFullaccess->setChecked(true);
    ui->chkPageguard->setCheckable(true);
    exec();
}
Ejemplo n.º 7
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);
 }
}
Ejemplo n.º 8
0
void RcManagerDlg::updateFileInfoTable()
{
    QTableWidget* tb = ui->tb_file_list;
    QStringList header;
    const QVector<FILEINFO>& fileInfos = m_parse.getFileInfoList();
    header << "Index" << "Name" << "Offset" << "Length" << "Type";
    tb->clear();
    tb->setRowCount(fileInfos.count());
    tb->setColumnCount(5);
    tb->setHorizontalHeaderLabels(header);
    ui->tb_file_list->setHorizontalHeaderLabels(header);

    int row = 0;
    foreach(const FILEINFO& info, fileInfos)
    {
        QTableWidgetItem* indexItem = new QTableWidgetItem(QString("%1").arg(info.index));
        if(!indexItem)
        {
            continue;
        }

        indexItem->setData(WRCINDEXROLE, info.index);
        tb->setItem(row, INDEX, indexItem);
        tb->setItem(row, NAME, new QTableWidgetItem(QString(info.name)));
        tb->setItem(row, OFFSET, new QTableWidgetItem(QString("%1").arg(info.offset)));
        tb->setItem(row, LENGTH, new QTableWidgetItem(QString("%1").arg(info.length)));
        tb->setItem(row, TYPE, new QTableWidgetItem(QString("%1").arg(info.type)));
        row++;
    }
Ejemplo n.º 9
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 );
}
Ejemplo n.º 10
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));
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 12
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMainWindow *w = new QMainWindow();

    QTableWidget* table = new QTableWidget();
    table->setFixedSize(300,300);

    QPalette* palette = new QPalette();
    palette->setColor(QPalette::Highlight,Qt::cyan);
    table->setPalette(*palette);

    table->setRowCount(2);
    table->setColumnCount(3);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);

    //Set Header Label Texts Here
    table->setHorizontalHeaderLabels(QString("HEADER 1;HEADER 2;HEADER 3").split(";"));

    //Add Table items here
    table->setItem(0,0,new QTableWidgetItem("ITEM 1_1"));
    table->setItem(0,1,new QTableWidgetItem("ITEM 1_2"));
    table->setItem(0,2,new QTableWidgetItem("ITEM 1_3"));

    table->setItem(1,0,new QTableWidgetItem("ITEM 2_1"));
    table->setItem(1,1,new QTableWidgetItem("ITEM 2_2"));
    table->setItem(1,2,new QTableWidgetItem("ITEM 2_3"));

    w->setCentralWidget(table);

    w->show();

    return a.exec();
}
Ejemplo n.º 13
0
void Window::createGUI()
{
    QList<QPair<QString, QColor> > list;
    list << QPair<QString, QColor>(tr("Alice"), QColor("aliceblue")) <<
            QPair<QString, QColor>(tr("Neptun"), QColor("aquamarine")) <<
            QPair<QString, QColor>(tr("Ferdinand"), QColor("springgreen"));

    QTableWidget *table = new QTableWidget(3, 2);
    table->setHorizontalHeaderLabels(QStringList() << tr("Name")
                                                   << tr("Hair Color"));
    table->verticalHeader()->setVisible(false);
    table->resize(150, 50);

    for (int i = 0; i < 3; ++i) {
        QPair<QString, QColor> pair = list.at(i);

        QTableWidgetItem *nameItem = new QTableWidgetItem(pair.first);
        QTableWidgetItem *colorItem = new QTableWidgetItem;
        colorItem->setData(Qt::DisplayRole, pair.second);

        table->setItem(i, 0, nameItem);
        table->setItem(i, 1, colorItem);
    }
    table->resizeColumnToContents(0);
    table->horizontalHeader()->setStretchLastSection(true);

    QGridLayout *layout = new QGridLayout;
    layout->addWidget(table, 0, 0);

    setLayout(layout);

    setWindowTitle(tr("Color Editor Factory"));
}
Ejemplo n.º 14
0
void VotePage::fillParkRateTable()
{
    QTableWidget* table = ui->parkRateTable;
    std::vector<CParkRate> parkRates;

    BOOST_FOREACH(const CParkRateVote& parkRateResult, lastBestBlock->vParkRateResult)
    {
        if (parkRateResult.cUnit == 'B')
        {
            parkRates = parkRateResult.vParkRate;
            break;
        }
    }

    table->setRowCount(parkRates.size());
    for (size_t i = 0; i < parkRates.size(); i++)
    {
        const CParkRate& parkRate = parkRates[i];

        QString durationString = GUIUtil::blocksToTime(parkRate.GetDuration());
        QTableWidgetItem *durationItem = new QTableWidgetItem(durationString);
        durationItem->setData(Qt::TextAlignmentRole, QVariant(Qt::AlignRight | Qt::AlignVCenter));
        table->setItem(i, 0, durationItem);

        double interestRate = GUIUtil::annualInterestRatePercentage(parkRate.nRate, parkRate.GetDuration());
        QString rateString = QString("%L1%").arg(interestRate, 0, 'f', 3);
        QTableWidgetItem *rateItem = new QTableWidgetItem(rateString);
        rateItem->setData(Qt::TextAlignmentRole, QVariant(Qt::AlignRight | Qt::AlignVCenter));
        table->setItem(i, 1, rateItem);
    }
    table->setVisible(false);
    table->resizeColumnsToContents();
    table->setVisible(true);
}
Ejemplo n.º 15
0
void VotePage::fillCustodianTable()
{
    QTableWidget* table = ui->custodianTable;
    table->setRowCount(0);
    int row = 0;
    for (CBlockIndex* pindex = lastBestBlock; pindex; pindex = pindex->pprevElected)
    {
        BOOST_FOREACH(const CCustodianVote& custodianVote, pindex->vElectedCustodian)
        {
            table->setRowCount(row + 1);

            QTableWidgetItem *addressItem = new QTableWidgetItem();
            addressItem->setData(Qt::DisplayRole, QString::fromStdString(custodianVote.GetAddress().ToString()));
            table->setItem(row, 0, addressItem);

            QTableWidgetItem *amountItem = new QTableWidgetItem();
            amountItem->setData(Qt::DisplayRole, BitcoinUnits::format(model->getOptionsModel()->getDisplayUnit(), custodianVote.nAmount));
            amountItem->setData(Qt::TextAlignmentRole, QVariant(Qt::AlignRight | Qt::AlignVCenter));
            table->setItem(row, 1, amountItem);

            QTableWidgetItem *dateItem = new QTableWidgetItem();
            dateItem->setData(Qt::DisplayRole, GUIUtil::dateTimeStr(pindex->nTime));
            table->setItem(row, 2, dateItem);

            row++;
        }
    }
    table->setVisible(false);
    table->resizeColumnsToContents();
    table->setVisible(true);
}
Ejemplo n.º 16
0
void GraphPlotDialog::setGraphVisibility(int currentVisibility)
{
    QTableWidget *currentList = NULL;
    QTableWidget *endList = NULL;
    if (currentVisibility == 1) {
        currentList = mUi.visibleGraph;
        endList = mUi.invisibleGraph;
    }
    else if (currentVisibility == 0) {
        currentList = mUi.invisibleGraph;
        endList = mUi.visibleGraph;
    }
    else {
        return;
    }
    QTableWidgetItem *item = currentList->takeItem(currentList->currentRow(), 0);
    QTableWidgetItem *valueItem = currentList->takeItem(currentList->currentRow(), 1);

    if (!item || !valueItem) {
        return;
    }
    currentList->removeRow(currentList->currentRow());
    unsigned graphId = item->data(Qt::UserRole).toUInt();
    mData[graphId].isSelected = false;
    int rowCount = endList->rowCount();
    endList->setRowCount(rowCount + 1);
    endList->setItem(rowCount, 0, item);
    endList->setItem(rowCount, 1, valueItem);
}
Ejemplo n.º 17
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();
		}
	}
}
Ejemplo n.º 18
0
HttpUserSetupDialog::HttpUserSetupDialog(QWidget *parent)
	: QDialog(parent)
	, ui(new Ui::HttpUserSetupDialog)
{
	ui->setupUi(this);
	
	QTableWidget * tableWidget = ui->httpUsers;
	QList<HttpUser*> users = HttpUserUtil::instance()->users();
	
	tableWidget->setRowCount(users.size());
	int row = 0;
	foreach(HttpUser *user, users)
	{
		tableWidget->setItem(row, 0, new QTableWidgetItem(user->user()));
		tableWidget->setItem(row, 1, new QTableWidgetItem(user->pass()));
		tableWidget->setItem(row, 2, new QTableWidgetItem(QString::number(user->level())));
		
		QComboBox *levelCombo = new QComboBox();
		
		levelCombo->addItems(QStringList() << "Guest" << "User" << "Admin");
		levelCombo->setCurrentIndex(user->level());
		
		tableWidget->setCellWidget(row, 2, levelCombo);
		 
		row ++;
	}
Ejemplo n.º 19
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);
}
Ejemplo n.º 20
0
Legend::Legend(QWidget *parent) :
    QDialog(parent)
{
    QLabel *label;
    QVBoxLayout *layout = new QVBoxLayout();
    setLayout(layout);

    DNSData d;
    Node *n = new Node(0);

    layout->addWidget(label = new QLabel(tr("<h2>DNSSEC-Nodes Coloring Legend</h2>")));
    label->setAlignment(Qt::AlignHCenter);

    QList<int> statuses;
    statuses << DNSData::UNKNOWN <<  DNSData::TRUSTED <<  DNSData::VALIDATED <<  DNSData::DNE
             << DNSData::FAILED <<  DNSData::IGNORE << (DNSData::DNE | DNSData::VALIDATED);

    // Add the legend widget
    QTableWidget *table = new QTableWidget(statuses.count(), 2, this);
    layout->addWidget(table);

    table->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Node")));
    table->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Description")));
    table->verticalHeader()->hide();

    QPointF rect = n->boundingRect().bottomRight() - n->boundingRect().topLeft();
    QSize size(rect.x() + 2, rect.y() + 2);
    QPointF br = n->boundingRect().bottomRight();

    int row = 0;
    foreach(int status, statuses) {
        QTableWidgetItem *item = new QTableWidgetItem(d.DNSSECStatusForEnum(status));
        item->setFlags(Qt::ItemIsEnabled);
        item->setBackgroundColor(n->getColorForStatus(status).lighter());
        table->setItem(row, 1, item);

        Node *node = new Node(0);
        QPixmap pm = QPixmap(size);
        QPainter painter(&pm);

        node->addSubData(DNSData("", status));

        painter.setBackground(Qt::white);
        painter.setBrush(Qt::white);
        painter.drawRect(-5, -5, size.width() + 5, size.height() + 5);
        painter.translate(br.x(), br.y());
        node->paint(&painter, 0, 0);

        QIcon icon = QIcon(pm);
        item = new QTableWidgetItem(icon, "");
        item->setFlags(Qt::ItemIsEnabled);
        table->setItem(row, 0, item);

        row++;
    }
Ejemplo n.º 21
0
void QgsMessageLogViewer::logMessage( QString message, QString tag, QgsMessageLog::MessageLevel level )
{
#ifdef ANDROID
  mCount++;
#else
  mButton->setToolTip( tr( "%1 message(s) logged." ).arg( mCount++ ) );
#endif

  if ( !isVisible() && level > QgsMessageLog::INFO )
  {
    mButton->show();
    if ( mShowToolTips )
      QToolTip::showText( mButton->mapToGlobal( QPoint( 0, 0 ) ), mButton->toolTip() );
  }

  if ( tag.isNull() )
    tag = tr( "General" );

  int i;
  for ( i = 0; i < tabWidget->count() && tabWidget->tabText( i ) != tag; i++ )
    ;

  QTableWidget *w;
  if ( i < tabWidget->count() )
  {
    w = qobject_cast<QTableWidget *>( tabWidget->widget( i ) );
    tabWidget->setCurrentIndex( i );
  }
  else
  {
    w = new QTableWidget( 0, 3, this );
    w->verticalHeader()->setDefaultSectionSize( 16 );
    w->verticalHeader()->setResizeMode( QHeaderView::ResizeToContents );
    w->verticalHeader()->setVisible( false );
    w->setGridStyle( Qt::DotLine );
    w->setEditTriggers( QAbstractItemView::NoEditTriggers );
    w->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel );
    w->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel );
    w->setHorizontalHeaderLabels( QStringList() << tr( "Timestamp" ) << tr( "Message" ) << tr( "Level" ) );
    tabWidget->addTab( w, tag );

    tabWidget->setCurrentIndex( tabWidget->count() - 1 );
  }

  int n = w->rowCount();

  w->setRowCount( n + 1 );
  QTableWidgetItem *item = new QTableWidgetItem( QDateTime::currentDateTime().toString( Qt::ISODate ) );
  w->setItem( n, 0, item );
  w->setItem( n, 1, new QTableWidgetItem( message ) );
  w->setItem( n, 2, new QTableWidgetItem( QString::number( level ) ) );
  w->scrollToBottom();

  w->horizontalHeader()->resizeSections( QHeaderView::ResizeToContents );
}
Ejemplo n.º 22
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)) );
    }
Ejemplo n.º 23
0
static void plugins_add_description(const char *name, const char *version,
                                    const char *types, const char *filename,
                                    void *user_data )
{

    QTableWidget *tbPlugins = (QTableWidget *)user_data;
    tbPlugins->setRowCount(tbPlugins->rowCount() + 1);

    tbPlugins->setItem(tbPlugins->rowCount()-1, 0, new QTableWidgetItem(name));
    tbPlugins->setItem(tbPlugins->rowCount()-1, 1, new QTableWidgetItem(version));
    tbPlugins->setItem(tbPlugins->rowCount()-1, 2, new QTableWidgetItem(types));
    tbPlugins->setItem(tbPlugins->rowCount()-1, 3, new QTableWidgetItem(filename));
}
Ejemplo n.º 24
0
void MainWindow::busMonitorAddItem( bool isRequest,
					uint8_t slave,
					uint8_t func,
					uint16_t addr,
					uint16_t nb,
					uint16_t expectedCRC,
					uint16_t actualCRC )
{
	QTableWidget * bm = ui->busMonTable;
	const int rowCount = bm->rowCount();
	bm->setRowCount( rowCount+1 );

	QTableWidgetItem * ioItem = new QTableWidgetItem( isRequest ? tr( "Req >>" ) : tr( "<< Resp" ) );
	QTableWidgetItem * slaveItem = new QTableWidgetItem( QString::number( slave ) );
	QTableWidgetItem * funcItem = new QTableWidgetItem( QString::number( func ) );
	QTableWidgetItem * addrItem = new QTableWidgetItem( QString::number( addr ) );
	QTableWidgetItem * numItem = new QTableWidgetItem( QString::number( nb ) );
	QTableWidgetItem * crcItem = new QTableWidgetItem;
	if( func > 127 )
	{
		addrItem->setText( QString() );
		numItem->setText( QString() );
		funcItem->setText( tr( "Exception (%1)" ).arg( func-128 ) );
		funcItem->setForeground( Qt::red );
	}
	else
	{
		if( expectedCRC == actualCRC )
		{
			crcItem->setText( QString().sprintf( "%.4x", actualCRC ) );
		}
		else
		{
			crcItem->setText( QString().sprintf( "%.4x (%.4x)", actualCRC, expectedCRC ) );
			crcItem->setForeground( Qt::red );
		}
	}
	ioItem->setFlags( ioItem->flags() & ~Qt::ItemIsEditable );
	slaveItem->setFlags( slaveItem->flags() & ~Qt::ItemIsEditable );
	funcItem->setFlags( funcItem->flags() & ~Qt::ItemIsEditable );
	addrItem->setFlags( addrItem->flags() & ~Qt::ItemIsEditable );
	numItem->setFlags( numItem->flags() & ~Qt::ItemIsEditable );
	crcItem->setFlags( crcItem->flags() & ~Qt::ItemIsEditable );
	bm->setItem( rowCount, 0, ioItem );
	bm->setItem( rowCount, 1, slaveItem );
	bm->setItem( rowCount, 2, funcItem );
	bm->setItem( rowCount, 3, addrItem );
	bm->setItem( rowCount, 4, numItem );
	bm->setItem( rowCount, 5, crcItem );
	bm->verticalScrollBar()->setValue( 100000 );
}
Ejemplo n.º 25
0
void MainWindow::updateObjectTable(int objId)
{
    if(noEmit)
        return;

    if(objId == -2 || levelObjects.count() <= objId)
    {
        clearObjectTable();
        return;
    }

    if(objId == -1)
        return;

    QTableWidget *table = ui->objectsTableWidget;

    int rowCount = 0;
    table->setColumnCount(2);
    table->setRowCount(0);

    QMap<QString, QVariant>::const_iterator it;
    for (it = levelObjects.at(objId).constBegin(); it != levelObjects.at(objId).constEnd(); ++it)
    {
        rowCount++;
        table->setRowCount(rowCount);

        table->setItem(rowCount-1, 0, new QTableWidgetItem(it.key()));

        if(it.value().type() == QVariant::String)
        {
            table->setItem(rowCount-1, 1, new QTableWidgetItem(it.value().toString()));
        }
        else if(it.value().type() == QVariant::List)
        {
            table->setItem(rowCount-1, 1, new QTableWidgetItem(QString("Click to edit")));
        }
        else
        {
            Q_ASSERT_X(false, "MainWindow::updateObjectTable", "Unknown QVariant type!");
        }
    }

    QString rotationStr = levelObjects[objId].value("rotation", "nil").toString();
    if(rotationStr != "nil"){
        int rotation = rotationStr.toInt();
        ui->rotationLabel->setText(QString("Rotation - " + QString::number(rotation) + " degrees").toAscii());

        ui->rotationSlider->setValue(rotation / 3.6);
    }
}
Ejemplo n.º 26
0
/**
  * @brief Updates the resolver pool display.
  */
void OpenNIC::updateResolverPool(QStringList resolverPool)
{
	/* @brief <status>;<score>;<kind>;<hostAddress>; */

	QTableWidget* table = ui->resolverPoolTable;
	double minScore,maxScore;
	scoreMinMax(resolverPool, minScore, maxScore);
	table->setRowCount(resolverPool.count());
	for(int row=0; row < resolverPool.count(); row++ )
	{
		QStringList elements = resolverPool.at(row).split(";");
		QString ip		= elements.at(3);
		QString kind	= elements.at(2);
		QString score	= elements.at(1);
		QString status	= elements.at(0);
		QString statusIcon;
		if (status == "R")
		{
			status = tr("FAIL");
			statusIcon = ":/images/status-red.png";
		}
		else if (status == "G")
		{
			status = tr("OK");
			statusIcon = ":/images/status-green.png";
		}
		else if (status == "Y")
		{
			status = tr("WARN");
			statusIcon = ":/images/status-yellow.png";
		}
		table->setItem(row,3,new QTableWidgetItem(ip));
		table->setItem(row,2,new QTableWidgetItem(kind));
#if 0
		table->setItem(row,1,new QTableWidgetItem(score));
#else
		QProgressBar* bar = new QProgressBar();
		bar->setRange((int)(minScore*1000.0),(int)(maxScore*1000.0));
		bar->setValue((int)(score.toDouble()*1000.0));
		table->setCellWidget(row,1,bar);
#endif
		table->setItem(row,0,new QTableWidgetItem(QIcon(statusIcon),status));
	}
	table->resizeColumnsToContents();
	table->resizeRowsToContents();
	table->setSortingEnabled(true);
	table->sortByColumn(1,Qt::DescendingOrder);
}
Ejemplo n.º 27
0
Archivo: main.cpp Proyecto: xizho10/qt
int main(int argc,char* argv[])
{
    QApplication app(argc,argv);
    QTableWidget* table = new QTableWidget();
    table->setWindowTitle("Connect to Mysql Database Example");

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("192.168.11.3");
    db.setDatabaseName("menudb");
    db.setUserName("root");
    db.setPassword("test");
    if (!db.open())
    {
      QMessageBox::critical(0, QObject::tr("Database Error"),
                db.lastError().text());
    }

    QSqlQuery query("SELECT * FROM test");

    table->setColumnCount(query.record().count());
    table->setRowCount(query.size());

    int index=0;
    while (query.next())
    {
    table->setItem(index,0,new QTableWidgetItem(query.value(0).toString()));
    table->setItem(index,1,new QTableWidgetItem(query.value(1).toString()));
    index++;
    }

    table->show();
    return app.exec();
}
Ejemplo n.º 28
0
unsigned StManagerStudyListComp::getSeriesIndex( const SerieInfoVector info )
{
  // no resize, just exit button - reject, result code is 0 -> returned value will be 0
  QDialog *seriesSelectorDialog = new QDialog( this, Qt::WindowTitleHint | Qt::WindowSystemMenuHint| Qt::MSWindowsFixedSizeDialogHint );
  seriesSelectorDialog->setWindowTitle( tr( "Series Selector" ) );

  QVBoxLayout *mainLayout = new QVBoxLayout;

  QLabel *seriesLabel = new QLabel( tr( "Series in selected study:\n(their descriptions)" ) );
  mainLayout->addWidget( seriesLabel );

  QSpacerItem *verticalSpacer = new QSpacerItem( 2, 10, QSizePolicy::Minimum, 
                                                 QSizePolicy::Minimum );
  mainLayout->addItem( verticalSpacer );

  QTableWidget *seriesTable = createSeriesSelectionTable();
  seriesTable->setRowCount( info.size() );
  for ( unsigned i = 0; i < info.size(); i++ ) {
    seriesTable->setItem( i, 0, new QTableWidgetItem( QString( info[i].description.c_str() ) ) );
  }
  connect( seriesTable, SIGNAL(cellClicked( int, int )), seriesSelectorDialog, SLOT(done( int )) );
  mainLayout->addWidget( seriesTable );

  seriesSelectorDialog->setLayout( mainLayout );

  return seriesSelectorDialog->exec();
}
Ejemplo n.º 29
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    const int n = 3;

    QTableWidget *mainTable = new QTableWidget(n,n);
    QTableWidgetItem *widgetItem = 0;
    QStringList nameItems;

      nameItems << "First" << "Second" << "Third";
      mainTable->setHorizontalHeaderLabels(nameItems); //set headers on Horizontal
      mainTable->setVerticalHeaderLabels(nameItems);   //set headers on Vertical

      for(int i = 0;  i < n; ++i)
        {
          for(int j = 0; j < n; ++j)
            {
              widgetItem = new QTableWidgetItem(QString("%1,%2").arg(i).arg(j));
              mainTable->setItem(i,j,widgetItem);
            }
        }
    mainTable->setGeometry(430,340,400,180);
    mainTable->setWindowTitle("Main table");
    mainTable->show();

    return a.exec();
}
Ejemplo n.º 30
0
QTableWidget* StatusViewer::prepareTable(int rows, int cols) {
    QTableWidget* table = new QTableWidget(this);
    table->setColumnCount(cols);
    table->setRowCount(rows);
    table->setSelectionBehavior(QAbstractItemView::SelectRows);
    table->setAttribute(Qt::WA_MacShowFocusRect, 0);
    table->setShowGrid(false);
    table->setAlternatingRowColors(true);
    table->setSortingEnabled(false);

    for (int c = 0; c < cols; ++c) {
        table->horizontalHeader()->setSectionResizeMode(c, QHeaderView::Stretch);
    }
    
    for(int row=0; row<rows; ++row) {
        for(int col=0; col<cols; ++col){
            QTableWidgetItem* tableItem = new QTableWidgetItem();
            tableItem->setFlags(tableItem->flags() ^ Qt::ItemIsEditable);
            tableItem->setTextAlignment(Qt::AlignRight);
            tableItem->setText("--");
            table->setItem(row, col, tableItem);
        }
    }
    
    return table;
}