Skip to content

Commit 0e42c09

Browse files
committed
Added essential grid view cell editing support, accessible from the Schema Explorer by double-clicking on a table (normal query grids remain read-only.) Cell editing currently is not type-aware but does check for constraints. Nullable cells can be set to NULL by completely deleting their content, while non-nullable cells will be set to an empty string when this is performed. Finer controls will be implemented in future versions. Adopted new build numbering to indicate major test-ready changes through the development process. Current commit version: 0.7.0.7.
1 parent bd0dd0d commit 0e42c09

7 files changed

Lines changed: 515 additions & 35 deletions

File tree

src/sqlite-ce-edit/database.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ void CloseDatabase(void) {
105105
g_db = NULL;
106106
}
107107
g_szDbPath[0] = '\0';
108+
ClearEditMode();
108109
/* Reopen in-memory database as scratchpad */
109110
g_db = sqlite_open(":memory:", 0, NULL);
110111
lstrcpyW(g_szDbPath, L":memory:");

src/sqlite-ce-edit/execute.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ void ExecuteSQL(const char *sql) {
238238

239239
if (!g_db || !sql) return;
240240

241+
/* Clear edit mode - this is a read-only query path */
242+
ClearEditMode();
243+
241244
/* Setup */
242245
g_abortQuery = 0;
243246
if (g_clearOnExec) ClearOutput();
@@ -291,6 +294,9 @@ void ExecuteQuery(void) {
291294
return;
292295
}
293296

297+
/* Clear edit mode - query editor results are read-only */
298+
ClearEditMode();
299+
294300
/* Disable Execute while running, enable Stop */
295301
EnableMenuItem(g_hMenu, IDM_EXECUTE, MF_GRAYED);
296302
SendMessage(g_hwndCB, TB_ENABLEBUTTON, IDM_EXECUTE, FALSE);

src/sqlite-ce-edit/globals.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ wchar_t g_recentFiles[MAX_RECENT_FILES][MAX_PATH] = {0};
6868
int g_recentCount = 0;
6969
wchar_t g_recentQueries[MAX_RECENT_FILES][MAX_PATH] = {0};
7070
int g_recentQueryCount = 0;
71+
72+
/* Grid edit mode state */
73+
int g_editMode = 0; /* 1 = grid is editable */
74+
char g_editTableName[128] = {0}; /* Table being edited */

src/sqlite-ce-edit/globals.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ BOOL WINAPI GetSaveFileNameW(CE_OPENFILENAME*);
8282
** Version
8383
**============================================================================*/
8484

85-
#define SQLITECEDIT_VERSION L"0.6.0"
85+
#define SQLITECEDIT_VERSION L"0.7.0.7"
8686

8787
/*============================================================================
8888
** Menu IDs
@@ -232,6 +232,10 @@ extern int g_recentCount;
232232
extern wchar_t g_recentQueries[MAX_RECENT_FILES][MAX_PATH];
233233
extern int g_recentQueryCount;
234234

235+
/* Grid edit mode state */
236+
extern int g_editMode;
237+
extern char g_editTableName[128];
238+
235239
/*============================================================================
236240
** Function Declarations - Output (output.c)
237241
**============================================================================*/
@@ -266,6 +270,8 @@ void CreateSchemaView(HWND hwndParent, int x, int y, int cx, int cy);
266270
void RefreshSchema(void);
267271
void OnSchemaExpanding(NMTREEVIEWW *pnm);
268272
void OnSchemaDoubleClick(void);
273+
void OpenTableForEditing(const char *tablename);
274+
void ClearEditMode(void);
269275

270276
/* Grid view (grid.c) */
271277
void CreateGridView(HWND hwndParent, int x, int y, int cx, int cy);
@@ -274,6 +280,7 @@ void OnGridGetDispInfo(NMLVDISPINFOW *pdi);
274280
void OnGridColumnClick(int col);
275281
void GridFindNext(void);
276282
LRESULT CALLBACK GridProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
283+
void OnGridDoubleClick(int row, int col);
277284
void OnSchemaDelete(void);
278285
int GetSelectedObjectType(void); /* Returns IMG_TABLE, IMG_VIEW, IMG_TRIGGER, or -1 */
279286
void GetSchemaStatus(wchar_t *buf, int bufLen);

0 commit comments

Comments
 (0)