KexiProjectData KexiDBConnectionTabWidget::currentProjectData() { KexiProjectData data; //! @todo check if that's database of connection shortcut. Now we're assuming db shortcut only! // collect data from the form's fields // if (d->isDatabaseShortcut) { if (mainWidget->connectionOnly()) { data.connectionData()->caption = mainWidget->titleEdit->text(); data.setCaption( QString::null ); data.connectionData()->description = detailsWidget->descriptionEdit->text(); data.setDatabaseName( QString::null ); } else { data.connectionData()->caption = QString::null; /* connection name is not specified... */ data.setCaption( mainWidget->titleEdit->text() ); data.setDescription( detailsWidget->descriptionEdit->text() ); data.setDatabaseName( mainWidget->nameCombo->currentText() ); } // } /* else { data.setCaption( QString::null ); data.connectionData()->connName = config.readEntry("caption"); data.setDescription( QString::null ); data.connectionData()->description = config.readEntry("comment"); data.setDatabaseName( QString::null ); }*/ data.connectionData()->driverName = mainWidget->driversCombo()->selectedDriverName(); /* if (data.connectionData()->driverName.isEmpty()) { //ERR: "No valid "engine" field specified for %1 section" group return false; }*/ data.connectionData()->hostName = (mainWidget->remotehostRBtn->isChecked()/*remote*/) ? mainWidget->hostEdit->text() : QString::null; data.connectionData()->port = mainWidget->chkPortDefault->isChecked() ? 0 : mainWidget->customPortEdit->value(); data.connectionData()->localSocketFileName = detailsWidget->chkSocketDefault->isChecked() ? QString::null : detailsWidget->customSocketEdit->url(); data.connectionData()->useLocalSocketFile = detailsWidget->chkUseSocket->isChecked(); //UNSAFE!!!! data.connectionData()->userName = mainWidget->userEdit->text(); data.connectionData()->password = mainWidget->passwordEdit->text(); data.connectionData()->savePassword = mainWidget->chkSavePassword->isChecked(); /* @todo add "options=", eg. as string list? */ return data; }
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(); }