Skip to content

Commit

Permalink
Signed-off-by: whelanh <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
whelanh committed Aug 4, 2016
1 parent 192c902 commit 28c1f09
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 24 deletions.
14 changes: 1 addition & 13 deletions dbmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ DbManager::DbManager(const QString &path)
if (!m_db.open())
{
qDebug() << "Error: connection with database fail";
}
else
} else
{
qDebug() << "Database: connection ok";
}
Expand All @@ -36,9 +35,6 @@ bool DbManager::isOpen() const
return m_db.isOpen();
}




QString DbManager::printAllRecords() const
{
qDebug() << "all records db:";
Expand All @@ -57,7 +53,6 @@ QString DbManager::printAllRecords() const
answer.append("--------------------------------------------------");
answer.append("\n");
}

return answer;
}

Expand Down Expand Up @@ -113,12 +108,10 @@ void DbManager::getRecordOnDate(const QDate &date)
qDebug() << "last ID:" << lastID;
}
}

}

QString DbManager::searchTermQuery(const QString &term)
{

bool success = false;

QSqlQuery query;
Expand All @@ -144,7 +137,6 @@ QString DbManager::searchTermQuery(const QString &term)
answer.append("\n");
}
}

return answer;
}

Expand Down Expand Up @@ -180,15 +172,13 @@ QString DbManager::similarDateQuery(const QDate &date)
answer.append("\n");
}
}

return answer;
}


void DbManager::writeRecord(int &id, QString &dt, QString &mnth, int &dy, int &yr,
QString &dyOfWk, QString &entry)
{

bool success = false;
QSqlQuery checkQuery;
checkQuery.prepare("SELECT ID, Date FROM journal WHERE ID = (:idin)");
Expand Down Expand Up @@ -255,7 +245,6 @@ void DbManager::writeRecord(int &id, QString &dt, QString &mnth, int &dy, int &y
qDebug() << "new record add failed" << query.lastError();
}
}

} else {
qDebug() << "check query failed" << checkQuery.lastError();
}
Expand Down Expand Up @@ -303,7 +292,6 @@ QString DbManager::getLastRecordDate() const
name = query.value(idName).toString();

qDebug() << "===" << name;

}
return name;

Expand Down
2 changes: 0 additions & 2 deletions dbmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class DbManager
QString lastDate;
int lastID;


/**
* @brief Constructor
*
Expand Down Expand Up @@ -106,7 +105,6 @@ class DbManager
*/
QString searchTermQuery(const QString &term);


private:
QSqlDatabase m_db;
};
Expand Down
2 changes: 1 addition & 1 deletion journalQT.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2016-08-04T11:46:42. -->
<!-- Written by QtCreator 3.5.1, 2016-08-04T13:33:19. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
8 changes: 0 additions & 8 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ MainWindow::~MainWindow()

void MainWindow::on_writeButton_clicked()
{

DbManager db(PATH);
QString dt = ui->dateEdit->date().toString("yyyy-MM-dd");
int id = ui->dateEdit->date().toJulianDay() - 2455711;
Expand All @@ -65,16 +64,13 @@ void MainWindow::on_writeButton_clicked()
//qDebug() << "id" << id << "date" << dt << "month" << month
// << "day" << day << "year" << year << "dayOfWeek" << dayOfWeek;
db.writeRecord(id, dt, month,day, year, dayOfWeek, entry);


}

void MainWindow::on_dateEdit_dateChanged(const QDate &date)
{
DbManager db(PATH);
db.getRecordOnDate(date);
ui->textEdit->setText(db.lastEntry);

}

void MainWindow::on_similarDatesButton_clicked()
Expand Down Expand Up @@ -104,18 +100,14 @@ void MainWindow::on_weightHistoryButton_clicked()
if(data.open(QFile::WriteOnly |QFile::Truncate)) {
QTextStream output(&data);


while (i.hasNext()) {
i.next();
answer.append(i.key() + " " + i.value() + "\n");
output << i.key() << "," << i.value().toFloat() << "\n";

// //qDebug() << i.key() << ": " << i.value() << endl;
}
}
ui->textEdit->setText(answer);


}

void MainWindow::on_exportHtmlButton_clicked()
Expand Down

0 comments on commit 28c1f09

Please sign in to comment.