Skip to content

Commit

Permalink
Up to 1.8.0
Browse files Browse the repository at this point in the history
* Fix critical issue #146
* Fix bug for a resultset with an error
* Ctrl + P to show/hide a preview area
* Minor UI improvements
  • Loading branch information
little-brother committed Jun 6, 2023
1 parent f261010 commit f828dc9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 21 deletions.
Binary file added resources/pinned_results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions src/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,8 @@ namespace dialogs {
DialogBoxParam(GetModuleHandle(0), MAKEINTRESOURCE(IDD_ROW), hWnd, (DLGPROC)&cbDlgRow, MAKELPARAM(ROW_ADD, 0));
int currRow = ListView_GetNextItem(hListWnd, -1, LVNI_SELECTED);
SendMessage(hWnd, WMU_SET_CURRENT_CELL, currRow, currCol);

ListView_SetSelectionMark(hListWnd, currRow);
}

if (cmd == IDM_ROW_REFRESH)
Expand Down Expand Up @@ -1560,7 +1562,9 @@ namespace dialogs {
int currCol = (int)(LONG_PTR)GetProp(hWnd, TEXT("CURRENTCOLUMN"));
if (firstRow - 1 > 0)
ListView_SetItemState (hListWnd, firstRow - 1, LVIS_FOCUSED | LVIS_SELECTED, 0x000F);
PostMessage(hWnd, WMU_SET_CURRENT_CELL, MAX(0, firstRow - 1), currCol);
int currRow = MAX(0, firstRow - 1);
PostMessage(hWnd, WMU_SET_CURRENT_CELL, currRow, currCol);
PostMessage(hListWnd, LVM_SETSELECTIONMARK, 0, currRow);
} else {
showDbError(hWnd);
}
Expand Down Expand Up @@ -2435,6 +2439,7 @@ namespace dialogs {
vCount += colCount + 1;
datatypes = (byte*)realloc(datatypes, vCount * sizeof(byte));
SetProp(hListWnd, TEXT("VALUECOUNT"), IntToPtr(vCount));
SetProp(hListWnd, TEXT("DATATYPES"), (HANDLE)datatypes);
}

int rowNo = mode == ROW_ADD ? ListView_GetItemCount(hListWnd) : currRow;
Expand Down Expand Up @@ -2472,6 +2477,9 @@ namespace dialogs {
if (mode == ROW_EDIT)
SendMessage(hWnd, WMU_SET_DLG_ROW_DATA, 0, 0);
SetFocus(GetDlgItem(hColumnsWnd, IDC_ROW_EDIT + 1));

for (int i = 1; prefs::get("clear-values") && (mode == ROW_ADD) && (i <= colCount); i++)
SetDlgItemText(hColumnsWnd, IDC_ROW_EDIT + i, TEXT(""));
} else
showDbError(hWnd);

Expand All @@ -2488,9 +2496,6 @@ namespace dialogs {
if (values8[i])
delete [] values8[i];
}

for (int i = 1; prefs::get("clear-values") && (mode == ROW_ADD) && (i <= colCount); i++)
SetDlgItemText(hColumnsWnd, IDC_ROW_EDIT + i, TEXT(""));
}

if (wParam == IDC_DLG_CANCEL || wParam == IDCANCEL)
Expand Down
42 changes: 28 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,11 @@ LRESULT CALLBACK cbMainWindow (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam
}
}

if (kd->wVKey == 0x50) { // Ctrl + P
SendMessage(hWnd, WM_COMMAND, IDM_RESULT_PREVIEW, 0);
return 0;
}

bool isNum = kd->wVKey >= 0x31 && kd->wVKey <= 0x39;
bool isNumPad = kd->wVKey >= 0x61 && kd->wVKey <= 0x69;
if ((isNum || isNumPad) && GetKeyState(VK_CONTROL)) // Ctrl + 1-9
Expand Down Expand Up @@ -5897,14 +5902,6 @@ int ListView_SetData(HWND hListWnd, sqlite3_stmt *stmt, bool isRef) {
ListView_SetColumn(hListWnd, colNo, &lvc);
}

int vCount = (colCount + 1) * rowCount;
SetProp(hListWnd, TEXT("VALUECOUNT"), IntToPtr(vCount));
datatypes = (byte*)realloc(datatypes, vCount * sizeof(byte));
SetProp(hListWnd, TEXT("DATATYPES"), (HANDLE)datatypes);


SetProp(hListWnd, TEXT("ORDERBY"), new int(0));

