diff --git a/src/main/startup/KexiConnSelector.cpp b/src/main/startup/KexiConnSelector.cpp index a80773fda..26eeb6478 100644 --- a/src/main/startup/KexiConnSelector.cpp +++ b/src/main/startup/KexiConnSelector.cpp @@ -1,397 +1,397 @@ /* This file is part of the KDE project Copyright (C) 2003,2005 Jaroslaw Staniek This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KexiConnSelector.h" #include #include #include #include "KexiConnSelectorBase.h" #include "KexiOpenExistingFile.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include ConnectionDataLVItem::ConnectionDataLVItem(KexiDB::ConnectionData *data, const KexiDB::Driver::Info& info, QListView *list) : QListViewItem(list) , m_data(data) { update(info); } ConnectionDataLVItem::~ConnectionDataLVItem() { } void ConnectionDataLVItem::update(const KexiDB::Driver::Info& info) { setText(0, m_data->caption+" "); const QString &sfile = i18n("File"); QString drvname = info.caption.isEmpty() ? m_data->driverName : info.caption; if (info.fileBased) setText(1, sfile + " ("+drvname+") " ); else setText(1, drvname+" " ); setText(2, (info.fileBased ? (QString("<")+sfile.lower()+">") : m_data->serverInfoString(true))+" " ); } /*================================================================*/ //! @internal class KexiConnSelectorWidgetPrivate { public: KexiConnSelectorWidgetPrivate() : conn_sel_shown(false) , file_sel_shown(false) , confirmOverwrites(true) { } QGuardedPtr conn_set; KexiDB::DriverManager manager; bool conn_sel_shown;//! helper bool file_sel_shown; bool confirmOverwrites; }; /*================================================================*/ KexiConnSelectorWidget::KexiConnSelectorWidget( KexiDBConnectionSet& conn_set, QWidget* parent, const char* name ) : QWidgetStack( parent, name ) ,d(new KexiConnSelectorWidgetPrivate()) { d->conn_set = &conn_set; QString none, iconname = KMimeType::mimeType( KexiDB::Driver::defaultFileBasedDriverMimeType() )->icon(none,0); const QPixmap &icon = KGlobal::iconLoader()->loadIcon( iconname, KIcon::Desktop ); setIcon( icon ); m_file = new KexiOpenExistingFile( this, "KexiOpenExistingFile"); m_file->btn_advanced->setIconSet( SmallIconSet("1downarrow") ); m_fileDlg = 0; addWidget(m_file); connect(m_file->btn_advanced,SIGNAL(clicked()),this,SLOT(showAdvancedConn())); m_remote = new KexiConnSelectorBase(this,"conn_sel"); m_remote->icon->setPixmap( DesktopIcon("socket") ); m_remote->btn_back->setIconSet( SmallIconSet("1uparrow") ); connect(m_remote->btn_add, SIGNAL(clicked()), this, SLOT(slotRemoteAddBtnClicked())); connect(m_remote->btn_edit, SIGNAL(clicked()), this, SLOT(slotRemoteEditBtnClicked())); connect(m_remote->btn_remove, SIGNAL(clicked()), this, SLOT(slotRemoteRemoveBtnClicked())); QToolTip::add(m_remote->btn_add, i18n("Add a new database connection")); QToolTip::add(m_remote->btn_edit, i18n("Edit selected database connection")); QToolTip::add(m_remote->btn_remove, i18n("Remove selected database connections")); addWidget(m_remote); if (m_remote->layout()) m_remote->layout()->setMargin(0); connect(m_remote->btn_back,SIGNAL(clicked()),this,SLOT(showSimpleConn())); connect(m_remote->list,SIGNAL(doubleClicked(QListViewItem*)), this,SLOT(slotConnectionItemExecuted(QListViewItem*))); connect(m_remote->list,SIGNAL(returnPressed(QListViewItem*)), this,SLOT(slotConnectionItemExecuted(QListViewItem*))); connect(m_remote->list,SIGNAL(selectionChanged()), this,SLOT(slotConnectionSelectionChanged())); } KexiConnSelectorWidget::~KexiConnSelectorWidget() { delete d; } void KexiConnSelectorWidget::disconnectShowSimpleConnButton() { m_remote->btn_back->disconnect(this,SLOT(showSimpleConn())); } void KexiConnSelectorWidget::showAdvancedConn() { #ifdef KEXI_SERVER_SUPPORT - showSimpleConn(); //safe -#else if (!d->conn_sel_shown) { d->conn_sel_shown=true; //setup //TODO // new KToolBarButton("change", 1, m_remote->frm_change, "change", i18n("Change")); /* KPopupMenu *pm = new KPopupMenu(0); pm->insertItem("aaa"); new KDropDownButtton(m_remote->frm_change, pm, m_remote->frm_change->setFixedWidth(100); // m_remote->frm_change->setBackgroundColor(black); // KToolBar *tbar = new KToolBar(m_remote->frm_change); // tbar->insertButton("change", 1, pm, true, i18n("Change")); tbar->insertButton("change", 1, KActionMenu * act_change = new KActionMenu(i18n2005-04-07("Change"), this, "change"); act_change->insert( new KAction("Add connection", KShortcut(), 0, 0, 0) ); act_change->plug( tbar );*/ //TODO //show connections (on demand): for (KexiDB::ConnectionData::ListIterator it(d->conn_set->list()); it.current(); ++it) { addConnectionData( it.current() ); // else { //this error should be more verbose: // kdWarning() << "KexiConnSelector::KexiConnSelector(): no driver found for '" << it.current()->driverName << "'!" << endl; // } } if (m_remote->list->firstChild()) { m_remote->list->setSelected(m_remote->list->firstChild(),true); } m_remote->descriptionEdit->setPaletteBackgroundColor(palette().active().background()); m_remote->descGroupBox->layout()->setMargin(2); m_remote->list->setFocus(); slotConnectionSelectionChanged(); } raiseWidget(m_remote); +#else + showSimpleConn(); //safe #endif } ConnectionDataLVItem* KexiConnSelectorWidget::addConnectionData( KexiDB::ConnectionData* data ) { const KexiDB::Driver::Info info( d->manager.driverInfo(data->driverName) ); // if (!info.name.isEmpty()) { return new ConnectionDataLVItem(data, info, m_remote->list); // } } void KexiConnSelectorWidget::showSimpleConn() { if (!d->file_sel_shown) { d->file_sel_shown=true; m_fileDlg = new KexiStartupFileDialog( "", KexiStartupFileDialog::Opening, m_file, "openExistingFileDlg"); m_fileDlg->setConfirmOverwrites( d->confirmOverwrites ); static_cast(m_file->layout())->insertWidget( 2, m_fileDlg ); for (QWidget *w = parentWidget(true);w;w=w->parentWidget(true)) { if (w->isDialog()) { //#ifndef Q_WS_WIN connect(m_fileDlg,SIGNAL(rejected()),static_cast(w),SLOT(reject())); //#endif // connect(m_fileDlg,SIGNAL(cancelled()),static_cast(w),SLOT(reject())); break; } } } raiseWidget(m_file); #ifndef KEXI_SERVER_SUPPORT m_file->spacer->hide(); m_file->label->hide(); m_file->btn_advanced->hide(); m_file->label->parentWidget()->hide(); #endif } int KexiConnSelectorWidget::selectedConnectionType() const { return (visibleWidget()==m_file) ? FileBased : ServerBased; } /*ConnectionDataLVItem* KexiConnSelectorWidget::selectedConnectionDataItem() const { if (selectedConnectionType()!=KexiConnSelectorWidget::ServerBased) return 0; ConnectionDataLVItem *item = 0; // = static_cast(m_remote->list->selectedItem()); for (QListViewItemIterator it(m_remote->list); it.current(); ++it) { if (it.current()->isSelected()) { if (item) return 0; //multiple item = static_cast(it.current()); } } return item; }*/ KexiDB::ConnectionData* KexiConnSelectorWidget::selectedConnectionData() const { ConnectionDataLVItem *item = static_cast(m_remote->list->selectedItem()); //ConnectionDataItem(); if (!item) return 0; return item->data(); } QString KexiConnSelectorWidget::selectedFileName() { if (selectedConnectionType()!=KexiConnSelectorWidget::FileBased) return QString::null; return m_fileDlg->currentFileName(); } void KexiConnSelectorWidget::slotConnectionItemExecuted(QListViewItem *item) { emit connectionItemExecuted(static_cast(item)); } void KexiConnSelectorWidget::slotConnectionSelectionChanged() { ConnectionDataLVItem* item = static_cast(m_remote->list->selectedItem()); //update buttons availability /* ConnectionDataLVItem *singleItem = 0; bool multi = false; for (QListViewItemIterator it(m_remote->list); it.current(); ++it) { if (it.current()->isSelected()) { if (singleItem) { singleItem = 0; multi = true; break; } else singleItem = static_cast(it.current()); } }*/ m_remote->btn_edit->setEnabled(item); m_remote->btn_remove->setEnabled(item); m_remote->descriptionEdit->setText(item ? item->data()->description : QString::null); emit connectionItemHighlighted(item); } QListView* KexiConnSelectorWidget::connectionsList() const { return m_remote->list; } void KexiConnSelectorWidget::setFocus() { QWidgetStack::setFocus(); if (visibleWidget()==m_file) m_fileDlg->setFocus(); //m_fileDlg->locationWidget()->setFocus(); else m_remote->list->setFocus(); } void KexiConnSelectorWidget::hideHelpers() { m_file->lbl->hide(); m_file->line->hide(); m_file->spacer->hide(); m_file->label->hide(); m_remote->label->hide(); m_remote->label_back->hide(); m_remote->btn_back->hide(); m_remote->icon->hide(); } void KexiConnSelectorWidget::setConfirmOverwrites(bool set) { d->confirmOverwrites = set; if (m_fileDlg) m_fileDlg->setConfirmOverwrites( d->confirmOverwrites ); } bool KexiConnSelectorWidget::confirmOverwrites() const { return d->confirmOverwrites; } /*static QString msgUnfinished() { return i18n("To define or change a connection, use command line options or click on .kexis file. " "You can find example .kexis file at here.").arg("") //temporary, please do not change for 0.8! + "\nhttp://www.kexi-project.org/resources/testdb.kexis"; */ // .arg("http://websvn.kde.org/*checkout*/branches/kexi/0.9/koffice/kexi/tests/startup/testdb.kexis"); //} void KexiConnSelectorWidget::slotRemoteAddBtnClicked() { KexiDB::ConnectionData data; KexiDBConnectionDialog dlg(data, QString::null, KGuiItem(i18n("&Add"), "button_ok", i18n("Add database connection")) ); dlg.setCaption(i18n("Add a New Database Connection")); if (QDialog::Accepted!=dlg.exec()) return; //store this conn. data KexiDB::ConnectionData *newData = new KexiDB::ConnectionData(*dlg.currentProjectData().connectionData()); if (!d->conn_set->addConnectionData(newData)) { //! @todo msg? delete newData; return; } ConnectionDataLVItem* item = addConnectionData(newData); // m_remote->list->clearSelection(); m_remote->list->setSelected(item, true); slotConnectionSelectionChanged(); } void KexiConnSelectorWidget::slotRemoteEditBtnClicked() { ConnectionDataLVItem* item = static_cast(m_remote->list->selectedItem()); if (!item) return; KexiDBConnectionDialog dlg(*item->data(), QString::null, KGuiItem(i18n("&Save"), "filesave", i18n("Save changes made to this database connection")) ); dlg.setCaption(i18n("Edit Database Connection")); if (QDialog::Accepted!=dlg.exec()) return; KexiDB::ConnectionData *newData = new KexiDB::ConnectionData( *dlg.currentProjectData().connectionData() ); if (!d->conn_set->saveConnectionData(item->data(), newData)) { //! @todo msg? delete newData; return; } const KexiDB::Driver::Info info( d->manager.driverInfo(item->data()->driverName) ); item->update(info); slotConnectionSelectionChanged(); //to update descr. edit } void KexiConnSelectorWidget::slotRemoteRemoveBtnClicked() { ConnectionDataLVItem* item = static_cast(m_remote->list->selectedItem()); if (!item) return; if (KMessageBox::Yes!=KMessageBox::questionYesNo(0, i18n("Do you want to remove database connection \"%1\" from the list of available connections?") .arg(item->data()->serverInfoString(true)), 0)) return; QListViewItem* nextItem = item->itemBelow(); if (!nextItem) nextItem = item->itemAbove(); if (!d->conn_set->removeConnectionData(item->data())) return; m_remote->list->removeItem(item); if (nextItem) m_remote->list->setSelected(nextItem, true); slotConnectionSelectionChanged(); } #include "KexiConnSelector.moc" diff --git a/src/main/startup/KexiNewFileDBWidget.ui b/src/main/startup/KexiNewFileDBWidget.ui deleted file mode 100644 index e528379df..000000000 --- a/src/main/startup/KexiNewFileDBWidget.ui +++ /dev/null @@ -1,154 +0,0 @@ - -KexiNewFileDBWidget - - - KexiNewFileDBWidget - - - - 0 - 0 - 392 - 255 - - - - - unnamed - - - 0 - - - - btn_advanced - - - - 0 - 0 - 0 - 0 - - - - &Advanced - - - - - spacer9_2 - - - Vertical - - - Fixed - - - - 20 - 16 - - - - - - icon - - - - 4 - 5 - 0 - 0 - - - - 5 - - - AlignTop - - - - - spacer9 - - - Vertical - - - MinimumExpanding - - - - 20 - 20 - - - - - - textLabel1_2 - - - - 1 - 1 - 1 - 0 - - - - Click "Advanced" button if you want to create a new database on a server instead of a file. - - - WordBreak|AlignTop - - - - - textLabel1 - - - - 1 - 1 - 0 - 0 - - - - <P><b>Kexi will create a new database, which will be stored in a file on this computer.</b> -<P>&nbsp; - - - WordBreak|AlignTop - - - - - chk_always - - - - 1 - 1 - 0 - 0 - - - - Always &use files for creating new projects. -Don't show me this dialog again. - - - - - - btn_advanced - chk_always - - - diff --git a/src/main/startup/KexiNewProjectWizard.cpp b/src/main/startup/KexiNewProjectWizard.cpp index 44bf84bf6..b4ab9b555 100644 --- a/src/main/startup/KexiNewProjectWizard.cpp +++ b/src/main/startup/KexiNewProjectWizard.cpp @@ -1,431 +1,433 @@ /* This file is part of the KDE project Copyright (C) 2003 Jaroslaw Staniek This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KexiNewProjectWizard.h" #include "KexiConnSelector.h" #include "KexiConnSelectorBase.h" #include "KexiNewPrjTypeSelector.h" #include "KexiOpenExistingFile.h" #include "KexiDBTitlePage.h" #include "KexiServerDBNamePage.h" #include "KexiProjectSelector.h" #include "kexi.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //! @internal class KexiNewProjectWizardPrivate { public: KexiNewProjectWizardPrivate() { le_dbname_txtchanged_disable = false; le_dbname_autofill = true; // conndata_to_show = 0; // project_set_to_show = 0; } ~KexiNewProjectWizardPrivate() { // delete conndata_to_show; // delete project_set_to_show; delete msgHandler; } // KListView *lv_types; KListViewItem *lvi_file, *lvi_server; QString chk_file_txt, chk_server_txt; //!< helper QString server_db_name_dblist_lbl_txt; //!< helper //for displaying db list of the selected conn. QGuardedPtr conndata_to_show; KexiProjectSet *project_set_to_show; KexiGUIMessageHandler* msgHandler; bool le_dbname_txtchanged_disable : 1; bool le_dbname_autofill : 1; }; KexiNewProjectWizard::KexiNewProjectWizard(KexiDBConnectionSet& conn_set, QWidget *parent, const char *name, bool modal, WFlags f) : KWizard(parent, name, modal, f) , d(new KexiNewProjectWizardPrivate() ) { d->msgHandler = new KexiGUIMessageHandler(this); setIcon( DesktopIcon("filenew") ); setCaption( i18n("Creating New Project") ); finishButton()->setText(i18n("Create")); //page: type selector m_prjtype_sel = new KexiNewPrjTypeSelector(this, "KexiNewPrjTypeSelector"); // lv_types = new KListView(m_prjtype_sel, "types listview"); // m_prjtype_sel->lv_types->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum, 0, 2)); #if KDE_VERSION >= KDE_MAKE_VERSION(3,3,9) m_prjtype_sel->lv_types->setShadeSortColumn(false); #endif m_prjtype_sel->lv_types->header()->hide(); m_prjtype_sel->lv_types->setSorting(-1); m_prjtype_sel->lv_types->setAlternateBackground(QColor()); //disable altering m_prjtype_sel->lv_types->setItemMargin( KDialogBase::marginHint() ); QString none; d->lvi_file = new KListViewItem( m_prjtype_sel->lv_types, i18n("New Project Stored in a File") ); d->lvi_file->setPixmap(0, KGlobal::iconLoader()->loadIcon( KMimeType::mimeType( KexiDB::Driver::defaultFileBasedDriverMimeType() )->icon(none,0), KIcon::Desktop ) ); d->lvi_file->setMultiLinesEnabled( true ); d->lvi_server = new KListViewItem( m_prjtype_sel->lv_types, d->lvi_file, i18n("New Project Stored on a Database Server") ); d->lvi_server->setPixmap(0, DesktopIcon("socket") ); d->lvi_server->setMultiLinesEnabled( true ); // m_prjtype_sel->lv_types->resize(d->m_prjtype_sel->lv_types->width(), d->lvi_file->height()*3); m_prjtype_sel->lv_types->setFocus(); QString txt_dns = i18n("Don't show me this question again."); d->chk_file_txt = m_prjtype_sel->chk_always->text() +"\n"+txt_dns; d->chk_server_txt = i18n("Always &use database server for creating new projects.") +"\n"+txt_dns; connect(m_prjtype_sel->lv_types,SIGNAL(executed(QListViewItem*)),this,SLOT(slotLvTypesExecuted(QListViewItem*))); connect(m_prjtype_sel->lv_types,SIGNAL(returnPressed(QListViewItem*)),this,SLOT(slotLvTypesExecuted(QListViewItem*))); connect(m_prjtype_sel->lv_types,SIGNAL(selectionChanged( QListViewItem*)),this,SLOT(slotLvTypesSelected(QListViewItem*))); // static_cast(m_prjtype_sel->layout())->insertWidget(1,d->m_prjtype_sel->lv_types); // static_cast(m_prjtype_sel->layout())->insertStretch(3,1); // updateGeometry(); addPage(m_prjtype_sel, i18n("Select Storage Method")); // d->m_prjtype_sel->lv_types->setMinimumHeight(QMAX(d->lvi_file->height(),d->lvi_server->height())+25); //page: db title m_db_title = new KexiDBTitlePage(this, "KexiDBTitlePage"); addPage(m_db_title, i18n("Select Project's Caption")); //page: connection selector m_conn_sel = new KexiConnSelectorWidget(conn_set, this, "KexiConnSelectorWidget"); //"Select database server connection" m_conn_sel->m_file->btn_advanced->hide(); m_conn_sel->m_file->label->hide(); m_conn_sel->m_file->lbl->setText( i18n("Enter a new Kexi project's file name:") ); m_conn_sel->m_remote->label->setText( i18n("Select database server's connection you wish to use to create a new Kexi project. " "

