Procházet zdrojové kódy

If database is on a network share refresh Ditto when showing if last write time of db has been updated

scott brogden před 5 roky
rodič
revize
b383d54469
7 změnil soubory, kde provedl 51 přidání a 4 odebrání
  1. 5 0
      ActionEnums.cpp
  2. 1 0
      ActionEnums.h
  3. 1 0
      CP_Main.cpp
  4. 1 0
      CP_Main.h
  5. 16 2
      DatabaseUtilities.cpp
  6. 25 2
      QPasteWnd.cpp
  7. 2 0
      QPasteWnd.h

+ 5 - 0
ActionEnums.cpp

@@ -371,6 +371,9 @@ CString ActionEnums::EnumDescription(ActionEnumValues value)
 	case FORCE_CLOSE_WINDOW:
 		val = "Force Close Window";
 		break;
+	case REFRESH_LIST:
+		val = "Refresh List";
+		break;
 	}
 
 	CString translatedValue = theApp.m_Language.GetQuickPasteKeyboardString(value, val);
@@ -448,6 +451,8 @@ int ActionEnums::GetDefaultShortCutKeyA(ActionEnumValues value, int pos)
 			return 'W';
 		case COPY_SELECTION:
 			return ACCEL_MAKEKEY('C', HOTKEYF_CONTROL);
+		case REFRESH_LIST:
+			return VK_F5;
 		}
 		break;
 	case 1:

+ 1 - 0
ActionEnums.h

@@ -125,6 +125,7 @@ public:
 		INVERT_CASE,
 		COPY_SELECTION,
 		FORCE_CLOSE_WINDOW,
+		REFRESH_LIST,
 
 		LAST_ACTION
 	};

+ 1 - 0
CP_Main.cpp

@@ -136,6 +136,7 @@ CCP_MainApp::CCP_MainApp()
 	m_PNG_Format = GetFormatID(_T("PNG"));
 
 	m_pNoDbMainFrame = NULL;
+	m_databaseOnNetworkShare = false;
 }
 
 CCP_MainApp::~CCP_MainApp()

+ 1 - 0
CP_Main.h

@@ -31,6 +31,7 @@ public:
 	~CCP_MainApp();
 
 	CppSQLite3DB m_db;
+	bool m_databaseOnNetworkShare;
 
 	HANDLE	m_hMutex; // for singleton app
 	HANDLE m_adminPasteMutex;

+ 16 - 2
DatabaseUtilities.cpp

@@ -193,12 +193,26 @@ BOOL IsDatabaseOpen()
 	return theApp.m_db.IsDatabaseOpen();
 }
 
-BOOL OpenDatabase(CString csDB)
+BOOL OpenDatabase(CString dbPath)
 {
 	try
 	{
+		CPath path(dbPath);
+
+		int len = 0;
+		auto rootType = path.GetRootType(&len);
+		auto driveLetter = path.GetDriveLetter();
+
+		theApp.m_databaseOnNetworkShare = false;
+		if (rootType == ERootType::rtServerShare ||
+			((rootType == ERootType::rtDriveCur || rootType == rtDriveRoot) && driveLetter >= 'A' && driveLetter != 'C'))
+		{
+			theApp.m_databaseOnNetworkShare = true;
+		}
+		
+
 		theApp.m_db.close();
-		theApp.m_db.open(csDB);		
+		theApp.m_db.open(dbPath);
 
 		theApp.m_db.setBusyTimeout(CGetSetOptions::GetDbTimeout());
 

+ 25 - 2
QPasteWnd.cpp

@@ -82,6 +82,7 @@ CQPasteWnd::CQPasteWnd()
 	m_leftSelectedCompareId = 0;
 	m_extraDataCounter = 0;
 	m_noSearchResults = false;
+	m_lastDbWrite = 0;
 }
 
 CQPasteWnd::~CQPasteWnd()
@@ -754,7 +755,22 @@ void CQPasteWnd::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized)
 		{
 			if (theApp.m_bShowingQuickPaste == false)
 			{
-				ShowQPasteWindow(m_listItems.size() == 0);
+				BOOL fillList = FALSE;
+				if (m_listItems.size() == 0)
+				{
+					fillList = TRUE;
+				}
+				else if(theApp.m_databaseOnNetworkShare)
+				{
+					__int64 lastWrite = GetLastWriteTime(CGetSetOptions::GetDBPath());
+					if (lastWrite > m_lastDbWrite)
+					{
+						m_lastDbWrite = lastWrite;
+						fillList = TRUE;
+					}
+				}
+
+				ShowQPasteWindow(fillList);
 			}
 
 			//Unregister the global hot keys for the last ten copies
@@ -3166,7 +3182,6 @@ bool CQPasteWnd::DoAction(CAccel a)
 	case ActionEnums::PASTE_TRIM_WHITE_SPACE:
 		ret = DoActionPasteTrimWhiteSpace();
 		break;
-
 	case ActionEnums::TRANSPARENCY_NONE:
 		SetTransparency(0);
 		break;
@@ -3221,6 +3236,8 @@ bool CQPasteWnd::DoAction(CAccel a)
 	case ActionEnums::COPY_SELECTION:
 		ret = DoCopySelection();
 		break;
+	case ActionEnums::REFRESH_LIST:
+		ret = DoRefreshList();
 	}
 
 	return ret;
@@ -7438,6 +7455,12 @@ bool CQPasteWnd::DoActionSlugify()
 	}
 }
 
+bool CQPasteWnd::DoRefreshList()
+{
+	FillList(_T(""));
+	return true;
+}
+
 bool CQPasteWnd::DoCopySelection()
 {
 	ARRAY IDs;

+ 2 - 0
QPasteWnd.h

@@ -173,6 +173,7 @@ public:
 	CCustomFriendsHelper m_customFriendsHelper;
 	bool m_noSearchResults;
 	CAccel m_timerAction;
+	__int64 m_lastDbWrite;
 
     void RefreshNc();
     void UpdateStatus(bool bRepaintImmediately = false); // regenerates the status (caption) text
@@ -304,6 +305,7 @@ public:
 	bool DoActionEmailToAttachContent();
 	bool DoActionSlugify();
 	bool DoCopySelection();
+	bool DoRefreshList();
 
 	bool OnNewClip();
 	bool OnImportClip();