ListView_SetExtendedListViewStyle(hListWnd, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_AUTOSIZECOLUMNS | LVS_EX_LABELTIP);
if ((WNDPROC)GetWindowLongPtr(hListWnd, GWLP_WNDPROC) != cbNewListView)
SetProp(hListWnd, TEXT("WNDPROC"), (HANDLE)SetWindowLongPtr(hListWnd, GWLP_WNDPROC, (LONG_PTR)&cbNewListView));
Expand All @@ -5918,28 +5915,45 @@ int ListView_SetData(HWND hListWnd, sqlite3_stmt *stmt, bool isRef) {
delete [] err16;

if (!isVirtual) {
TCHAR rowLength16[64];
_sntprintf(rowLength16, 63, TEXT("%i"), _tcslen(msg16));
LVITEM lvi = {0};
lvi.mask = LVIF_TEXT;
lvi.iItem = rowNo;
lvi.iSubItem = 0;
lvi.iItem = 0;
lvi.pszText = rowLength16;
lvi.cchTextMax = _tcslen(rowLength16) + 1;
ListView_InsertItem(hListWnd, &lvi);

lvi.iSubItem = 1;
lvi.mask = LVIF_TEXT;
lvi.pszText = msg16;
lvi.cchTextMax = _tcslen(msg16) + 1;
ListView_InsertItem(hListWnd, &lvi);
ListView_SetItem(hListWnd, &lvi);
} else {
cache[rowNo] = (TCHAR**)calloc (colCount + 1, sizeof (TCHAR*));
cache[rowNo][1] = _tcsdup(msg16); // malloc!
rowNo++;
}
delete [] msg16;

datatypes[1 + rowNo * colCount] = SQLITE_TEXT;
rowCount++;
}

int vCount = (colCount + 1) * rowCount;
SetProp(hListWnd, TEXT("VALUECOUNT"), IntToPtr(vCount));
datatypes = (byte*)realloc(datatypes, vCount * sizeof(byte));
SetProp(hListWnd, TEXT("DATATYPES"), (HANDLE)datatypes);

SetProp(hListWnd, TEXT("ORDERBY"), new int(0));

if (isVirtual) {
cache = (TCHAR***)realloc(cache, vCount * sizeof(TCHAR**));
blobs = (unsigned char**)realloc(blobs, vCount * sizeof(unsigned char*));
SetProp(hListWnd, TEXT("CACHE"), cache);
SetProp(hListWnd, TEXT("BLOBS"), (HANDLE)blobs);
SetProp(hListWnd, TEXT("ROWCOUNT"), new int(rowNo));
SetProp(hListWnd, TEXT("TOTALROWCOUNT"), new int(rowNo));
SetProp(hListWnd, TEXT("ROWCOUNT"), new int(rowCount));
SetProp(hListWnd, TEXT("TOTALROWCOUNT"), new int(rowCount));

ListView_SetItemCount(hListWnd, 0);
SendMessage(hListWnd, WMU_UPDATE_RESULTSET, 0, 0);
Expand All @@ -5948,7 +5962,7 @@ int ListView_SetData(HWND hListWnd, sqlite3_stmt *stmt, bool isRef) {
SendMessage(hListWnd, WMU_AUTO_COLUMN_SIZE, 0, 0);
ListView_EnsureVisible(hListWnd, 0, 0);

return isStopByLimit ? -rowNo : rowNo;
return isStopByLimit ? -rowCount : rowCount;
}

int ListView_ShowRef(HWND hListWnd, int rowNo, int colNo) {
Expand Down
6 changes: 3 additions & 3 deletions src/resource.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define GUI_VERSION "1.7.9"
#define GUI_VERSION2 1, 7, 9, 0
#define GUI_VERSION "1.8.0"
#define GUI_VERSION2 1, 8, 0, 0
#ifdef __MINGW64__
#define GUI_PLATFORM 64
#else
Expand Down Expand Up @@ -31,7 +31,7 @@
#define IDD_TEXT_COMPARISON 32
#define IDD_FK_SELECTOR 33
#define IDD_COLOR_PICKER 34
#define IDD_URI_DB_PATH 35
#define IDD_URI_DB_PATH 35

#define IDD_TOOL_IMPORT_CSV 55
#define IDD_TOOL_IMPORT_JSON 56
Expand Down
1 change: 1 addition & 0 deletions src/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ BEGIN
"Ctrl + Tab - Toggle to a next result\n" \
"Ctrl + 1, Ctrl + 2, ... - Sort by column 1, 2, ... \n" \
"Ctrl + I - Invert row selection\n" \
"Ctrl + P - Show/Hide a preview\n" \
"Ctrl + Shift + C - Copy selected rows to clipboard with a header\n" \
"Alt + Click - Show referenced data\n" \
"Alt + Double Click - Drill-down by referenced value\n" \
Expand Down

0 comments on commit f828dc9

Please sign in to comment.