Ejemplo n.º 1
0
std::set<QString> ActivateModsDialog::getESPsToActivate()
{
  std::set<QString> result;
  QTableWidget *modsTable = findChild<QTableWidget*>("modsTable");

  for (int row = 0; row < modsTable->rowCount(); ++row) {
    QComboBox *comboBox = dynamic_cast<QComboBox*>(modsTable->cellWidget(row, 1));
    if (comboBox != nullptr) {
      QLabel *espName = dynamic_cast<QLabel*>(modsTable->cellWidget(row, 0));

      result.insert(espName->text());
    }
  }
  return result;
}
Ejemplo n.º 2
0
QVector<QVariantList> DebugPanel::getBreakpoints()
{
    QTableWidget *table = ui->breakpointTableWidget;
    QVector<QVariantList> breakpoints;
    for (int row = 0; row < table->rowCount(); row++) {
        QVariantList bp;
        QCheckBox *cb = static_cast<QCheckBox *>(table->cellWidget(row,0));
        if (cb->isChecked()) {
            QTableWidgetItem *item = table->item(row,1);
            bp << item->data(Qt::DisplayRole).toString();
			if (bp.back().toString() == "instr" ) {
				item = table->item(row,2);
				bp << item->data(Qt::DisplayRole).toDouble();
				item = table->item(row,3);
				bp << item->data(Qt::DisplayRole).toInt();
				breakpoints.append(bp);
			} else {
				item = table->item(row,2);
				QStringList parts = item->data(Qt::DisplayRole).toString().split(":");
				Q_ASSERT(parts.size() == 2);
				bp << parts[0].toInt();
				bp << parts[1].toInt();
				item = table->item(row,3);
				bp << item->data(Qt::DisplayRole).toInt();
				breakpoints.append(bp);
			}
        }
    }
    return breakpoints;
}
Ejemplo n.º 3
0
void ItemSyncLoader::onBrowseButtonClicked()
{
    QTableWidget *t = ui->tableWidgetSyncTabs;

    QObject *button = sender();
    Q_ASSERT(button != nullptr);

    int row = 0;
    for ( ; row < t->rowCount() && t->cellWidget(row, syncTabsTableColumns::browse) != button; ++row ) {}
    Q_ASSERT(row != t->rowCount());

    QTableWidgetItem *item = t->item(row, syncTabsTableColumns::path);
    const QString path =
            QFileDialog::getExistingDirectory( t, tr("Open Directory for Synchronization"), item->text() );
    if ( !path.isEmpty() )
        item->setText(path);
}
Ejemplo n.º 4
0
QVariantMap ItemSyncLoader::applySettings()
{
    // Apply settings from tab sync path table.
    QTableWidget *t = ui->tableWidgetSyncTabs;
    QStringList tabPaths;
    m_tabPaths.clear();
    for (int row = 0; row < t->rowCount(); ++row) {
        const QString tabName = t->item(row, syncTabsTableColumns::tabName)->text();
        if ( !tabName.isEmpty() ) {
            const QString tabPath = t->item(row, syncTabsTableColumns::path)->text();
            tabPaths << tabName << tabPath;
            m_tabPaths.insert(tabName, tabPath);
        }
    }
    m_settings.insert(configSyncTabs, tabPaths);

    // Apply settings from file format table.
    t = ui->tableWidgetFormatSettings;
    QVariantList formatSettings;
    m_formatSettings.clear();
    for (int row = 0; row < t->rowCount(); ++row) {
        FileFormat fileFormat;
        fileFormat.extensions = t->item(row, formatSettingsTableColumns::formats)->text()
                .split( QRegExp("[,;\\s]"), QString::SkipEmptyParts );
        fileFormat.itemMime = t->item(row, formatSettingsTableColumns::itemMime)->text();
        if ( fileFormat.extensions.isEmpty() && fileFormat.itemMime.isEmpty() )
            continue;
        fileFormat.icon = t->cellWidget(row, formatSettingsTableColumns::icon)
                ->property("currentIcon").toString();

        QVariantMap format;
        format["formats"] = fileFormat.extensions;
        format["itemMime"] = fileFormat.itemMime;
        format["icon"] = fileFormat.icon;
        formatSettings.append(format);

        fixUserExtensions(&fileFormat.extensions);
        fixUserMimeType(&fileFormat.itemMime);
        m_formatSettings.append(fileFormat);
    }
    m_settings.insert(configFormatSettings, formatSettings);

    return m_settings;
}
Ejemplo n.º 5
0
void WindowFacade::setDockFontColor(QColor fontColor) {
    QPalette p;
    foreach(QDockWidget* dock, dockWindows) {
        if(qobject_cast<QPlainTextEdit*>(dock->widget()) != NULL) {
            p = ((QPlainTextEdit*)dock->widget())->viewport()->palette();
            p.setColor(QPalette::Text, fontColor);
            ((QPlainTextEdit*)dock->widget())->viewport()->setPalette(p);
        } else if(qobject_cast<QTableWidget*>(dock->widget()) != NULL) {
            QTableWidget* tableWidget = (QTableWidget*)dock->widget();
            for(int i = 0; i < tableWidget->rowCount(); i++) {
                QLabel* widget = (QLabel*)tableWidget->cellWidget(i, 0);
                QPalette p = widget->palette();
                p.setColor(QPalette::Text, fontColor);
                widget->setPalette(p);
            }
        }
    }

    foreach(QDockWidget* dock, streamWindows) {
        p = ((QPlainTextEdit*)dock->widget())->viewport()->palette();
        p.setColor(QPalette::Text, fontColor);
        ((QPlainTextEdit*)dock->widget())->viewport()->setPalette(p);
    }
Ejemplo n.º 6
0
void SetComboText(QTableWidget& Widget, QString Text, int Row, int Col)
{
    auto Combo((QComboBox*) Widget.cellWidget(Row, Col));
    Combo->setCurrentText(Text);
}
Ejemplo n.º 7
0
QString GetComboText(QTableWidget& Widget, int Row, int Col)
{
    auto Combo((QComboBox*) Widget.cellWidget(Row, Col));
    return Combo->currentText();
}
Ejemplo n.º 8
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);
}