1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#ifndef DBDIALOG_H
#define DBDIALOG_H
#include "db/db.h"
#include "db/dbpluginoption.h"
#include "guiSQLiteStudio_global.h"
#include <QDialog>
#include <QList>
#include <QHash>
#include <QStringList>
class DbPlugin;
class QGridLayout;
struct DbPluginOption;
class ImmediateTooltip;
namespace Ui {
class DbDialog;
}
class GUI_API_EXPORT DbDialog : public QDialog
{
Q_OBJECT
public:
enum Mode
{
ADD,
EDIT
};
DbDialog(Mode mode, QWidget *parent = 0);
~DbDialog();
void setDb(Db* db);
void setPermanent(bool perm);
QString getPath();
void setPath(const QString& path);
QString getName();
QHash<QString,QVariant> collectOptions();
bool isPermanent();
void setDoAutoTest(bool value);
protected:
void changeEvent(QEvent *e);
void showEvent(QShowEvent* e);
void dragEnterEvent(QDragEnterEvent* e);
void dropEvent(QDropEvent*e);
private:
void init();
void updateOptions();
void addOption(const DbPluginOption& option, int& row);
QWidget* getEditor(const DbPluginOption& opt, QWidget *&editorHelper);
QVariant getValueFrom(DbPluginOption::Type type, QWidget* editor);
void setValueFor(DbPluginOption::Type type, QWidget* editor, const QVariant& value);
void updateType();
bool testDatabase(QString& errorMsg);
bool validate();
void updateState();
Ui::DbDialog *ui = nullptr;
Mode mode;
QStringList existingDatabaseNames;
Db* db = nullptr;
QHash<QString,DbPlugin*> dbPlugins;
QList<QWidget*> optionWidgets;
QHash<QString,QWidget*> optionKeyToWidget;
QHash<QString,DbPluginOption::Type> optionKeyToType;
QHash<QWidget*,QString> helperToKey;
QWidget* lastWidgetInTabOrder = nullptr;
DbPluginOption::CustomBrowseHandler customBrowseHandler = nullptr;
bool disableTypeAutodetection = false;
bool doAutoTest = false;
bool nameManuallyEdited = false;
bool createMode = false;
ImmediateTooltip* connIconTooltip = nullptr;
static const constexpr int ADDITIONAL_ROWS_BEGIN_INDEX = 1;
private slots:
void typeChanged(int index);
void valueForNameGenerationChanged();
void browseForFile();
void fileChanged(const QString &arg1);
void browseClicked();
void testConnectionClicked();
void propertyChanged();
void dbTypeChanged(int index);
void nameModified(const QString &value);
void updateCreateMode();
public slots:
void accept();
};
#endif // DBDIALOG_H
|