QTableWidget *StManagerStudyListComp::createStudyTable ()
{
  QTableWidget *table  = new QTableWidget;

  table->setSelectionBehavior( QAbstractItemView::SelectRows );
  table->setSelectionMode( QAbstractItemView::SingleSelection );
  table->setEditTriggers( QAbstractItemView::NoEditTriggers );

  QStringList labels;
  for ( int i = 0; i < ATTRIBUTE_NUMBER; i++ ) {
    labels << tr( attributeNames[i] );
  }
  
  table->setColumnCount( labels.size() + 1 );
  table->setHorizontalHeaderLabels( labels );
  table->setColumnHidden( ATTRIBUTE_NUMBER, true );

  for ( int i = 0; i < ATTRIBUTE_NUMBER; i++ ) 
  {
    if ( attributeResizes[i] ) {
      table->horizontalHeader()->setResizeMode( i, QHeaderView::ResizeToContents );
    }
  }

  connect( table, SIGNAL(itemSelectionChanged()), this, SLOT(setEnabledView()) );
  connect( table, SIGNAL(itemDoubleClicked( QTableWidgetItem * )), this, SLOT(view()) );

  return table;
}
void TrainLinePanel::__initTableHeader()
{
    int listLineCount = ui->listWidget->count();
    for(int i = 0; i < listLineCount;i++)
    {
        QTableWidget *tableWidget = new QTableWidget;
        tableWidget->setAlternatingRowColors(true);
        tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
        tableWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);

    //    connect(tableWidget,SIGNAL(doubleClicked(QModelIndex)),keyboard,SLOT(show(QModelIndex)));

        tableWidget->verticalHeader()->setHidden(true);


        tableWidget->setColumnCount(10);
        tableWidget->setColumnHidden(9,true);
        tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
        tableWidget->horizontalHeader()->setMinimumHeight(30);
        tableWidget->horizontalHeader()->setMinimumSectionSize(140);
        QTableWidgetItem* item = new QTableWidgetItem("Station number");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(0,item);
        item = new QTableWidgetItem("Station id");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(1,item);
        item = new QTableWidgetItem("Name(EN)");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(2,item);
        item = new QTableWidgetItem("Name(TH)");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(3,item);
        item = new QTableWidgetItem("Start time");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(4,item);
        item = new QTableWidgetItem("Arrive time");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(5,item);

        item = new QTableWidgetItem("Lng");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(6,item);

        item = new QTableWidgetItem("Lat");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(7,item);

        item = new QTableWidgetItem("Sea level");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(8,item);

        item = new QTableWidgetItem("Rowid");
        item->setTextAlignment(Qt::AlignHCenter);
        tableWidget->setHorizontalHeaderItem(9,item);

        ui->stackedWidget->addWidget(tableWidget);
    }
