TypeDocForm::TypeDocForm(QString id, QWidget *parent, bool onlyForRead) :
    QDialog(parent)
{
    exchangeFile.setFileName("Message.txt");
    if(!exchangeFile.isOpen()){
        exchangeFile.open(QIODevice::ReadWrite);
    }

    indexTemp = id;

    QFile file(":/ToolButtonStyle.txt");
    file.open(QFile::ReadOnly);
    //QString styleSheetString = QLatin1String(file.readAll());

    labelName = new QLabel(trUtf8("Prichina Obuch:"));
    editName = new LineEdit;
    editName->setReadOnly(onlyForRead);
    QRegExp regExp("[\\x0410-\\x044f 0-9 ()\" -]{150}");
    editName->setValidator(new QRegExpValidator(regExp,this));
    labelName->setBuddy(editName);

    savePushButton = new QPushButton(trUtf8("Save"));
    connect(savePushButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    savePushButton->setToolTip(trUtf8("Save And Close Button"));

    cancelPushButton = new QPushButton(trUtf8("Cancel"));
    cancelPushButton->setDefault(true);
    cancelPushButton->setStyleSheet("QPushButton:hover {color: red}");
    connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(accept()));
    cancelPushButton->setToolTip(trUtf8("Cancel Button"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole);

    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("SELECT typedocname FROM typedoc WHERE typedocid = :typedocid");
        query.bindValue(":typedocid",indexTemp);
        query.exec();
        while(query.next()){
            editName->setText(query.value(0).toString());
        }
    }else{
        editName->clear();
    }

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(labelName,0,0);
    mainLayout->addWidget(editName,0,1);
    if(!onlyForRead){
        mainLayout->addWidget(buttonBox,1,1);
        editName->selectAll();
    }

    setLayout(mainLayout);

    setWindowTitle(trUtf8("Type doc"));
    readSettings();
}
Esempio n. 2
0
Card::Card(QSqlQueryModel *personModel, QSqlQueryModel *responseModel, QWidget *parent) : CardUI(parent){
    setFormPersonMap(personModel);
    setFormResponseMap(responseModel);

    connect(submitNew, SIGNAL(clicked()), this, SLOT(addRecord()));
    connect(submitEdit, SIGNAL(clicked()), this, SLOT(editRecord()));
    connect(submitReset, SIGNAL(clicked()), this, SLOT(clearFields()));
    connect(submitDelete,SIGNAL(clicked()), this, SLOT(deleteRecord()));
}
SafetyRequirements::SafetyRequirements(QString id, QWidget *parent, bool onlyForRead) :
    QDialog(parent)
{
    indexTemp = id;

    labelName = new QLabel(trUtf8("Name:"));
    editName = new LineEdit;
    editName->setReadOnly(onlyForRead);
    QRegExp regExp("[\\x0410-\\x044f . , 0-9]{100}");
    editName->setValidator(new QRegExpValidator(regExp,this));
    labelName->setBuddy(editName);

    savePushButton = new QPushButton(trUtf8("Save"));
    connect(savePushButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    savePushButton->setToolTip(trUtf8("Save And Close Button"));

    cancelPushButton = new QPushButton(trUtf8("Cancel"));
    cancelPushButton->setDefault(true);
    cancelPushButton->setStyleSheet("QPushButton:hover {color: red}");
    connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(accept()));
    cancelPushButton->setToolTip(trUtf8("Cancel Button"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole);

    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("SELECT * FROM safetyreq WHERE safetyreqid = ?;");
        query.addBindValue(indexTemp);
        query.exec();
        while(query.next()){
            editName->setText(query.value(1).toString());
        }
        if(!query.isActive()){
            QMessageBox::warning(this,QObject::trUtf8("Safetyreq Update ERROR!"),query.lastError().text());
        }
    }

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(labelName,0,0,Qt::AlignRight);
    mainLayout->addWidget(editName,0,1);
    if(!onlyForRead){
        mainLayout->addWidget(buttonBox,1,0,1,2);
        editName->selectAll();
    }

    setLayout(mainLayout);

    setWindowTitle(trUtf8("Safetyreq"));
    SafetyRequirements::setTabOrder(editName,cancelPushButton);
}
ObosoblForm::ObosoblForm(QString id, QWidget *parent, bool onlyForRead) :
    QDialog(parent)
{
    indexTemp = id;

    labelName = new QLabel(trUtf8("Name:"));
    editName = new LineEdit;
    editName->setReadOnly(onlyForRead);
    QRegExp regExpFamiliya("[\\x0410-\\x044f 0-9 \" -]{150}");
    editName->setValidator(new QRegExpValidator(regExpFamiliya,this));
    labelName->setBuddy(editName);

    savePushButton = new QPushButton(trUtf8("Save"));
    connect(savePushButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    savePushButton->setToolTip(trUtf8("Save And Close Button"));

    cancelPushButton = new QPushButton(trUtf8("Cancel"));
    cancelPushButton->setDefault(true);
    cancelPushButton->setStyleSheet("QPushButton:hover {color: red}");
    connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(accept()));
    cancelPushButton->setToolTip(trUtf8("Cancel Button"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole);

    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("SELECT obosoblname FROM obosobl WHERE obosoblid = ?");
        query.addBindValue(indexTemp);
        query.exec();
        while(query.next()){
            editName->setText(query.value(0).toString());
        }
    }else{
        editName->clear();
    }

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(labelName,0,0);
    mainLayout->addWidget(editName,0,1);
    if(!onlyForRead){
        mainLayout->addWidget(buttonBox,1,1);
        editName->selectAll();
    }

    setLayout(mainLayout);

    setWindowTitle(trUtf8("Obosobl"));
}
Esempio n. 5
0
void
CmdInterface::run(PhoneBook & pb)
{
    cout << "==============Phone Book 0.1 By JackalDire==============\n";
    
    main_menu();

    string cmd;
    do
    {
        cout << "cmd>";
        cin >> cmd;
        if (cmd.size() > 1)
        {
            cout << "Error Command!\n";
            cin.clear();
            cin.sync();
            cmd[0] = 1;
            continue;
        }

        switch (cmd[0])
        {
            case '1': addRecord(pb); main_menu(); break;
            case '2': editRecord(); main_menu(); break;
            case '3': searchRecord(); main_menu(); break;
            case '4': delRecord(); main_menu(); break;
            case '5': show(pb); main_menu(); break;
            case '9': main_menu(); break;
            case '0': cout << "Exit.\n"; break;
            default:
                cout << "Error Command!\n";
                cin.clear();
                cin.sync();
                break;

        }
    }
    while(cmd[0] != '0');
}
Esempio n. 6
0
CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
    bool createAndDelete, bool sorting, CSMDoc::Document& document)
