MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), help_process(0) { ui->setupUi(this); db = QSqlDatabase::addDatabase("QMYSQL"); QCoreApplication::setOrganizationName(DEFAULTS::Organization); QCoreApplication::setOrganizationDomain(DEFAULTS::Domain); QCoreApplication::setApplicationName(DEFAULTS::Application); QCoreApplication::setApplicationVersion(QString().setNum(DEFAULTS::AppVersion)); if (importSettings()) { connectDB(); } PatientFrame *patientFrame = new PatientFrame; PrescriptionFrame *prescriptionFrame = new PrescriptionFrame; FormularyFrame *formularyFrame = new FormularyFrame; InventoryFrame *inventoryFrame = new InventoryFrame; PrescriberFrame *prescriberFrame = new PrescriberFrame; PharmacistFrame *pharmacistFrame = new PharmacistFrame; ui->mainTabs->addTab(patientFrame, QString("Patients")); ui->mainTabs->addTab(prescriptionFrame, QString("Prescription log")); ui->mainTabs->addTab(formularyFrame, QString("Formulary")); ui->mainTabs->addTab(prescriberFrame, QString("Prescribers")); ui->mainTabs->addTab(pharmacistFrame, QString("Pharmacists")); ui->mainTabs->addTab(inventoryFrame, QString("Inventory")); connect(ui->optionsAction, SIGNAL(triggered()), this, SLOT(initiateOptions())); connect(ui->helpAction, SIGNAL(triggered()), this, SLOT(initiateHelp())); }
bool Gui::GUIApplicationNativeEventAware::x11EventFilter(XEvent *event) { #ifdef SPNAV_FOUND spnav_event navEvent; if (!spnav_x11_event(event, &navEvent)) return false; QWidget *currentWidget = this->focusWidget(); if (!currentWidget) currentWidget = mainWindow; if (navEvent.type == SPNAV_EVENT_MOTION) { motionDataArray[0] = navEvent.motion.x; motionDataArray[1] = navEvent.motion.y; motionDataArray[2] = navEvent.motion.z; motionDataArray[3] = navEvent.motion.rx; motionDataArray[4] = navEvent.motion.ry; motionDataArray[5] = navEvent.motion.rz; if (!setOSIndependentMotionData()) return false; importSettings(); Spaceball::MotionEvent *motionEvent = new Spaceball::MotionEvent(); motionEvent->setTranslations(motionDataArray[0], motionDataArray[1], motionDataArray[2]); motionEvent->setRotations(motionDataArray[3], motionDataArray[4], motionDataArray[5]); this->postEvent(currentWidget, motionEvent); return true; } if (navEvent.type == SPNAV_EVENT_BUTTON) { Spaceball::ButtonEvent *buttonEvent = new Spaceball::ButtonEvent(); buttonEvent->setButtonNumber(navEvent.button.bnum); if (navEvent.button.press) buttonEvent->setButtonStatus(Spaceball::BUTTON_PRESSED); else buttonEvent->setButtonStatus(Spaceball::BUTTON_RELEASED); this->postEvent(currentWidget, buttonEvent); return true; } Base::Console().Log("Unknown spaceball event\n"); return true; #else return false; #endif // SPNAV_FOUND }
CLandmarkOverlay::CLandmarkOverlay( QWidget* _pqParent ) : COverlayBaseTree( _pqParent, tr("Landmarks") ) { importSettings(); // Tree widget // ... columns QTreeWidget::setColumnCount( 3 ); QTreeWidget::setColumnWidth( NAME, 184 ); // ... header QTreeWidgetItem* __pqTreeWidgetItem = new QTreeWidgetItem(); __pqTreeWidgetItem->setText( NAME, tr("Name") ); __pqTreeWidgetItem->setIcon( VISIBLE, QIcon( ":icons/16x16/visible.png" ) ); __pqTreeWidgetItem->setIcon( SELECT, QIcon( ":icons/16x16/select.png" ) ); QTreeWidget::setHeaderItem( __pqTreeWidgetItem ); QTreeWidget::resizeColumnToContents( VISIBLE ); QTreeWidget::resizeColumnToContents( SELECT ); // ... top-level item QTreeWidgetItem::setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable ); QTreeWidgetItem::setText( NAME, COverlay::qsName ); QTreeWidgetItem::setCheckState( VISIBLE, Qt::Checked ); // ... drag 'n drop QTreeWidget::setDragDropMode( QAbstractItemView::InternalMove ); }
bool Gui::GUIApplicationNativeEventAware::x11EventFilter(XEvent *event) { #ifdef SPNAV_FOUND /* First we check if we have a motion flush event: - If there are unprocessed motion events we are in a flooding situation. In that case we wait with generating a Spaceball event. - A motion event counter of 0 indicates that FreeCAD is ready to process the event. A Spaceball event, using the saved motion data, is posted. */ static Display* display = QX11Info::display(); static Atom motion_flush_event = XInternAtom(display, "FCMotionFlushEvent", false); static int nMotionEvents = 0; QWidget *currentWidget = this->focusWidget(); if (!currentWidget) currentWidget = mainWindow; if (event->type == ClientMessage) { Atom message_type = event->xclient.message_type; if (message_type == motion_flush_event) { nMotionEvents--; if (nMotionEvents == 0) { importSettings(); Spaceball::MotionEvent *motionEvent = new Spaceball::MotionEvent(); motionEvent->setTranslations(motionDataArray[0], motionDataArray[1], motionDataArray[2]); motionEvent->setRotations(motionDataArray[3], motionDataArray[4], motionDataArray[5]); this->postEvent(currentWidget, motionEvent); } return true; } // XEvent: motion_flush_event } // XEvent: ClientMessage /* From here on we deal with spacenav events only: - motion: The event data is saved and a self addressed flush event is sent through the window system (XEvent). In the case of an event flooding, the motion data is added up. - button: A Spaceball event is posted (QInputEvent). */ spnav_event navEvent; if (!spnav_x11_event(event, &navEvent)) return false; if (navEvent.type == SPNAV_EVENT_MOTION) { /* If the motion data of the preceding event has not been processed through posting an Spaceball event (flooding situation), the motion data provided by the incoming event is added to the saved data. */ int dx, dy, dz, drx, dry, drz; if (nMotionEvents == 0) { dx = 0; dy = 0; dz = 0; drx = 0; dry = 0; drz = 0; } else { dx = motionDataArray[0]; dy = motionDataArray[1]; dz = motionDataArray[2]; drx = motionDataArray[3]; dry = motionDataArray[4]; drz = motionDataArray[5]; } motionDataArray[0] = navEvent.motion.x; motionDataArray[1] = navEvent.motion.y; motionDataArray[2] = navEvent.motion.z; motionDataArray[3] = navEvent.motion.rx; motionDataArray[4] = navEvent.motion.ry; motionDataArray[5] = navEvent.motion.rz; if (!setOSIndependentMotionData()) return false; motionDataArray[0] += dx; motionDataArray[1] += dy; motionDataArray[2] += dz; motionDataArray[3] += drx; motionDataArray[4] += dry; motionDataArray[5] += drz; /* Send a self addressed flush event through the window system. This will trigger a Spaceball event if FreeCAD is ready to do so. */ nMotionEvents++; XClientMessageEvent flushEvent; flushEvent.display = display; flushEvent.window = event->xclient.window; flushEvent.type = ClientMessage; flushEvent.format = 8; flushEvent.message_type = motion_flush_event; XSendEvent (display, flushEvent.window, False, 0, (XEvent*)&flushEvent); // siehe spnavd, False, 0 return true; } if (navEvent.type == SPNAV_EVENT_BUTTON) { Spaceball::ButtonEvent *buttonEvent = new Spaceball::ButtonEvent(); buttonEvent->setButtonNumber(navEvent.button.bnum); if (navEvent.button.press) buttonEvent->setButtonStatus(Spaceball::BUTTON_PRESSED); else buttonEvent->setButtonStatus(Spaceball::BUTTON_RELEASED); this->postEvent(currentWidget, buttonEvent); return true; } Base::Console().Log("Unknown spaceball event\n"); return true; #else return false; #endif // SPNAV_FOUND }
void ImportSettingsFromFileMenuItem(HANDLE hContact, char* FilePath) { char szFileNames[MAX_PATH*10] = {0}; char szPath[MAX_PATH] = ""; char szFile[MAX_PATH]; int index = 0; HANDLE hFile, hMap; PBYTE pFile = NULL; DWORD offset = 0; if (lstrcmp(FilePath, "") == 0) offset = Openfile2Import(szFileNames); else { if(Exists(FilePath)) lstrcpy(szFileNames, FilePath); else lstrcpy(szFileNames, ""); } if (!lstrcmp(szFileNames, "") == 0) { if ((DWORD)lstrlenA(szFileNames) < offset) { index += offset; strncpy(szPath, szFileNames, offset); strcat(szPath, "\\"); } while(szFileNames[index]) { strcpy(szFile, szPath); strcat(szFile, &szFileNames[index]); index += (int)strlen(&szFileNames[index])+1; hFile = CreateFile(szFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile != INVALID_HANDLE_VALUE) { if (GetFileSize(hFile, NULL) > 0) { hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); if (hMap) { pFile = (PBYTE)MapViewOfFile(hMap, FILE_MAP_COPY, 0, 0 ,0); if (pFile) { importSettings(hContact, (char*)pFile); UnmapViewOfFile(pFile); } CloseHandle(hMap); } } CloseHandle(hFile); } else break; } if (lstrcmp(FilePath, "") == 0) refreshTree(1); } }
INT_PTR CALLBACK ImportDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { hwnd2importWindow = hwnd; SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); TranslateDialogDefault(hwnd); SendDlgItemMessage(hwnd, IDC_TEXT, EM_LIMITTEXT, (WPARAM)sizeof(TCHAR)*0x7FFFFFFF, 0); } break; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_CRLF: { int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); char *string = (char*)_malloca(length+3); int Pos = 2; if (length) { int Range = SendDlgItemMessage(hwnd,IDC_TEXT,EM_GETSEL,0,0); int Min = LOWORD(Range); int Max = HIWORD(Range); GetDlgItemText(hwnd, IDC_TEXT, string, length+1); if (Min == -1) memcpy(string, crlf_string, SIZEOF(crlf_string)); else if (Max == -1 || Max >= length) memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); else if (Max-Min > 2) { memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); memmove(&string[Min+2], &string[Max], length - Max + 1); } else { memmove(&string[Min+2], &string[Max], length - Max + 1); memcpy(&string[Min], crlf_string, SIZEOF(crlf_string)); } if (Min) Pos += Min; } else memcpy(string, crlf_string, SIZEOF(crlf_string)); SetDlgItemText(hwnd, IDC_TEXT, string); SendDlgItemMessage(hwnd,IDC_TEXT,EM_SETSEL,Pos,Pos); SetFocus(GetDlgItem(hwnd, IDC_TEXT)); } break; case IDOK: { HANDLE hContact = (HANDLE)GetWindowLongPtr(hwnd,GWLP_USERDATA); int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT)); char *string; if (length) { string = (char*)_malloca(length+1); if (!string) {msg(Translate("Couldnt allocate enough memory!"), modFullname); DestroyWindow(hwnd); } GetDlgItemText(hwnd, IDC_TEXT, string, length+1); importSettings(hContact, string); refreshTree(1); } } break; case IDCANCEL: DestroyWindow(hwnd); hwnd2importWindow = 0; break; } } break; } return 0; }