std::vector -> QVector in config

This commit is contained in:
Abs62 2012-12-10 16:49:45 +04:00
parent 465db53353
commit 5070b5b859
10 changed files with 38 additions and 40 deletions

View file

@ -143,17 +143,17 @@ Romaji::Romaji():
Group * Class::getGroup( unsigned id )
{
for( unsigned x = 0; x < groups.size(); x++ )
if( groups[ x ].id == id )
for( int x = 0; x < groups.size(); x++ )
if( groups.at( x ).id == id )
return &groups[ x ];
return 0;
}
Group const * Class::getGroup( unsigned id ) const
{
for( unsigned x = 0; x < groups.size(); x++ )
if( groups[ x ].id == id )
return &groups[ x ];
for( int x = 0; x < groups.size(); x++ )
if( groups.at( x ).id == id )
return &groups.at( x );
return 0;
}
@ -795,7 +795,7 @@ void saveGroup( Group const & data, QDomElement & group )
group.setAttributeNode( shortcut );
}
for( vector< DictionaryRef >::const_iterator j = data.dictionaries.begin(); j != data.dictionaries.end(); ++j )
for( QVector< DictionaryRef >::const_iterator j = data.dictionaries.begin(); j != data.dictionaries.end(); ++j )
{
QDomElement dictionary = dd.createElement( "dictionary" );
@ -924,10 +924,10 @@ void save( Class const & c ) throw( exError )
hunspell.setAttributeNode( path );
root.appendChild( hunspell );
for( unsigned x = 0; x < c.hunspell.enabledDictionaries.size(); ++x )
for( int x = 0; x < c.hunspell.enabledDictionaries.size(); ++x )
{
QDomElement en = dd.createElement( "enabled" );
QDomText value = dd.createTextNode( c.hunspell.enabledDictionaries[ x ] );
QDomText value = dd.createTextNode( c.hunspell.enabledDictionaries.at( x ) );
en.appendChild( value );
hunspell.appendChild( en );

View file

@ -4,7 +4,7 @@
#ifndef __CONFIG_HH_INCLUDED__
#define __CONFIG_HH_INCLUDED__
#include <vector>
#include <QVector>
#include <QString>
#include <QSize>
#include <QDateTime>
@ -15,8 +15,6 @@
/// GoldenDict's configuration
namespace Config {
using std::vector;
/// Dictionaries which are temporarily disabled via the dictionary bar.
typedef QSet< QString > MutedDictionaries;
@ -39,7 +37,7 @@ struct Path
};
/// A list of paths where to search for the dictionaries
typedef vector< Path > Paths;
typedef QVector< Path > Paths;
/// A directory holding bunches of audiofiles, which is indexed into a separate
/// dictionary.
@ -59,7 +57,7 @@ struct SoundDir
};
/// A list of SoundDirs
typedef vector< SoundDir > SoundDirs;
typedef QVector< SoundDir > SoundDirs;
struct DictionaryRef
{
@ -83,7 +81,7 @@ struct Group
QString name, icon;
QByteArray iconData;
QKeySequence shortcut;
vector< DictionaryRef > dictionaries;
QVector< DictionaryRef > dictionaries;
Config::MutedDictionaries mutedDictionaries; // Disabled via dictionary bar
Config::MutedDictionaries popupMutedDictionaries; // Disabled via dictionary bar in popup
@ -101,7 +99,7 @@ struct Group
};
/// All the groups
struct Groups: public vector< Group >
struct Groups: public QVector< Group >
{
unsigned nextId; // Id to use to create the group next time
@ -239,14 +237,14 @@ struct WebSite
};
/// All the WebSites
typedef vector< WebSite > WebSites;
typedef QVector< WebSite > WebSites;
/// Hunspell configuration
struct Hunspell
{
QString dictionariesPath;
typedef vector< QString > Dictionaries;
typedef QVector< QString > Dictionaries;
Dictionaries enabledDictionaries;
@ -259,7 +257,7 @@ struct Hunspell
};
/// All the MediaWikis
typedef vector< MediaWiki > MediaWikis;
typedef QVector< MediaWiki > MediaWikis;
/// Romaji transliteration configuration
struct Romaji
@ -364,7 +362,7 @@ struct Program
{ return ! operator == ( other ); }
};
typedef vector< Program > Programs;
typedef QVector< Program > Programs;
struct Class
{

View file

@ -48,7 +48,7 @@ Groups::Groups( QWidget * parent,
void Groups::editGroup( unsigned id )
{
for( unsigned x = 0; x < groups.size(); ++x )
for( int x = 0; x < groups.size(); ++x )
{
if ( groups[ x ].id == id )
{

View file

@ -497,7 +497,7 @@ void DictGroupsWidget::populate( Config::Groups const & groups,
allDicts = &allDicts_;
for( unsigned x = 0; x < groups.size(); ++x )
for( int x = 0; x < groups.size(); ++x )
addTab( new DictGroupWidget( this, *allDicts, groups[ x ] ), escapeAmps( groups[ x ].name ) );
nextId = groups.nextId;

View file

@ -688,7 +688,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::Hunspell const & c
vector< DataFiles > dataFiles = findDataFiles( cfg.dictionariesPath );
for( unsigned x = 0; x < cfg.enabledDictionaries.size(); ++x )
for( int x = 0; x < cfg.enabledDictionaries.size(); ++x )
{
for( unsigned d = dataFiles.size(); d--; )
{

View file

@ -20,7 +20,7 @@ Group::Group( Config::Group const & cfgGroup,
if ( !cfgGroup.iconData.isEmpty() )
iconData = iconFromData( cfgGroup.iconData );
for( unsigned x = 0; x < cfgGroup.dictionaries.size(); ++x )
for( unsigned x = 0; x < (unsigned)cfgGroup.dictionaries.size(); ++x )
{
std::string id = cfgGroup.dictionaries[ x ].id.toStdString();
@ -53,10 +53,10 @@ Group::Group( Config::Group const & cfgGroup,
if( n < dictionaries.size() )
continue;
for( n = x + 1; n < cfgGroup.dictionaries.size(); n++ )
for( n = x + 1; n < (unsigned)cfgGroup.dictionaries.size(); n++ )
if( cfgGroup.dictionaries[ n ].name == qname )
break;
if( n < cfgGroup.dictionaries.size() )
if( n < (unsigned)cfgGroup.dictionaries.size() )
continue;
for( unsigned y = 0; y < allDictionaries.size(); ++y )
@ -179,7 +179,7 @@ void updateNames( Config::Group & group,
void updateNames( Config::Groups & groups,
vector< sptr< Dictionary::Class > > const & allDictionaries )
{
for( unsigned x = 0; x < groups.size(); ++x )
for( int x = 0; x < groups.size(); ++x )
updateNames( groups[ x ], allDictionaries );
}

View file

@ -826,7 +826,7 @@ void MainWindow::updateGroupList()
groupInstances.push_back( g );
}
for( unsigned x = 0; x < cfg.groups.size(); ++x )
for( int x = 0; x < cfg.groups.size(); ++x )
groupInstances.push_back( Instances::Group( cfg.groups[ x ], dictionaries ) );
// Update names for dictionaries that are present, so that they could be
@ -1382,7 +1382,7 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup )
{
// Set muted dictionaries from old groups
for( unsigned x = 0; x < newCfg.groups.size(); x++ )
for( int x = 0; x < newCfg.groups.size(); x++ )
{
unsigned id = newCfg.groups[ x ].id;
if( id != Instances::Group::NoGroupId )

View file

@ -422,7 +422,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries(
{
vector< sptr< Dictionary::Class > > result;
for( unsigned x = 0; x < wikis.size(); ++x )
for( int x = 0; x < wikis.size(); ++x )
{
if ( wikis[ x ].enabled )
result.push_back( new MediaWikiDictionary( wikis[ x ].id.toStdString(),

View file

@ -406,7 +406,7 @@ QVariant MediaWikisModel::headerData( int section, Qt::Orientation /*orientation
QVariant MediaWikisModel::data( QModelIndex const & index, int role ) const
{
if ( (unsigned)index.row() >= mediawikis.size() )
if ( index.row() >= mediawikis.size() )
return QVariant();
if ( role == Qt::DisplayRole || role == Qt::EditRole )
@ -433,7 +433,7 @@ QVariant MediaWikisModel::data( QModelIndex const & index, int role ) const
bool MediaWikisModel::setData( QModelIndex const & index, const QVariant & value,
int role )
{
if ( (unsigned)index.row() >= mediawikis.size() )
if ( index.row() >= mediawikis.size() )
return false;
if ( role == Qt::CheckStateRole && !index.column() )
@ -563,7 +563,7 @@ QVariant WebSitesModel::headerData( int section, Qt::Orientation /*orientation*/
QVariant WebSitesModel::data( QModelIndex const & index, int role ) const
{
if ( (unsigned)index.row() >= webSites.size() )
if ( index.row() >= webSites.size() )
return QVariant();
if ( role == Qt::DisplayRole || role == Qt::EditRole )
@ -590,7 +590,7 @@ QVariant WebSitesModel::data( QModelIndex const & index, int role ) const
bool WebSitesModel::setData( QModelIndex const & index, const QVariant & value,
int role )
{
if ( (unsigned)index.row() >= webSites.size() )
if ( index.row() >= webSites.size() )
return false;
if ( role == Qt::CheckStateRole && !index.column() )
@ -722,7 +722,7 @@ QVariant ProgramsModel::headerData( int section, Qt::Orientation /*orientation*/
QVariant ProgramsModel::data( QModelIndex const & index, int role ) const
{
if ( (unsigned) index.row() >= programs.size() )
if ( index.row() >= programs.size() )
return QVariant();
if ( role == Qt::DisplayRole || role == Qt::EditRole )
@ -754,7 +754,7 @@ QVariant ProgramsModel::data( QModelIndex const & index, int role ) const
bool ProgramsModel::setData( QModelIndex const & index, const QVariant & value,
int role )
{
if ( (unsigned)index.row() >= programs.size() )
if ( index.row() >= programs.size() )
return false;
if ( role == Qt::CheckStateRole && !index.column() )
@ -900,7 +900,7 @@ QVariant PathsModel::headerData( int section, Qt::Orientation /*orientation*/, i
QVariant PathsModel::data( QModelIndex const & index, int role ) const
{
if ( (unsigned)index.row() >= paths.size() )
if ( index.row() >= paths.size() )
return QVariant();
if ( ( role == Qt::DisplayRole || role == Qt::EditRole ) && !index.column() )
@ -915,7 +915,7 @@ QVariant PathsModel::data( QModelIndex const & index, int role ) const
bool PathsModel::setData( QModelIndex const & index, const QVariant & /*value*/,
int role )
{
if ( (unsigned)index.row() >= paths.size() )
if ( index.row() >= paths.size() )
return false;
if ( role == Qt::CheckStateRole && index.column() == 1 )
@ -1006,7 +1006,7 @@ QVariant SoundDirsModel::headerData( int section, Qt::Orientation /*orientation*
QVariant SoundDirsModel::data( QModelIndex const & index, int role ) const
{
if ( (unsigned)index.row() >= soundDirs.size() )
if ( index.row() >= soundDirs.size() )
return QVariant();
if ( ( role == Qt::DisplayRole || role == Qt::EditRole ) && !index.column() )
@ -1021,7 +1021,7 @@ QVariant SoundDirsModel::data( QModelIndex const & index, int role ) const
bool SoundDirsModel::setData( QModelIndex const & index, const QVariant & value,
int role )
{
if ( (unsigned)index.row() >= soundDirs.size() )
if ( index.row() >= soundDirs.size() )
return false;
if ( ( role == Qt::DisplayRole || role == Qt::EditRole ) && index.column() < 2 )

View file

@ -142,7 +142,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Config::WebSites const & w
{
vector< sptr< Dictionary::Class > > result;
for( unsigned x = 0; x < ws.size(); ++x )
for( int x = 0; x < ws.size(); ++x )
{
if ( ws[ x ].enabled )
result.push_back( new WebSiteDictionary( ws[ x ].id.toUtf8().data(),