Clean up the DBBrowserDB class a bit · feng2010java/sqlitebrowser@b87992c · GitHub
Skip to content

Commit b87992c

Browse files
committed
Clean up the DBBrowserDB class a bit
1 parent 03879d9 commit b87992c

6 files changed

Lines changed: 14 additions & 31 deletions

File tree

‎src/CreateIndexDialog.cpp‎

Lines changed: 1 addition & 1 deletion

‎src/sqlitedb.cpp‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -755,28 +755,9 @@ objectMap DBBrowserDB::getBrowsableObjects() const
755755
return res;
756756
}
757757

758-
QStringList DBBrowserDB::getTableFields(const QString & tablename) const
759-
{
760-
objectMap::ConstIterator it;
761-
QStringList res;
762-
763-
for ( it = objMap.begin(); it != objMap.end(); ++it )
764-
{
765-
if((*it).getname() == tablename)
766-
{
767-
for(int i=0;i<(*it).table.fields().size();i++)
768-
res.append((*it).table.fields().at(i)->name());
769-
}
770-
}
771-
return res;
772-
}
773-
774758
DBBrowserObject DBBrowserDB::getObjectByName(const QString& name) const
775759
{
776-
objectMap::ConstIterator it;
777-
QStringList res;
778-
779-
for ( it = objMap.begin(); it != objMap.end(); ++it )
760+
for (objectMap::ConstIterator it = objMap.begin(); it != objMap.end(); ++it )
780761
{
781762
if((*it).getname() == name)
782763
return *it;

‎src/sqlitedb.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ class DBBrowserObject
2929
QString getsql() const { return sql; }
3030
QString gettype() const { return type; }
3131
QString getTableName() const { return table_name; }
32-
sqlb::FieldPtr getField(const QString& name)
33-
{
34-
int id = table.findField(name);
35-
if(id == -1)
36-
return sqlb::FieldPtr();
37-
else
38-
return table.fields().at(id);
39-
}
4032
sqlb::Table table;
4133
private:
4234
QString name;
@@ -93,7 +85,6 @@ class DBBrowserDB : public QObject
9385
*/
9486
bool renameColumn(const QString& tablename, const QString& name, sqlb::FieldPtr to, int move = 0);
9587

96-
QStringList getTableFields(const QString & tablename) const;
9788
QStringList getBrowsableObjectNames() const;
9889
objectMap getBrowsableObjects() const;
9990
DBBrowserObject getObjectByName(const QString& name) const;

‎src/sqlitetablemodel.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void SqliteTableModel::setTable(const QString& table)
4242
if(t.name() != "") // parsing was OK
4343
{
4444
m_headers.push_back(t.rowidColumn());
45-
m_headers.append(m_db->getTableFields(table));
45+
m_headers.append(m_db->getObjectByName(table).table.fieldNames());
4646
}
4747
else
4848
{

‎src/sqlitetypes.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ QStringList Table::fieldList() const
118118
return sl;
119119
}
120120

121+
QStringList Table::fieldNames() const
122+
{
123+
QStringList sl;
124+
125+
foreach(FieldPtr f, m_fields)
126+
sl << f->name();
127+
128+
return sl;
129+
}
130+
121131
bool Table::hasAutoIncrement() const
122132
{
123133
foreach(FieldPtr f, m_fields) {

‎src/sqlitetypes.h‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)