void MVListBase::selectNext(uint direction,int count,ulong modifiers, ibool toTop) /**************************************************************************** * * Function: MVListBase::selectNext * Parameters: direction - Flags indicating the direction to move * count - Number of cells to move down * modifiers - Keyboard shift modifiers * toTop - True if the cell should be moved to the top * * Description: Adjusts the selection by the specified number of cells in * the specified direction. If the shift modifiers are set, * then the selection is extended. * ****************************************************************************/ { MVPoint oldCursor(cursor); int maxv = maxV(),minv = minV(); int maxh = maxH(),minh = minH(); if (direction & lsBelow) if ((cursor.y += count) > maxv) cursor.y = maxv; if (direction & lsAbove) if ((cursor.y -= count) < minv) cursor.y = minv; if (direction & lsRight) if ((cursor.x += count) > maxh) cursor.x = maxh; if (direction & lsLeft) if ((cursor.x -= count) < minh) cursor.x = minh; if (cursor != oldCursor || (flags & lsExtending)) { if ((flags & lsMultipleSelect) && (modifiers & mdShift)) { if (cursor == oldCursor) return; if (direction & lsLeft) { if (flags & lsExtendRight) { // We are currently extending in the opposite direction, // so clear all of the cells from the old cursor position // to one above the new cursor position. If the selection // is only one high, then turn off the extending flags. if (cursor.x <= selection.left()) { flags &= ~lsExtendHoriz; selection.right() = selection.left()+1; selection.left() = cursor.x; if (selection.left() != selection.right()-1) { flags |= lsExtendLeft; selectRange(selection); } } else selection.right() = cursor.x+1; clearRange(selection.right(),selection.top(), oldCursor.x+1,selection.bottom()); } else { // We are currently extending the selection in the same // direction, or have just started to extend the selection flags |= lsExtendLeft; selection.left() = cursor.x; selectRange(cursor.x,selection.top(), oldCursor.x,selection.bottom()); } } if (direction & lsRight) { if (flags & lsExtendLeft) { if (cursor.x >= selection.right()-1) { flags &= ~lsExtendHoriz; selection.left() = selection.right()-1; selection.right() = cursor.x+1; if (selection.left() != selection.right()-1) { flags |= lsExtendRight; selectRange(selection); } } else selection.left() = cursor.x; clearRange(oldCursor.x,selection.top(), selection.left(),selection.bottom()); } else { flags |= lsExtendRight; selection.right() = cursor.x+1; selectRange(oldCursor.x+1,selection.top(), cursor.x+1,selection.bottom()); } } if (direction & lsAbove) { if (flags & lsExtendDown) { if (cursor.y <= selection.top()) { flags &= ~lsExtendVert; selection.bottom() = selection.top()+1; selection.top() = cursor.y; if (selection.top() != selection.bottom()-1) { flags |= lsExtendUp; selectRange(selection); } } else selection.bottom() = cursor.y+1; clearRange(selection.left(),selection.bottom(), selection.right(),oldCursor.y+1); } else { flags |= lsExtendUp; selection.top() = cursor.y; selectRange(selection.left(),cursor.y, selection.right(),oldCursor.y); } } if (direction & lsBelow) { if (flags & lsExtendUp) { if (cursor.y >= selection.bottom()-1) { flags &= ~lsExtendVert; selection.top() = selection.bottom()-1; selection.bottom() = cursor.y+1; if (selection.top() != selection.bottom()-1) { flags |= lsExtendDown; selectRange(selection); } } else selection.top() = cursor.y; clearRange(selection.left(),oldCursor.y, selection.right(),selection.top()); } else { flags |= lsExtendDown; selection.bottom() = cursor.y+1; selectRange(selection.left(),oldCursor.y+1, selection.right(),cursor.y+1); } } dirtyCell(oldCursor); } else { // The selection is not being extended, so clear any previous // selection and turn extending off, and reselect the cell // under the cursor. flags &= ~lsExtending; if (!(flags & lsDisjointSelect)) { clearSelection(); selectCell(cursor); } else { dirtyCell(oldCursor); dirtyCell(cursor); } } MV_message(owner,evBroadcast,cmListCursorChanged,this); refresh(); } focusCurrent(toTop); }
void Mouse::setCursor( const MouseCursor cursor ) { SDL_SystemCursor cursorName(SDL_SYSTEM_CURSOR_ARROW); switch(cursor) { case io::MouseCursor_Progress: cursorName = SDL_SYSTEM_CURSOR_WAIT; break; case io::MouseCursor_Custom: case io::MouseCursor_ZoomIn: case io::MouseCursor_ZoomOut: case io::MouseCursor_Pointer: case io::MouseCursor_Copy: case io::MouseCursor_None: case io::MouseCursor_VerticalText: case io::MouseCursor_Cell: case io::MouseCursor_ContextMenu: case io::MouseCursor_Alias: cursorName = SDL_SYSTEM_CURSOR_ARROW; break; case io::MouseCursor_Cross: cursorName = SDL_SYSTEM_CURSOR_CROSSHAIR; break; case io::MouseCursor_Grab: case io::MouseCursor_Grabbing: case io::MouseCursor_Hand: cursorName = SDL_SYSTEM_CURSOR_HAND; break; case io::MouseCursor_Help: cursorName = SDL_SYSTEM_CURSOR_ARROW; break; case io::MouseCursor_IBeam: cursorName = SDL_SYSTEM_CURSOR_IBEAM; break; case io::MouseCursor_NoDrop: case io::MouseCursor_NotAllowed: cursorName = SDL_SYSTEM_CURSOR_NO; break; case io::MouseCursor_Move: case io::MouseCursor_MiddlePanning: case io::MouseCursor_EastPanning: case io::MouseCursor_WestPanning: case io::MouseCursor_NorthPanning: case io::MouseCursor_SouthPanning: case io::MouseCursor_NorthEastPanning: case io::MouseCursor_SouthWestPanning: case io::MouseCursor_NorthWestPanning: case io::MouseCursor_SouthEastPanning: cursorName = SDL_SYSTEM_CURSOR_SIZEALL; break; case io::MouseCursor_NorthEastSouthWestResize: case io::MouseCursor_NorthEastResize: case io::MouseCursor_SouthWestResize: cursorName = SDL_SYSTEM_CURSOR_SIZENESW; break; case io::MouseCursor_NorthSouthResize: case io::MouseCursor_NorthResize: case io::MouseCursor_RowResize: case io::MouseCursor_SouthResize: cursorName = SDL_SYSTEM_CURSOR_SIZENS; break; case io::MouseCursor_NorthWestResize: case io::MouseCursor_NorthWestSouthEastResize: case io::MouseCursor_SouthEastResize: cursorName = SDL_SYSTEM_CURSOR_SIZENWSE; break; case io::MouseCursor_EastWestResize: case io::MouseCursor_EastResize: case io::MouseCursor_ColumnResize: case io::MouseCursor_WestResize: cursorName = SDL_SYSTEM_CURSOR_SIZEWE; break; case io::MouseCursor_Wait: cursorName = SDL_SYSTEM_CURSOR_WAITARROW; break; default: LOG(LogType_ProgrammerAssert, "Unknow mouse cursor %d", cursor); } SDL_Cursor* oldCursor(m_Cursor); m_Cursor = SDL_CreateSystemCursor(cursorName); SDL_SetCursor(m_Cursor); if (oldCursor != nullptr) SDL_FreeCursor(oldCursor); }
bool SqliteDriver::alterTable(const QString &mtd1, const QString &mtd2, const QString &key) { #ifndef FL_QUICK_CLIENT FLTableMetaData *oldMTD = 0; FLTableMetaData *newMTD = 0; QDomDocument doc("doc"); QDomElement docElem; if (!FLUtil::domDocumentSetContent(doc, mtd1)) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Error al cargar los metadatos.")); #endif } else { docElem = doc.documentElement(); oldMTD = db_->manager()->metadata(&docElem, true); } if (oldMTD && oldMTD->isQuery()) return true; if (!FLUtil::domDocumentSetContent(doc, mtd2)) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Error al cargar los metadatos.")); #endif return false; } else { docElem = doc.documentElement(); newMTD = db_->manager()->metadata(&docElem, true); } if (!oldMTD) oldMTD = newMTD; if (oldMTD->name() != newMTD->name()) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Los nombres de las tablas nueva y vieja difieren.")); #endif if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } QString oldPK = oldMTD->primaryKey(), newPK = newMTD->primaryKey(); if (oldPK != newPK) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Los nombres de las claves primarias difieren.")); #endif if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } if (oldMTD->fieldType(oldPK) != newMTD->fieldType(newPK)) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Los tipos de las claves primarias difieren.")); #endif if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } if (db_->manager()->checkMetaData(oldMTD, newMTD)) { if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return true; } if (!db_->manager()->existsTable(oldMTD->name())) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("La tabla %1 antigua de donde importar los registros no existe.").arg(oldMTD->name())); #endif if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } FLTableMetaData::FLFieldMetaDataList *fieldList = oldMTD->fieldList(); FLFieldMetaData *oldField = 0; if (!fieldList) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Los antiguos metadatos no tienen campos.")); #endif if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } QString renameOld = oldMTD->name().left(6) + "alteredtable" + QDateTime::currentDateTime().toString("ddhhssz"); if (!db_->dbAux()) { if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } db_->dbAux() ->transaction(); if (!key.isEmpty() && key.length() == 40) { QSqlCursor c("flfiles", true, db_->dbAux()); c.setForwardOnly(true); QSqlRecord *buffer; c.setFilter("nombre='" + renameOld + ".mtd'"); c.select(); if (!c.next()) { buffer = c.primeInsert(); buffer->setValue("nombre", renameOld + ".mtd"); buffer->setValue("contenido", mtd1); buffer->setValue("sha", key); c.insert(); } } QSqlQuery q(QString::null, db_->dbAux()); if (!q.exec("CREATE TABLE " + renameOld + " AS SELECT * FROM " + oldMTD->name() + ";") || !q.exec("DROP TABLE " + oldMTD->name() + ";")) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("No se ha podido renombrar la tabla antigua.")); #endif db_->dbAux() ->rollback(); if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } if (!db_->manager()->createTable(newMTD)) { db_->dbAux() ->rollback(); if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } QSqlCursor oldCursor(renameOld, true, db_->dbAux()); oldCursor.setMode(QSqlCursor::ReadOnly); QSqlCursor newCursor(newMTD->name(), true, db_->dbAux()); newCursor.setMode(QSqlCursor::Insert); oldCursor.select(); int totalSteps = oldCursor.size(); QProgressDialog progress(QApplication::tr("Reestructurando registros para %1...").arg(newMTD->alias()), 0, totalSteps, qApp->focusWidget(), 0, true); progress.setCaption(QApplication::tr("Tabla modificada")); int step = 0; QSqlRecord *newBuffer; QString sequence; fieldList = newMTD->fieldList(); FLFieldMetaData *newField = 0; if (!fieldList) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Los nuevos metadatos no tienen campos.")); #endif db_->dbAux() ->rollback(); if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } if (fieldList->isEmpty()) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Los nuevos metadatos no tienen campos.")); #endif db_->dbAux() ->rollback(); if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; return false; } QVariant v; bool ok = true; while (oldCursor.next()) { newBuffer = newCursor.primeInsert(); QDictIterator<FLFieldMetaData> it(*fieldList); while ((newField = it.current()) != 0) { ++it; oldField = oldMTD->field(newField->name()); if (!oldField || !oldCursor.field(oldField->name())) { if (!oldField) oldField = newField; v = newField->defaultValue(); v.cast(FLFieldMetaData::flDecodeType(newField->type())); } else { v = oldCursor.value(newField->name()); if ((!oldField->allowNull() || !newField->allowNull()) && (v.isNull() || !v.isValid())) { QVariant defVal(newField->defaultValue()); if (!defVal.isNull() && defVal.isValid()) v = defVal; } if (!v.cast(newBuffer->value(newField->name()).type())) { #ifdef FL_DEBUG qWarning("FLManager::alterTable : " + QApplication::tr("Los tipos del campo %1 no son compatibles. Se introducirá un valor nulo.") .arg(newField->name())); #endif } } if ((!oldField->allowNull() || !newField->allowNull()) && (v.isNull() || !v.isValid())) { switch (oldField->type()) { case QVariant::Int: case FLFieldMetaData::Serial: case QVariant::UInt: case QVariant::Bool: case FLFieldMetaData::Unlock: v = int(0); break; case QVariant::Double: v = double(0.0); break; case QVariant::Time: v = QTime::currentTime(); break; case QVariant::Date: v = QDate::currentDate(); break; default: v = QString("NULL").left(newField->length()); break; } } newBuffer->setValue(newField->name(), v); } if (!newCursor.insert()) { ok = false; break; } progress.setProgress(++step); } progress.setProgress(totalSteps); if ((oldMTD != newMTD) && oldMTD) delete oldMTD; if (newMTD) delete newMTD; if (ok) db_->dbAux() ->commit(); else { db_->dbAux() ->rollback(); return false; } #else return true; #endif //FL_QUICK_CLIENT }