initial commit
@ -0,0 +1,7 @@
|
||||
/*!
|
||||
\file common.cpp
|
||||
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
/*!
|
||||
\file common.h
|
||||
|
||||
*/
|
||||
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
|
||||
#elif __MINGW32__
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __PRETTY_FUNCTION__ << ":"
|
||||
#else
|
||||
#define myDebug qDebug() << __FILE__ << "(" << __LINE__ << ") - " << __FUNCTION__ << ":"
|
||||
#endif
|
||||
|
||||
|
||||
#endif // COMMON_H
|
||||
@ -0,0 +1,114 @@
|
||||
#include "cpicturelibrary.h"
|
||||
#include "common.h"
|
||||
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
|
||||
cPictureLibrary::cPictureLibrary(QObject *parent) : QObject(parent)
|
||||
{
|
||||
if(!openDatabase())
|
||||
return;
|
||||
}
|
||||
|
||||
bool cPictureLibrary::openDatabase()
|
||||
{
|
||||
QSettings settings;
|
||||
QString szDB = settings.value("database/path").toString();
|
||||
|
||||
m_db = QSqlDatabase::addDatabase("QSQLITE");
|
||||
m_db.setHostName("localhost");
|
||||
m_db.setDatabaseName(szDB);
|
||||
|
||||
if(!m_db.open())
|
||||
{
|
||||
myDebug << m_db.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!m_db.tables().contains("config"))
|
||||
createDatabase();
|
||||
else
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare("SELECT version FROM config;");
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
m_db.close();
|
||||
return(false);
|
||||
}
|
||||
|
||||
query.next();
|
||||
if(query.value("version").toInt() < 2)
|
||||
updateDatabase(query.value("version").toInt());
|
||||
query.finish();
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::createTable(const QString& szSQL)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
query.prepare(szSQL);
|
||||
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << szSQL << "\n" << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::createDatabase()
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
if(!createTable("CREATE TABLE config ( "
|
||||
" version INTEGER"
|
||||
"); "))
|
||||
return(false);
|
||||
|
||||
query.prepare("INSERT INTO config (version) VALUES (:version);");
|
||||
query.bindValue(":version", 1);
|
||||
if(!query.exec())
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::updateDatabase(qint32 version)
|
||||
{
|
||||
if(version < 2)
|
||||
updateDatabase2(version);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool cPictureLibrary::updateDatabase2(qint32 /*version*/)
|
||||
{
|
||||
QSqlQuery query;
|
||||
|
||||
if(!query.exec("ALTER TABLE config ADD rootPath TEXT;"))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(!query.exec("UPDATE config SET version=2;"))
|
||||
{
|
||||
myDebug << query.lastError().text();
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
#ifndef CPICTURELIBRARY_H
|
||||
#define CPICTURELIBRARY_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QSqlDatabase>
|
||||
|
||||
|
||||
class cPictureLibrary : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit cPictureLibrary(QObject *parent = nullptr);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn openDatabase
|
||||
\return bool
|
||||
*/
|
||||
bool openDatabase();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QSqlDatabase m_db; /*!< TODO: describe */
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn createDatabase
|
||||
\return bool
|
||||
*/
|
||||
bool createDatabase();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn updateDatabase
|
||||
\param version
|
||||
\return bool
|
||||
*/
|
||||
bool updateDatabase(qint32 version);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn updateDatabase1
|
||||
\return bool
|
||||
*/
|
||||
bool updateDatabase2(qint32 version);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn createTable
|
||||
\param szSQL
|
||||
\return bool
|
||||
*/
|
||||
bool createTable(const QString& szSQL);
|
||||
};
|
||||
|
||||
#endif // CPICTURELIBRARY_H
|
||||
@ -0,0 +1,35 @@
|
||||
#include "csplashscreen.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
cSplashScreen::cSplashScreen(const QPixmap& pixmap, QFont& font) :
|
||||
QSplashScreen(pixmap)
|
||||
{
|
||||
setFont(font);
|
||||
m_textDocument.setDefaultFont(font);
|
||||
}
|
||||
|
||||
void cSplashScreen::drawContents(QPainter *painter)
|
||||
{
|
||||
painter->translate(m_rect.topLeft());
|
||||
m_textDocument.setHtml(m_szMessage);
|
||||
m_textDocument.drawContents(painter);
|
||||
}
|
||||
|
||||
void cSplashScreen::showStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage = message;
|
||||
showMessage(m_szMessage);
|
||||
}
|
||||
|
||||
void cSplashScreen::addStatusMessage(const QString& message)
|
||||
{
|
||||
m_szMessage.append(message);
|
||||
showMessage(m_szMessage);
|
||||
}
|
||||
|
||||
void cSplashScreen::setMessageRect(QRect rect)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_textDocument.setTextWidth(rect.width());
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#ifndef CSPLASHSCREEN_H
|
||||
#define CSPLASHSCREEN_H
|
||||
|
||||
|
||||
#include <QSplashScreen>
|
||||
#include <QPainter>
|
||||
#include <QTextDocument>
|
||||
|
||||
|
||||
class cSplashScreen : public QSplashScreen
|
||||
{
|
||||
public:
|
||||
cSplashScreen(const QPixmap& pixmap, QFont &font);
|
||||
|
||||
virtual void drawContents(QPainter *painter);
|
||||
void showStatusMessage(const QString &message);
|
||||
void addStatusMessage(const QString &message);
|
||||
void setMessageRect(QRect rect);
|
||||
|
||||
private:
|
||||
QTextDocument m_textDocument;
|
||||
QString m_szMessage;
|
||||
QRect m_rect;
|
||||
};
|
||||
|
||||
#endif // CSPLASHSCREEN_H
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 796 B |
|
After Width: | Height: | Size: 897 B |
|
After Width: | Height: | Size: 686 B |
|
After Width: | Height: | Size: 628 B |
|
After Width: | Height: | Size: 477 B |
|
After Width: | Height: | Size: 672 B |
|
After Width: | Height: | Size: 684 B |
|
After Width: | Height: | Size: 779 B |
|
After Width: | Height: | Size: 544 B |
|
After Width: | Height: | Size: 464 B |
|
After Width: | Height: | Size: 756 B |
|
After Width: | Height: | Size: 866 B |
|
After Width: | Height: | Size: 911 B |
|
After Width: | Height: | Size: 773 B |
|
After Width: | Height: | Size: 498 B |
|
After Width: | Height: | Size: 807 B |
|
After Width: | Height: | Size: 680 B |
|
After Width: | Height: | Size: 776 B |
|
After Width: | Height: | Size: 617 B |
|
After Width: | Height: | Size: 561 B |
|
After Width: | Height: | Size: 591 B |
|
After Width: | Height: | Size: 441 B |
|
After Width: | Height: | Size: 650 B |
|
After Width: | Height: | Size: 635 B |
|
After Width: | Height: | Size: 436 B |
|
After Width: | Height: | Size: 435 B |
|
After Width: | Height: | Size: 330 B |
|
After Width: | Height: | Size: 317 B |
|
After Width: | Height: | Size: 324 B |
|
After Width: | Height: | Size: 342 B |
|
After Width: | Height: | Size: 705 B |
|
After Width: | Height: | Size: 619 B |
|
After Width: | Height: | Size: 611 B |
|
After Width: | Height: | Size: 673 B |
|
After Width: | Height: | Size: 663 B |
|
After Width: | Height: | Size: 683 B |
|
After Width: | Height: | Size: 666 B |
|
After Width: | Height: | Size: 606 B |
|
After Width: | Height: | Size: 723 B |
|
After Width: | Height: | Size: 685 B |
|
After Width: | Height: | Size: 676 B |
|
After Width: | Height: | Size: 655 B |
|
After Width: | Height: | Size: 636 B |
|
After Width: | Height: | Size: 652 B |
|
After Width: | Height: | Size: 323 B |
|
After Width: | Height: | Size: 247 B |
|
After Width: | Height: | Size: 681 B |
|
After Width: | Height: | Size: 882 B |
|
After Width: | Height: | Size: 756 B |
|
After Width: | Height: | Size: 619 B |
|
After Width: | Height: | Size: 868 B |
|
After Width: | Height: | Size: 693 B |
|
After Width: | Height: | Size: 540 B |
|
After Width: | Height: | Size: 628 B |
|
After Width: | Height: | Size: 464 B |
|
After Width: | Height: | Size: 660 B |
|
After Width: | Height: | Size: 429 B |
|
After Width: | Height: | Size: 653 B |
|
After Width: | Height: | Size: 764 B |
|
After Width: | Height: | Size: 782 B |
|
After Width: | Height: | Size: 770 B |
|
After Width: | Height: | Size: 771 B |
|
After Width: | Height: | Size: 820 B |
|
After Width: | Height: | Size: 764 B |
|
After Width: | Height: | Size: 799 B |
|
After Width: | Height: | Size: 935 B |
|
After Width: | Height: | Size: 534 B |
|
After Width: | Height: | Size: 514 B |
|
After Width: | Height: | Size: 650 B |
|
After Width: | Height: | Size: 912 B |
|
After Width: | Height: | Size: 583 B |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 686 B |
|
After Width: | Height: | Size: 558 B |
|
After Width: | Height: | Size: 574 B |
|
After Width: | Height: | Size: 932 B |
|
After Width: | Height: | Size: 422 B |
|
After Width: | Height: | Size: 550 B |
|
After Width: | Height: | Size: 474 B |
|
After Width: | Height: | Size: 928 B |
|
After Width: | Height: | Size: 603 B |
|
After Width: | Height: | Size: 652 B |
|
After Width: | Height: | Size: 720 B |
|
After Width: | Height: | Size: 553 B |
|
After Width: | Height: | Size: 653 B |
|
After Width: | Height: | Size: 452 B |
|
After Width: | Height: | Size: 650 B |