: DragRecordTable(document), mCreateAction (0),
  mCloneAction(0),mRecordStatusDisplay (0)
{
    CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance();
    QString jumpSetting = settings.settingValue ("table-input/jump-to-added");
    if (jumpSetting.isEmpty() || jumpSetting == "Jump and Select") // default
    {
        mJumpToAddedRecord = true;
        mUnselectAfterJump = false;
    }
    else if(jumpSetting == "Jump Only")
    {
        mJumpToAddedRecord = true;
        mUnselectAfterJump = true;
    }
    else
    {
        mJumpToAddedRecord = false;
        mUnselectAfterJump = false;
    }

    mModel = &dynamic_cast<CSMWorld::IdTableBase&> (*mDocument.getData().getTableModel (id));

    bool isInfoTable = id.getType() == CSMWorld::UniversalId::Type_TopicInfos ||
                       id.getType() == CSMWorld::UniversalId::Type_JournalInfos;
    if (isInfoTable)
    {
        mProxyModel = new CSMWorld::InfoTableProxyModel(id.getType(), this);
    }
    else
    {
        mProxyModel = new CSMWorld::IdTableProxyModel (this);
    }
    mProxyModel->setSourceModel (mModel);

    mDispatcher = new CSMWorld::CommandDispatcher (document, id, this);

    setModel (mProxyModel);
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    horizontalHeader()->setSectionResizeMode (QHeaderView::Interactive);
#else
    horizontalHeader()->setResizeMode (QHeaderView::Interactive);
#endif
    verticalHeader()->hide();
    setSortingEnabled (sorting);
    setSelectionBehavior (QAbstractItemView::SelectRows);
    setSelectionMode (QAbstractItemView::ExtendedSelection);

    int columns = mModel->columnCount();

    for (int i=0; i<columns; ++i)
    {
        int flags = mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();

        if (flags & CSMWorld::ColumnBase::Flag_Table)
        {
            CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display> (
                mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());

            CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display,
                mDispatcher, document, this);

            mDelegates.push_back (delegate);
            setItemDelegateForColumn (i, delegate);
        }
        else
            hideColumn (i);
    }

    mEditAction = new QAction (tr ("Edit Record"), this);
    connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord()));
    addAction (mEditAction);

    if (createAndDelete)
    {
        mCreateAction = new QAction (tr ("Add Record"), this);
        connect (mCreateAction, SIGNAL (triggered()), this, SIGNAL (createRequest()));
        addAction (mCreateAction);

        mCloneAction = new QAction (tr ("Clone Record"), this);
        connect(mCloneAction, SIGNAL (triggered()), this, SLOT (cloneRecord()));
        addAction(mCloneAction);
    }

    mRevertAction = new QAction (tr ("Revert Record"), this);
    connect (mRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeRevert()));
    addAction (mRevertAction);

    mDeleteAction = new QAction (tr ("Delete Record"), this);
    connect (mDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeDelete()));
    addAction (mDeleteAction);

    mMoveUpAction = new QAction (tr ("Move Up"), this);
    connect (mMoveUpAction, SIGNAL (triggered()), this, SLOT (moveUpRecord()));
    addAction (mMoveUpAction);

    mMoveDownAction = new QAction (tr ("Move Down"), this);
    connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord()));
    addAction (mMoveDownAction);

    mEditCellAction = new QAction( tr("Edit Cell"), this );
    connect( mEditCellAction, SIGNAL(triggered()), this, SLOT(editCell()) );
    addAction( mEditCellAction );

    mViewAction = new QAction (tr ("View"), this);
    connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord()));
    addAction (mViewAction);

    mPreviewAction = new QAction (tr ("Preview"), this);
    connect (mPreviewAction, SIGNAL (triggered()), this, SLOT (previewRecord()));
    addAction (mPreviewAction);

    /// \todo add a user option, that redirects the extended action to an input panel (in
    /// the bottom bar) that lets the user select which record collections should be
    /// modified.

    mExtendedDeleteAction = new QAction (tr ("Extended Delete Record"), this);
    connect (mExtendedDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedDelete()));
    addAction (mExtendedDeleteAction);

    mExtendedRevertAction = new QAction (tr ("Extended Revert Record"), this);
    connect (mExtendedRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedRevert()));
    addAction (mExtendedRevertAction);

    connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
        this, SLOT (tableSizeUpdate()));

    connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
        this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int)));

    /// \note This signal could instead be connected to a slot that filters out changes not affecting
    /// the records status column (for permanence reasons)
    connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
        this, SLOT (tableSizeUpdate()));

    connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
        this, SLOT (selectionSizeUpdate ()));

    setAcceptDrops(true);

    mDoubleClickActions.insert (std::make_pair (Qt::NoModifier, Action_InPlaceEdit));
    mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier, Action_EditRecord));
    mDoubleClickActions.insert (std::make_pair (Qt::ControlModifier, Action_View));
    mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier | Qt::ControlModifier, Action_EditRecordAndClose));
}
Esempio n. 7
0
void CSVWorld::Table::mouseDoubleClickEvent (QMouseEvent *event)
{
    Qt::KeyboardModifiers modifiers =
        event->modifiers() & (Qt::ShiftModifier | Qt::ControlModifier);

    QModelIndex index = currentIndex();

    selectionModel()->select (index,
        QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Rows);

    std::map<Qt::KeyboardModifiers, DoubleClickAction>::iterator iter =
        mDoubleClickActions.find (modifiers);

    if (iter==mDoubleClickActions.end())
    {
        event->accept();
        return;
    }

    switch (iter->second)
    {
        case Action_None:

            event->accept();
            break;

        case Action_InPlaceEdit:

            DragRecordTable::mouseDoubleClickEvent (event);
            break;

        case Action_EditRecord:

            event->accept();
            editRecord();
            break;

        case Action_View:

            event->accept();
            viewRecord();
            break;

        case Action_Revert:

            event->accept();
            if (mDispatcher->canRevert())
                mDispatcher->executeRevert();
            break;

        case Action_Delete:

            event->accept();
            if (mDispatcher->canDelete())
                mDispatcher->executeDelete();
            break;

        case Action_EditRecordAndClose:

            event->accept();
            editRecord();
            emit closeRequest();
            break;

        case Action_ViewAndClose:

            event->accept();
            viewRecord();
            emit closeRequest();
            break;
    }
}
Esempio n. 8
0
ContractForm::ContractForm(QString id, QWidget *parent, bool onlyForRead) :
    QDialog(parent)
{
    indexTemp = id;
    QFile file(":/ToolButtonStyle.txt");
    file.open(QFile::ReadOnly);
    QString styleSheetString = QLatin1String(file.readAll());

    labelNumber = new QLabel(trUtf8("Number:"));
    editNumber = new LineEdit;
    editNumber->setReadOnly(onlyForRead);
    labelNumber->setBuddy(editNumber);

    labelDate = new QLabel(trUtf8("Date:"));
    editDate = new QDateEdit;
    editDate->setCalendarPopup(true);
    editDate->setReadOnly(onlyForRead);
    editDate->setDate(QDate::currentDate());

    labelEmployee = new QLabel(trUtf8("FIO:"));
    editEmployee = new LineEdit;
    editEmployee->setReadOnly(onlyForRead);
    labelEmployee->setBuddy(editEmployee);

    QSqlQueryModel *employeeModel = new QSqlQueryModel;
    employeeModel->setQuery("SELECT employeename FROM employee");
    QCompleter *employeeCompleter = new QCompleter(employeeModel);
    employeeCompleter->setCompletionMode(QCompleter::PopupCompletion);
    employeeCompleter->setCaseSensitivity(Qt::CaseSensitive);
    editEmployee->setCompleter(employeeCompleter);

    QToolButton *addButton = new QToolButton;
    QPixmap addPix(":/add.png");
    addButton->setIcon(addPix);
    addButton->setToolTip(trUtf8("Add new record"));
    connect(addButton,SIGNAL(clicked()),this,SLOT(addRecord()));
    addButton->setStyleSheet(styleSheetString);

    QToolButton *seeButton = new QToolButton;
    QPixmap seePix(":/see.png");
    seeButton->setIcon(seePix);
    seeButton->setToolTip(trUtf8("See select item"));
    connect(seeButton,SIGNAL(clicked()),this,SLOT(seeRecord()));
    seeButton->setStyleSheet(styleSheetString);

    QToolButton *listButton = new QToolButton;
    QPixmap listPix(":/list.png");
    listButton->setIcon(listPix);
    listButton->setToolTip(trUtf8("See list of item"));
    connect(listButton,SIGNAL(clicked()),this,SLOT(listRecord()));
    listButton->setStyleSheet(styleSheetString);

    QHBoxLayout *editLayout = new QHBoxLayout;
    editLayout->addWidget(labelEmployee);
    editLayout->addWidget(editEmployee);
    if(!onlyForRead){
        editLayout->addWidget(addButton);
        editLayout->addWidget(seeButton);
        editLayout->addWidget(listButton);
    }

    savePushButton = new QPushButton(trUtf8("Save"));
    connect(savePushButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    savePushButton->setToolTip(trUtf8("Save And Close Button"));

    cancelPushButton = new QPushButton(trUtf8("Cancel"));
    cancelPushButton->setDefault(true);
    cancelPushButton->setStyleSheet("QPushButton:hover {color: red}");
    connect(cancelPushButton,SIGNAL(clicked()),this,SLOT(accept()));
    cancelPushButton->setToolTip(trUtf8("Cancel Button"));

    printPushButton = new QPushButton(trUtf8("Print"));
    //connect(savePushButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    printPushButton->setToolTip(trUtf8("Print Contract Button"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(printPushButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(cancelPushButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(savePushButton,QDialogButtonBox::ActionRole);

    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("SELECT organizationname FROM organization WHERE organizationid = ?");
        query.addBindValue(indexTemp);
        query.exec();
        while(query.next()){
            //editOrganization->setText(query.value(0).toString());
        }
    }else{
        //editOrganization->clear();
    }

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(labelNumber,0,0);
    mainLayout->addWidget(editNumber,0,1);
    mainLayout->addWidget(labelDate,0,2);
    mainLayout->addWidget(editDate,0,3);
    mainLayout->addLayout(editLayout,1,0,1,3);
    if(!onlyForRead){
        mainLayout->addWidget(buttonBox,2,3);
        //editOrganization->selectAll();
    }

    setLayout(mainLayout);

    setWindowTitle(trUtf8("Organization"));
}
Esempio n. 9
0
int findRec(char *fileName, char *delimeter, char *query)
{
	char *buffer = NULL;
	int readBytes = 0;
	FILE *fp = NULL;
	int deli_len = strlen(delimeter);
	int query_len = strlen(query);
	int cntField_len = strlen(cntField);

	char *temp = NULL;
	char *temp_nxt = NULL;
	int left_len = 0;
	int buffer_len = 0;
	char *recBuffer = NULL;
	char *leftBuffer = NULL;
	int readBuf_pos = 0;

	char *cnt_temp = NULL;
	char *cnt_value = NULL;
	char *recToWrite = NULL;
	
	if( (fp = fopen(fileName, "r+")) == NULL)
	{
		return 1;
	}

	fseek(fp, 0, SEEK_SET);
	buffer = (char *)malloc( sizeof(char) * MAXSIZE );
	readBytes = fread(buffer, 1, MAXSIZE, fp);
	//printf("readBytes:%d\n==========\n\n", readBytes);
	if(readBytes == 0){
		return 4;
	}
	//printf("buffer:%s\n",buffer);

	if( (temp = memmem(buffer,readBytes, delimeter, deli_len)) == NULL ){
			return 3;
	}
	left_len = readBytes;
	while( temp != NULL ){
		temp_nxt = memmem(temp+deli_len, left_len-deli_len, delimeter, deli_len);
		if(temp_nxt !=NULL){
			buffer_len = temp_nxt - temp;
		}
		else{
			buffer_len = left_len;
		}

		//printf("buffer_len:%d\n", buffer_len);
		recBuffer = (char *)malloc(sizeof(char) * buffer_len);
		memcpy(recBuffer, temp, buffer_len);
		//printf("---\n%s\n---\n", recBuffer);

		left_len = left_len - buffer_len;
		temp = temp_nxt;

		if( memmem(recBuffer, buffer_len, query, query_len)!=NULL ){
			leftBuffer = (char *)malloc(sizeof(char) * left_len);
			memcpy(leftBuffer, temp, left_len);

			if(flag == 1){
				recToWrite = editRecord(recBuffer, delimeter, deli_len, query, cntField);
				printf("recToWrite:%s\n", recToWrite);

				//printf("ftell:%d\n", ftell(fp));
				fseek(fp, readBuf_pos, SEEK_SET);
				//printf("ftell:%d\n", ftell(fp));
				fwrite(recToWrite, 1, strlen(recToWrite), fp);
				fwrite(leftBuffer, 1,left_len, fp);
				fclose(fp);
				return 0;
			}
			else if(flag == -1){
				recToWrite = editRecord_u(recBuffer, delimeter, deli_len, query, cntField);
				fseek(fp, readBuf_pos, SEEK_SET);
				fwrite(recToWrite, 1, strlen(recToWrite), fp);
				fwrite(leftBuffer, 1,left_len, fp);
				fclose(fp);
				return 0;
			}
			else{
				//printf("!!!!!!!!!!");
				getCount(recBuffer, delimeter, deli_len, query, cntField);
				fclose(fp);
				return 0;
			}
			//}
		}
		readBuf_pos = readBuf_pos + buffer_len;
	}

	fclose(fp);
	return 2;

}
Esempio n. 10
0
CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack,
    bool createAndDelete)
    : mUndoStack (undoStack), mCreateAction (0), mEditLock (false), mRecordStatusDisplay (0)
{
    mModel = &dynamic_cast<CSMWorld::IdTable&> (*data.getTableModel (id));

    mProxyModel = new CSMWorld::IdTableProxyModel (this);
    mProxyModel->setSourceModel (mModel);

    setModel (mProxyModel);
    horizontalHeader()->setResizeMode (QHeaderView::Interactive);
    verticalHeader()->hide();
    setSortingEnabled (true);
    setSelectionBehavior (QAbstractItemView::SelectRows);
    setSelectionMode (QAbstractItemView::ExtendedSelection);

    int columns = mModel->columnCount();

    for (int i=0; i<columns; ++i)
    {
        int flags = mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();

        if (flags & CSMWorld::ColumnBase::Flag_Table)
        {
            CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display> (
                mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());

            CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display,
                undoStack, this);

            mDelegates.push_back (delegate);
            setItemDelegateForColumn (i, delegate);
        }
        else
            hideColumn (i);
    }

    mEditAction = new QAction (tr ("Edit Record"), this);
    connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord()));
    addAction (mEditAction);

    if (createAndDelete)
    {
        mCreateAction = new QAction (tr ("Add Record"), this);
        connect (mCreateAction, SIGNAL (triggered()), this, SIGNAL (createRequest()));
        addAction (mCreateAction);
    }

    mRevertAction = new QAction (tr ("Revert Record"), this);
    connect (mRevertAction, SIGNAL (triggered()), this, SLOT (revertRecord()));
    addAction (mRevertAction);

    mDeleteAction = new QAction (tr ("Delete Record"), this);
    connect (mDeleteAction, SIGNAL (triggered()), this, SLOT (deleteRecord()));
    addAction (mDeleteAction);

    connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
        this, SLOT (tableSizeUpdate()));

    /// \note This signal could instead be connected to a slot that filters out changes not affecting
    /// the records status column (for permanence reasons)
    connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
        this, SLOT (tableSizeUpdate()));

    connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
        this, SLOT (selectionSizeUpdate ()));
}
void SizPostForm::saveRecord()
{
    editRecord();
    emit accept();
}
Esempio n. 12
0
int main()
{
  // próba po³±czenia
  PGconn *myconnection = PQconnectdb("host=localhost port=5432 dbname=myDb user=mateuszek password=mateuszek");
  //PGconn *myconnection = PQconnectdb("");
  // sprawdzamy status po³±czenia
  if(PQstatus(myconnection) == CONNECTION_OK) {
		printf("connection made\n");
		// informacje o po³±czeniu
		printf("PGDBNAME   = %s\n",PQdb(myconnection));
		printf("PGUSER     = %s\n",PQuser(myconnection));
		//printf("PGPASSWORD = %s\n",PQpass(myconnection));
		printf("PGPASSWORD = ********\n");
		printf("PGHOST     = %s\n",PQhost(myconnection));
		printf("PGPORT     = %s\n",PQport(myconnection));
		printf("OPTIONS    = %s\n",PQoptions(myconnection));
  }
  else{
	  printf("connection failed: %s\n", PQerrorMessage(myconnection));
	  // w razie utraty po³±czenia wywo³anie 
	  // PQreset(myconnection);
	  // zamyka op³±czenie i nawi±zuje je raz jeszcze  
	  // z dotychczasowymi parametrami
	  PQfinish(myconnection);
	  return EXIT_SUCCESS;
	}
  int k=1;
  int choice;
  while (k==1){
	  printf("wpisz: \n");
	  printf("\t '0': aby zakonczyc\n");
	  printf("\t '1' : aby utworzyc tabele\n");
	  printf("\t '2' : aby usunac tabele\n");
	  printf("\t '3' : aby dodac rekord\n");
	  printf("\t '4' : aby edytowac rekord\n");
	  printf("\t '6' : aby wyswietlic wszystkie rekordy\n");
	  printf("\t '7' : wyszukaj pracownika po dacie urodzenia\n");
	  printf("\t '8' : wyszukaj pracownika po stanowisku i nazwisku\n");
	  scanf("\t%d",&choice);
	  switch (choice){
		  case 1 :  system("clear");
					createTable(myconnection);
					break;
		  case 2 :  system("clear");
					dropTable(myconnection);
					break;
		  case 3 :  system("clear");
					addRecord(myconnection);
					break;
		  case 4 :	system("clear");
					editRecord(myconnection);
					break;		
		  case 5 :	system("clear");
					deleteRecord(myconnection);
					break;				
		  case 6 :  system("clear");
					showAllRecords(myconnection);
					break;					
					
		  case 7 :  system("clear");
					searchByBirthDate(myconnection);
					break;			
		  case 8 :  system("clear");
					searchByPosAndSalary(myconnection);
					break;		
		  default:  system("clear");
				    printf("Nieodpowiedni wybor ('%d').\n\n",choice);
	  }
   
  }
}
void PostSizTableForm::saveRecord()
{
    editRecord();
    emit accept();
}
Esempio n. 14
0
CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
    bool createAndDelete, bool sorting, CSMDoc::Document& document)
