本文整理汇总了C++中TQStringList::sort方法的典型用法代码示例。如果您正苦于以下问题:C++ TQStringList::sort方法的具体用法?C++ TQStringList::sort怎么用?C++ TQStringList::sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TQStringList
的用法示例。
在下文中一共展示了TQStringList::sort方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: timezones
TQStringList CityList::timezones()
{
TQStringList r;
TQPtrListIterator<City> it(_cities);
for ( ; it.current(); ++it)
r << it.current()->name();
r.sort();
return r;
}
示例2: loadLanguageList
void TDMAppearanceWidget::loadLanguageList(KLanguageButton *combo)
{
TQStringList langlist = TDEGlobal::dirs()->findAllResources("locale",
TQString::fromLatin1("*/entry.desktop"));
langlist.sort();
for ( TQStringList::ConstIterator it = langlist.begin();
it != langlist.end(); ++it )
{
TQString fpath = (*it).left((*it).length() - 14);
int index = fpath.findRev('/');
TQString nid = fpath.mid(index + 1);
KSimpleConfig entry(*it);
entry.setGroup(TQString::fromLatin1("KCM Locale"));
TQString name = entry.readEntry(TQString::fromLatin1("Name"), i18n("without name"));
combo->insertLanguage(nid, name, TQString::fromLatin1("l10n/"), TQString::null);
}
}
示例3: TQVBoxLayout
KLineEditTest::KLineEditTest (TQWidget* widget, const char* name )
:TQWidget( widget, name )
{
TQVBoxLayout* layout = new TQVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
TQStringList list;
list << "Tree" << "Suuupa" << "Stroustrup" << "Stone" << "Slick"
<< "Slashdot" << "Send" << "Peables" << "Mankind" << "Ocean"
<< "Chips" << "Computer" << "Sandworm" << "Sandstorm" << "Chops";
list.sort();
m_lineedit = new KLineEdit( this, "klineedittest" );
m_lineedit->completionObject()->setItems( list );
m_lineedit->setFixedSize(500,30);
m_lineedit->setEnableSqueezedText( true );
connect( m_lineedit, TQT_SIGNAL( returnPressed() ), TQT_SLOT( slotReturnPressed() ) );
connect( m_lineedit, TQT_SIGNAL( returnPressed(const TQString&) ),
TQT_SLOT( slotReturnPressed(const TQString&) ) );
TQHBox *hbox = new TQHBox (this);
m_btnExit = new TQPushButton( "E&xit", hbox );
m_btnExit->setFixedSize(100,30);
connect( m_btnExit, TQT_SIGNAL( clicked() ), TQT_SLOT( quitApp() ) );
m_btnReadOnly = new TQPushButton( "&Read Only", hbox );
m_btnReadOnly->setToggleButton (true);
m_btnReadOnly->setFixedSize(100,30);
connect( m_btnReadOnly, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( slotReadOnly(bool) ) );
m_btnEnable = new TQPushButton( "Dis&able", hbox );
m_btnEnable->setToggleButton (true);
m_btnEnable->setFixedSize(100,30);
connect( m_btnEnable, TQT_SIGNAL( toggled(bool) ), TQT_SLOT( slotEnable(bool) ) );
m_btnHide = new TQPushButton( "Hi&de", hbox );
m_btnHide->setFixedSize(100,30);
connect( m_btnHide, TQT_SIGNAL( clicked() ), TQT_SLOT( slotHide() ) );
layout->addWidget( m_lineedit );
layout->addWidget( hbox );
setCaption( "KLineEdit Unit Test" );
}
示例4: initialize
void FindMenu::initialize()
{
TQStringList list = TDEGlobal::dirs()->findAllResources( "data", "kicker/menuext/find/*.desktop", false, true );
list.sort();
int id = 0;
mConfigList.clear();
for ( TQStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
KSimpleConfig config( *it, true );
config.setDesktopGroup();
mConfigList.append( *it );
TQString text = config.readEntry( "Name" );
insertItem( SmallIconSet( config.readEntry( "Icon" ) ), text, id );
id++;
}
}
示例5: init
void ConfigWidget::init( Broker *broker )
{
d = new Private;
d->broker = broker;
TQVBoxLayout *layout = new TQVBoxLayout( this, 0, 0, "KSpell2ConfigUILayout");
d->ui = new KSpell2ConfigUI( this );
TQStringList langs = d->broker->languages();
//TQStringList clients = d->broker->clients();
d->ui->m_langCombo->insertStringList( langs );
setCorrectLanguage( langs );
//d->ui->m_clientCombo->insertStringList( clients );
d->ui->m_skipUpperCB->setChecked( !d->broker->settings()->checkUppercase() );
d->ui->m_skipRunTogetherCB->setChecked( d->broker->settings()->skipRunTogether() );
TQStringList ignoreList = d->broker->settings()->currentIgnoreList();
ignoreList.sort();
d->ui->m_ignoreListBox->insertStringList( ignoreList );
d->ui->m_bgSpellCB->setChecked( d->broker->settings()->backgroundCheckerEnabled() );
d->ui->m_bgSpellCB->hide();//hidden by default
connect( d->ui->m_ignoreListBox, TQT_SIGNAL(changed()), TQT_SLOT(slotChanged()) );
layout->addWidget( d->ui );
}
示例6: loadStyle
void KCMStyle::loadStyle( TDEConfig& config )
{
cbStyle->clear();
// Create a dictionary of WidgetStyle to Name and Desc. mappings,
// as well as the config page info
styleEntries.clear();
styleEntries.setAutoDelete(true);
TQString strWidgetStyle;
TQStringList list = TDEGlobal::dirs()->findAllResources("themes", "*.themerc", true, true);
for (TQStringList::iterator it = list.begin(); it != list.end(); ++it)
{
KSimpleConfig config( *it, true );
if ( !(config.hasGroup("KDE") && config.hasGroup("Misc")) )
continue;
config.setGroup("KDE");
strWidgetStyle = config.readEntry("WidgetStyle");
if (strWidgetStyle.isNull())
continue;
// We have a widgetstyle, so lets read the i18n entries for it...
StyleEntry* entry = new StyleEntry;
config.setGroup("Misc");
entry->name = config.readEntry("Name");
entry->desc = config.readEntry("Comment", i18n("No description available."));
entry->configPage = config.readEntry("ConfigPage", TQString::null);
// Check if this style should be shown
config.setGroup("Desktop Entry");
entry->hidden = config.readBoolEntry("Hidden", false);
// Insert the entry into our dictionary.
styleEntries.insert(strWidgetStyle.lower(), entry);
}
// Obtain all style names
TQStringList allStyles = TQStyleFactory::keys();
// Get translated names, remove all hidden style entries.
TQStringList styles;
StyleEntry* entry;
for (TQStringList::iterator it = allStyles.begin(); it != allStyles.end(); it++)
{
TQString id = (*it).lower();
// Find the entry.
if ( (entry = styleEntries.find(id)) != 0 )
{
// Do not add hidden entries
if (entry->hidden)
continue;
styles += entry->name;
nameToStyleKey[entry->name] = id;
}
else
{
styles += (*it); //Fall back to the key (but in original case)
nameToStyleKey[*it] = id;
}
}
// Sort the style list, and add it to the combobox
styles.sort();
cbStyle->insertStringList( styles );
// Find out which style is currently being used
config.setGroup( "General" );
TQString defaultStyle = TDEStyle::defaultStyle();
TQString cfgStyle = config.readEntry( "widgetStyle", defaultStyle );
// Select the current style
// Do not use cbStyle->listBox() as this may be NULL for some styles when
// they use QPopupMenus for the drop-down list!
// ##### Since Trolltech likes to seemingly copy & paste code,
// TQStringList::findItem() doesn't have a Qt::StringComparisonMode field.
// We roll our own (yuck)
cfgStyle = cfgStyle.lower();
int item = 0;
for( int i = 0; i < cbStyle->count(); i++ )
{
TQString id = nameToStyleKey[cbStyle->text(i)];
item = i;
if ( id == cfgStyle ) // ExactMatch
break;
else if ( id.contains( cfgStyle ) )
break;
else if ( id.contains( TQApplication::style().className() ) )
break;
item = 0;
}
cbStyle->setCurrentItem( item );
m_bStyleDirty = false;
switchStyle( currentStyle() ); // make resets visible
//.........这里部分代码省略.........
示例7: historyConfig
KComboBoxTest::KComboBoxTest(TQWidget* widget, const char* name )
:TQWidget(widget, name)
{
TQVBoxLayout *vbox = new TQVBoxLayout (this, KDialog::marginHint(), KDialog::spacingHint());
// Test for KCombo's KLineEdit destruction
KComboBox *testCombo = new KComboBox( true, this ); // rw, with KLineEdit
testCombo->setEditable( false ); // destroys our KLineEdit
assert( testCombo->delegate() == 0L );
delete testCombo; // not needed anymore
// Qt combobox
TQHBox* hbox = new TQHBox(this);
hbox->setSpacing (KDialog::spacingHint());
TQLabel* lbl = new TQLabel("&QCombobox:", hbox);
lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);
m_qc = new TQComboBox(hbox, "QtReadOnlyCombo" );
lbl->setBuddy (m_qc);
TQObject::connect (m_qc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
TQObject::connect (m_qc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
vbox->addWidget (hbox);
// Read-only combobox
hbox = new TQHBox(this);
hbox->setSpacing (KDialog::spacingHint());
lbl = new TQLabel("&Read-Only Combo:", hbox);
lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);
m_ro = new KComboBox(hbox, "ReadOnlyCombo" );
lbl->setBuddy (m_ro);
m_ro->setCompletionMode( TDEGlobalSettings::CompletionAuto );
TQObject::connect (m_ro, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
TQObject::connect (m_ro, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
vbox->addWidget (hbox);
// Read-write combobox
hbox = new TQHBox(this);
hbox->setSpacing (KDialog::spacingHint());
lbl = new TQLabel("&Editable Combo:", hbox);
lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);
m_rw = new KComboBox( true, hbox, "ReadWriteCombo" );
lbl->setBuddy (m_rw);
m_rw->setDuplicatesEnabled( true );
m_rw->setInsertionPolicy( TQComboBox::NoInsertion );
m_rw->setTrapReturnKey( true );
TQObject::connect (m_rw, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
TQObject::connect (m_rw, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&)));
TQObject::connect (m_rw, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
TQObject::connect (m_rw, TQT_SIGNAL(returnPressed(const TQString&)), TQT_SLOT(slotReturnPressed(const TQString&)));
vbox->addWidget (hbox);
// History combobox...
hbox = new TQHBox(this);
hbox->setSpacing (KDialog::spacingHint());
lbl = new TQLabel("&History Combo:", hbox);
lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);
m_hc = new KHistoryCombo( true, hbox, "HistoryCombo" );
lbl->setBuddy (m_hc);
m_hc->setDuplicatesEnabled( true );
m_hc->setInsertionPolicy( TQComboBox::NoInsertion );
TQObject::connect (m_hc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
TQObject::connect (m_hc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(slotActivated(const TQString&)));
TQObject::connect (m_hc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
vbox->addWidget (hbox);
m_hc->setTrapReturnKey(true);
// Read-write combobox that is a replica of code in konqueror...
hbox = new TQHBox(this);
hbox->setSpacing (KDialog::spacingHint());
lbl = new TQLabel( "&Konq's Combo:", hbox);
lbl->setSizePolicy (TQSizePolicy::Maximum, TQSizePolicy::Preferred);
m_konqc = new KComboBox( true, hbox, "KonqyCombo" );
lbl->setBuddy (m_konqc);
m_konqc->setMaxCount( 10 );
TQObject::connect (m_konqc, TQT_SIGNAL(activated(int)), TQT_SLOT(slotActivated(int)));
TQObject::connect (m_konqc, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT (slotActivated(const TQString&)));
TQObject::connect (m_konqc, TQT_SIGNAL(returnPressed()), TQT_SLOT(slotReturnPressed()));
vbox->addWidget (hbox);
// Create an exit button
hbox = new TQHBox (this);
m_btnExit = new TQPushButton( "E&xit", hbox );
TQObject::connect( m_btnExit, TQT_SIGNAL(clicked()), TQT_SLOT(quitApp()) );
// Create a disable button...
m_btnEnable = new TQPushButton( "Disa&ble", hbox );
TQObject::connect (m_btnEnable, TQT_SIGNAL(clicked()), TQT_SLOT(slotDisable()));
vbox->addWidget (hbox);
// Popuplate the select-only list box
TQStringList list;
list << "Stone" << "Tree" << "Peables" << "Ocean" << "Sand" << "Chips"
<< "Computer" << "Mankind";
list.sort();
//.........这里部分代码省略.........
示例8: if
void
KBuildServiceTypeFactory::savePatternLists(TQDataStream &str)
{
// Store each patterns in one of the 2 string lists (for sorting)
TQStringList fastPatterns; // for *.a to *.abcd
TQStringList otherPatterns; // for the rest (core.*, *.tar.bz2, *~) ...
TQDict<KMimeType> dict;
// For each mimetype in servicetypeFactory
for(TQDictIterator<KSycocaEntry::Ptr> it ( *m_entryDict );
it.current();
++it)
{
KSycocaEntry *entry = (*it.current());
if ( entry->isType( KST_KMimeType ) )
{
KMimeType *mimeType = (KMimeType *) entry;
TQStringList pat = mimeType->patterns();
TQStringList::ConstIterator patit = pat.begin();
for ( ; patit != pat.end() ; ++patit )
{
const TQString &pattern = *patit;
if ( pattern.findRev('*') == 0
&& pattern.findRev('.') == 1
&& pattern.length() <= 6 )
// it starts with "*.", has no other '*' and no other '.', and is max 6 chars
// => fast patttern
fastPatterns.append( pattern );
else if (!pattern.isEmpty()) // some stupid mimetype files have "Patterns=;"
otherPatterns.append( pattern );
// Assumption : there is only one mimetype for that pattern
// It doesn't really make sense otherwise, anyway.
dict.replace( pattern, mimeType );
}
}
}
// Sort the list - the fast one, useless for the other one
fastPatterns.sort();
TQ_INT32 entrySize = 0;
TQ_INT32 nrOfEntries = 0;
m_fastPatternOffset = str.device()->at();
// Write out fastPatternHeader (Pass #1)
str.device()->at(m_fastPatternOffset);
str << nrOfEntries;
str << entrySize;
// For each fast pattern
TQStringList::ConstIterator it = fastPatterns.begin();
for ( ; it != fastPatterns.end() ; ++it )
{
int start = str.device()->at();
// Justify to 6 chars with spaces, so that the size remains constant
// in the database file.
TQString paddedPattern = (*it).leftJustify(6).right(4); // remove leading "*."
//kdDebug(7021) << TQString("FAST : '%1' '%2'").arg(paddedPattern).arg(dict[(*it)]->name()) << endl;
str << paddedPattern;
str << dict[(*it)]->offset();
entrySize = str.device()->at() - start;
nrOfEntries++;
}
// store position
m_otherPatternOffset = str.device()->at();
// Write out fastPatternHeader (Pass #2)
str.device()->at(m_fastPatternOffset);
str << nrOfEntries;
str << entrySize;
// For the other patterns
str.device()->at(m_otherPatternOffset);
it = otherPatterns.begin();
for ( ; it != otherPatterns.end() ; ++it )
{
//kdDebug(7021) << TQString("OTHER : '%1' '%2'").arg(*it).arg(dict[(*it)]->name()) << endl;
str << (*it);
str << dict[(*it)]->offset();
}
str << TQString(""); // end of list marker (has to be a string !)
}
示例9: aboutData
//.........这里部分代码省略.........
for(int i=0; i < args->count(); i++)
eargs.append( args->arg(i) );
if (title.isEmpty() &&
(kapp->caption() == kapp->aboutData()->programName()))
{
title = TQFile::decodeName(shell); // program executed in the title bar
}
showtip = false;
}
TQCString sz = "";
sz = args->getOption("vt_sz");
histon = args->isSet("hist");
menubaron = args->isSet("menubar");
tabbaron = args->isSet("tabbar") && args->isSet("toolbar");
frameon = args->isSet("frame");
scrollbaron = args->isSet("scrollbar");
TQCString wname = qtargs->getOption("name");
full_script = args->isSet("script");
auto_close = args->isSet("close");
fixed_size = !args->isSet("resize");
if (!full_script)
a->dcopClient()->setQtBridgeEnabled(false);
TQCString type = "";
if(args->isSet("type")) {
type = args->getOption("type");
}
if(args->isSet("types")) {
TQStringList types = TDEGlobal::dirs()->findAllResources("appdata", "*.desktop", false, true);
types.sort();
for(TQStringList::ConstIterator it = types.begin();
it != types.end(); ++it)
{
TQString file = *it;
file = file.mid(file.findRev('/')+1);
if (file.endsWith(".desktop"))
file = file.left(file.length()-8);
printf("%s\n", TQFile::encodeName(file).data());
}
return 0;
}
if(args->isSet("schemas") || args->isSet("schemata")) {
ColorSchemaList colors;
colors.checkSchemas();
for(int i = 0; i < (int) colors.count(); i++)
{
ColorSchema *schema = colors.find(i);
TQString relPath = schema->relPath();
if (!relPath.isEmpty())
printf("%s\n", TQFile::encodeName(relPath).data());
}
return 0;
}
if(args->isSet("keytabs")) {
TQStringList lst = TDEGlobal::dirs()->findAllResources("data", "konsole/*.keytab");
printf("default\n"); // 'buildin' keytab
lst.sort();
for(TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
{
TQFileInfo fi(*it);
示例10: paletteFile
void
KPaletteTable::readNamedColor( void )
{
if( mNamedColorList->count() != 0 )
{
return; // Strings already present
}
TDEGlobal::locale()->insertCatalogue("tdelibs_colors");
//
// Code somewhat inspired by KPalette.
//
const char * const *path = namedColorFilePath();
for( int i=0; path[i]; ++i )
{
TQFile paletteFile( path[i] );
if( !paletteFile.open( IO_ReadOnly ) )
{
continue;
}
TQString line;
TQStringList list;
while( paletteFile.readLine( line, 100 ) != -1 )
{
int red, green, blue;
int pos = 0;
if( sscanf(line.ascii(), "%d %d %d%n", &red, &green, &blue, &pos ) == 3 )
{
//
// Remove duplicates. Every name with a space and every name
// that start with "gray".
//
TQString name = line.mid(pos).stripWhiteSpace();
if( name.isNull() || name.find(' ') != -1 ||
name.find( "gray" ) != -1 || name.find( "grey" ) != -1 )
{
continue;
}
const TQColor color ( red, green, blue );
if ( color.isValid() )
{
const TQString colorName( i18n("color", name.latin1() ) );
list.append( colorName );
d->m_namedColorMap[ colorName ] = color;
}
}
}
list.sort();
mNamedColorList->insertStringList( list );
break;
}
if( mNamedColorList->count() == 0 )
{
//
// Give the error dialog box a chance to center above the
// widget (or dialog). If we had displayed it now we could get a
// situation where the (modal) error dialog box pops up first
// preventing the real dialog to become visible until the
// error dialog box is removed (== bad UI).
//
TQTimer::singleShot( 10, this, TQT_SLOT(slotShowNamedColorReadError()) );
}
}