KUbuntu 14.04 support restored (#1298)

* - [NEW] Add new interface and functionality to manage database file extension. (Implements feature request #659)

* - [FIX] Fixed CMake file to src.pro

* - Applied changes requested by mgrojo to uniform code with sqlitebrowser standards
- Add "history" when closing editor window, but reopen before closing preferences
- Revert some changes done by QtCreator

* Refuse from previous commit

* Additional changes requested by MKleusberg:
- [CHG] Always add "All files (*)" to filters
- [FIX] Removed unused include

* merged from master

* Merge sqlitebrowser master

* [FIX] Fixed compatibility to compile on KUbuntu 14.04 with Qt 5.2.1

* [FIX] Fix Qt version for QOpenGLWidget support on previous commit

* [CHG] Uniformed QT_VERSION_CHECK style
[CHG] Reverted macOS check on Mainwindow for OpenGL context creation
This commit is contained in:
GortiZ
2018-05-20 15:56:01 +02:00
committed by Martin Kleusberg
parent b69e7cd034
commit e7752d7398
9 changed files with 85 additions and 7 deletions

View File

@@ -342,7 +342,18 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
if(item->checkState(column) == Qt::Checked)
pk.push_back(field);
else
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
pk.removeAll(field);
#else
{
int idx = pk.indexOf (field);
while ( idx != -1 )
{
pk.remove (idx);
idx = pk.indexOf (field);
}
}
#endif
} else if(item->checkState(column) == Qt::Checked) {
// There is no primary key in the table yet. This means we need to add a default one.
m_table.addConstraint({field}, sqlb::ConstraintPtr(new sqlb::PrimaryKeyConstraint()));

View File

@@ -18,6 +18,10 @@
#include <QLineEdit>
#include <limits>
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
typedef QList<QByteArray> QByteArrayList;
#endif
QList<QByteArrayList> ExtendedTableWidget::m_buffer;
QString ExtendedTableWidget::m_generatorStamp;

View File

@@ -48,9 +48,12 @@
#include <QClipboard>
#include <QShortcut>
#include <QTextCodec>
#include <QOpenGLWidget>
#include <QUrlQuery>
#ifdef Q_OS_MACX //Needed only on macOS
#include <QOpenGLWidget>
#endif
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent),
ui(new Ui::MainWindow),
@@ -84,8 +87,8 @@ void MainWindow::init()
tabifyDockWidget(ui->dockLog, ui->dockSchema);
tabifyDockWidget(ui->dockLog, ui->dockRemote);
// Add OpenGL Context for macOS
#ifdef Q_OS_MACX
// Add OpenGL Context for macOS
QOpenGLWidget *ogl = new QOpenGLWidget(this);
ui->horizontalLayout->addWidget(ogl);
ogl->setHidden(true);

View File

@@ -254,7 +254,13 @@ void PreferencesDialog::saveSettings()
// This is a new certificate. Copy file to a safe place.
// Generate unique destination file name
QString copy_to = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation).append("/").append(QFileInfo(path).fileName());
QString copy_to = QStandardPaths::writableLocation(
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QStandardPaths::AppDataLocation
#else
QStandardPaths::GenericDataLocation
#endif
).append("/").append(QFileInfo(path).fileName());
int suffix = 0;
do
{
@@ -263,7 +269,13 @@ void PreferencesDialog::saveSettings()
// Copy file
copy_to.append(QString::number(suffix));
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
QDir().mkpath(QStandardPaths::writableLocation(
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QStandardPaths::AppDataLocation
#else
QStandardPaths::GenericDataLocation
#endif
));
QFile::copy(path, copy_to);
new_client_certs.push_back(copy_to);

View File

@@ -205,7 +205,15 @@ void RemoteDatabase::gotReply(QNetworkReply* reply)
branches.append(it.key());
// Get default branch
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QString default_branch = obj["default_branch"].toString("master");
#else
QString default_branch = obj["default_branch"].toString();
if ( default_branch.isEmpty () )
{
default_branch = "master";
}
#endif
// Send branch list to anyone who is interested
emit gotBranchList(branches, default_branch);
@@ -534,7 +542,13 @@ void RemoteDatabase::localAssureOpened()
return;
// Open file
QString database_file = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/remotedbs.db";
QString database_file = QStandardPaths::writableLocation(
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QStandardPaths::AppDataLocation
#else
QStandardPaths::GenericDataLocation
#endif
) + "/remotedbs.db";
if(sqlite3_open_v2(database_file.toUtf8(), &m_dbLocal, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr) != SQLITE_OK)
{
QMessageBox::warning(nullptr, qApp->applicationName(), tr("Error opening local databases list.\n%1").arg(QString::fromUtf8(sqlite3_errmsg(m_dbLocal))));

View File

@@ -276,7 +276,7 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name)
// editor/fontsize or log/fontsize?
if((group == "editor" || group == "log") && name == "fontsize")
#ifdef Q_OS_MAC
// Use 12 pt size as the default on OSX
// Use 12 pt size as the default on OSX
return 12;
#else
return 9;
@@ -339,7 +339,11 @@ QVariant Settings::getDefaultValue(const QString& group, const QString& name)
// Clone directory
if(name == "clonedirectory")
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
#else
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
#endif
}
// Unknown combination of group and name? Return an invalid QVariant!

View File

@@ -12,6 +12,24 @@
namespace sqlb {
#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
struct QHashCombine {
typedef uint result_type;
template <typename T>
Q_DECL_CONSTEXPR result_type operator()(uint seed, const T &t) const Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(t)))
// combiner taken from N3876 / boost::hash_combine
{ return seed ^ (qHash(t) + 0x9e3779b9 + (seed << 6) + (seed >> 2)) ; }
};
template <typename InputIterator>
inline uint qHashRange(InputIterator first, InputIterator last, uint seed = 0)
Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(*first))) // assume iterator operations don't throw
{
return std::accumulate(first, last, seed, QHashCombine());
}
#endif
template<typename T>
uint qHash(const QVector<T>& key, uint seed = 0)
Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))

View File

@@ -9,7 +9,12 @@ CONFIG += debug_and_release
CONFIG += qt
CONFIG += warn_on
QMAKE_CXXFLAGS += -std=c++11
contains(QT_VERSION, ^4\\..*\\..*) {
QMAKE_CXXFLAGS += -std=c++0x
}
contains(QT_VERSION, ^5\\..*\\..*) {
QMAKE_CXXFLAGS += -std=c++11
}
# create a unittest option
CONFIG(unittest) {