Here you may also add, edit or remove connections from the list.")); m_conn_sel->m_remote->label_back->hide(); m_conn_sel->m_remote->btn_back->hide(); m_conn_sel->showSimpleConn(); //anyway, db files will be _saved_ m_conn_sel->m_fileDlg->setMode( KexiStartupFileDialog::SavingFileBasedDB ); // m_conn_sel->m_fileDlg->setMode( KFile::LocalOnly | KFile::File ); // m_conn_sel->m_fileDlg->setOperationMode( KFileDialog::Saving ); ////js connect(m_conn_sel->m_fileDlg,SIGNAL(rejected()),this,SLOT(reject())); // connect(m_conn_sel->m_fileDlg,SIGNAL(fileHighlighted(const QString&)),this,SLOT(slotFileHighlighted(const QString&))); connect(m_conn_sel->m_fileDlg,SIGNAL(accepted()),this,SLOT(accept())); m_conn_sel->showAdvancedConn(); connect(m_conn_sel,SIGNAL(connectionItemExecuted(ConnectionDataLVItem*)), this,SLOT(next())); addPage(m_conn_sel, i18n("Select Project's Location")); //page: server db name m_server_db_name = new KexiServerDBNamePage(this, "KexiServerDBNamePage"); d->server_db_name_dblist_lbl_txt = i18n("Existing project databases on %1 database server:"); connect(m_server_db_name->le_caption, SIGNAL(textChanged(const QString&)), this,SLOT(slotServerDBCaptionTxtChanged(const QString&))); connect(m_server_db_name->le_dbname, SIGNAL(textChanged(const QString&)), this,SLOT(slotServerDBNameTxtChanged(const QString&))); connect(m_server_db_name->le_caption, SIGNAL(returnPressed()), this,SLOT(accept())); connect(m_server_db_name->le_dbname, SIGNAL(returnPressed()), this,SLOT(accept())); m_server_db_name->le_caption->setText(i18n("New database")); m_server_db_name->le_dbname->setValidator(new KexiUtils::IdentifierValidator(this, "id_val")); m_project_selector = new KexiProjectSelectorWidget( m_server_db_name->frm_dblist, "KexiProjectSelectorWidget", 0, false, false ); GLUE_WIDGET(m_project_selector, m_server_db_name->frm_dblist); m_project_selector->setFocusPolicy(NoFocus); m_project_selector->setSelectable(false); addPage(m_server_db_name, i18n("Select Project's Caption & Database Name")); setFinishEnabled(m_prjtype_sel,false); setFinishEnabled(m_db_title,false); setFinishEnabled(m_server_db_name,true); //finish: updateGeometry(); // d->m_prjtype_sel->lv_types->setMaximumWidth(width()/2); m_prjtype_sel->lv_types->setSelected(d->lvi_file, true); #ifdef KEXI_SERVER_SUPPORT //get settings KGlobal::config()->setGroup("Startup"); //"" means goto 1st page QString default_storage = KGlobal::config()->readEntry("DefaultStorageForNewProjects",""); #else QString default_storage = "file"; setBackEnabled(m_db_title, false); #endif - if (default_storage.lower()=="file") { - m_prjtype_sel->chk_always->setChecked(true); - showPage(m_db_title); - } else if (default_storage.lower()=="server") { + if (default_storage.lower()=="server") { m_prjtype_sel->lv_types->setSelected(d->lvi_server, true); m_prjtype_sel->chk_always->setChecked(true); + m_conn_sel->showAdvancedConn(); showPage(m_conn_sel); } + else { //"file" + m_prjtype_sel->chk_always->setChecked(true); + showPage(m_db_title); + } } KexiNewProjectWizard::~KexiNewProjectWizard() { delete d; } void KexiNewProjectWizard::show() { KDialog::centerOnScreen(this); KWizard::show(); } void KexiNewProjectWizard::slotLvTypesExecuted(QListViewItem *) { next();//showPage(m_conn_sel); } void KexiNewProjectWizard::slotLvTypesSelected(QListViewItem *item) { if (item==d->lvi_file) { m_prjtype_sel->chk_always->setText(d->chk_file_txt); } else if (item==d->lvi_server) { m_prjtype_sel->chk_always->setText(d->chk_server_txt); } setAppropriate( m_db_title, item==d->lvi_file ); setAppropriate( m_server_db_name, item==d->lvi_server ); } void KexiNewProjectWizard::showPage(QWidget *page) { if (page==m_prjtype_sel) {//p 1 m_prjtype_sel->lv_types->setFocus(); m_prjtype_sel->lv_types->setCurrentItem(m_prjtype_sel->lv_types->currentItem()); } else if (page==m_db_title) {//p 2 if (m_db_title->le_caption->text().stripWhiteSpace().isEmpty()) m_db_title->le_caption->setText(i18n("New database")); m_db_title->le_caption->selectAll(); m_db_title->le_caption->setFocus(); } else if (page==m_conn_sel) {//p 3 if (m_prjtype_sel->lv_types->currentItem()==d->lvi_file) { m_conn_sel->showSimpleConn(); QString fn = KexiUtils::string2FileName( m_db_title->le_caption->text() ); if (!fn.endsWith(".kexi")) fn += ".kexi"; m_conn_sel->m_fileDlg->setLocationText(fn); setFinishEnabled(m_conn_sel,true); m_conn_sel->setFocus(); } else { m_conn_sel->showAdvancedConn(); setFinishEnabled(m_conn_sel,false); m_conn_sel->setFocus(); m_server_db_name->le_caption->selectAll(); } } else if (page==m_server_db_name) { if (m_conn_sel->selectedConnectionData() && (static_cast(d->conndata_to_show) != m_conn_sel->selectedConnectionData())) { m_project_selector->setProjectSet(0); // delete d->project_set_to_show; d->conndata_to_show = 0; d->project_set_to_show = new KexiProjectSet(*m_conn_sel->selectedConnectionData(), d->msgHandler); if (d->project_set_to_show->error()) { delete d->project_set_to_show; d->project_set_to_show = 0; return; } d->conndata_to_show = m_conn_sel->selectedConnectionData(); //-refresh projects list m_project_selector->setProjectSet( d->project_set_to_show ); } } KWizard::showPage(page); } void KexiNewProjectWizard::next() { //let's check if move to next page is allowed: if (currentPage()==m_db_title) { //pg 2 if (m_db_title->le_caption->text().stripWhiteSpace().isEmpty()) { KMessageBox::information(this, i18n("Enter project caption.")); m_db_title->le_caption->setText(""); m_db_title->le_caption->setFocus(); return; } } else if (currentPage()==m_conn_sel) {//p 3 if (m_prjtype_sel->lv_types->currentItem()==d->lvi_file) { //test for db file selection } else { //test for db conn selection if (!m_conn_sel->selectedConnectionData()) { KMessageBox::information(this, i18n("Select server connection for a new project.")); return; } m_project_selector->label->setText( d->server_db_name_dblist_lbl_txt.arg(m_conn_sel->selectedConnectionData()->serverInfoString(false)) ); m_server_db_name->le_caption->setFocus(); } } KWizard::next(); } void KexiNewProjectWizard::accept() { if (m_prjtype_sel->lv_types->currentItem()==d->lvi_file) {//FILE: //check if new db file name is ok kdDebug() << "********** sender() " << sender()->className() << endl; if (sender()==finishButton()) { /*(only if signal does not come from filedialog)*/ kdDebug() << "********** sender()==finishButton() ********" << endl; // if (!m_conn_sel->m_fileDlg->checkURL()) { if (!m_conn_sel->m_fileDlg->checkFileName()) { return; } } } else {//SERVER: //check if we have enough of data if (m_server_db_name->le_caption->text().stripWhiteSpace().isEmpty()) { KMessageBox::information(this, i18n("Enter project caption.")); m_server_db_name->le_caption->setText(""); m_server_db_name->le_caption->setFocus(); return; } QString dbname = m_server_db_name->le_dbname->text().stripWhiteSpace(); if (dbname.isEmpty()) { KMessageBox::information(this, i18n("Enter project's database name.")); m_server_db_name->le_dbname->setText(""); m_server_db_name->le_dbname->setFocus(); return; } //check for duplicated dbname if (m_conn_sel->confirmOverwrites() && m_project_selector->projectSet() && m_project_selector->projectSet() ->findProject( m_server_db_name->le_dbname->text() )) { if (KMessageBox::Continue!=KMessageBox::warningContinueCancel( this, "" +i18n("A project with database name \"%1\" already exists" "

