void KexiDBConnectionTabWidget::setData(const KexiProjectData& data, const QString& shortcutFileName) { mainWidget->setData( data, shortcutFileName ); detailsWidget->chkUseSocket->setChecked( data.constConnectionData()->useLocalSocketFile ); detailsWidget->customSocketEdit->setURL( data.constConnectionData()->localSocketFileName ); detailsWidget->customSocketEdit->setEnabled( detailsWidget->chkUseSocket->isChecked() ); detailsWidget->chkSocketDefault->setChecked( data.constConnectionData()->localSocketFileName.isEmpty() ); detailsWidget->chkSocketDefault->setEnabled( detailsWidget->chkUseSocket->isChecked() ); detailsWidget->descriptionEdit->setText( data.description() ); }
QVariant KexiRecentProjectsModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) { return QVariant(); } KexiProjectData *pdata = static_cast<KexiProjectData*>(index.internalPointer()); bool fileBased = !pdata->constConnectionData()->dbFileName().isEmpty(); QString opened(openedString(pdata->lastOpened())); if (!opened.isEmpty()) opened.prepend('\n'); switch (role) { case Qt::DisplayRole: { //! @todo add support for imported entries, e.g. MS Access if (fileBased) { QString n = pdata->caption().trimmed(); if (n.isEmpty()) n = pdata->constConnectionData()->dbFileName(); return n + opened; } else { QString n = pdata->captionOrName(); if (!n.isEmpty()) { n += '\n'; } QString serverInfo = pdata->connectionData()->serverInfoString(false /* without user */); // friendly message: if (serverInfo == "localhost") { serverInfo = i18n("on local server"); } else { serverInfo = i18n("on \"%1\" server", serverInfo); } return n + serverInfo + opened; } } case Qt::ToolTipRole: //! @todo add support for imported entries, e.g. MS Access if (fileBased) { return i18nc("File database <file>", "File database %1", pdata->constConnectionData()->fileName()); } else { KexiDB::DriverManager manager; return i18nc("<type> database", "%1 database", manager.driverInfo(pdata->constConnectionData()->driverName).caption); return pdata->objectName(); } case Qt::DecorationRole: { //! @todo show icon specific to given database or mimetype if (fileBased) { return KIcon(KexiDB::defaultFileBasedDriverIconName()); } else { return KIcon(KEXI_DATABASE_SERVER_ICON_NAME); } } /*case KCategorizedSortFilterProxyModel::CategorySortRole: { int index = m_categoryNameIndex.value(info->category); if (index >= 0 && index < m_templateCategories.count()) { QVariantList list; list << index << info->caption; return list; } return QVariantList(); } case KCategorizedSortFilterProxyModel::CategoryDisplayRole: { int index = m_categoryNameIndex.value(info->category); if (index >= 0 && index < m_templateCategories.count()) { KexiTemplateCategoryInfo category = m_templateCategories.value(index); return category.caption; } return QVariant(); }*/ case NameRole: return pdata->databaseName(); /*case CategoryRole: return info->category;*/ default: break; } return QVariant(); }