/****************************************************************************** * Return the descriptions of all undo or redo items, in order latest first. * For alarms which have undergone more than one change, only the first one is * listed, to force dependent undos to be executed in their correct order. * If 'ids' is non-null, also returns a list of their corresponding IDs. */ QValueList<int> Undo::ids(Undo::Type type) { QValueList<int> ids; QStringList ignoreIDs; //int n=0; List *list = (type == UNDO) ? &mUndoList : (type == REDO) ? &mRedoList : 0; if(!list) return ids; for(Iterator it = list->begin(); it != list->end(); ++it) { // Check whether this item should be ignored because it is a // deendent undo. If not, add this item's ID to the ignore list. UndoItem *item = *it; bool omit = false; if(item->operation() == UndoItem::MULTI) { // If any item in a multi-undo is disqualified, omit the whole multi-undo QStringList newIDs; const Undo::List &undos = ((UndoMultiBase *)item)->undos(); for(Undo::List::ConstIterator u = undos.begin(); u != undos.end(); ++u) { QString evid = (*u)->eventID(); if(ignoreIDs.find(evid) != ignoreIDs.end()) omit = true; else if(omit) ignoreIDs.append(evid); else newIDs.append(evid); } if(omit) { for(QStringList::ConstIterator i = newIDs.begin(); i != newIDs.end(); ++i) ignoreIDs.append(*i); } } else { omit = (ignoreIDs.find(item->eventID()) != ignoreIDs.end()); if(!omit) ignoreIDs.append(item->eventID()); if(item->operation() == UndoItem::EDIT) ignoreIDs.append(item->oldEventID()); // continue looking for its post-edit ID } if(!omit) ids.append(item->id()); //else kdDebug(5950)<<"Undo::ids(): omit "<<item->actionText()<<": "<<item->description()<<endl; } //kdDebug(5950)<<"Undo::ids(): "<<n<<" -> "<<ids.count()<<endl; return ids; }
void boxAsker::nextQuestionHook(const QString &division) { QString otherDivision; QStringList auxList; int i; setFocus(); for (i = 0; i < 4; i++) p_rb[i] -> setChecked(false); auxList << division; // we put the division in a random place p_position = (int)((float)4 * kapp -> random() / (RAND_MAX + 1.0)); nextBoxAskerQuestionHook(division, p_position, true); // we put other 3 names i = 0; while (i < 4) { // false because boxaskers never are clickOnDivision otherDivision = p_map -> getRandomDivision(false); while (auxList.find(otherDivision) != auxList.end()) otherDivision = p_map -> getRandomDivision(false); if (i == p_position) i++; if (i < 4 && nextBoxAskerQuestionHook(otherDivision, i, false)) i++; auxList << otherDivision; } }
//----------------------------------------------------------------------------- // /// DESCRIPTION: /// This method checks if a section is present twice in an ini file /// and returns the list of section name /// /// RETURNS: /// the list of section names /// /// REQUIREMENT ID: NONE //----------------------------------------------------------------------------- QStringList CIniFile::GetIniProfileSectionNames(bool& bDouble) { QStringList sectionList; QString current; QString sDoubleList=""; for (int line=0;line<m_StringTable.GetSize();line++) { current=m_StringTable[line]; if (current.length()) { // looks if section SecName has been found in the ini file if ((current[0]=='[') && (current.at(current.length()-1)==']')) { QString sSection = current.right(current.length()-1); if (sectionList.find(sSection) != sectionList.end()) bDouble = true; sectionList += sSection; } } } // CDS BREAK JPM 2006/05/17 Use of ptr->fld access cannot be used in this case // the iterator is of type QStringList QStringList::Iterator iter = sectionList.begin(); while (iter != sectionList.end()) { (*iter).remove("]"); iter++; } return sectionList; }
void KPluginSelectionWidget::save() { kdDebug(702) << k_funcinfo << endl; for(QMap< QCheckListItem *, KPluginInfo * >::Iterator it = d->pluginInfoMap.begin(); it != d->pluginInfoMap.end(); ++it) { KPluginInfo *info = it.data(); bool checked = it.key()->isOn(); info->setPluginEnabled(checked); info->save(d->config); d->plugincheckedchanged[info] = false; } QStringList updatedModules; for(QValueList< KCModuleProxy * >::Iterator it = d->modulelist.begin(); it != d->modulelist.end(); ++it) if((*it)->changed()) { (*it)->save(); QStringList *names = d->moduleParentComponents[*it]; if(names->size() == 0) names->append(QString::null); for(QStringList::ConstIterator nameit = names->begin(); nameit != names->end(); ++nameit) if(updatedModules.find(*nameit) == updatedModules.end()) updatedModules.append(*nameit); } for(QStringList::ConstIterator it = updatedModules.begin(); it != updatedModules.end(); ++it) emit configCommitted((*it).latin1()); updateConfigPage(); kdDebug(702) << "syncing config file" << endl; d->config->sync(); d->changed = 0; emit changed(false); }
void FX_SetupImpl::Init(QStringList c_avail) { m_config->setGroup("Effect Stack Configuration"); QStringList conf_active = m_config->readListEntry("Activated"); QStringList c_active; QStringList::Iterator sit, it; listBox_Available->clear(); listBox_Active->clear(); c_active.clear(); pushButton_removeAll->setEnabled(false); for (sit=conf_active.begin(); sit!=conf_active.end(); ++sit){ it = c_avail.find(*sit); if ( it!=c_avail.end() ){ // active plugin as per config-file in pluginlist found c_active.append(*sit); // append to active list c_avail.remove(*sit); // remove active plugin from the list of avail plugins } } if ( !c_active.isEmpty() ){ pushButton_removeAll->setEnabled(true); } // Fill ListBoxes for(it=c_avail.begin(); it!=c_avail.end(); ++it){ listBox_Available->insertItem( (*it), -1 ); } for(it=c_active.begin(); it!=c_active.end(); ++it){ listBox_Active->insertItem( (*it), -1 ); } }
void MainWindow::addSelectedToBookmarks(void) { QListViewItem *item = stationView->selectedItem(); assert(item != 0); QStringList bookmarks = Settings::instance()->bookmarks(); if (bookmarks.find(item->text(0)) == bookmarks.end()) { bookmarks.append(item->text(0)); Settings::instance()->setBookmarks(bookmarks); } } /* MainWindow::addSelectedToBookmarks */
QStringList PrivacyManager::difference( const QStringList & lhs, const QStringList & rhs ) { QStringList diff; const QStringList::ConstIterator lhsEnd = lhs.end(); const QStringList::ConstIterator rhsEnd = rhs.end(); for ( QStringList::ConstIterator lhsIt = lhs.begin(); lhsIt != lhsEnd; ++lhsIt ) { if ( rhs.find( *lhsIt ) == rhsEnd ) diff.append( *lhsIt ); } return diff; }
void KOIncidenceEditor::setupDesignerTabs( const QString &type ) { QStringList activePages = KOPrefs::instance()->activeDesignerFields(); QStringList list = KGlobal::dirs()->findAllResources( "data", "korganizer/designer/" + type + "/*.ui", true, true ); for ( QStringList::iterator it = list.begin(); it != list.end(); ++it ) { const QString &fn = (*it).mid( (*it).findRev('/') + 1 ); if ( activePages.find( fn ) != activePages.end() ) { addDesignerTab( *it ); } } }
void KOAttendeeEditor::fillOrganizerCombo() { Q_ASSERT( mOrganizerCombo ); // Get all emails from KOPrefs (coming from various places), // and insert them - removing duplicates const QStringList lst = KOPrefs::instance()->fullEmails(); QStringList uniqueList; for( QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it ) { if ( uniqueList.find( *it ) == uniqueList.end() ) uniqueList << *it; } mOrganizerCombo->insertStringList( uniqueList ); }
QString KProtocolManager::defaultUserAgent(const QString &_modifiers) { if(!d) d = new KProtocolManagerPrivate; QString modifiers = _modifiers.lower(); if(modifiers.isEmpty()) modifiers = DEFAULT_USER_AGENT_KEYS; if(d->modifiers == modifiers) return d->useragent; QString supp; struct utsname nam; if(uname(&nam) >= 0) { if(modifiers.contains('o')) { supp += QString("; %1").arg(nam.sysname); if(modifiers.contains('v')) supp += QString(" %1").arg(nam.release); } if(modifiers.contains('p')) { // TODO: determine this value instead of hardcoding it... supp += QString::fromLatin1("; X11"); } if(modifiers.contains('m')) { supp += QString("; %1").arg(nam.machine); } if(modifiers.contains('l')) { QStringList languageList = KGlobal::locale()->languageList(); QStringList::Iterator it = languageList.find(QString::fromLatin1("C")); if(it != languageList.end()) { if(languageList.contains(QString::fromLatin1("en")) > 0) languageList.remove(it); else (*it) = QString::fromLatin1("en"); } if(languageList.count()) supp += QString("; %1").arg(languageList.join(", ")); } } d->modifiers = modifiers; d->useragent = CFG_DEFAULT_UAGENT(supp); return d->useragent; }
WeatherGlobal::WeatherGlobal() { QStringList serverList = QStringList::split(";", config_file.readEntry("Weather", "Servers")); QStringList serversUsing = QStringList::split(";", config_file.readEntry("Weather", "ServersUsing")); QDir dir(dataPath(WeatherConfigPath), "*.ini"); dir.setFilter(QDir::Files); QStringList iniFiles; for (unsigned int i = 0; i < dir.count(); ++i) iniFiles.append(dir[i]); // Remove non-existent files from the server list // for (unsigned int i = 0; i < serverList.count(); ++i) { QStringList::iterator file = iniFiles.find(serverList[i]); if (file == iniFiles.end()) { serverList.removeAt(i); serversUsing.removeAt(i); } else iniFiles.erase(file); } // Add new files to the server list // serverList += iniFiles; for (unsigned int i = 0; i < iniFiles.count(); ++i) serversUsing.append("1"); // Load server configs and initialize server list // for (unsigned int i = 0; i < serverList.count(); ++i) { PlainConfigFile wConfig(getConfigPath(serverList[i])); servers_.append(Server(wConfig.readEntry("Header","Name"), serverList[i], serversUsing[i] == "1")); } // Load recent locations search list // for (unsigned int i = 0; i < RECENT_LOCATIONS_COUNT; i++) { QString city = config_file.readEntry("Weather", QString("Location%1").arg(i + 1)); if (!city.isEmpty() && !recentLocations_.contains(city)) recentLocations_.push_back(city); } }
NewLanguageDialog::NewLanguageDialog(LanguageItemList &suppressedLangs, QWidget *parent, const char *name, bool modal) : KDialogBase(parent, name, modal, i18n("New Language"), Ok | Cancel, Ok, true) { // layout the page (a combobox with label): QWidget *page = makeMainWidget(); QHBoxLayout *hlay = new QHBoxLayout(page, 0, spacingHint()); mComboBox = new QComboBox(false, page); hlay->addWidget(new QLabel(mComboBox, i18n("Choose &language:"), page)); hlay->addWidget(mComboBox, 1); QStringList pathList = KGlobal::dirs()->findAllResources("locale", QString::fromLatin1("*/entry.desktop")); // extract a list of language tags that should not be included: QStringList suppressedAcronyms; for(LanguageItemList::Iterator lit = suppressedLangs.begin(); lit != suppressedLangs.end(); ++lit) suppressedAcronyms << (*lit).mLanguage; // populate the combo box: for(QStringList::ConstIterator it = pathList.begin(); it != pathList.end(); ++it) { KSimpleConfig entry(*it); entry.setGroup("KCM Locale"); // full name: QString name = entry.readEntry("Name"); // {2,3}-letter abbreviation: // we extract it from the path: "/prefix/de/entry.desktop" -> "de" QString acronym = (*it).section('/', -2, -2); if(suppressedAcronyms.find(acronym) == suppressedAcronyms.end()) { // not found: QString displayname = QString::fromLatin1("%1 (%2)") .arg(name).arg(acronym); QPixmap flag(locate("locale", acronym + flagPng)); mComboBox->insertItem(flag, displayname); } } if(!mComboBox->count()) { mComboBox->insertItem(i18n("No More Languages Available")); enableButtonOK(false); } else mComboBox->listBox()->sort(); }
void MainWindow::removeSelectedFromBookmarks(void) { QListViewItem *item = stationView->selectedItem(); assert(item != 0); QStringList bookmarks = Settings::instance()->bookmarks(); QStringList::iterator it = bookmarks.find(item->text(0)); if (it != bookmarks.end()) { bookmarks.remove(it); Settings::instance()->setBookmarks(bookmarks); item = explorerView->selectedItem(); if (item != 0) { explorerViewClicked(item); } } } /* MainWindow::removeSelectedFromBookmarks */
void MainWindow::readProperties( KConfig *config ) { Core::readProperties( config ); QStringList activePlugins = config->readListEntry( "ActivePlugins" ); QValueList<Plugin*>::ConstIterator it = mPlugins.begin(); QValueList<Plugin*>::ConstIterator end = mPlugins.end(); for ( ; it != end; ++it ) { Plugin *plugin = *it; if ( !plugin->isRunningStandalone() ) { QStringList::ConstIterator activePlugin = activePlugins.find( plugin->identifier() ); if ( activePlugin != activePlugins.end() ) { plugin->readProperties( config ); } } } }
QString Playlist::removeDuplicateTracks(const QString &new_songlist) { raw_songlist.remove(' '); QStringList curList = raw_songlist.split(",", QString::SkipEmptyParts); QStringList newList = new_songlist.split(",", QString::SkipEmptyParts); QStringList::iterator it = newList.begin(); QString songlist; for (; it != newList.end(); it++) { if (curList.find(QString(*it)) == curList.end()) songlist += "," + QString(*it); } songlist.remove(0, 1); return songlist; }
void FolderLister::readConfig( KPIM::GroupwarePrefsBase *newprefs ) { kdDebug(7000) << "FolderLister::readConfig()" << endl; mFolders.clear(); QStringList active = newprefs->activeFolders(); int nr = newprefs->folderNumber(); for ( int i=0; i<nr; ++i ) { QStringList l( newprefs->folder( i ) ); // QStringList l( cfgg.readListEntry( QString("Folder%1").arg( i ) ) ); Entry e; if ( l.count()>0 ) { e.id = l.first(); l.pop_front(); } if ( l.count()>1 ) { e.name = l.first(); l.pop_front(); } e.type = Unknown; for ( QStringList::Iterator it = l.begin(); it != l.end(); ++it ) { e.type = (FolderLister::ContentType)( e.type | contentTypeFromString( *it ) ); } if ( active.find( e.id ) != active.end() ) e.active = true; mFolders.append( e ); } QStringList destinations( newprefs->defaultDestinations() ); #define readDestination(type) \ if ( destinations.count()>0 ) { \ mWriteDestinationId[ type ] = destinations.first(); \ destinations.pop_front(); \ } readDestination( FolderLister::Event ); readDestination( FolderLister::Todo ); readDestination( FolderLister::Journal ); readDestination( FolderLister::Contact ); readDestination( FolderLister::All ); readDestination( FolderLister::Unknown ); #undef readDestination }
void CheckedListView::setChecked( const QStringList &checked ) { // iterate over all items bool showingChecked = FALSE; for ( QCheckListItem *i = (QCheckListItem *) firstChild(); i; i = (QCheckListItem *)i->nextSibling() ) // see if the item should be checked by searching the // checked list if ( checked.find( i->text( 0 ) ) != checked.end() ) { i->setOn( TRUE ); // make sure it is showing at least one checked item if ( !showingChecked ) { ensureItemVisible( i ); showingChecked = TRUE; } } else i->setOn( FALSE ); }
QPopupMenu *KOTodoView::getCategoryPopupMenu( KOTodoViewItem *todoItem ) { QPopupMenu *tempMenu = new QPopupMenu( this ); QStringList checkedCategories = todoItem->todo()->categories(); tempMenu->setCheckable( true ); QStringList::Iterator it; for ( it = KOPrefs::instance()->mCustomCategories.begin(); it != KOPrefs::instance()->mCustomCategories.end(); ++it ) { int index = tempMenu->insertItem( *it ); mCategory[ index ] = *it; if ( checkedCategories.find( *it ) != checkedCategories.end() ) tempMenu->setItemChecked( index, true ); } connect ( tempMenu, SIGNAL( activated( int ) ), SLOT( changedCategories( int ) ) ); return tempMenu; }
void MainWindow::addNamedStationToBookmarks(void) { QString call = QInputDialog::getText(trUtf8("Qtel - Add station..."), trUtf8("Enter callsign of the station to add")); if (!call.isEmpty()) { call = call.upper(); QStringList bookmarks = Settings::instance()->bookmarks(); if (bookmarks.find(call) == bookmarks.end()) { bookmarks.append(call); Settings::instance()->setBookmarks(bookmarks); QListViewItem *item = explorerView->selectedItem(); if ((item != 0) && (item->text(0) == MainWindowBase::trUtf8("Bookmarks"))) { explorerViewClicked(item); } } } } /* MainWindow::addNamedStationToBookmarks */
void AddresseeEditorWidget::setupCustomFieldsTabs() { QStringList activePages = KABPrefs::instance()->advancedCustomFields(); const QStringList list = KGlobal::dirs()->findAllResources( "data", "kaddressbook/contacteditorpages/*.ui", true, true ); for ( QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { if ( activePages.find( (*it).mid( (*it).findRev('/') + 1 ) ) == activePages.end() ) continue; ContactEditorTabPage *page = new ContactEditorTabPage( mTabWidget ); AdvancedCustomFields *wdg = new AdvancedCustomFields( *it, KABC::StdAddressBook::self( true ), page ); if ( wdg ) { mTabPages.insert( wdg->pageIdentifier(), page ); mTabWidget->addTab( page, wdg->pageTitle() ); page->addWidget( wdg ); page->updateLayout(); connect( page, SIGNAL( changed() ), SLOT( emitModified() ) ); } else delete page; } }
void KOTodoView::changedCategories(int index) { if ( !mActiveItem || !mChanger ) return; Todo *todo = mActiveItem->todo(); if ( !todo ) return; if ( !todo->isReadOnly() && mChanger->beginChange( todo ) ) { Todo *oldTodo = todo->clone(); QStringList categories = todo->categories (); if ( categories.find( mCategory[index] ) != categories.end() ) categories.remove( mCategory[index] ); else categories.insert( categories.end(), mCategory[index] ); categories.sort(); todo->setCategories( categories ); mActiveItem->construct(); mChanger->changeIncidence( oldTodo, todo, KOGlobals::CATEGORY_MODIFIED ); mChanger->endChange( todo ); delete oldTodo; } else { kdDebug(5850) << "No active item, active item is read-only, or locking failed" << endl; } }
void buildFile(QTextStream &ts, const QString &group, const QString &fileName, const QString &pluginName, const QString &iconPath) { KConfig input(fileName, true, false); input.setGroup("Global"); QMap< QString, QString > MainMap; MainMap.insert("PluginName", input.readEntry("PluginName", pluginName)); MainMap.insert("PluginNameLower", input.readEntry("PluginName", pluginName).lower()); MainMap.insert("Init", input.readEntry("Init", "")); MainMap.insert("Destroy", input.readEntry("Destroy", "")); ts << classHeader << endl; QStringList includes = input.readListEntry("Includes", ','); for(uint idx = 0; idx < includes.count(); ++idx) ts << "#include <" << includes[idx] << ">" << endl; QStringList classes = input.groupList(); classes.remove(classes.find("Global")); // Autogenerate widget includes here for(uint idx = 0; idx < classes.count(); ++idx) ts << buildWidgetInclude(classes[idx], input) << endl; // Generate embedded icons if(!iconPath.isEmpty()) { for(uint idx = 0; idx < classes.count(); ++idx) ts << buildPixmap(classes[idx], input, iconPath) << endl; ts << "#define EMBED_IMAGES" << endl; } // Generate the main class code. ts << KMacroExpander::expandMacros(classDef, MainMap) << endl; // Autogenerate widget defs here for(uint idx = 0; idx < classes.count(); ++idx) ts << buildWidgetDef(classes[idx], input, group) << endl; ts << KMacroExpander::expandMacros(endCtor, MainMap) << endl; // Autogenerate create code here... for(uint idx = 0; idx < classes.count(); ++idx) ts << buildWidgetCreate(classes[idx], input) << endl; ts << KMacroExpander::expandMacros(endCreate, MainMap) << endl; }
bool CupsdConf::parseOption(const QString &line) { int p(-1); QString keyword, value, l(line.simplifyWhiteSpace()); if((p = l.find(' ')) != -1) { keyword = l.left(p).lower(); value = l.mid(p + 1); } else { keyword = l.lower(); } // kdDebug() << "cupsd.conf keyword=" << keyword << endl; if(keyword == "accesslog") accesslog_ = value; else if(keyword == "autopurgejobs") autopurgejobs_ = (value.lower() == "yes"); else if(keyword == "browseaddress") browseaddresses_.append("Send " + value); else if(keyword == "browseallow") browseaddresses_.append("Allow " + value); else if(keyword == "browsedeny") browseaddresses_.append("Deny " + value); else if(keyword == "browseinterval") browseinterval_ = value.toInt(); else if(keyword == "browseorder") browseorder_ = (value.lower() == "deny,allow" ? ORDER_DENY_ALLOW : ORDER_ALLOW_DENY); else if(keyword == "browsepoll") browseaddresses_.append("Poll " + value); else if(keyword == "browseport") browseport_ = value.toInt(); else if(keyword == "browseprotocols") { browseprotocols_.clear(); QStringList prots = QStringList::split(QRegExp("\\s"), value, false); if(prots.find("all") != prots.end()) browseprotocols_ << "CUPS" << "SLP"; else for(QStringList::ConstIterator it = prots.begin(); it != prots.end(); ++it) browseprotocols_ << (*it).upper(); } else if(keyword == "browserelay") browseaddresses_.append("Relay " + value); else if(keyword == "browseshortnames") useshortnames_ = (value.lower() != "no"); else if(keyword == "browsetimeout") browsetimeout_ = value.toInt(); else if(keyword == "browsing") browsing_ = (value.lower() != "off"); else if(keyword == "classification") { QString cl = value.lower(); if(cl == "none") classification_ = CLASS_NONE; else if(cl == "classified") classification_ = CLASS_CLASSIFIED; else if(cl == "confidential") classification_ = CLASS_CONFIDENTIAL; else if(cl == "secret") classification_ = CLASS_SECRET; else if(cl == "topsecret") classification_ = CLASS_TOPSECRET; else if(cl == "unclassified") classification_ = CLASS_UNCLASSIFIED; else { classification_ = CLASS_OTHER; otherclassname_ = cl; } } else if(keyword == "classifyoverride") classoverride_ = (value.lower() == "yes"); else if(keyword == "datadir") datadir_ = value; else if(keyword == "defaultcharset") charset_ = value; else if(keyword == "defaultlanguage") language_ = value; else if(keyword == "documentroot") documentdir_ = value; else if(keyword == "errorlog") errorlog_ = value; else if(keyword == "filterlimit") filterlimit_ = value.toInt(); else if(keyword == "fontpath") fontpath_ += QStringList::split(':', value, false); else if(keyword == "group") group_ = value; else if(keyword == "hideimplicitmembers") hideimplicitmembers_ = (value.lower() != "no"); else if(keyword == "hostnamelookups") { QString h = value.lower(); if(h == "on") hostnamelookup_ = HOSTNAME_ON; else if(h == "double") hostnamelookup_ = HOSTNAME_DOUBLE; else hostnamelookup_ = HOSTNAME_OFF; } else if(keyword == "implicitclasses") useimplicitclasses_ = (value.lower() != "off"); else if(keyword == "implicitanyclasses") useanyclasses_ = (value.lower() == "on"); else if(keyword == "keepalive") keepalive_ = (value.lower() != "off"); else if(keyword == "keepalivetimeout") keepalivetimeout_ = value.toInt(); else if(keyword == "listen") listenaddresses_.append("Listen " + value); else if(keyword == "loglevel") { QString ll = value.lower(); if(ll == "none") loglevel_ = LOGLEVEL_NONE; else if(ll == "error") loglevel_ = LOGLEVEL_ERROR; else if(ll == "warn") loglevel_ = LOGLEVEL_WARN; else if(ll == "info") loglevel_ = LOGLEVEL_INFO; else if(ll == "debug") loglevel_ = LOGLEVEL_DEBUG; else if(ll == "debug2") loglevel_ = LOGLEVEL_DEBUG2; } else if(keyword == "maxclients") maxclients_ = value.toInt(); else if(keyword == "maxjobs") maxjobs_ = value.toInt(); else if(keyword == "maxjobsperprinter") maxjobsperprinter_ = value.toInt(); else if(keyword == "maxjobsperuser") maxjobsperuser_ = value.toInt(); else if(keyword == "maxrequestsize") maxrequestsize_ = value; else if(keyword == "maxlogsize") maxlogsize_ = value; /*{ // FIXME: support for suffixes int suffix; splitSizeSpec( value, maxlogsize_, suffix ); }*/ else if(keyword == "pagelog") pagelog_ = value; else if(keyword == "port") listenaddresses_.append("Listen *:" + value); else if(keyword == "preservejobhistory") keepjobhistory_ = (value != "off"); else if(keyword == "preservejobfiles") keepjobfiles_ = (value == "on"); else if(keyword == "printcap") printcap_ = value; else if(keyword == "printcapformat") printcapformat_ = (value.lower() == "solaris" ? PRINTCAP_SOLARIS : PRINTCAP_BSD); else if(keyword == "requestroot") requestdir_ = value; else if(keyword == "remoteroot") remoteroot_ = value; else if(keyword == "ripcache") ripcache_ = value; else if(keyword == "serveradmin") serveradmin_ = value; else if(keyword == "serverbin") serverbin_ = value; else if(keyword == "servercertificate") encryptcert_ = value; else if(keyword == "serverkey") encryptkey_ = value; else if(keyword == "servername") servername_ = value; else if(keyword == "serverroot") serverfiles_ = value; else if(keyword == "ssllisten") listenaddresses_.append("SSLListen " + value); else if(keyword == "sslport") listenaddresses_.append("SSLListen *:" + value); else if(keyword == "systemgroup") systemgroup_ = value; else if(keyword == "tempdir") tmpfiles_ = value; else if(keyword == "timeout") clienttimeout_ = value.toInt(); else if(keyword == "user") user_ = value; else { // unrecognized option unknown_ << QPair< QString, QString >(keyword, value); } return true; }
/****************************************************************************** * Check if any alarms are pending for a specified calendar, and display the * pending alarms. */ void AlarmDaemon::checkAlarms(ADCalendar *cal) { kdDebug(5901) << "AlarmDaemons::checkAlarms(" << cal->urlString() << ")" << endl; if(!cal->loaded() || !cal->enabled()) return; QDateTime now = QDateTime::currentDateTime(); kdDebug(5901) << " To: " << now.toString() << endl; QValueList<KCal::Alarm *> alarms = cal->alarmsTo(now); if(!alarms.count()) return; QValueList<KCal::Event *> eventsDone; for(QValueList<KCal::Alarm *>::ConstIterator it = alarms.begin(); it != alarms.end(); ++it) { KCal::Event *event = dynamic_cast<KCal::Event *>((*it)->parent()); if(!event || eventsDone.find(event) != eventsDone.end()) continue; // either not an event, or the event has already been processed eventsDone += event; const QString &eventID = event->uid(); kdDebug(5901) << "AlarmDaemon::checkAlarms(): event " << eventID << endl; // Check which of the alarms for this event are due. // The times in 'alarmtimes' corresponding to due alarms are set. // The times for non-due alarms are set invalid in 'alarmtimes'. bool recurs = event->doesRecur(); const QStringList cats = event->categories(); bool floats = (cats.find(QString::fromLatin1("DATE")) != cats.end()); QDateTime nextDateTime = event->dtStart(); if(recurs) { QString prop = event->customProperty("KALARM", "NEXTRECUR"); if(prop.length() >= 8) { // The next due recurrence time is specified QDate d(prop.left(4).toInt(), prop.mid(4, 2).toInt(), prop.mid(6, 2).toInt()); if(d.isValid()) { if(floats && prop.length() == 8) nextDateTime = d; else if(!floats && prop.length() == 15 && prop[8] == QChar('T')) { QTime t(prop.mid(9, 2).toInt(), prop.mid(11, 2).toInt(), prop.mid(13, 2).toInt()); if(t.isValid()) nextDateTime = QDateTime(d, t); } } } } if(floats) nextDateTime.setTime(mStartOfDay); QValueList<QDateTime> alarmtimes; KCal::Alarm::List alarms = event->alarms(); for(KCal::Alarm::List::ConstIterator al = alarms.begin(); al != alarms.end(); ++al) { KCal::Alarm *alarm = *al; QDateTime dt; if(alarm->enabled()) { QDateTime dt1; if(!alarm->hasTime()) { // Find the latest recurrence for the alarm. // Need to do this for alarms with offsets in order to detect // reminders due for recurrences. int offset = alarm->hasStartOffset() ? alarm->startOffset().asSeconds() : alarm->endOffset().asSeconds() + event->dtStart().secsTo(event->dtEnd()); if(offset) { dt1 = nextDateTime.addSecs(floats ? (offset / SECS_PER_DAY) * SECS_PER_DAY : offset); if(dt1 > now) dt1 = QDateTime(); } } // Get latest due repetition, or the recurrence time if none dt = nextDateTime; if(nextDateTime <= now && alarm->repeatCount() > 0) { int snoozeSecs = alarm->snoozeTime() * 60; int offset = alarm->repeatCount() * snoozeSecs; QDateTime lastRepetition = nextDateTime.addSecs(floats ? (offset / SECS_PER_DAY) * SECS_PER_DAY : offset); if(lastRepetition <= now) dt = lastRepetition; else { int repetition = nextDateTime.secsTo(now) / snoozeSecs; int offset = repetition * snoozeSecs; dt = nextDateTime.addSecs(floats ? (offset / SECS_PER_DAY) * SECS_PER_DAY : offset); } } if(!dt.isValid() || dt > now || dt1.isValid() && dt1 > dt) // already tested dt1 <= now dt = dt1; } alarmtimes.append(dt); } if(!cal->eventHandled(event, alarmtimes)) { if(notifyEvent(cal, eventID)) cal->setEventPending(event, alarmtimes); } } }
/*! Creates an implementation (cpp-file) for the form given in \a e. \sa createFormDecl(), createObjectImpl() */ void Uic::createFormImpl( const QDomElement &e ) { QDomElement n; QDomNodeList nl; int i; QString objClass = getClassName( e ); if ( objClass.isEmpty() ) return; QString objName = getObjectName( e ); // generate local and local includes required QStringList globalIncludes, localIncludes; QStringList::Iterator it; QMap<QString, CustomInclude> customWidgetIncludes; // find additional slots and functions QStringList extraFuncts; QStringList extraFunctTyp; QStringList extraFunctSpecifier; nl = e.parentNode().toElement().elementsByTagName( "slot" ); for ( i = 0; i < (int) nl.length(); i++ ) { n = nl.item(i).toElement(); if ( n.parentNode().toElement().tagName() != "slots" && n.parentNode().toElement().tagName() != "connections" ) continue; if ( n.attribute( "language", "C++" ) != "C++" ) continue; QString functionName = n.firstChild().toText().data().stripWhiteSpace(); if ( functionName.endsWith( ";" ) ) functionName = functionName.left( functionName.length() - 1 ); extraFuncts += functionName; extraFunctTyp += n.attribute( "returnType", "void" ); extraFunctSpecifier += n.attribute( "specifier", "virtual" ); } nl = e.parentNode().toElement().elementsByTagName( "function" ); for ( i = 0; i < (int) nl.length(); i++ ) { n = nl.item(i).toElement(); if ( n.parentNode().toElement().tagName() != "functions" ) continue; if ( n.attribute( "language", "C++" ) != "C++" ) continue; QString functionName = n.firstChild().toText().data().stripWhiteSpace(); if ( functionName.endsWith( ";" ) ) functionName = functionName.left( functionName.length() - 1 ); extraFuncts += functionName; extraFunctTyp += n.attribute( "returnType", "void" ); extraFunctSpecifier += n.attribute( "specifier", "virtual" ); } for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { if ( n.tagName() == "customwidgets" ) { QDomElement n2 = n.firstChild().toElement(); while ( !n2.isNull() ) { if ( n2.tagName() == "customwidget" ) { QDomElement n3 = n2.firstChild().toElement(); QString cl; WidgetDatabaseRecord *r = new WidgetDatabaseRecord; while ( !n3.isNull() ) { if ( n3.tagName() == "class" ) { cl = n3.firstChild().toText().data(); r->name = cl; } else if ( n3.tagName() == "header" ) { CustomInclude ci; ci.header = n3.firstChild().toText().data(); ci.location = n3.attribute( "location", "global" ); r->includeFile = ci.header; customWidgetIncludes.insert( cl, ci ); } WidgetDatabase::append( r ); n3 = n3.nextSibling().toElement(); } } n2 = n2.nextSibling().toElement(); } } } // additional includes (local or global) and forward declaractions nl = e.parentNode().toElement().elementsByTagName( "include" ); for ( i = 0; i < (int) nl.length(); i++ ) { QDomElement n2 = nl.item(i).toElement(); QString s = n2.firstChild().toText().data(); if ( n2.attribute( "location" ) != "local" ) { if ( s.right( 5 ) == ".ui.h" && !QFile::exists( s ) ) continue; if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" ) continue; globalIncludes += s; } } registerDatabases( e ); dbConnections = unique( dbConnections ); if ( dbConnections.count() ) globalIncludes += "qsqldatabase.h"; if ( dbCursors.count() ) globalIncludes += "qsqlcursor.h"; bool dbForm = FALSE; if ( dbForms[ "(default)" ].count() ) dbForm = TRUE; bool subDbForms = FALSE; for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { if ( !(*it).isEmpty() && (*it) != "(default)" ) { if ( dbForms[ (*it) ].count() ) { subDbForms = TRUE; break; } } } if ( dbForm || subDbForms ) { globalIncludes += "qsqlform.h"; globalIncludes += "qsqlrecord.h"; } // do the local includes afterwards, since global includes have priority on clashes for ( i = 0; i < (int) nl.length(); i++ ) { QDomElement n2 = nl.item(i).toElement(); QString s = n2.firstChild().toText().data(); if ( n2.attribute( "location" ) == "local" &&!globalIncludes.contains( s ) ) { if ( s.right( 5 ) == ".ui.h" && !QFile::exists( s ) ) continue; if ( n2.attribute( "impldecl", "in implementation" ) != "in implementation" ) continue; localIncludes += s; } } // additional custom widget headers nl = e.parentNode().toElement().elementsByTagName( "header" ); for ( i = 0; i < (int) nl.length(); i++ ) { QDomElement n2 = nl.item(i).toElement(); QString s = n2.firstChild().toText().data(); if ( n2.attribute( "location" ) != "local" ) globalIncludes += s; else localIncludes += s; } // includes for child widgets for ( it = tags.begin(); it != tags.end(); ++it ) { nl = e.parentNode().toElement().elementsByTagName( *it ); for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget QString name = getClassName( nl.item(i).toElement() ); if ( name == "Spacer" ) { globalIncludes += "qlayout.h"; globalIncludes += "qapplication.h"; continue; } if ( name.mid( 1 ) == "ListView" ) globalIncludes += "qheader.h"; if ( name != objClass ) { int wid = WidgetDatabase::idFromClassName( name ); QMap<QString, CustomInclude>::Iterator it = customWidgetIncludes.find( name ); if ( it == customWidgetIncludes.end() ) globalIncludes += WidgetDatabase::includeFile( wid ); } } } out << "#include <qvariant.h>" << endl; // first for gcc 2.7.2 globalIncludes = unique( globalIncludes ); for ( it = globalIncludes.begin(); it != globalIncludes.end(); ++it ) { if ( !(*it).isEmpty() ) out << "#include <" << *it << ">" << endl; } out << "#include <qlayout.h>" << endl; out << "#include <qtooltip.h>" << endl; out << "#include <qwhatsthis.h>" << endl; if ( objClass == "QMainWindow" ) { out << "#include <qaction.h>" << endl; out << "#include <qmenubar.h>" << endl; out << "#include <qpopupmenu.h>" << endl; out << "#include <qtoolbar.h>" << endl; } // find out what images are required QStringList requiredImages; static const char *imgTags[] = { "pixmap", "iconset", 0 }; for ( i = 0; imgTags[i] != 0; i++ ) { nl = e.parentNode().toElement().elementsByTagName( imgTags[i] ); for ( int j = 0; j < (int) nl.length(); j++ ) { QDomNode nn = nl.item(j); while ( nn.parentNode() != e.parentNode() ) nn = nn.parentNode(); if ( nn.nodeName() != "customwidgets" ) requiredImages += nl.item(j).firstChild().toText().data(); } } if ( !requiredImages.isEmpty() || externPixmaps ) { out << "#include <qimage.h>" << endl; out << "#include <qpixmap.h>" << endl << endl; } /* Put local includes after all global includes */ localIncludes = unique( localIncludes ); for ( it = localIncludes.begin(); it != localIncludes.end(); ++it ) { if ( !(*it).isEmpty() && *it != QFileInfo( fileName + ".h" ).fileName() ) out << "#include \"" << *it << "\"" << endl; } QString uiDotH = fileName + ".h"; if ( QFile::exists( uiDotH ) ) { if ( !outputFileName.isEmpty() ) uiDotH = combinePath( uiDotH, outputFileName ); out << "#include \"" << uiDotH << "\"" << endl; writeFunctImpl = FALSE; } // register the object and unify its name objName = registerObject( objName ); QStringList images; QStringList xpmImages; if ( pixmapLoaderFunction.isEmpty() && !externPixmaps ) { // create images for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { if ( n.tagName() == "images" ) { nl = n.elementsByTagName( "image" ); for ( i = 0; i < (int) nl.length(); i++ ) { QString img = registerObject( nl.item(i).toElement().attribute("name") ); if ( !requiredImages.contains( img ) ) continue; QDomElement tmp = nl.item(i).firstChild().toElement(); if ( tmp.tagName() != "data" ) continue; QString format = tmp.attribute("format", "PNG" ); QString data = tmp.firstChild().toText().data(); if ( format == "XPM.GZ" ) { xpmImages += img; ulong length = tmp.attribute("length").toULong(); QByteArray baunzip = unzipXPM( data, length ); length = baunzip.size(); // shouldn't we test the initial 'length' against the // resulting 'length' to catch corrupt UIC files? int a = 0; int column = 0; bool inQuote = FALSE; out << "static const char* const " << img << "_data[] = { " << endl; while ( baunzip[a] != '\"' ) a++; for ( ; a < (int) length; a++ ) { out << baunzip[a]; if ( baunzip[a] == '\n' ) { column = 0; } else if ( baunzip[a] == '"' ) { inQuote = !inQuote; } if ( column++ >= 511 && inQuote ) { out << "\"\n\""; // be nice with MSVC & Co. column = 1; } } out << endl; } else { images += img; out << "static const unsigned char " << img << "_data[] = { " << endl; out << " "; int a ; for ( a = 0; a < (int) (data.length()/2)-1; a++ ) { out << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << ","; if ( a % 12 == 11 ) out << endl << " "; else out << " "; } out << "0x" << QString(data[2*a]) << QString(data[2*a+1]) << endl; out << "};" << endl << endl; } } } } out << endl; } else if ( externPixmaps ) { pixmapLoaderFunction = "QPixmap::fromMimeSource"; } // constructor if ( objClass == "QDialog" || objClass == "QWizard" ) { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; out << " * name 'name' and widget flags set to 'f'." << endl; out << " *" << endl; out << " * The " << objClass.mid(1).lower() << " will by default be modeless, unless you set 'modal' to" << endl; out << " * TRUE to construct a modal " << objClass.mid(1).lower() << "." << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent, const char* name, bool modal, WFlags fl )" << endl; out << " : " << objClass << "( parent, name, modal, fl )"; } else if ( objClass == "QWidget" ) { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; out << " * name 'name' and widget flags set to 'f'." << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent, const char* name, WFlags fl )" << endl; out << " : " << objClass << "( parent, name, fl )"; } else if ( objClass == "QMainWindow" ) { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " as a child of 'parent', with the" << endl; out << " * name 'name' and widget flags set to 'f'." << endl; out << " *" << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent, const char* name, WFlags fl )" << endl; out << " : " << objClass << "( parent, name, fl )"; isMainWindow = TRUE; } else { out << "/*" << endl; out << " * Constructs a " << nameOfClass << " which is a child of 'parent', with the" << endl; out << " * name 'name'.' " << endl; out << " */" << endl; out << nameOfClass << "::" << bareNameOfClass << "( QWidget* parent, const char* name )" << endl; out << " : " << objClass << "( parent, name )"; } // create pixmaps for all images if ( !xpmImages.isEmpty() ) { for ( it = xpmImages.begin(); it != xpmImages.end(); ++it ) { out << "," << endl; out << indent << " " << *it << "( (const char **) " << (*it) << "_data )"; } } out << endl; out << "{" << endl; if ( isMainWindow ) out << indent << "(void)statusBar();" << endl; if ( !images.isEmpty() ) { out << indent << "QImage img;" << endl; for ( it = images.begin(); it != images.end(); ++it ) { out << indent << "img.loadFromData( " << (*it) << "_data, sizeof( " << (*it) << "_data ), \"PNG\" );" << endl; out << indent << (*it) << " = img;" << endl; } } // set the properties QSize geometry( 0, 0 ); for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { if ( n.tagName() == "property" ) { bool stdset = stdsetdef; if ( n.hasAttribute( "stdset" ) ) stdset = toBool( n.attribute( "stdset" ) ); QString prop = n.attribute("name"); QDomElement n2 = n.firstChild().toElement(); QString value = setObjectProperty( objClass, QString::null, prop, n2, stdset ); if ( value.isEmpty() ) continue; if ( prop == "geometry" && n2.tagName() == "rect" ) { QDomElement n3 = n2.firstChild().toElement(); while ( !n3.isNull() ) { if ( n3.tagName() == "width" ) geometry.setWidth( n3.firstChild().toText().data().toInt() ); else if ( n3.tagName() == "height" ) geometry.setHeight( n3.firstChild().toText().data().toInt() ); n3 = n3.nextSibling().toElement(); } } else { QString call; if ( stdset ) { call = mkStdSet( prop ) + "( "; } else { call = "setProperty( \"" + prop + "\", "; } call += value + " );"; if ( n2.tagName() == "string" ) { trout << indent << call << endl; } else if ( prop == "name" ) { out << indent << "if ( !name )" << endl; out << "\t" << call << endl; } else { out << indent << call << endl; } } } } // create all children, some forms have special requirements if ( objClass == "QWizard" ) { for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { if ( tags.contains( n.tagName() ) ) { QString page = createObjectImpl( n, objClass, "this" ); QString comment; QString label = DomTool::readAttribute( n, "title", "", comment ).toString(); out << indent << "addPage( " << page << ", QString(\"\") );" << endl; trout << indent << "setTitle( " << page << ", " << trcall( label, comment ) << " );" << endl; QVariant def( FALSE, 0 ); if ( DomTool::hasAttribute( n, "backEnabled" ) ) out << indent << "setBackEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "backEnabled", def).toBool() ) << endl; if ( DomTool::hasAttribute( n, "nextEnabled" ) ) out << indent << "setNextEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "nextEnabled", def).toBool() ) << endl; if ( DomTool::hasAttribute( n, "finishEnabled" ) ) out << indent << "setFinishEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "finishEnabled", def).toBool() ) << " );" << endl; if ( DomTool::hasAttribute( n, "helpEnabled" ) ) out << indent << "setHelpEnabled( " << page << ", " << mkBool( DomTool::readAttribute( n, "helpEnabled", def).toBool() ) << endl; if ( DomTool::hasAttribute( n, "finish" ) ) out << indent << "setFinish( " << page << ", " << mkBool( DomTool::readAttribute( n, "finish", def).toBool() ) << endl; } } } else { // standard widgets for ( n = e.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { if ( tags.contains( n.tagName() ) ) createObjectImpl( n, objName, "this" ); } } // database support dbConnections = unique( dbConnections ); if ( dbConnections.count() ) out << endl; for ( it = dbConnections.begin(); it != dbConnections.end(); ++it ) { if ( !(*it).isEmpty() && (*it) != "(default)") { out << indent << (*it) << "Connection = QSqlDatabase::database( \"" <<(*it) << "\" );" << endl; } } nl = e.parentNode().toElement().elementsByTagName( "widget" ); for ( i = 1; i < (int) nl.length(); i++ ) { // start at 1, 0 is the toplevel widget n = nl.item(i).toElement(); QString s = getClassName( n ); if ( (dbForm || subDbForms) && (s == "QDataBrowser" || s == "QDataView") ) { QString objName = getObjectName( n ); QString tab = getDatabaseInfo( n, "table" ); QString con = getDatabaseInfo( n, "connection" ); out << indent << "QSqlForm* " << objName << "Form = new QSqlForm( this, \"" << objName << "Form\" );" << endl; QDomElement n2; for ( n2 = n.firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) createFormImpl( n2, objName, con, tab ); out << indent << objName << "->setForm( " << objName << "Form );" << endl; } } // actions, toolbars, menubar bool needEndl = FALSE; for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { if ( n.tagName() == "actions" ) { if ( !needEndl ) out << endl << indent << "// actions" << endl; createActionImpl( n.firstChild().toElement(), "this" ); needEndl = TRUE; } } if ( needEndl ) out << endl; needEndl = FALSE; for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { if ( n.tagName() == "toolbars" ) { if ( !needEndl ) out << endl << indent << "// toolbars" << endl; createToolbarImpl( n, objClass, objName ); needEndl = TRUE; } } if ( needEndl ) out << endl; needEndl = FALSE; for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { if ( n.tagName() == "menubar" ) { if ( !needEndl ) out << endl << indent << "// menubar" << endl; createMenuBarImpl( n, objClass, objName ); needEndl = TRUE; } } if ( needEndl ) out << endl; out << indent << "languageChange();" << endl; // take minimumSizeHint() into account, for height-for-width widgets if ( !geometry.isNull() ) { out << indent << "resize( QSize(" << geometry.width() << ", " << geometry.height() << ").expandedTo(minimumSizeHint()) );" << endl; out << indent << "clearWState( WState_Polished );" << endl; } for ( n = e; !n.isNull(); n = n.nextSibling().toElement() ) { if ( n.tagName() == "connections" ) { // setup signals and slots connections out << endl << indent << "// signals and slots connections" << endl; nl = n.elementsByTagName( "connection" ); for ( i = 0; i < (int) nl.length(); i++ ) { QString sender, receiver, signal, slot; for ( QDomElement n2 = nl.item(i).firstChild().toElement(); !n2.isNull(); n2 = n2.nextSibling().toElement() ) { if ( n2.tagName() == "sender" ) sender = n2.firstChild().toText().data(); else if ( n2.tagName() == "receiver" ) receiver = n2.firstChild().toText().data(); else if ( n2.tagName() == "signal" ) signal = n2.firstChild().toText().data(); else if ( n2.tagName() == "slot" ) slot = n2.firstChild().toText().data(); } if ( sender.isEmpty() || receiver.isEmpty() || signal.isEmpty() || slot.isEmpty() ) continue; if ( sender[0] == '<' || receiver[0] == '<' || signal[0] == '<' || slot[0] == '<' ) continue; sender = registeredName( sender ); receiver = registeredName( receiver ); // translate formwindow name to "this" if ( sender == objName ) sender = "this"; if ( receiver == objName ) receiver = "this"; out << indent << "connect( " << sender << ", SIGNAL( " << signal << " ), " << receiver << ", SLOT( " << slot << " ) );" << endl; } } else if ( n.tagName() == "tabstops" ) { // setup tab order out << endl << indent << "// tab order" << endl; QString lastName; QDomElement n2 = n.firstChild().toElement(); while ( !n2.isNull() ) { if ( n2.tagName() == "tabstop" ) { QString name = n2.firstChild().toText().data(); name = registeredName( name ); if ( !lastName.isEmpty() ) out << indent << "setTabOrder( " << lastName << ", " << name << " );" << endl; lastName = name; } n2 = n2.nextSibling().toElement(); } } } // buddies bool firstBuddy = TRUE; for ( QValueList<Buddy>::Iterator buddy = buddies.begin(); buddy != buddies.end(); ++buddy ) { if ( isObjectRegistered( (*buddy).buddy ) ) { if ( firstBuddy ) { out << endl << indent << "// buddies" << endl; } out << indent << (*buddy).key << "->setBuddy( " << registeredName( (*buddy).buddy ) << " );" << endl; firstBuddy = FALSE; } } if ( extraFuncts.find( "init()" ) != extraFuncts.end() ) out << indent << "init();" << endl; // end of constructor out << "}" << endl; out << endl; // destructor out << "/*" << endl; out << " * Destroys the object and frees any allocated resources" << endl; out << " */" << endl; out << nameOfClass << "::~" << bareNameOfClass << "()" << endl; out << "{" << endl; if ( extraFuncts.find( "destroy()" ) != extraFuncts.end() ) out << indent << "destroy();" << endl; out << indent << "// no need to delete child widgets, Qt does it all for us" << endl; out << "}" << endl; out << endl; // handle application events if required bool needFontEventHandler = FALSE; bool needSqlTableEventHandler = FALSE; bool needSqlDataBrowserEventHandler = FALSE; nl = e.elementsByTagName( "widget" ); for ( i = 0; i < (int) nl.length(); i++ ) { if ( !DomTool::propertiesOfType( nl.item(i).toElement() , "font" ).isEmpty() ) needFontEventHandler = TRUE; QString s = getClassName( nl.item(i).toElement() ); if ( s == "QDataTable" || s == "QDataBrowser" ) { if ( !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) continue; if ( s == "QDataTable" ) needSqlTableEventHandler = TRUE; if ( s == "QDataBrowser" ) needSqlDataBrowserEventHandler = TRUE; } if ( needFontEventHandler && needSqlTableEventHandler && needSqlDataBrowserEventHandler ) break; } if ( needFontEventHandler && FALSE ) { // indent = "\t"; // increase indentation for if-clause below out << "/*" << endl; out << " * Main event handler. Reimplemented to handle" << endl; out << " * application font changes"; out << " */" << endl; out << "bool " << nameOfClass << "::event( QEvent* ev )" << endl; out << "{" << endl; out << " bool ret = " << objClass << "::event( ev ); " << endl; if ( needFontEventHandler ) { indent += "\t"; out << " if ( ev->type() == QEvent::ApplicationFontChange ) {" << endl; for ( i = 0; i < (int) nl.length(); i++ ) { n = nl.item(i).toElement(); QStringList list = DomTool::propertiesOfType( n, "font" ); for ( it = list.begin(); it != list.end(); ++it ) createExclusiveProperty( n, *it ); } out << " }" << endl; indent = " "; } out << "}" << endl; out << endl; } if ( needSqlTableEventHandler || needSqlDataBrowserEventHandler ) { out << "/*" << endl; out << " * Widget polish. Reimplemented to handle" << endl; if ( needSqlTableEventHandler ) out << " * default data table initialization" << endl; if ( needSqlDataBrowserEventHandler ) out << " * default data browser initialization" << endl; out << " */" << endl; out << "void " << nameOfClass << "::polish()" << endl; out << "{" << endl; if ( needSqlTableEventHandler ) { for ( i = 0; i < (int) nl.length(); i++ ) { QString s = getClassName( nl.item(i).toElement() ); if ( s == "QDataTable" ) { n = nl.item(i).toElement(); QString c = getObjectName( n ); QString conn = getDatabaseInfo( n, "connection" ); QString tab = getDatabaseInfo( n, "table" ); if ( !( conn.isEmpty() || tab.isEmpty() || !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) ) { out << indent << "if ( " << c << " ) {" << endl; out << indent << indent << "QSqlCursor* cursor = " << c << "->sqlCursor();" << endl; out << indent << indent << "if ( !cursor ) {" << endl; if ( conn == "(default)" ) out << indent << indent << indent << "cursor = new QSqlCursor( \"" << tab << "\" );" << endl; else out << indent << indent << indent << "cursor = new QSqlCursor( \"" << tab << "\", TRUE, " << conn << "Connection );" << endl; out << indent << indent << indent << "if ( " << c << "->isReadOnly() ) " << endl; out << indent << indent << indent << indent << "cursor->setMode( QSqlCursor::ReadOnly );" << endl; out << indent << indent << indent << c << "->setSqlCursor( cursor, FALSE, TRUE );" << endl; out << indent << indent << "}" << endl; out << indent << indent << "if ( !cursor->isActive() )" << endl; out << indent << indent << indent << c << "->refresh( QDataTable::RefreshAll );" << endl; out << indent << "}" << endl; } } } } if ( needSqlDataBrowserEventHandler ) { nl = e.elementsByTagName( "widget" ); for ( i = 0; i < (int) nl.length(); i++ ) { QString s = getClassName( nl.item(i).toElement() ); if ( s == "QDataBrowser" ) { QString obj = getObjectName( nl.item(i).toElement() ); QString tab = getDatabaseInfo( nl.item(i).toElement(), "table" ); QString conn = getDatabaseInfo( nl.item(i).toElement(), "connection" ); if ( !(tab.isEmpty() || !isFrameworkCodeGenerated( nl.item(i).toElement() ) ) ) { out << indent << "if ( " << obj << " ) {" << endl; out << indent << indent << "if ( !" << obj << "->sqlCursor() ) {" << endl; if ( conn == "(default)" ) out << indent << indent << indent << "QSqlCursor* cursor = new QSqlCursor( \"" << tab << "\" );" << endl; else out << indent << indent << indent << "QSqlCursor* cursor = new QSqlCursor( \"" << tab << "\", TRUE, " << conn << "Connection );" << endl; out << indent << indent << indent << obj << "->setSqlCursor( cursor, TRUE );" << endl; out << indent << indent << indent << obj << "->refresh();" << endl; out << indent << indent << indent << obj << "->first();" << endl; out << indent << indent << "}" << endl; out << indent << "}" << endl; } } } } out << indent << objClass << "::polish();" << endl; out << "}" << endl; out << endl; } out << "/*" << endl; out << " * Sets the strings of the subwidgets using the current" << endl; out << " * language." << endl; out << " */" << endl; out << "void " << nameOfClass << "::languageChange()" << endl; out << "{" << endl; out << languageChangeBody; out << "}" << endl; out << endl; // create stubs for additional slots if necessary if ( !extraFuncts.isEmpty() && writeFunctImpl ) { it = extraFuncts.begin(); QStringList::Iterator it2 = extraFunctTyp.begin(); QStringList::Iterator it3 = extraFunctSpecifier.begin(); while ( it != extraFuncts.end() ) { QString type = *it2; if ( type.isEmpty() ) type = "void"; type = type.simplifyWhiteSpace(); QString fname = Parser::cleanArgs( *it ); if ( !(*it3).startsWith("pure") ) { // "pure virtual" or "pureVirtual" out << type << " " << nameOfClass << "::" << fname << endl; out << "{" << endl; if ( *it != "init()" && *it != "destroy()" ) { QRegExp numeric( "^(?:signed|unsigned|u?char|u?short|u?int" "|u?long|Q_U?INT(?:8|16|32)|Q_U?LONG|float" "|double)$" ); QString retVal; /* We return some kind of dummy value to shut the compiler up. 1. If the type is 'void', we return nothing. 2. If the type is 'bool', we return 'FALSE'. 3. If the type is 'unsigned long' or 'Q_UINT16' or 'double' or similar, we return '0'. 4. If the type is 'Foo *', we return '0'. 5. If the type is 'Foo &', we create a static variable of type 'Foo' and return it. 6. If the type is 'Foo', we assume there's a default constructor and use it. */ if ( type != "void" ) { QStringList toks = QStringList::split( " ", type ); bool isBasicNumericType = ( toks.grep(numeric).count() == toks.count() ); if ( type == "bool" ) { retVal = "FALSE"; } else if ( isBasicNumericType || type.endsWith("*") ) { retVal = "0"; } else if ( type.endsWith("&") ) { do { type.truncate( type.length() - 1 ); } while ( type.endsWith(" ") ); retVal = "uic_temp_var"; out << indent << "static " << type << " " << retVal << ";" << endl; } else { retVal = type + "()"; } } out << indent << "qWarning( \"" << nameOfClass << "::" << fname << ": Not implemented yet\" );" << endl; if ( !retVal.isEmpty() ) out << indent << "return " << retVal << ";" << endl; } out << "}" << endl; out << endl; } ++it; ++it2; ++it3; } } }
/** * Refresh the nicklistview for a single server. * @param server The server to be refreshed. */ void NicksOnline::updateServerOnlineList(Server* servr) { bool newNetworkRoot = false; QString serverName = servr->getServerName(); QString networkName = servr->getDisplayName(); QListViewItem* networkRoot = findNetworkRoot(networkName); // If network is not in our list, add it. if (!networkRoot) { networkRoot = new NicksOnlineItem(NicksOnlineItem::NetworkRootItem,m_nickListView,networkName); newNetworkRoot = true; } // Store server name in hidden column. // Note that there could be more than one server in the network connected, // but it doesn't matter because all the servers in a network have the same // watch list. networkRoot->setText(nlvcServerName, serverName); // Update list of servers in the network that are connected. QStringList serverList = QStringList::split(",", networkRoot->text(nlvcAdditionalInfo)); if (!serverList.contains(serverName)) serverList.append(serverName); networkRoot->setText(nlvcAdditionalInfo, serverList.join(",")); // Get item in nicklistview for the Offline branch. QListViewItem* offlineRoot = findItemType(networkRoot, NicksOnlineItem::OfflineItem); if (!offlineRoot) { offlineRoot = new NicksOnlineItem(NicksOnlineItem::OfflineItem,networkRoot,i18n("Offline")); offlineRoot->setText(nlvcServerName, serverName); } // Get watch list. QStringList watchList = servr->getWatchList(); QStringList::iterator itEnd = watchList.end(); QString nickname; for (QStringList::iterator it = watchList.begin(); it != itEnd; ++it) { nickname = (*it); NickInfoPtr nickInfo = getOnlineNickInfo(networkName, nickname); if (nickInfo && nickInfo->getPrintedOnline()) { // Nick is online. // Which server did NickInfo come from? Server* server=nickInfo->getServer(); // Get addressbook entry (if any) for the nick. KABC::Addressee addressee = nickInfo->getAddressee(); // Construct additional information string for nick. bool needWhois = false; QString nickAdditionalInfo = getNickAdditionalInfo(nickInfo, addressee, needWhois); // Remove from offline branch if present. QListViewItem* item = findItemChild(offlineRoot, nickname, NicksOnlineItem::NicknameItem); if (item) delete item; // Add to network if not already added. QListViewItem* nickRoot = findItemChild(networkRoot, nickname, NicksOnlineItem::NicknameItem); if (!nickRoot) nickRoot = new NicksOnlineItem(NicksOnlineItem::NicknameItem,networkRoot, nickname, nickAdditionalInfo); nickRoot->setText(nlvcAdditionalInfo, nickAdditionalInfo); nickRoot->setText(nlvcServerName, serverName); // If no additional info available, request a WHOIS on the nick. if (!m_whoisRequested) { if (needWhois) { requestWhois(networkName, nickname); m_whoisRequested = true; } } // Set Kabc icon if the nick is associated with an addressbook entry. if (!addressee.isEmpty()) nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap( QIconSet::Small, QIconSet::Normal, QIconSet::On)); else nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap( QIconSet::Small, QIconSet::Disabled, QIconSet::Off)); QStringList channelList = server->getNickChannels(nickname); QStringList::iterator itEnd2 = channelList.end(); for (QStringList::iterator it2 = channelList.begin(); it2 != itEnd2; ++it2) { // Known channels where nickname is online and mode in each channel. // FIXME: If user connects to multiple servers in same network, the // channel info will differ between the servers, resulting in inaccurate // mode and led info displayed. QString channelName = (*it2); ChannelNickPtr channelNick = server->getChannelNick(channelName, nickname); QString nickMode; if (channelNick->hasVoice()) nickMode = nickMode + i18n(" Voice"); if (channelNick->isHalfOp()) nickMode = nickMode + i18n(" HalfOp"); if (channelNick->isOp()) nickMode = nickMode + i18n(" Operator"); if (channelNick->isOwner()) nickMode = nickMode + i18n(" Owner"); if (channelNick->isAdmin()) nickMode = nickMode + i18n(" Admin"); QListViewItem* channelItem = findItemChild(nickRoot, channelName, NicksOnlineItem::ChannelItem); if (!channelItem) channelItem = new NicksOnlineItem(NicksOnlineItem::ChannelItem,nickRoot, channelName, nickMode); channelItem->setText(nlvcAdditionalInfo, nickMode); // Icon for mode of nick in each channel. Images::NickPrivilege nickPrivilege = Images::Normal; if (channelNick->hasVoice()) nickPrivilege = Images::Voice; if (channelNick->isHalfOp()) nickPrivilege = Images::HalfOp; if (channelNick->isOp()) nickPrivilege = Images::Op; if (channelNick->isOwner()) nickPrivilege = Images::Owner; if (channelNick->isAdmin()) nickPrivilege = Images::Admin; if (server->getJoinedChannelMembers(channelName) != 0) channelItem->setPixmap(nlvcChannel, KonversationApplication::instance()->images()->getNickIcon(nickPrivilege, false)); else channelItem->setPixmap(nlvcChannel, KonversationApplication::instance()->images()->getNickIcon(nickPrivilege, true)); } // Remove channel if nick no longer in it. QListViewItem* child = nickRoot->firstChild(); while (child) { QListViewItem* nextChild = child->nextSibling(); if (channelList.find(child->text(nlvcNick)) == channelList.end()) delete child; child = nextChild; } } else { // Nick is offline. // Remove from online nicks, if present. QListViewItem* item = findItemChild(networkRoot, nickname, NicksOnlineItem::NicknameItem); if (item) delete item; // Add to offline list if not already listed. QListViewItem* nickRoot = findItemChild(offlineRoot, nickname, NicksOnlineItem::NicknameItem); if (!nickRoot) nickRoot = new NicksOnlineItem(NicksOnlineItem::NicknameItem,offlineRoot, nickname); nickRoot->setText(nlvcServerName, serverName); // Get addressbook entry for the nick. KABC::Addressee addressee = servr->getOfflineNickAddressee(nickname); // Format additional information for the nick. bool needWhois = false; QString nickAdditionalInfo = getNickAdditionalInfo(0, addressee, needWhois); nickRoot->setText(nlvcAdditionalInfo, nickAdditionalInfo); // Set Kabc icon if the nick is associated with an addressbook entry. if (!addressee.isEmpty()) nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap( QIconSet::Small, QIconSet::Normal, QIconSet::On)); else nickRoot->setPixmap(nlvcKabc, m_kabcIconSet.pixmap( QIconSet::Small, QIconSet::Disabled, QIconSet::Off)); } } // Erase nicks no longer being watched. QListViewItem* item = networkRoot->firstChild(); while (item) { QListViewItem* nextItem = item->nextSibling(); if (static_cast<NicksOnlineItem*>(item)->type() != NicksOnlineItem::OfflineItem) { QString nickname = item->text(nlvcNick); if ((watchList.find(nickname) == watchList.end()) && (serverName == item->text(nlvcServerName))) delete item; } item = nextItem; } item = offlineRoot->firstChild(); if(item) { while (item) { QListViewItem* nextItem = item->nextSibling(); QString nickname = item->text(nlvcNick); if ((watchList.find(nickname) == watchList.end()) && (serverName == item->text(nlvcServerName))) delete item; item = nextItem; } } else { delete offlineRoot; } // Expand server if newly added to list. if (newNetworkRoot) { networkRoot->setOpen(true); // Connect server NickInfo updates. connect (servr, SIGNAL(nickInfoChanged(Server*, const NickInfoPtr)), this, SLOT(slotNickInfoChanged(Server*, const NickInfoPtr))); } }
Account::Account(const QString & acc_name) : accname( acc_name ), type( Account::UNDEFINE ), auth( Account::NONE ), haspassword(false), port(0), ssl(false), tls(false), useCertificates(false), s_type( Account::Sendmail ), s_auth( Account::NONE ), s_haspassword(false), s_port(0), s_ssl(false), s_tls(false), s_useCertificates(false), leave(true), sync(true), sorted(true), enabled(true), getdisabled(false), passentered(true), persistence(true), groupware(false), groupType( Account::Citadel ), max_action( Account::ask ), max_dl(0) { if(acc_name.isEmpty()) { qDebug("ERROR: cannot setup an account with an empty name."); return; } // qDebug("Trying to set up account %s...", (const char *)acc_name); // Check if the name has already the settings path in it QString group = QString("/Aethera/Accounts/") + acc_name + "/"; // receive account type QString t = Settings::instance()->readEntry(group + "Type"); if(t == "POP3") type = Account::POP3; else if(t == "IMAP4") type = Account::IMAP4; else type = Account::MAILBOX; // send account type t = Settings::instance()->readEntry(group + "SendType"); if( "Qmail" == t ) s_type = Account::Qmail; else if( "SMTP" == t ) s_type = Account::SMTP; else s_type = Account::Sendmail; // receive account auth mode t = Settings::instance()->readEntry(group + "AuthType"); if( "LOGIN" == t ) auth = Account::LOGIN; else if( "PLAIN" == t ) auth = Account::PLAIN; else if( "DIGEST_MD5" == t ) auth = Account::DIGEST_MD5; else if( "CRAM_MD5" == t ) auth = Account::CRAM_MD5; else auth = Account::NONE; // send account auth mode t = Settings::instance()->readEntry(group + "SendAuthType"); if( "LOGIN" == t ) s_auth = Account::LOGIN; else if( "PLAIN" == t ) s_auth = Account::PLAIN; else if( "DIGEST_MD5" == t ) s_auth = Account::DIGEST_MD5; else if( "CRAM_MD5" == t ) s_auth = Account::CRAM_MD5; else s_auth = Account::NONE; // SMTP server and port smtp = Settings::instance()->readEntry(group + "Smtp"); s_port = Settings::instance()->readNumEntry(group + "SPort"); // SMTP defaults if(s_port==0) s_port=25; if(smtp.isEmpty()) smtp=Names::systemSMTPServerName(); // send login s_user = Settings::instance()->readEntry(group + "SendUser"); // login default if( s_user.isEmpty() ) s_user = Names::systemServerLoginName(); // has password? s_haspassword= Settings::instance()->readBoolEntry(group + "SendRememberPassword", false); // password if(s_haspassword) s_password = decodePassword( QCString(Settings::instance()->readEntry(group + "SendPassword")) ); // Send SSL s_ssl= Settings::instance()->readBoolEntry(group + "SendSSL", false); // Send TLS s_tls= Settings::instance()->readBoolEntry(group + "SendTLS", false); // Send uses SSL Certificates s_useCertificates = Settings::instance()->readBoolEntry(group + "SendCertificates", false); // "From" address from=Settings::instance()->readEntry(group + "From"); // "From" default if(from.isEmpty()) from=Names::systemFromAddress(); // "Reply-To" address reply=Settings::instance()->readEntry(group + "Reply To"); // full user name name=Settings::instance()->readEntry(group + "Name"); // name default if(name.isEmpty()) name=Names::systemUserName(); // speed speed=Settings::instance()->readEntry(group + "Speed").lower(); // speed default if(speed.isEmpty() || !QString("normal, slow, very slow").contains(speed)) speed="normal"; // max download max_dl=Settings::instance()->readNumEntry(group + "Max download"); // enabled enabled= Settings::instance()->readBoolEntry(group + "Enabled", true); // max download action // QString act=Settings::instance()->readEntry(group + "Max action"); // max_action=act=="ignore"?ignore:(act=="remove"?remove:ask); max_action = Account::ask; if(type==MAILBOX) { // mailbox mbox=Settings::instance()->readEntry(group + "Mailbox"); // mailbox default if(mbox.isEmpty()) mbox=Names::systemMailbox(); } else { // server server=Settings::instance()->readEntry(group + "Server"); // port port=Settings::instance()->readNumEntry(group + "Port"); // server defaults if(server.isEmpty()) if(type==POP3) server=Names::systemPOP3ServerName(); else server=Names::systemIMAP4ServerName(); // port defaults if(!port) if(type==POP3) port=110; else port=143; // server login user=Settings::instance()->readEntry(group + "User"); // login default if(user.isEmpty()) user=Names::systemServerLoginName(); // has password? haspassword= Settings::instance()->readBoolEntry(group + "Remember password", false); // password if(haspassword) password = decodePassword( QCString(Settings::instance()->readEntry(group + "Password")) ); // SSL ssl= Settings::instance()->readBoolEntry(group + "SSL", false); // TLS tls= Settings::instance()->readBoolEntry(group + "TLS", false); // SSL Certificates useCertificates = Settings::instance()->readBoolEntry(group + "Certificates", false); if(type==POP3) // POP3 specific options { // persistence persistence=Settings::instance()->readBoolEntry(group + "Persistence", true); // leave on server leave=Settings::instance()->readBoolEntry(group + "Leave on server", true); // sync on delete sync=Settings::instance()->readBoolEntry(group + "Sync", true); // retrieve sorted by size sorted=Settings::instance()->readBoolEntry(group + "Sorted", false); } else // IMAP specific options { // mailbox mbox=Settings::instance()->readEntry(group + "Mailbox"); // mailbox default if(mbox.isEmpty()) mbox="Inbox"; } } groupware = Settings::instance()->readBoolEntry(group + "Kolab", false); if(groupware) { QStringList kolabList = Settings::instance()->readListEntry("/Aethera/Kolab/Accounts", ','); if( kolabList.end() == kolabList.find( accname ) ) { QStringList citadelList = Settings::instance()->readListEntry("/Aethera/Citadel/Accounts", ','); if( citadelList.end() != citadelList.find( accname ) ) { groupType = Account::Citadel; } } else { groupType = Account::Kolab1; } calendarFolder = Settings::instance()->readEntry(group + "Kolab/Calendar"); contactsFolder = Settings::instance()->readEntry(group + "Kolab/Contacts"); notesFolder = Settings::instance()->readEntry(group + "Kolab/Notes"); todoFolder = Settings::instance()->readEntry(group + "Kolab/ToDo"); } getdisabled=false; }
int main(int argc, char **argv) { const bool kdeRunning = kdeIsRunning(); KAboutData aboutData("kbookmarkmerger", I18N_NOOP("KBookmarkMerger"), "1.0", I18N_NOOP("Merges bookmarks installed by 3rd parties into the user's bookmarks"), KAboutData::License_BSD, I18N_NOOP("Copyright © 2005 Frerich Raabe")); aboutData.addAuthor("Frerich Raabe", I18N_NOOP("Original author"), "*****@*****.**"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(cmdLineOptions); if(!kdeRunning) { KApplication::disableAutoDcopRegistration(); } KApplication app(false, false); app.disableSessionManagement(); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if(args->count() != 1) { kdError() << "No directory to scan for bookmarks specified." << endl; return 1; } KBookmarkManager *konqBookmarks = KBookmarkManager::userBookmarksManager(); QStringList mergedFiles; { KBookmarkGroup root = konqBookmarks->root(); for(KBookmark bm = root.first(); !bm.isNull(); bm = root.next(bm)) { if(bm.isGroup()) { continue; } QString mergedFrom = bm.metaDataItem("merged_from"); if(!mergedFrom.isNull()) { mergedFiles << mergedFrom; } } } bool didMergeBookmark = false; QString extraBookmarksDirName = QFile::decodeName(args->arg(0)); QDir extraBookmarksDir(extraBookmarksDirName, "*.xml"); if(!extraBookmarksDir.isReadable()) { kdError() << "Failed to read files in directory " << extraBookmarksDirName << endl; return 1; } for(unsigned int i = 0; i < extraBookmarksDir.count(); ++i) { const QString fileName = extraBookmarksDir[i]; if(mergedFiles.find(fileName) != mergedFiles.end()) { continue; } const QString absPath = extraBookmarksDir.filePath(fileName); KBookmarkManager *mgr = KBookmarkManager::managerForFile(absPath, false); KBookmarkGroup root = mgr->root(); for(KBookmark bm = root.first(); !bm.isNull(); bm = root.next(bm)) { if(bm.isGroup()) { continue; } bm.setMetaDataItem("merged_from", fileName); konqBookmarks->root().addBookmark(konqBookmarks, bm, false); didMergeBookmark = true; } } if(didMergeBookmark) { if(!konqBookmarks->save()) { kdError() << "Failed to write merged bookmarks." << endl; return 1; } if(kdeRunning) { konqBookmarks->notifyChanged(""); } } }
void VisualizationsEditor::fillWidgets(const QString ¤tSelection) { Q3ListViewItem *item; QStringList currentList = QStringList::split(";", currentSelection); QStringList visualizations = MainVisual::Visualizations(); visualizations.sort(); item = NULL; for (int i = 0; i < currentList.size(); i++) { // check the visualizer is supported if (visualizations.find(currentList[i]) != visualizations.end()) { QString visName, pluginName; if (currentList[i].contains("-")) { pluginName = currentList[i].section('-', 0, 0); visName = currentList[i].section('-', 1, 1); } else { visName = currentList[i]; pluginName = "MythMusic"; } item = new Q3ListViewItem(selectedList, item, visName, pluginName); } else LOG(VB_GENERAL, LOG_ERR, QString("'%1' is not in the list of supported visualizers") .arg(currentList[i])); } item = NULL; for (int i = 0; i < visualizations.size(); i++) { if (currentList.find(visualizations[i]) == currentList.end()) { QString visName, pluginName; if (visualizations[i].contains("-")) { pluginName = visualizations[i].section('-', 0, 0); visName = visualizations[i].section('-', 1, 1); } else { visName = visualizations[i]; pluginName = "MythMusic"; } item = new Q3ListViewItem(availableList, item, visName, pluginName); } } if (selectedList->lastItem()) { selectedList->setCurrentItem(selectedList->lastItem()); selectedList->setSelected(selectedList->lastItem(), true); } if (availableList->firstChild()) { availableList->setCurrentItem(availableList->firstChild()); availableList->setSelected(availableList->firstChild(), true); } }
void ReportManager::updateReportBrowser() { QStringList openReports; for (QListViewItemIterator lvi(browser); *lvi; ++lvi) if ((*lvi)->firstChild()) if ((*lvi)->isOpen()) openReports.append((*lvi)->text(0)); QString currentReport; if (browser->currentItem() && browser->currentItem()->firstChild() == 0) currentReport = browser->currentItem()->text(0) + browser->currentItem()->text(1) + browser->currentItem()->text(2) + browser->currentItem()->text(3); browser->clear(); qtReports = new KListViewItem(browser, i18n("Interactive Reports")); qtReports->setPixmap(0, KGlobal::iconLoader()-> loadIcon("tj_interactive_reports", KIcon::Small)); qtReports->setOpen(openReports.isEmpty() || openReports.find(qtReports->text(0)) != openReports.end()); htmlReports = new KListViewItem(browser, i18n("HTML Reports")); htmlReports->setPixmap(0, KGlobal::iconLoader()-> loadIcon("tj_html_reports", KIcon::Small)); htmlReports->setOpen(openReports.find(htmlReports->text(0)) != openReports.end()); csvReports = new KListViewItem(browser, i18n("CSV Reports")); csvReports->setPixmap(0, KGlobal::iconLoader()-> loadIcon("tj_csv_reports", KIcon::Small)); csvReports->setOpen(openReports.find(csvReports->text(0)) != openReports.end()); svgReports = new KListViewItem(browser, i18n("SVG Reports")); svgReports->setPixmap(0, KGlobal::iconLoader()-> loadIcon("tj_svg_reports", KIcon::Small)); svgReports->setOpen(openReports.find(svgReports->text(0)) != openReports.end()); xmlReports = new KListViewItem(browser, i18n("XML Reports")); xmlReports->setPixmap(0, KGlobal::iconLoader()-> loadIcon("tj_xml_reports", KIcon::Small)); xmlReports->setOpen(openReports.find(xmlReports->text(0)) != openReports.end()); icalReports = new KListViewItem(browser, i18n("iCalendars")); icalReports->setPixmap(0, KGlobal::iconLoader()-> loadIcon("tj_ical_reports", KIcon::Small)); icalReports->setOpen(openReports.find(icalReports->text(0)) != openReports.end()); exportReports = new KListViewItem(browser, i18n("Export Reports")); exportReports->setPixmap(0, KGlobal::iconLoader()-> loadIcon("tj_export_reports", KIcon::Small)); exportReports->setOpen(openReports.find(exportReports->text(0)) != openReports.end()); for (std::list<ManagedReportInfo*>::const_iterator mri = reports.begin(); mri != reports.end(); ++mri) { if ((*mri)->getBrowserEntry()) continue; Report* r = (*mri)->getProjectReport(); addReportItem(r, currentReport); } // Make sure that we have a current report. If the current report is a // report folder, then select the first interactive report if it exists. if (browser->currentItem() == 0 || browser->currentItem()->firstChild() != 0) if (qtReports->firstChild() != 0) browser->setCurrentItem(qtReports->firstChild()); searchLine->updateSearch(); }