Do you want to delete it and create a new one?") .arg( m_server_db_name->le_dbname->text() ) )) { m_server_db_name->le_dbname->setFocus(); return; } } } KWizard::accept(); } void KexiNewProjectWizard::done(int r) { //save state (always, no matter if dialog is accepted or not) KGlobal::config()->setGroup("Startup"); if (!m_prjtype_sel->chk_always->isChecked()) KGlobal::config()->deleteEntry("DefaultStorageForNewProjects"); else if (m_prjtype_sel->lv_types->currentItem()==d->lvi_file) KGlobal::config()->writeEntry("DefaultStorageForNewProjects","File"); else KGlobal::config()->writeEntry("DefaultStorageForNewProjects","Server"); KGlobal::config()->sync(); KWizard::done(r); } QString KexiNewProjectWizard::projectDBName() const { if (m_prjtype_sel->lv_types->currentItem()==d->lvi_server) return m_server_db_name->le_dbname->text(); return m_conn_sel->selectedFileName(); } QString KexiNewProjectWizard::projectCaption() const { if (m_prjtype_sel->lv_types->currentItem()==d->lvi_server) { return m_server_db_name->le_caption->text(); } return m_db_title->le_caption->text(); } KexiDB::ConnectionData* KexiNewProjectWizard::projectConnectionData() const { if (m_prjtype_sel->lv_types->currentItem()==d->lvi_file) return 0; return m_conn_sel->selectedConnectionData(); } void KexiNewProjectWizard::slotServerDBCaptionTxtChanged(const QString &capt) { if (m_server_db_name->le_dbname->text().isEmpty()) d->le_dbname_autofill=true; if (d->le_dbname_autofill) { d->le_dbname_txtchanged_disable = true; QString captionAsId = KexiUtils::string2Identifier(capt); m_server_db_name->le_dbname->setText(captionAsId); d->le_dbname_txtchanged_disable = false; } } void KexiNewProjectWizard::slotServerDBNameTxtChanged(const QString &) { if (d->le_dbname_txtchanged_disable) return; d->le_dbname_autofill = false; } /*! If true, user will be asked to accept overwriting existing file. This is true by default. */ void KexiNewProjectWizard::setConfirmOverwrites(bool set) { m_conn_sel->setConfirmOverwrites(set); } #include "KexiNewProjectWizard.moc" diff --git a/src/main/startup/KexiStartupDialog.cpp b/src/main/startup/KexiStartupDialog.cpp index ff1410164..984dee852 100644 --- a/src/main/startup/KexiStartupDialog.cpp +++ b/src/main/startup/KexiStartupDialog.cpp @@ -1,651 +1,653 @@ /* This file is part of the KDE project Copyright (C) 2003-2004 Jaroslaw Staniek This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "KexiStartupDialog.h" #include "kexi.h" #include "KexiProjectSelector.h" #include "KexiOpenExistingFile.h" #include "KexiConnSelector.h" #include "KexiConnSelectorBase.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //! we'll remove this later... #define NO_DB_TEMPLATES #ifdef KEXI_SHOW_UNIMPLEMENTED #define KEXI_STARTUP_SHOW_TEMPLATES #define KEXI_STARTUP_SHOW_RECENT #endif class TemplateItem : public KIconViewItem { public: TemplateItem(KIconView* parent, const QString& name, const QPixmap& icon) : KIconViewItem(parent,name,icon) {} ~TemplateItem() {} QString key, name, description; }; TemplatesPage::TemplatesPage( Orientation o, QWidget * parent, const char * name ) : QSplitter(o, parent, name) { templates = new KIconView(this, "templates"); templates->setItemsMovable(false); templates->setShowToolTips(false); info = new KTextBrowser(this,"info"); setResizeMode(templates,KeepSize); setResizeMode(info,KeepSize); connect(templates,SIGNAL(selectionChanged(QIconViewItem*)),this,SLOT(itemClicked(QIconViewItem*))); } TemplatesPage::~TemplatesPage() {} void TemplatesPage::addItem(const QString& key, const QString& name, const QString& description, const QPixmap& icon) { TemplateItem *item = new TemplateItem(templates, name, icon); item->key=key; item->name=name; item->description=description; } void TemplatesPage::itemClicked(QIconViewItem *item) { if (!item) { info->setText(""); return; } QString t = QString("

