/* * Constructs a MainForm as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ MainForm::MainForm( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "MainForm" ); MainFormLayout = new QVBoxLayout( this, 11, 6, "MainFormLayout"); optionsPushButton = new QPushButton( this, "optionsPushButton" ); MainFormLayout->addWidget( optionsPushButton ); quitPushButton = new QPushButton( this, "quitPushButton" ); MainFormLayout->addWidget( quitPushButton ); languageChange(); resize( QSize(284, 120).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); // signals and slots connections connect( optionsPushButton, SIGNAL( clicked() ), this, SLOT( optionsDlg() ) ); connect( quitPushButton, SIGNAL( clicked() ), this, SLOT( quit() ) ); init(); }
void Project::slotOptions() { KURL url; KDialogBase optionsDlg(KDialogBase::Tabbed, WStyle_DialogBorder, d->m_mainWindow, "project_options", true, i18n("Project Settings"), KDialogBase::Ok | KDialogBase::Cancel); // optionsDlg.setMainWidget(&optionsPage); //add the main options page QFrame *page = optionsDlg.addPage(i18n("Options")); ProjectOptions optionsPage(page); QVBoxLayout *topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&optionsPage); optionsPage.linePrjName->setText( d->projectName ); url = QExtFileInfo::toRelative(d->templateURL, d->baseURL); optionsPage.linePrjTmpl->setText(QuantaCommon::qUrl(url)); url = QExtFileInfo::toRelative(d->toolbarURL, d->baseURL); optionsPage.linePrjToolbar->setText( QuantaCommon::qUrl(url) ); optionsPage.lineAuthor->setText( d->author ); optionsPage.lineEmail->setText( d->email ); // Signals to handle debugger settings connect(optionsPage.buttonDebuggerOptions, SIGNAL(clicked()), d, SLOT(slotDebuggerOptions())); connect(optionsPage.comboDebuggerClient, SIGNAL(activated(const QString &)), d, SLOT(slotDebuggerChanged(const QString &))); // Debuggers Combo KTrader::OfferList offers = KTrader::self()->query("Quanta/Debugger"); KTrader::OfferList::ConstIterator iterDbg; optionsPage.comboDebuggerClient->clear(); optionsPage.comboDebuggerClient->insertItem(i18n("No Debugger")); int idxDbg = 0; d->m_debuggerClientEdit = d->debuggerClient; optionsPage.buttonDebuggerOptions->setEnabled(false); for(iterDbg = offers.begin(); iterDbg != offers.end(); ++iterDbg) { KService::Ptr service = *iterDbg; optionsPage.comboDebuggerClient->insertItem(service->name()); idxDbg++; if(d->debuggerClient == service->name()) { optionsPage.comboDebuggerClient->setCurrentItem(idxDbg); optionsPage.buttonDebuggerOptions->setEnabled(true); } } optionsPage.checkDebuggerPersistentBreakpoints->setChecked(d->m_debuggerPersistentBreakpoints); optionsPage.checkDebuggerPersistentWatches->setChecked(d->m_debuggerPersistentWatches); QString excludeStr; for (uint i = 0; i < d->excludeList.count(); i++) { excludeStr.append(d->excludeList[i]); excludeStr.append(";"); } optionsPage.lineExclude->setText(excludeStr); optionsPage.checkCvsignore->setChecked(d->m_excludeCvsignore); optionsPage.linePrefix->setText(d->previewPrefix.prettyURL()); QStringList lst = DTDs::ref()->nickNameList(true); uint pos = 0; for (uint i = 0; i < lst.count(); i++) { optionsPage.dtdCombo->insertItem(lst[i]); if (lst[i] == DTDs::ref()->getDTDNickNameFromName(d->m_defaultDTD)) pos = i; } optionsPage.dtdCombo->setCurrentItem(pos); QStringList availableEncodingNames(KGlobal::charsets()->availableEncodingNames()); optionsPage.encodingCombo->insertStringList( availableEncodingNames ); QStringList::ConstIterator iter; int iIndex = -1; for (iter = availableEncodingNames.begin(); iter != availableEncodingNames.end(); ++iter) { ++iIndex; if ((*iter).lower() == d->m_defaultEncoding.lower()) { optionsPage.encodingCombo->setCurrentItem(iIndex); break; } } QStringList list = d->projectViewList(); QString defaultView = d->dom.firstChild().firstChild().namedItem("autoload").toElement().attribute("projectview"); if (list.count() > 0) { optionsPage.viewCombo->insertStringList(list); for (uint i = 0; i < list.count(); i++) { if (list[i] == defaultView) { optionsPage.viewCombo->setCurrentItem(i); break; } } } else { optionsPage.viewCombo->insertItem(i18n("No view was saved yet.")); optionsPage.viewCombo->setEnabled(false); } optionsPage.checkPrefix->setChecked(d->usePreviewPrefix); optionsPage.checkPersistentBookmarks->setChecked(d->m_persistentBookmarks); //add upload profiles page page = optionsDlg.addPage(i18n("Up&load Profiles")); UploadProfilesPage uploadProfilesPage(page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&uploadProfilesPage); QDomElement uploadEl = d->m_sessionDom.firstChild().firstChild().namedItem("uploadprofiles").toElement(); uploadProfilesPage.profileLabel->setText(uploadEl.attribute("defaultProfile")); uploadProfilesPage.checkShowUploadTreeviews->setChecked(d->m_showUploadTreeviews); //add the team members page page = optionsDlg.addPage(i18n("Team Configuration")); TeamMembersDlg membersPage(page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&membersPage); QListViewItem *item; if (!teamLeader().name.isEmpty()) { TeamMember member = teamLeader(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Team Leader"), member.task); membersPage.membersListView->insertItem(item); } for (QMap<QString, TeamMember>::ConstIterator it = d->m_subprojectLeaders.constBegin(); it != d->m_subprojectLeaders.constEnd(); ++it) { TeamMember member = it.data(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Subproject Leader"), member.task, it.key()); } for (QMap<QString, TeamMember>::ConstIterator it = d->m_taskLeaders.constBegin(); it != d->m_taskLeaders.constEnd(); ++it) { TeamMember member = it.data(); item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Task Leader"), it.key()); } for (QValueList<TeamMember>::ConstIterator it = d->m_simpleMembers.constBegin(); it != d->m_simpleMembers.constEnd(); ++it) { TeamMember member = *it; item = new QListViewItem(membersPage.membersListView, member.name, member.nickName, member.email, i18n("Simple Member"), member.task); } membersPage.mailingListEdit->setText(d->m_mailingList); membersPage.setYourself(d->m_yourself); //add the event configuration page page = optionsDlg.addPage(i18n("Event Configuration")); EventConfigurationDlg eventsPage(d->m_mainWindow->actionCollection(), page); topLayout = new QVBoxLayout( page, 0, KDialog::spacingHint() ); topLayout->addWidget(&eventsPage); eventsPage.initEvents(d->m_events); eventsPage.enableEventsBox->setChecked(d->m_eventsEnabled); if ( optionsDlg.exec() ) { d->projectName = optionsPage.linePrjName->text(); d->author = optionsPage.lineAuthor ->text(); d->email = optionsPage.lineEmail ->text(); // Debugger d->debuggerClient = optionsPage.comboDebuggerClient->currentText(); d->m_debuggerPersistentBreakpoints = optionsPage.checkDebuggerPersistentBreakpoints->isChecked(); d->m_debuggerPersistentWatches = optionsPage.checkDebuggerPersistentWatches->isChecked(); d->m_defaultDTD = DTDs::ref()->getDTDNameFromNickName(optionsPage.dtdCombo->currentText()).lower(); d->m_defaultEncoding = optionsPage.encodingCombo->currentText(); QuantaCommon::setUrl(d->templateURL, optionsPage.linePrjTmpl->text()); d->templateURL.adjustPath(1); d->templateURL = QExtFileInfo::toAbsolute(d->templateURL, d->baseURL); if (!QExtFileInfo::createDir(d->templateURL, d->m_mainWindow)) { QuantaCommon::dirCreationError(d->m_mainWindow, d->templateURL); } QuantaCommon::setUrl(d->toolbarURL, optionsPage.linePrjToolbar->text()); d->toolbarURL.adjustPath(1); d->toolbarURL = QExtFileInfo::toAbsolute(d->toolbarURL, d->baseURL); if (!QExtFileInfo::createDir(d->toolbarURL, d->m_mainWindow)) { QuantaCommon::dirCreationError(d->m_mainWindow, d->toolbarURL); } d->previewPrefix = KURL::fromPathOrURL( optionsPage.linePrefix->text() ); d->usePreviewPrefix = optionsPage.checkPrefix->isChecked(); d->m_persistentBookmarks = optionsPage.checkPersistentBookmarks->isChecked(); QDomNode projectNode = d->dom.firstChild().firstChild(); QDomElement el; el = projectNode.toElement(); el.setAttribute("name",d->projectName); el.setAttribute("encoding", d->m_defaultEncoding); el = d->m_sessionDom.firstChild().firstChild().toElement(); el.setAttribute("previewPrefix", d->previewPrefix.url() ); el.setAttribute("usePreviewPrefix", d->usePreviewPrefix ); el.setAttribute("usePersistentBookmarks", d->m_persistentBookmarks); el = projectNode.namedItem("author").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("author"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->author ) ); el = projectNode.namedItem("email").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("email"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->email ) ); // Debugger el =projectNode.namedItem("debuggerclient").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("debuggerclient"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( d->debuggerClient ) ); el.setAttribute("persistentBreakpoints", d->m_debuggerPersistentBreakpoints); el.setAttribute("persistentWatches", d->m_debuggerPersistentWatches); d->m_excludeCvsignore = optionsPage.checkCvsignore->isChecked(); excludeStr = optionsPage.lineExclude->text(); el =projectNode.namedItem("exclude").toElement(); if (!el.isNull()) el.parentNode().removeChild(el); el =d->dom.createElement("exclude"); if (d->m_excludeCvsignore) el.setAttribute("cvsignore", "true"); else el.setAttribute("cvsignore", "false"); projectNode.appendChild( el ); el.appendChild(d->dom.createTextNode( excludeStr ) ); el =projectNode.namedItem("defaultDTD").toElement(); if(el.isNull()) { el =d->dom.createElement("defaultDTD"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(d->m_defaultDTD)); } else { el.firstChild().setNodeValue(d->m_defaultDTD); } el = projectNode.namedItem("templates").toElement(); url = QExtFileInfo::toRelative(d->templateURL, d->baseURL); if(el.isNull()) { el =d->dom.createElement("templates"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(QuantaCommon::qUrl(url))); } else { el.firstChild().setNodeValue(QuantaCommon::qUrl(url)); } url = QExtFileInfo::toRelative(d->toolbarURL, d->baseURL); el = projectNode.namedItem("toolbars").toElement(); if(el.isNull()) { el =d->dom.createElement("toolbars"); projectNode.appendChild(el); el.appendChild(d->dom.createTextNode(QuantaCommon::qUrl(url))); } else { el.firstChild().setNodeValue(QuantaCommon::qUrl(url)); } if (optionsPage.viewCombo->isEnabled()) { defaultView = optionsPage.viewCombo->currentText(); el = projectNode.namedItem("autoload").toElement(); if (el.isNull()) { el =d->dom.createElement("autoload"); el.setAttribute("projectview", defaultView); projectNode.appendChild( el ); } else { el.setAttribute("projectview", defaultView); } } uploadEl.setAttribute("showtreeviews", uploadProfilesPage.checkShowUploadTreeviews->isChecked() ? "true" : "false"); QDomNode teamNode = projectNode.namedItem("teamdata"); if (!teamNode.isNull()) projectNode.removeChild(teamNode); teamNode = d->dom.createElement("teamdata"); QDomNode taskLeadersNode = d->dom.createElement("taskleaders"); teamNode.appendChild(taskLeadersNode); QDomNode subLeadersNode = d->dom.createElement("subprojectleaders"); teamNode.appendChild(subLeadersNode); QListViewItemIterator it(membersPage.membersListView); QListViewItem *item; QStringList savedSubprojects; while (it.current()) { item = it.current(); QString role = item->text(3); if (role == i18n(teamLeaderStr.utf8())) { QDomElement leaderEl = d->dom.createElement("leader"); teamNode.appendChild(leaderEl); el = d->dom.createElement("name"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(0))); el = d->dom.createElement("nickName"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(1))); el = d->dom.createElement("email"); leaderEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(2))); } else if (role == i18n(subprojectLeaderStr.utf8())) { QString prjName = item->text(5); savedSubprojects.append(prjName); QDomElement subEl = d->dom.createElement("subproject"); for (uint i = 0; i < d->m_subprojects.count(); i++) { if (d->m_subprojects[i].name == prjName) { subEl.setAttribute("location", d->m_subprojects[i].location); break; } } subEl.setAttribute("name", prjName); subLeadersNode.appendChild(subEl); el = d->dom.createElement("subprojectleader"); el.setAttribute("name", item->text(0)); el.setAttribute("nickName", item->text(1)); el.setAttribute("email", item->text(2)); subEl.appendChild(el); } else if (role == i18n(taskLeaderStr.utf8())) { el = d->dom.createElement("projecttask"); el.setAttribute("tasklead", item->text(0)); el.setAttribute("nickName", item->text(1)); el.setAttribute("email", item->text(2)); el.setAttribute("task", item->text(4)); taskLeadersNode.appendChild(el); } else if (role == i18n(simpleMemberStr.utf8())) { QDomElement memberEl = d->dom.createElement("member"); memberEl.setAttribute("task", item->text(4)); teamNode.appendChild(memberEl); el = d->dom.createElement("name"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(0))); el = d->dom.createElement("nickName"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(1))); el = d->dom.createElement("email"); memberEl.appendChild(el); el.appendChild(d->dom.createTextNode(item->text(2))); } ++it; } //subprojects without a leader for (uint i = 0; i < d->m_subprojects.count(); i++) { if (!savedSubprojects.contains(d->m_subprojects[i].name)) { el = d->dom.createElement("subproject"); el.setAttribute("name", d->m_subprojects[i].name); el.setAttribute("location", d->m_subprojects[i].location); } } el = d->dom.createElement("mailinglist"); el.setAttribute("address", membersPage.mailingListEdit->text()); teamNode.appendChild(el); projectNode.appendChild(teamNode); teamNode = d->m_sessionDom.firstChild().namedItem("teamdata"); if (!teamNode.isNull()) d->m_sessionDom.firstChild().removeChild(teamNode); d->m_yourself = membersPage.yourself(); el = d->m_sessionDom.createElement("teamdata"); el.setAttribute("yourself", d->m_yourself); d->m_sessionDom.firstChild().appendChild(el); eventsPage.saveEvents(d->dom); d->m_eventsEnabled = eventsPage.enableEventsBox->isChecked(); projectNode.toElement().setAttribute("enableEvents", d->m_eventsEnabled?"true":"false"); setModified(); d->loadProjectXML(); } }