: mCreateAction (0), mCloneAction(0), mRecordStatusDisplay (0),
  DragRecordTable(document)
{
    mModel = &dynamic_cast<CSMWorld::IdTableBase&> (*mDocument.getData().getTableModel (id));

    mProxyModel = new CSMWorld::IdTableProxyModel (this);
    mProxyModel->setSourceModel (mModel);

    mDispatcher = new CSMWorld::CommandDispatcher (document, id, this);

    setModel (mProxyModel);
    horizontalHeader()->setResizeMode (QHeaderView::Interactive);
    verticalHeader()->hide();
    setSortingEnabled (sorting);
    setSelectionBehavior (QAbstractItemView::SelectRows);
    setSelectionMode (QAbstractItemView::ExtendedSelection);

    int columns = mModel->columnCount();

    for (int i=0; i<columns; ++i)
    {
        int flags = mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt();

        if (flags & CSMWorld::ColumnBase::Flag_Table)
        {
            CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display> (
                mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt());

            CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display,
                mDocument, this);

            mDelegates.push_back (delegate);
            setItemDelegateForColumn (i, delegate);
        }
        else
            hideColumn (i);
    }

    mEditAction = new QAction (tr ("Edit Record"), this);
    connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord()));
    addAction (mEditAction);

    if (createAndDelete)
    {
        mCreateAction = new QAction (tr ("Add Record"), this);
        connect (mCreateAction, SIGNAL (triggered()), this, SIGNAL (createRequest()));
        addAction (mCreateAction);

        mCloneAction = new QAction (tr ("Clone Record"), this);
        connect(mCloneAction, SIGNAL (triggered()), this, SLOT (cloneRecord()));
        addAction(mCloneAction);
    }

    mRevertAction = new QAction (tr ("Revert Record"), this);
    connect (mRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeRevert()));
    addAction (mRevertAction);

    mDeleteAction = new QAction (tr ("Delete Record"), this);
    connect (mDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeDelete()));
    addAction (mDeleteAction);

    mMoveUpAction = new QAction (tr ("Move Up"), this);
    connect (mMoveUpAction, SIGNAL (triggered()), this, SLOT (moveUpRecord()));
    addAction (mMoveUpAction);

    mMoveDownAction = new QAction (tr ("Move Down"), this);
    connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord()));
    addAction (mMoveDownAction);

    mViewAction = new QAction (tr ("View"), this);
    connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord()));
    addAction (mViewAction);

    mPreviewAction = new QAction (tr ("Preview"), this);
    connect (mPreviewAction, SIGNAL (triggered()), this, SLOT (previewRecord()));
    addAction (mPreviewAction);

    /// \todo add a user option, that redirects the extended action to an input panel (in
    /// the bottom bar) that lets the user select which record collections should be
    /// modified.

    mExtendedDeleteAction = new QAction (tr ("Extended Delete Record"), this);
    connect (mExtendedDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedDelete()));
    addAction (mExtendedDeleteAction);

    mExtendedRevertAction = new QAction (tr ("Extended Revert Record"), this);
    connect (mExtendedRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedRevert()));
    addAction (mExtendedRevertAction);

    connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
        this, SLOT (tableSizeUpdate()));

    /// \note This signal could instead be connected to a slot that filters out changes not affecting
    /// the records status column (for permanence reasons)
    connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
        this, SLOT (tableSizeUpdate()));

    connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
        this, SLOT (selectionSizeUpdate ()));

    setAcceptDrops(true);
}
Esempio n. 15
0
void viewFoundRecordsHelper(){
  while (1){
    while ((c=getkey()) == KEY_NOTHING);
    //    xt_par2(XT_SET_ROW_COL_POS, 18, 1);
    //    xt_par0(XT_ERASE_LINE);
    if (c == KEY_LEFT){
      if (numFoundRecords != 1){
	fi--;
	if (fi < 0)
	  fi = numFoundRecords-1;
	displayFoundRecords();
	break;
      }
    }
    else if (c == KEY_RIGHT){
      if (numFoundRecords != 1){
	fi++;
	if (fi == numFoundRecords)
	  fi = 0;
	displayFoundRecords();
	break;
      }
    }
    else if (c == KEY_F3){
      if (numFoundRecords > 0){
	int tempRecordCounter = numRecords;
	deleteRecordHelper();
	calculateNumRecords();
	if (numRecords < tempRecordCounter)
	  numFoundRecords--;
	//numRecords --;
	if (fi == numRecords)
	  fi--;
	displayFoundRecords();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to delete.");
      }
    }
    else if (c == KEY_F4){
      if (numRecords > 0)
	recordNum = 1;
      display();
      break;
    }
    else if (c == KEY_F5){
      findInputScreen();
      break;
    }
    else if (c == KEY_F6){
      if (numFoundRecords > 0){
	editRecord();
	//displayFoundRecords();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to edit.");
      }
    }
  }
  getkey_terminate();
}
Esempio n. 16
0
void viewRecordHelper(){
  while (1){
    while ((c=getkey()) == KEY_NOTHING);
    if (c == KEY_LEFT){
      if (numRecords != 1){
	recordNum --;
	if (recordNum <= 0)
	  recordNum = numRecords;
	display();
	break;
      }
    }
    else if (c == KEY_RIGHT){
      if (numRecords != 1){
	recordNum ++;
	if (recordNum == (numRecords + 1)){
	  if (numRecords > 0)
	    recordNum = 1;
	  else
	    recordNum = 0;
	}
	display();
	break;
      }
    }
    else if (c == KEY_F2){
      addRecord();
      break;
    }
    else if (c == KEY_F3){
      if (recordNum > 0){
	deleteRecordHelper();
	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to delete.");
      }
    }
    else if (c == KEY_F4){
      welcomeScreen();
      break;
    }
    else if (c == KEY_F5){
      if (recordNum > 0){
	deleteAllRecords();
	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No records to delete.");
      }
    }
    else if (c == KEY_F6){
      if (numRecords > 0){
	editRecord();
	//	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No record to edit.");
      }
    }
    
    else if (c == KEY_F7){
      if (numRecords > 0){
	findInputScreen();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("No records to search through.");
      }
    }
    else if (c == KEY_F9){
      if (numRecords > 0){
	recordNum = 1;
	display();
	break;
      }
      else{
	xt_par2(XT_SET_ROW_COL_POS, 18, 1);
	xt_par0(XT_ERASE_LINE);
	printf("There is no first record yet!");
      }
    }

  }
  getkey_terminate();
}
Esempio n. 17
0
TreatmentForm::TreatmentForm(QString id, QWidget *parent, bool onlyForRead) :
    QDialog(parent)
{
    readSettings();
    indexTemp = id;

    labelName = new QLabel(tr("Name:"));
    editName = new LineEdit;
    editName->setReadOnly(onlyForRead);
    QRegExp regExp("[\\x0410-\\x044f 0-9 \" -]{150}");
    editName->setValidator(new QRegExpValidator(regExp,this));
    labelName->setBuddy(editName);

    labelCost = new QLabel(tr("Cost:"));
    editCost = new LineEdit;
    QRegExp regCost("^([1-9][0-9]*|0)(\\.|,)[0-9]{2}");
    editCost->setValidator(new QRegExpValidator(regCost,this));

    saveButton = new QPushButton(tr("Save"));
    connect(saveButton,SIGNAL(clicked()),this,SLOT(editRecord()));
    saveButton->setToolTip(tr("Save And Close Button"));

    cancelButton = new QPushButton(tr("Cancel"));
    cancelButton->setDefault(true);
    cancelButton->setStyleSheet("QPushButton:hover {color: red}");
    connect(cancelButton,SIGNAL(clicked()),this,SLOT(accept()));
    cancelButton->setToolTip(tr("Cancel Button"));

    buttonBox = new QDialogButtonBox;
    buttonBox->addButton(cancelButton,QDialogButtonBox::ActionRole);
    buttonBox->addButton(saveButton,QDialogButtonBox::ActionRole);

    if(indexTemp != ""){
        QSqlQuery query;
        query.prepare("SELECT treatmentname, cost FROM treatment WHERE treatmentid = :id");
        query.bindValue(":id",indexTemp);
        query.exec();
        while(query.next()){
            editName->setText(query.value(0).toString());
            double tt = query.value(1).toDouble();
            editCost->setText(QString::number(tt,'f',2));
        }
    }else{
        editName->clear();
    }

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(labelName,0,0);
    mainLayout->addWidget(editName,0,1);
    if(!onlyForRead){
        mainLayout->addWidget(buttonBox,1,1);
        editName->selectAll();
    }

    setLayout(mainLayout);

    setWindowTitle(tr("Treatment"));

    exchangeFile.setFileName("exchange.txt");
    if(!exchangeFile.isOpen()){
        exchangeFile.open(QIODevice::ReadWrite);
    }
}