//    connect(tableWidget,SIGNAL(itemChanged(QTableWidgetItem*)),this,SLOT(updateDatabase(QTableWidgetItem*)));
}
Example #3
0
QTableWidget *PublicTalks::getPersons(int type)
{
    std::vector<sql_item> vt;
//    QString str = "SELECT yleisokokous.pvm, henkilot.nimi, henkilot.id, henkilot.etunimi "
//                  "FROM henkilot LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.puheenjohtaja_id "
//                  "WHERE ohjelmatyypit & " + QString::number(type) + " GROUP BY henkilot.id";
    QString str = "SELECT yleisokokous.pvm, henkilot.nimi, henkilot.id, henkilot.etunimi "
                  "FROM henkilot LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.";
    if(type == person::chairman) {
        str.append("puheenjohtaja_id");
    } else {
        str.append("vt_lukija_id");
    }
    str.append(" WHERE ohjelmatyypit & " + QString::number(type) + " GROUP BY henkilot.id");

    vt = sql.selectSql(str);

    QTableWidget *vttable = new QTableWidget();
    vttable->horizontalHeader()->show();
    vttable->verticalHeader()->setVisible(false);
    vttable->setColumnCount(3);
    vttable->setColumnHidden(0,true);
    vttable->setColumnWidth(1,150);
    vttable->setColumnWidth(2,100);
    vttable->setMinimumWidth(270);
    vttable->setSortingEnabled(true);

    vttable->setHorizontalHeaderItem(1,new QTableWidgetItem(QObject::tr("Name")));
    vttable->setHorizontalHeaderItem(2,new QTableWidgetItem(QObject::tr("Last")));

    vttable->setRowCount(vt.size()+1);
    vttable->setItem(0,0,new QTableWidgetItem(""));
    for(unsigned int i = 0; i < vt.size(); i++) {
        vttable->setItem(i+1,0,new QTableWidgetItem(vt[i].getValue("id")));
        vttable->setItem(i+1,1,new QTableWidgetItem(vt[i].getValue("nimi") + " " + vt[i].getValue("etunimi")));
        vttable->setItem(i+1,2,new QTableWidgetItem(vt[i].getValue("pvm")));
    }
    return vttable;
}
Example #4
0
void PublicTalks::beforeSpeakerShown(QString name, cPersonComboBox *c)
{
    //cPersonComboBox *c = combo;

    // get speakers for comboBox
    //cPersonComboBox *combo = static_cast<cPersonComboBox *>(maintable->cellWidget(combo->property("currentrow").toInt(),3));
    cPersonComboBox *themeCombo = static_cast<cPersonComboBox *>(maintable->cellWidget(c->property("currentrow").toInt(),2));
    qDebug() << "currentRow1:" << c->currentText() << "rownumber:" << c->property("currentrow") << name;
    if (c) {
        qDebug() << "combo ok";
    } else {
        qDebug() << "combo false";
    }

    QTableWidget *table = new QTableWidget(0,4);
    table->setColumnHidden(0,true);
    table->setColumnWidth(3,0);
    std::vector<sql_item> speakers;
    if(themeCombo->currentText() == "") {
        // ei teemaa valittu
        speakers = sql.selectSql("SELECT henkilot.*,yleisokokous.pvm "
                                 "FROM henkilot "
                                 "LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.puhuja_id "
                                 "WHERE henkilot.ohjelmatyypit & 512 GROUP BY henkilot.id ORDER BY nimi");
    } else {
        // teema valittu --> haetaan teeman sopivat puhujat
        speakers = sql.selectSql("SELECT henkilot.*,P_Esitelmat.aihe_id,yleisokokous.pvm "
                                 "FROM henkilot "
                                 "LEFT JOIN P_Esitelmat ON henkilot.id = P_Esitelmat.puhuja_id "
                                 "LEFT JOIN yleisokokous ON henkilot.id = yleisokokous.puhuja_id "
                                 " WHERE P_Esitelmat.aihe_id = '" +
                                 QString::number(getThemeId(themeCombo->currentText())) +
                                 "' AND henkilot.ohjelmatyypit & 512 GROUP BY henkilot.id ORDER BY nimi, etunimi");
    }
    table->setRowCount(speakers.size()+1);
    int currentRow = 0;
    for(unsigned int i = 0; i < speakers.size(); i++) {
        table->setItem(i+1,0,new QTableWidgetItem( speakers[i].getValue("id") ));
        table->setItem(i+1,1,new QTableWidgetItem( speakers[i].getValue("nimi") + ", " + speakers[i].getValue("etunimi")) );
        table->setItem(i+1,2,new QTableWidgetItem( speakers[i].getValue("pvm")) );
        table->setItem(i+1,3,new QTableWidgetItem( speakers[i].getValue("etunimi") + " " + speakers[i].getValue("nimi")) );

        if(c->currentText() == table->item(i+1,3)->text()) {
            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);
            currentRow = i+1;
        }
    }
    table->verticalHeader()->hide();
    table->setColumnWidth(1,150);
    table->setColumnWidth(2,100);
    table->setMinimumWidth(280);

    c->clear();
    c->setModel(table->model());
    c->setView(table);
    c->setModelColumn(1);
    c->setCurrentIndex(currentRow);
    table->setSortingEnabled(true);
    table->sortByColumn(1,Qt::AscendingOrder);
}
Example #5
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);
}