%1

%2

") .arg(static_cast(item)->name) .arg(static_cast(item)->description); #ifdef NO_DB_TEMPLATES t += QString("

") + i18n("We are sorry, templates are not yet available.") +"

"; #endif info->setText( t ); } /*================================================================*/ //! @internal class KexiStartupDialogPrivate { public: KexiStartupDialogPrivate() : pageTemplates(0), pageOpenExisting(0), pageOpenRecent(0) , pageTemplatesID(-1), pageOpenExistingID(-1), pageOpenRecentID(-1) { result = 0; QString none, iconname; iconname = KMimeType::mimeType( KexiDB::Driver::defaultFileBasedDriverMimeType() )->icon(none,0); kexi_sqlite_icon = KGlobal::iconLoader()->loadIcon( iconname, KIcon::Desktop ); iconname = KMimeType::mimeType("application/x-kexiproject-shortcut")->icon(none,0); kexi_shortcut_icon = KGlobal::iconLoader()->loadIcon( iconname, KIcon::Desktop ); prj_selector = 0; chkDoNotShow = 0; openExistingConnWidget = 0; templatesWidget = 0; templatesWidget_IconListBox = 0; } ~KexiStartupDialogPrivate() {} int dialogType, dialogOptions; QFrame *pageTemplates, *pageOpenExisting, *pageOpenRecent; int pageTemplatesID, pageOpenExistingID, pageOpenRecentID; QCheckBox *chkDoNotShow; //widgets for template tab: KJanusWidget* templatesWidget; QObject *templatesWidget_IconListBox;//helper QWidgetStack *viewBlankTempl; TemplatesPage *viewPersonalTempl; TemplatesPage *viewBusinessTempl; int result; QPixmap kexi_sqlite_icon, kexi_shortcut_icon; //! Key string of selected database template. \sa selectedTemplateKey() QString selectedTemplateKey; //! used for "open existing" KexiDBConnectionSet *connSet; KexiStartupFileDialog *openExistingFileDlg; //! embedded file dialog KexiConnSelectorWidget *openExistingConnWidget; QString existingFileToOpen; //! helper for returning a file name to open KexiDB::ConnectionData* selectedExistingConnection; //! helper for returning selected connection //! used for "open recent" KexiProjectSet *recentProjects; KexiProjectSelectorWidget* prj_selector; //! true if the dialog contain single page, not tabs bool singlePage : 1; }; bool dlgSinglePage(int type) { return (type==KexiStartupDialog::Templates) || (type==KexiStartupDialog::OpenExisting) || (type==KexiStartupDialog::OpenRecent); } QString captionForDialogType(int type) { if (type==KexiStartupDialog::Templates) return i18n("Create Project"); else if (type==KexiStartupDialog::OpenExisting) return i18n("Open Existing Project"); else if (type==KexiStartupDialog::OpenRecent) return i18n("Open Recent Project"); return i18n("Choose Project"); } /*================================================================*/ /*KexiStartupDialog::KexiStartupDialog(QWidget *parent, const char *name, KInstance* global, const QCString &format, const QString &nativePattern, const QString &nativeName, const DialogType &dialogType, const QCString& templateType) : KDialogBase(parent, name, true, i18n("Open Document"), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok) { */ KexiStartupDialog::KexiStartupDialog( int dialogType, int dialogOptions, KexiDBConnectionSet& connSet, KexiProjectSet& recentProjects, QWidget *parent, const char *name ) : KDialogBase( dlgSinglePage(dialogType) ? Plain : Tabbed ,captionForDialogType(dialogType) ,Help | Ok | Cancel, Ok, parent, name ) , d(new KexiStartupDialogPrivate()) { d->recentProjects = &recentProjects; d->connSet = &connSet; d->dialogType = dialogType; d->dialogOptions = dialogOptions; d->singlePage = dlgSinglePage(dialogType); if (dialogType==OpenExisting) {//this dialog has "open" tab only! setIcon(DesktopIcon("fileopen")); } else { setIcon(d->kexi_sqlite_icon); } setSizeGripEnabled(true); int id=0; if (d->dialogType & Templates) { setupPageTemplates(); d->pageTemplatesID = id++; d->templatesWidget->setFocus(); } if (d->dialogType & OpenExisting) { setupPageOpenExisting(); d->pageOpenExistingID = id++; if (d->singlePage) d->openExistingConnWidget->setFocus(); } #ifdef KEXI_STARTUP_SHOW_RECENT if (d->dialogType & OpenRecent) { setupPageOpenRecent(); d->pageOpenRecentID = id++; if (d->singlePage) d->prj_selector->setFocus(); } #endif if (!d->singlePage) { connect(this, SIGNAL(aboutToShowPage(QWidget*)), this, SLOT(tabShown(QWidget*))); d->templatesWidget->setFocus(); } showPage(0); adjustSize(); } KexiStartupDialog::~KexiStartupDialog() { delete d; } bool KexiStartupDialog::shouldBeShown() { KGlobal::config()->setGroup("Startup"); return KGlobal::config()->readBoolEntry("ShowStartupDialog",true); } void KexiStartupDialog::show() { //just some cleanup d->selectedTemplateKey=QString::null; d->existingFileToOpen=QString::null; d->result=-1; KDialog::centerOnScreen(this); KDialogBase::show(); } int KexiStartupDialog::result() const { return d->result; } void KexiStartupDialog::done(int r) { if (d->result!=-1) //already done! return; kdDebug() << "KexiStartupDialog::done(" << r << ")" << endl; updateSelectedTemplateKeyInfo(); //save settings KGlobal::config()->setGroup("Startup"); if (d->openExistingConnWidget) KGlobal::config()->writeEntry("OpenExistingType", (d->openExistingConnWidget->selectedConnectionType() == KexiConnSelectorWidget::FileBased) ? "File" : "Server"); if (d->chkDoNotShow) KGlobal::config()->writeEntry("ShowStartupDialog",!d->chkDoNotShow->isChecked()); KGlobal::config()->sync(); if (r==QDialog::Rejected) { d->result = CancelResult; } else { const int idx = activePageIndex(); if (idx == d->pageTemplatesID) { d->result = TemplateResult; } else if (idx == d->pageOpenExistingID) { d->result = OpenExistingResult; // return file or connection: if (d->openExistingConnWidget->selectedConnectionType()==KexiConnSelectorWidget::FileBased) { d->existingFileToOpen = d->openExistingFileDlg->currentFileName(); // d->existingFileToOpen = d->openExistingFileDlg->currentURL().path(); d->selectedExistingConnection = 0; } else { d->existingFileToOpen = QString::null; d->selectedExistingConnection = d->openExistingConnWidget->selectedConnectionData(); } } else { d->result = OpenRecentResult; } } KDialogBase::done(r); } void KexiStartupDialog::reject() { // d->result = CancelResult; KDialogBase::reject(); } void KexiStartupDialog::setupPageTemplates() { d->pageTemplates = addPage( i18n("&Create Project") ); QVBoxLayout *lyr = new QVBoxLayout( d->pageTemplates, 0, KDialogBase::spacingHint() ); d->templatesWidget = new KJanusWidget( d->pageTemplates, "templatesWidget", KJanusWidget::IconList); {//aaa! dirty hack d->templatesWidget_IconListBox = d->templatesWidget->child(0,"KListBox"); if (d->templatesWidget_IconListBox) d->templatesWidget_IconListBox->installEventFilter(this); } lyr->addWidget(d->templatesWidget); connect(d->templatesWidget, SIGNAL(aboutToShowPage(QWidget*)), this, SLOT(templatesPageShown(QWidget*))); if (d->dialogOptions & CheckBoxDoNotShowAgain) { d->chkDoNotShow = new QCheckBox(i18n("Don't show me this dialog again"), d->pageTemplates, "chkDoNotShow"); lyr->addWidget(d->chkDoNotShow); } //template groups: QFrame *templPageFrame; //- page "blank db" templPageFrame = d->templatesWidget->addPage ( i18n("Blank Database"), i18n("New Blank Database Project"), DesktopIcon("empty") ); QVBoxLayout *tmplyr = new QVBoxLayout(templPageFrame, 0, KDialogBase::spacingHint()); - QLabel *lbl_blank = new QLabel( i18n("Kexi will create a new blank database. Click \"OK\" button to proceed."), templPageFrame ); + QLabel *lbl_blank = new QLabel( + i18n("Kexi will create a new blank database. Click \"OK\" button to proceed."), templPageFrame ); + lbl_blank->setAlignment(Qt::AlignAuto|Qt::AlignTop|Qt::WordBreak); lbl_blank->setMargin(0); tmplyr->addWidget( lbl_blank ); tmplyr->addStretch(1); #ifdef KEXI_STARTUP_SHOW_TEMPLATES //- page "personal db" templPageFrame = d->templatesWidget->addPage ( i18n("Personal Databases"), i18n("New Personal Database Project Templates"), DesktopIcon("folder_home") ); tmplyr = new QVBoxLayout(templPageFrame, 0, KDialogBase::spacingHint()); d->viewPersonalTempl = new TemplatesPage( Vertical, templPageFrame, "personal_page" ); tmplyr->addWidget( d->viewPersonalTempl ); connect(d->viewPersonalTempl->templates,SIGNAL(doubleClicked(QIconViewItem*)),this,SLOT(templateItemExecuted(QIconViewItem*))); connect(d->viewPersonalTempl->templates,SIGNAL(returnPressed(QIconViewItem*)),this,SLOT(templateItemExecuted(QIconViewItem*))); connect(d->viewPersonalTempl->templates,SIGNAL(currentChanged(QIconViewItem*)),this,SLOT(templateItemSelected(QIconViewItem*))); //- page "business db" templPageFrame = d->templatesWidget->addPage ( i18n("Business Databases"), i18n("New Business Database Project Templates"), DesktopIcon( "business_user" )); tmplyr = new QVBoxLayout(templPageFrame, 0, KDialogBase::spacingHint()); d->viewBusinessTempl = new TemplatesPage( Vertical, templPageFrame, "business_page" ); tmplyr->addWidget( d->viewBusinessTempl ); connect(d->viewBusinessTempl->templates,SIGNAL(doubleClicked(QIconViewItem*)),this,SLOT(templateItemExecuted(QIconViewItem*))); connect(d->viewBusinessTempl->templates,SIGNAL(returnPressed(QIconViewItem*)),this,SLOT(templateItemExecuted(QIconViewItem*))); connect(d->viewBusinessTempl->templates,SIGNAL(currentChanged(QIconViewItem*)),this,SLOT(templateItemSelected(QIconViewItem*))); #endif //KEXI_STARTUP_SHOW_TEMPLATES } void KexiStartupDialog::templatesPageShown(QWidget *page) { int idx = d->templatesWidget->pageIndex(page); KIconView *templ = 0; if (idx==0) {//blank // kdDebug() << "blank" << endl; } else if (idx==1) {//personal templ = d->viewPersonalTempl->templates; if (templ->count()==0) { //add items (on demand): d->viewPersonalTempl->addItem("cd_catalog", i18n("CD Catalog"), i18n("Easy-to-use database for storing information about your CD collection."), DesktopIcon("cdrom_unmount")); d->viewPersonalTempl->addItem("expenses", i18n("Expenses"), i18n("A database for managing your personal expenses."), DesktopIcon("kcalc")); d->viewPersonalTempl->addItem("image_gallery", i18n("Image Gallery"), i18n("A database for archiving your image collection in a form of gallery."), DesktopIcon("icons")); } } else if (idx==2) {//business templ = d->viewBusinessTempl->templates; if (templ->count()==0) { //add items (on demand): d->viewBusinessTempl->addItem("address_book", i18n("Address Book"), i18n("A database that offers you a contact information"), DesktopIcon("contents")); } } updateDialogOKButton(d->pageTemplates); } void KexiStartupDialog::templateItemSelected(QIconViewItem *) { updateDialogOKButton(d->pageTemplates); } void KexiStartupDialog::templateItemExecuted(QIconViewItem *item) { if (!item) return; updateSelectedTemplateKeyInfo(); #ifndef NO_DB_TEMPLATES accept(); #endif } void KexiStartupDialog::updateSelectedTemplateKeyInfo() { if (activePageIndex()!=d->pageTemplatesID) {//not a 'new db' tab is selected d->selectedTemplateKey=QString::null; return; } QIconViewItem *item; if (d->templatesWidget->activePageIndex()==0) { d->selectedTemplateKey = "blank"; } else if (d->templatesWidget->activePageIndex()==1) { item = d->viewPersonalTempl->templates->currentItem(); if (!item) { d->selectedTemplateKey=QString::null; return; } d->selectedTemplateKey=QString("personal/")+static_cast(item)->key; } else if (d->templatesWidget->activePageIndex()==2) { item = d->viewBusinessTempl->templates->currentItem(); if (!item) { d->selectedTemplateKey=QString::null; return; } d->selectedTemplateKey=QString("business/")+static_cast(item)->key; } } void KexiStartupDialog::tabShown(QWidget *w) { // kdDebug() << "KexiStartupDialog::tabShown " << (long)w << " "<< long(d->pageTemplates)<pageTemplatesID) w = d->pageTemplates; else if (idx==d->pageOpenExistingID) w = d->pageOpenExisting; else if (idx==d->pageOpenRecentID) w = d->pageOpenRecent; if (!w) return; } bool enable = true; if (w==d->pageTemplates) { int t_id = d->templatesWidget->activePageIndex(); #ifdef NO_DB_TEMPLATES enable = (t_id==0); #else enable = (t_id==0 || (t_id==1 && d->viewPersonalTempl->templates->currentItem()!=0) || (t_id==2 && d->viewBusinessTempl->templates->currentItem()!=0)); #endif } else if (w==d->pageOpenExisting) { // enable = !d->openExistingFileDlg->currentURL().path().isEmpty(); enable = (d->openExistingConnWidget->selectedConnectionType()==KexiConnSelectorWidget::FileBased) ? !d->openExistingFileDlg->currentFileName().isEmpty() : (bool)d->openExistingConnWidget->selectedConnectionData(); } else if (w==d->pageOpenRecent) { enable = (d->prj_selector->selectedProjectData()!=0); } enableButton(Ok,enable); } QString KexiStartupDialog::selectedTemplateKey() const { return d->selectedTemplateKey; } void KexiStartupDialog::setupPageOpenExisting() { if (d->singlePage) d->pageOpenExisting = plainPage(); else d->pageOpenExisting = addPage( i18n("Open &Existing Project") ); QVBoxLayout *lyr = new QVBoxLayout( d->pageOpenExisting, 0, KDialogBase::spacingHint() ); d->openExistingConnWidget = new KexiConnSelectorWidget(*d->connSet, d->pageOpenExisting, "KexiConnSelectorWidget"); lyr->addWidget( d->openExistingConnWidget ); if (KGlobal::config()->readEntry("OpenExistingType","File")=="File") d->openExistingConnWidget->showSimpleConn(); else { d->openExistingConnWidget->showSimpleConn(); #ifdef KEXI_SERVER_SUPPORT d->openExistingConnWidget->showAdvancedConn(); #endif } d->openExistingFileDlg = d->openExistingConnWidget->m_fileDlg; connect(d->openExistingFileDlg,SIGNAL(accepted()),this,SLOT(accept())); connect(d->openExistingConnWidget,SIGNAL(connectionItemExecuted(ConnectionDataLVItem*)), this,SLOT(connectionItemForOpenExistingExecuted(ConnectionDataLVItem*))); connect(d->openExistingConnWidget,SIGNAL(connectionItemHighlighted(ConnectionDataLVItem*)), this,SLOT(connectionItemForOpenExistingHighlighted(ConnectionDataLVItem*))); } void KexiStartupDialog::connectionItemForOpenExistingExecuted(ConnectionDataLVItem *item) { if (!item) return; accept(); } void KexiStartupDialog::connectionItemForOpenExistingHighlighted(ConnectionDataLVItem *item) { actionButton(KDialogBase::Ok)->setEnabled(item); } void KexiStartupDialog::slotOk() { kdDebug()<<"KexiStartupDialog::slotOk()"<pageOpenExistingID) { if (d->openExistingFileDlg) { if (d->openExistingFileDlg->okButton()) d->openExistingFileDlg->okButton()->animateClick(); // return; } } KDialogBase::slotOk(); } void KexiStartupDialog::showSimpleConnForOpenExisting() { kdDebug() << "simple" << endl; d->openExistingConnWidget->showSimpleConn(); } void KexiStartupDialog::showAdvancedConnForOpenExisting() { kdDebug() << "adv" << endl; d->openExistingConnWidget->showAdvancedConn(); } QString KexiStartupDialog::selectedExistingFile() const { kdDebug() << activePageIndex() << " " << d->openExistingFileDlg->isVisible() << ": " << d->existingFileToOpen << endl; return d->existingFileToOpen; } KexiDB::ConnectionData* KexiStartupDialog::selectedExistingConnection() const { return d->selectedExistingConnection; } void KexiStartupDialog::existingFileSelected(const QString &f) { if (f.isEmpty()) return; d->existingFileToOpen=f; updateDialogOKButton(d->openExistingFileDlg); } void KexiStartupDialog::setupPageOpenRecent() { #ifdef KEXI_STARTUP_SHOW_RECENT d->pageOpenRecent = addPage( i18n("Open &Recent Project") ); QVBoxLayout *lyr = new QVBoxLayout( d->pageOpenRecent, 0, KDialogBase::spacingHint() ); lyr->addWidget( d->prj_selector = new KexiProjectSelectorWidget( d->pageOpenRecent, "prj_selector", d->recentProjects ) ); connect(d->prj_selector,SIGNAL(projectExecuted(KexiProjectData*)), this,SLOT(recentProjectItemExecuted(KexiProjectData*))); #endif } KexiProjectData* KexiStartupDialog::selectedProjectData() const { if (activePageIndex()==d->pageOpenRecentID) { return d->prj_selector->selectedProjectData(); } return 0; } void KexiStartupDialog::recentProjectItemExecuted(KexiProjectData *data) { updateDialogOKButton(d->pageOpenRecent); if (!data) return; accept(); } //! used for accepting templates dialog with just return key press bool KexiStartupDialog::eventFilter( QObject *o, QEvent *e ) { if (o==d->templatesWidget_IconListBox && d->templatesWidget_IconListBox) { if (e->type()==QEvent::KeyPress && (static_cast(e)->key()==Key_Enter || static_cast(e)->key()==Key_Return) || e->type()==QEvent::MouseButtonDblClick) { if (d->templatesWidget->activePageIndex()==0 ) { accept(); } } } return KDialogBase::eventFilter(o,e); } // internal reimplementation int KexiStartupDialog::activePageIndex() const { if (!d->singlePage) { kdDebug() << "int KexiStartupDialog::activePageIndex()" << KDialogBase::activePageIndex() << endl; return KDialogBase::activePageIndex(); } kdDebug() << "int KexiStartupDialog::activePageIndex() == " << 0 << endl; return 0; //there is always "plain page" #0 selected } #include "KexiStartupDialog.moc" diff --git a/src/main/startup/Makefile.am b/src/main/startup/Makefile.am index c238618bb..d57b0bf32 100644 --- a/src/main/startup/Makefile.am +++ b/src/main/startup/Makefile.am @@ -1,47 +1,47 @@ include $(top_srcdir)/kexi/Makefile.global noinst_LTLIBRARIES = libkeximainstartup.la libkeximainstartup_la_SOURCES = KexiConnSelectorBase.ui KexiProjectSelectorBase.ui \ - KexiNewFileDBWidget.ui KexiOpenExistingFile.ui \ + KexiOpenExistingFile.ui \ KexiNewPrjTypeSelector.ui KexiDBTitlePageBase.ui \ KexiServerDBNamePage.ui \ KexiDBTitlePage.cpp \ KexiConnSelector.cpp KexiProjectSelector.cpp \ KexiStartupDialog.cpp \ KexiStartupFileDialog.cpp KexiNewProjectWizard.cpp \ KexiStartup.cpp KexiStartup_p.cpp noinst_HEADERS = KexiStartup_p.h libkeximainstartup_la_LDFLAGS = $(all_libraries) -Wnounresolved libkeximainstartup_la_LIBADD = \ ../../widget/libkexiextendedwidgets.la libkeximainstartup_la_METASOURCES = AUTO SUBDIRS = . # kde_appsdir Where your application's menu entry (.desktop) should go to. # kde_icondir Where your icon should go to - better use KDE_ICON. # kde_sounddir Where your sounds should go to. # kde_htmldir Where your docs should go to. (contains lang subdirs) # kde_datadir Where you install application data. (Use a subdir) # kde_locale Where translation files should go to. (contains lang subdirs) # kde_cgidir Where cgi-bin executables should go to. # kde_confdir Where config files should go to (system-wide ones with default values). # kde_mimedir Where mimetypes .desktop files should go to. # kde_servicesdir Where services .desktop files should go to. # kde_servicetypesdir Where servicetypes .desktop files should go to. # kde_toolbardir Where general toolbar icons should go to (deprecated, use KDE_ICON). # kde_wallpaperdir Where general wallpapers should go to. # kde_templatesdir Where templates for the "New" menu (Konqueror/KDesktop) should go to. # kde_bindir Where executables should go to. Use bin_PROGRAMS or bin_SCRIPTS. # kde_libdir Where shared libraries should go to. Use lib_LTLIBRARIES. # kde_moduledir Where modules (e.g. parts) should go to. Use kde_module_LTLIBRARIES. # kde_styledir Where Qt/KDE widget styles should go to (new in KDE 3). # kde_designerdir Where Qt Designer plugins should go to (new in KDE 3). # set the include path for X, qt and KDE INCLUDES= -I$(top_srcdir)/kexi -I$(top_srcdir)/kexi/main/startup -I$(top_srcdir)/kexi/core -I$(top_srcdir)/kexi/widget -I$(top_builddir)/kexi/widget $(all_includes)