mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Clean up SQLiteDB
Much of the code in there is not really needed anymore as quite a bit of functionality has been moved to the SqliteTableModel.
This commit is contained in:
@@ -296,9 +296,6 @@ void MainWindow::populateTable( const QString & tablename)
|
||||
curBrowseOrderByMode = Qt::AscendingOrder;
|
||||
m_browseTableModel->sort(curBrowseOrderByIndex, curBrowseOrderByMode);
|
||||
|
||||
// Get table layout
|
||||
db.browseTable(tablename);
|
||||
|
||||
// Update the filter row
|
||||
qobject_cast<FilterTableHeader*>(ui->dataTable->horizontalHeader())->generateFilters(m_browseTableModel->columnCount());
|
||||
|
||||
@@ -405,7 +402,7 @@ void MainWindow::deleteRecord()
|
||||
int row = ui->dataTable->currentIndex().row();
|
||||
if(m_browseTableModel->removeRow(row))
|
||||
{
|
||||
populateTable(db.curBrowseTableName);
|
||||
populateTable(ui->comboBrowseTable->currentText());
|
||||
if(row > m_browseTableModel->totalRowCount())
|
||||
row = m_browseTableModel->totalRowCount();
|
||||
selectTableLine(row);
|
||||
|
||||
@@ -191,9 +191,6 @@ void DBBrowserDB::close (){
|
||||
}
|
||||
_db = 0;
|
||||
objMap.clear();
|
||||
idmap.clear();
|
||||
browseRecs.clear();
|
||||
browseFields.clear();
|
||||
hasValidBrowseSet = false;
|
||||
}
|
||||
|
||||
@@ -471,24 +468,6 @@ bool DBBrowserDB::updateRecord(const QString& table, const QString& column, int
|
||||
}
|
||||
}
|
||||
|
||||
bool DBBrowserDB::browseTable( const QString & tablename, const QString& /*orderby*/ )
|
||||
{
|
||||
QStringList testFields = getTableFields( tablename );
|
||||
|
||||
if (testFields.count()>0) {//table exists
|
||||
browseFields = testFields;
|
||||
hasValidBrowseSet = true;
|
||||
curBrowseTableName = tablename;
|
||||
} else {
|
||||
hasValidBrowseSet = false;
|
||||
curBrowseTableName = QString(" ");
|
||||
browseFields.clear();
|
||||
browseRecs.clear();
|
||||
idmap.clear();
|
||||
}
|
||||
return hasValidBrowseSet;
|
||||
}
|
||||
|
||||
bool DBBrowserDB::createTable(const QString& name, const QList<DBBrowserField>& structure)
|
||||
{
|
||||
// Build SQL statement
|
||||
@@ -734,19 +713,6 @@ objectMap DBBrowserDB::getBrowsableObjects() const
|
||||
return res;
|
||||
}
|
||||
|
||||
QStringList DBBrowserDB::getIndexNames() const
|
||||
{
|
||||
QList<DBBrowserObject> tmap = objMap.values("index");
|
||||
QList<DBBrowserObject>::ConstIterator it;
|
||||
QStringList res;
|
||||
|
||||
for ( it = tmap.begin(); it != tmap.end(); ++it ) {
|
||||
res.append( (*it).getname() );
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
QStringList DBBrowserDB::getTableFields(const QString & tablename) const
|
||||
{
|
||||
objectMap::ConstIterator it;
|
||||
@@ -766,25 +732,6 @@ QStringList DBBrowserDB::getTableFields(const QString & tablename) const
|
||||
return res;
|
||||
}
|
||||
|
||||
QStringList DBBrowserDB::getTableTypes(const QString & tablename) const
|
||||
{
|
||||
objectMap::ConstIterator it;
|
||||
QStringList res;
|
||||
|
||||
for ( it = objMap.begin(); it != objMap.end(); ++it )
|
||||
{
|
||||
if((*it).getname() == tablename)
|
||||
{
|
||||
fieldMap::ConstIterator fit;
|
||||
|
||||
for ( fit = (*it).fldmap.begin(); fit != (*it).fldmap.end(); ++fit ) {
|
||||
res.append( fit.value().gettype() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
DBBrowserObject DBBrowserDB::getObjectByName(const QString& name) const
|
||||
{
|
||||
objectMap::ConstIterator it;
|
||||
@@ -798,11 +745,6 @@ DBBrowserObject DBBrowserDB::getObjectByName(const QString& name) const
|
||||
return DBBrowserObject();
|
||||
}
|
||||
|
||||
int DBBrowserDB::getRecordCount() const
|
||||
{
|
||||
return browseRecs.count();
|
||||
}
|
||||
|
||||
void DBBrowserDB::logSQL(const QString& statement, int msgtype)
|
||||
{
|
||||
if(mainWindow)
|
||||
|
||||
@@ -16,21 +16,8 @@ enum
|
||||
kLogMsg_App
|
||||
};
|
||||
|
||||
/*types for encoded media data*/
|
||||
enum
|
||||
{
|
||||
kSQLiteMediaType_Void,
|
||||
kSQLiteMediaType_Integer,
|
||||
kSQLiteMediaType_String,
|
||||
kSQLiteMediaType_Binary
|
||||
};
|
||||
|
||||
typedef QMap<int, class DBBrowserField> fieldMap;
|
||||
typedef QMultiMap<QString, class DBBrowserObject> objectMap;
|
||||
typedef QMap<int, int> rowIdMap;
|
||||
|
||||
typedef QList<QList<QByteArray> > rowList;
|
||||
typedef QMap<int, QString> resultMap;
|
||||
|
||||
class DBBrowserField
|
||||
{
|
||||
@@ -98,11 +85,10 @@ public:
|
||||
* or the create table statement.
|
||||
*/
|
||||
QString getTableSQL(const QString& sTable);
|
||||
void updateSchema() ;
|
||||
void updateSchema();
|
||||
int addRecord(const QString& sTableName);
|
||||
bool deleteRecord(const QString& table, int rowid);
|
||||
bool updateRecord(const QString& table, const QString& column, int row, const QByteArray& value);
|
||||
bool browseTable( const QString & tablename, const QString& orderby = "rowid" );
|
||||
|
||||
bool createTable(const QString& name, const QList<DBBrowserField>& structure);
|
||||
bool renameTable(const QString& from_table, const QString& to_table);
|
||||
@@ -111,12 +97,9 @@ public:
|
||||
bool dropColumn(const QString& tablename, const QString& column);
|
||||
|
||||
QStringList getTableFields(const QString & tablename) const;
|
||||
QStringList getTableTypes(const QString & tablename) const;
|
||||
QStringList getBrowsableObjectNames() const;
|
||||
objectMap getBrowsableObjects() const;
|
||||
DBBrowserObject getObjectByName(const QString& name) const;
|
||||
QStringList getIndexNames() const;
|
||||
int getRecordCount() const;
|
||||
bool isOpen() const;
|
||||
void setDirty(bool dirtyval);
|
||||
bool getDirty() const;
|
||||
@@ -132,12 +115,8 @@ public:
|
||||
QStringList decodeCSV(const QString & csvfilename, char sep, char quote, int maxrecords, int * numfields);
|
||||
|
||||
objectMap objMap;
|
||||
rowIdMap idmap;
|
||||
|
||||
rowList browseRecs;
|
||||
QStringList browseFields;
|
||||
bool hasValidBrowseSet;
|
||||
QString curBrowseTableName;
|
||||
QString lastErrorMessage;
|
||||
QString curDBFilename;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user