Ejemplo n.º 1
0
static UA_StatusCode
UA_NodeMap_replaceNode(void *context, UA_Node *node) {
    UA_NodeMap *ns = (UA_NodeMap*)context;
    BEGIN_CRITSECT(ns);

    /* Find the node */
    UA_NodeMapEntry **slot = findOccupiedSlot(ns, &node->nodeId);
    if(!slot) {
        END_CRITSECT(ns);
        return UA_STATUSCODE_BADNODEIDUNKNOWN;
    }
    UA_NodeMapEntry *newEntryContainer = container_of(node, UA_NodeMapEntry, node);
    UA_NodeMapEntry *oldEntryContainer = *slot;

    /* The node was already updated since the copy was made? */
    if(oldEntryContainer != newEntryContainer->orig) {
        deleteEntry(newEntryContainer);
        END_CRITSECT(ns);
        return UA_STATUSCODE_BADINTERNALERROR;
    }

    /* Replace the entry with an atomic operation */
    if(UA_atomic_cmpxchg((void**)slot, oldEntryContainer,
                         newEntryContainer) != oldEntryContainer) {
        deleteEntry(newEntryContainer);
        END_CRITSECT(ns);
        return UA_STATUSCODE_BADINTERNALERROR;
    }

    oldEntryContainer->deleted = true;
    cleanupEntry(oldEntryContainer);
    END_CRITSECT(ns);
    return UA_STATUSCODE_GOOD;
}
Ejemplo n.º 2
0
bool RollingValueStore::declareKey(char* key,int numSamples)
{
	RollingValueStoreEntry* current;
	bool exists = store->get(key,(void**)&current,RollingValue);

	RollingValueStoreEntry* newEntry=newEntry = createEntry(numSamples);
	bool isSuccess = store->put(key,newEntry,RollingValue);
	if(isSuccess)
	{
		//free the memory of the earlier entry if it exists
		if(exists) {
			deleteEntry(current);
		}

		return true;
	}
	else
	{
		//could not add the rolling value to the store so free the memory
		deleteEntry(newEntry);
		return false;

	}


}
Ejemplo n.º 3
0
/**
 * Removes the given entry and all its child entries from the tree.
 *
 * @param entry The entry to be removed.
 */
void CBspTree::deleteEntry(TBspEntry* entry)
{
  if (entry->left != NULL)
    deleteEntry(entry->left);
  if (entry->right != NULL)
    deleteEntry(entry->right);

  delete entry;
}
Ejemplo n.º 4
0
bool OpenAddressingTable::insert(uint64_t table, uint64_t key, void* data, void** actualData /* = nullptr */) {
    checkDataKey(table, key);
    checkDataPtr(data);

    auto hash = calculateHash(table, key);
    for (auto pos = hash; pos < (hash + mCapacity); ++pos) {
        auto& entry = mBuckets[pos % mCapacity];
        auto ptr = entry.ptr.load();

        // Check if pointer is already acquired (i.e. not a deletion and not free) - Skip bucket if it is
        // There is no need to check if the insertion will conflict as this will be resolved at a later time.
        if ((ptr != (crossbow::to_underlying(EntryMarker::DELETED))
                && (ptr != crossbow::to_underlying(EntryMarker::FREE)))) {
            continue;
        }

        // Try to claim this bucket by setting the pointer to inserting
        // If this fails somebody else claimed the bucket in the mean time
        auto insertPtr = (reinterpret_cast<uintptr_t>(data) | crossbow::to_underlying(EntryMarker::INSERTING));
        if (!entry.ptr.compare_exchange_strong(ptr, insertPtr)) {
            continue;
        }

        // Write the key and table information
        // Table has to be written last as it is read last by readers to detect if key was written correctly
        entry.keyId.store(key);
        entry.tableId.store(table);

        // Check if another insert conflicts with ours
        // If this fails somebody else is inserting or has already inserted the same key, set pointer to invalid and
        // free bucket.
        if (hasInsertConflict(hash, pos, table, key, actualData)) {
            entry.ptr.store(crossbow::to_underlying(EntryMarker::INVALID));
            deleteEntry(entry);
            return false;
        }

        // Try to set the pointer from null or deleted to our data pointer
        // If this fails somebody else set the element to invalid and the bucket has to be released
        if (!entry.ptr.compare_exchange_strong(insertPtr, reinterpret_cast<uintptr_t>(data))) {
            deleteEntry(entry);

            if (actualData) *actualData = nullptr;
            return false;
        }

        return true;
    }

    LOG_ERROR("Hash table is full");
    return false;
}
Ejemplo n.º 5
0
/**
 * Removes all entries from the tree.
 */
void CBspTree::clear(void)
{
  if (FRoot.left != NULL)
  {
    deleteEntry(FRoot.left);
    FRoot.left = NULL;
  };
  if (FRoot.right != NULL)
  {
    deleteEntry(FRoot.right);
    FRoot.right = NULL;
  };
}
Ejemplo n.º 6
0
inline extern void deleteDir (char *pattern) {
  struct dirEntryStruct *entry;
  entryIndex_t entryIndex = 0;

  while ((entry = getEntry (entryIndex++))) {
    /* only process non-deleted dirs */
    if (entry->startBlock) {
      /* only delete dirs that match pattern */
      if (filenameMatch (entry->fileName, pattern)) {
        block_t blockWithEntry = dirBufferBlock;

        /* only delete dirs */
        if (entry->fileType == DIR) {
          getBlock (entry->startBlock);
          /* only delete empty dirs */
          if (!getUsedEntryInCurrentBlock()) {
            /* delete directory */
            getBlock (blockWithEntry);
            freeBlock (entry->startBlock);
            deleteEntry (entry);
            flushDirBuffer();
            flushFreeBlockList();
            /* begin counting at 0 because direntries may have been moved */
            entryIndex = 0;
          }
        }
      }
    }
  }
}
Ejemplo n.º 7
0
void cmd_purge(char* key){
	entry *currentEntry = getEntry(key);
	snapshot *currentSnapshot = snapshot_head;
	if(currentEntry != NULL){
		deleteEntry(currentEntry);
	}
	while (currentSnapshot != NULL){
		currentEntry = currentSnapshot->entries;
		while(currentEntry != NULL){
			if(strcmp(key, currentEntry->key) == 0){
				deleteAllValue(currentEntry->values);
				if(currentSnapshot->entries == currentEntry){
					currentSnapshot->entries = currentEntry->next;
					currentEntry->next->prev = NULL;
				}else{
					currentEntry->prev->next = currentEntry->next;
					currentEntry->next->prev = currentEntry->prev;
				}
				free(currentEntry);
			}
			currentEntry = currentEntry->next;
		}
		currentSnapshot = currentSnapshot->next;
	}
	printf("ok\n");
}
Ejemplo n.º 8
0
	bool doRedo()
	{
		if (!created)
			return deleteEntry();
		else
			return createEntry();
	}
Ejemplo n.º 9
0
	bool doUndo()
	{
		if (created)
			return deleteEntry();
		else
			return createEntry();
	}
Ejemplo n.º 10
0
void CPlainWriteWindow::initActions() {
    insertKeyboardActions(actionCollection());

    QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
    Q_ASSERT(action != 0);
    bool ok = QObject::connect(action, SIGNAL(triggered()),
                               this,   SLOT(saveCurrentText()));
    Q_ASSERT(ok);

    action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
    Q_ASSERT(action != 0);
    ok = QObject::connect(action, SIGNAL(triggered()),
                          this,   SLOT(saveCurrentText()));
    Q_ASSERT(ok);

    action = actionCollection()->action(CResMgr::displaywindows::writeWindow::deleteEntry::actionName);
    Q_ASSERT(action != 0);
    ok = QObject::connect(action, SIGNAL(triggered()),
                          this,   SLOT(deleteEntry()));
    Q_ASSERT(ok);

    action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
    Q_ASSERT(action != 0);
    ok = QObject::connect(action, SIGNAL(triggered()),
                          this,   SLOT(restoreText()));
    Q_ASSERT(ok);
}
Ejemplo n.º 11
0
static UA_StatusCode
UA_NodeMap_getNodeCopy(void *context, const UA_NodeId *nodeid,
                       UA_Node **outNode) {
    UA_NodeMap *ns = (UA_NodeMap*)context;
    BEGIN_CRITSECT(ns);
    UA_NodeMapEntry **slot = findOccupiedSlot(ns, nodeid);
    if(!slot) {
        END_CRITSECT(ns);
        return UA_STATUSCODE_BADNODEIDUNKNOWN;
    }
    UA_NodeMapEntry *entry = *slot;
    UA_NodeMapEntry *newItem = newEntry(entry->node.nodeClass);
    if(!newItem) {
        END_CRITSECT(ns);
        return UA_STATUSCODE_BADOUTOFMEMORY;
    }
    UA_StatusCode retval = UA_Node_copy(&entry->node, &newItem->node);
    if(retval == UA_STATUSCODE_GOOD) {
        newItem->orig = entry; // store the pointer to the original
        *outNode = &newItem->node;
    } else {
        deleteEntry(newItem);
    }
    END_CRITSECT(ns);
    return retval;
}
Ejemplo n.º 12
0
void AddressBook::createActions()
{
    exitAction = new QAction(tr("E&xit"), this);
    exitAction->setShortcut(tr("Ctrl+Q"));
    exitAction->setStatusTip(tr("Exit the application"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    addEntryAction = new QAction(tr("&Add Entry..."), this);
    addEntryAction->setShortcut(tr("Ins"));
    addEntryAction->setStatusTip(tr("Add a new entry to the address "
                                    "book"));
    connect(addEntryAction, SIGNAL(triggered()),
            this, SLOT(addEntry()));

    editEntryAction = new QAction(tr("&Edit Entry..."), this);
    editEntryAction->setShortcut(tr("F2"));
    editEntryAction->setStatusTip(tr("Edit the current address book "
                                     "entry"));
    connect(editEntryAction, SIGNAL(triggered()),
            this, SLOT(editEntry()));

    deleteEntryAction = new QAction(tr("&Delete Entry"), this);
    deleteEntryAction->setShortcut(QKeySequence::Delete);
    deleteEntryAction->setStatusTip(tr("Delete the current address "
                                       "book entry"));
    connect(deleteEntryAction, SIGNAL(triggered()),
            this, SLOT(deleteEntry()));
}
void ChangeJournalWatcher::deleteWithChildren(_i64 frn, _i64 rid)
{
	std::vector<_i64> children=getChildren(frn, rid);
	deleteEntry(frn, rid);
	for(size_t i=0;i<children.size();++i)
	{
		deleteWithChildren(children[i], rid);
	}
}
Ejemplo n.º 14
0
int getFonctionMenu (unsigned char c, struct Entry *entry, int *nbrOfEntry, int *selected, char *passfilePath)
{
    switch (c)
    {
        case 'q':
            endwin();
            return 2;
        
        case '?':
            windowHelp();
            windowBasic(entry, *nbrOfEntry, selected, c);
            break;

        case ' ':
            displayDetail(entry[*selected], selected);
            windowBasic(entry, *nbrOfEntry, selected, c);
            break;

        case 'j':
            if(*selected < *nbrOfEntry)
                *selected = *selected + 1;
            windowBasic(entry, *nbrOfEntry, selected, c);
            break;

        case 'k':
            if(*selected >= 1)
                *selected = *selected - 1;
            windowBasic(entry, *nbrOfEntry, selected, c);
            break;

        case 'd':
            if(confirmationWindow() == 1)
                deleteEntry(selected, entry, nbrOfEntry, passfilePath);
            int row; row = 0;
            int col; col = 0;
            getmaxyx(stdscr, row, col);
            
            if(*nbrOfEntry <= (row -5))
            {
                /* if the one deleted is the last one   */
                if(*selected >= *nbrOfEntry)
                    *selected = *nbrOfEntry;
            }
            windowBasic(entry, *nbrOfEntry, selected, c);
            break;

        case 'a':
            addEntry(selected, entry, nbrOfEntry, passfilePath);
            windowBasic(entry, *nbrOfEntry, selected, c);
            break;

        default:
            windowBasic(entry, *nbrOfEntry, selected, c);
            break;
    }
return 0;
}
Ejemplo n.º 15
0
Boolean BasicHashTable::Remove(char const* key) {
  unsigned index;
  TableEntry* entry = lookupKey(key, index);
  if (entry == NULL) return False; // no such entry

  deleteEntry(index, entry);

  return True;
}
Ejemplo n.º 16
0
void cmd_del(char* key){
	entry *entry = getEntry(key);
	if(entry != NULL){
		deleteEntry(entry);
		printf("ok\n");
		return;
	}
	printf("no such key\n");
}
Ejemplo n.º 17
0
void UA_NodeStore_delete(UA_NodeStore *ns) {
    UA_UInt32 size = ns->size;
    UA_NodeStoreEntry **entries = ns->entries;
    for(UA_UInt32 i = 0; i < size; i++) {
        if(entries[i])
            deleteEntry(entries[i]);
    }
    UA_free(ns->entries);
    UA_free(ns);
}
Ejemplo n.º 18
0
void cmd_checkout(int id){
	snapshot* checkoutSnapshot = getSnapshot(id);
	entry* currentEntry = entry_head;
	entry* previousEntry;
	entry* duplicateEntry;

	if(checkoutSnapshot == NULL){
		printf("no such snapshot\n");
		return;
	}

	while(currentEntry != NULL){
		previousEntry = currentEntry;
		currentEntry = currentEntry->next;
		deleteEntry(previousEntry);
	}
	currentEntry = checkoutSnapshot->entries;
	
	while(currentEntry != NULL){
		value *currentValue, *duplicateValue = NULL;

		entry* newEntry = (entry*)malloc(sizeof(*newEntry));
		strcpy(newEntry->key, currentEntry->key);
		newEntry->next = NULL;
		newEntry->prev = NULL;
		newEntry->values = NULL;
		if(currentEntry->prev == NULL){
			newEntry->prev = NULL;
			entry_head = newEntry;
		}else{
			newEntry->prev = duplicateEntry;
			duplicateEntry->next = newEntry;
		}
		duplicateEntry = newEntry;
		currentValue = currentEntry->values;
		
		while(currentValue != NULL){
			value* newValue = (value*)malloc(sizeof(*newValue));
			newValue->value = currentValue->value;
			newValue->next = NULL;
			newValue->prev = NULL;
			if(currentValue->prev == NULL){
				newEntry->values = newValue;
			}else{
				newValue->prev = duplicateValue;
				duplicateValue->next = newValue;
			}
			duplicateValue = newValue;
			currentValue = currentValue->next;
		}
		currentEntry = currentEntry->next;
	}
	entry_tail = duplicateEntry;
	printf("ok\n");
}
Ejemplo n.º 19
0
void KexiCSVExportWizard::done(int result)
{
    if (QDialog::Accepted == result) {
        if (m_fileSavePage)
            m_options.fileName = m_fileSavePage->selectedFile();
        m_options.delimiter = m_delimiterWidget->delimiter();
        m_options.textQuote = m_textQuote->textQuote();
        m_options.addColumnNames = m_addColumnNamesCheckBox->isChecked();
        if (!KexiCSVExport::exportData(*m_tableOrQuery, m_options))
            return;
    } else if (QDialog::Rejected == result) {
        //nothing to do
    }

    //store options
    if (m_options.mode != KexiCSVExport::Clipboard)
        writeEntry("ShowOptionsInCSVExportDialog", m_exportOptionsSection->isVisible());
    const bool store = m_alwaysUseCheckBox->isChecked();
    writeEntry("StoreOptionsForCSVExportDialog", store);
    // only save if an option differs from default

    if (store && m_delimiterWidget->delimiter() != defaultDelimiter())
        writeEntry("DefaultDelimiterForExportingCSVFiles", m_delimiterWidget->delimiter());
    else
        deleteEntry("DefaultDelimiterForExportingCSVFiles");
    if (store && m_textQuote->textQuote() != defaultTextQuote())
        writeEntry("DefaultTextQuoteForExportingCSVFiles", m_textQuote->textQuote());
    else
        deleteEntry("DefaultTextQuoteForExportingCSVFiles");
    if (store && !m_characterEncodingCombo->defaultEncodingSelected())
        writeEntry(
            "DefaultEncodingForExportingCSVFiles", m_characterEncodingCombo->selectedEncoding());
    else
        deleteEntry("DefaultEncodingForExportingCSVFiles");
    if (store && !m_addColumnNamesCheckBox->isChecked())
        writeEntry(
            "AddColumnNamesForExportingCSVFiles", m_addColumnNamesCheckBox->isChecked());
    else
        deleteEntry("AddColumnNamesForExportingCSVFiles");

    K3Wizard::done(result);
}
Ejemplo n.º 20
0
static void
UA_NodeMap_deleteNode(void *context, UA_Node *node) {
#ifdef UA_ENABLE_MULTITHREADING
    UA_NodeMap *ns = (UA_NodeMap*)context;
#endif
    BEGIN_CRITSECT(ns);
    UA_NodeMapEntry *entry = container_of(node, UA_NodeMapEntry, node);
    UA_assert(&entry->node == node);
    deleteEntry(entry);
    END_CRITSECT(ns);
}
Ejemplo n.º 21
0
UA_StatusCode UA_NodeStore_remove(UA_NodeStore *ns, const UA_NodeId *nodeid) {
    UA_NodeStoreEntry *slot;
    if(!containsNodeId(ns, nodeid, &slot))
        return UA_STATUSCODE_BADNODEIDUNKNOWN;
    deleteEntry(slot);
    ns->count--;
    /* Downsize the hashmap if it is very empty */
    if(ns->count * 8 < ns->size && ns->size > 32)
        expand(ns); // this can fail. we just continue with the bigger hashmap.
    return UA_STATUSCODE_GOOD;
}
Ejemplo n.º 22
0
BasicHashTable::~BasicHashTable() {
  // Free all the entries in the table:
  for (unsigned i = 0; i < fNumBuckets; ++i) {
    TableEntry* entry;
    while ((entry = fBuckets[i]) != NULL) {
      deleteEntry(i, entry);
    }
  }

  // Also free the bucket array, if it was dynamically allocated:
  if (fBuckets != fStaticBuckets) delete[] fBuckets;
}
Ejemplo n.º 23
0
/**
 * Find first fit block
 **/
block* firstFit(int size)
{
	int minSize = sizeof(block);
	if (size < minSize)
		size = minSize;
	pageHeader* header = (pageHeader*)(mainPage->ptr);
	block* cursor = (block*)(header->head);

	while (cursor)
	{
		// no enough size
		if (cursor->size < size)
		{
			cursor = cursor->next;
			continue;
		}
		// perfect fit
		else if (cursor->size == size || (cursor->size - size) < minSize)
		{
			deleteEntry(cursor);
			return (void*)cursor;
		}
		// fit, add fragement to the linked list
		else
		{
			addEntry((void*)((long int)cursor + size), (cursor->size - size));
			deleteEntry(cursor);
			return (void*)cursor;
		}
	}
	// no enough space, then add a new page
	kma_page_t* newPage = get_page();
	initPage(newPage);
	header->pageCount++;
	return firstFit(size);
}
Ejemplo n.º 24
0
UA_StatusCode
UA_NodeStore_replace(UA_NodeStore *ns, UA_Node *oldNode,
                     UA_Node *node, UA_Node **inserted) {
    UA_NodeStoreEntry *slot;
    if(!containsNodeId(ns, &node->nodeId, &slot))
        return UA_STATUSCODE_BADNODEIDUNKNOWN;
    /* that is not the node you are looking for */
    if(&slot->node.node != oldNode)
        return UA_STATUSCODE_BADINTERNALERROR;
    deleteEntry(slot);
    fillEntry(slot, node);
    if(inserted)
        *inserted = &slot->node.node;
    return UA_STATUSCODE_GOOD;
}
Ejemplo n.º 25
0
bool OpenAddressingTable::erase(uint64_t table, uint64_t key, const void* oldData, void** actualData /* = nullptr */) {
    checkDataKey(table, key);
    checkDataPtr(oldData);

    return execOnElement(table, key, true, [table, key, oldData, actualData] (Entry& entry, const void* /* ptr */) {
        auto expected = reinterpret_cast<uintptr_t>(oldData);
        if (entry.ptr.compare_exchange_strong(expected, crossbow::to_underlying(EntryMarker::INVALID))) {
            deleteEntry(entry);
            return true;
        }

        setActualData(table, key, actualData, entry, expected);
        return false;
    });
}
Ejemplo n.º 26
0
PageItemAttributes::PageItemAttributes( QWidget* parent, const char* name, bool modal, Qt::WFlags fl )
	: QDialog(parent, fl)
{
	setupUi(this);
	setModal(modal);
	relationships << tr("None", "relationship") << tr("Relates To") << tr("Is Parent Of") << tr("Is Child Of");
	relationshipsData << "none" << "relation" << "parent" << "child";

	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
	connect(okButton, SIGNAL(clicked()), this, SLOT(okClicked()));
	connect(attributesTable, SIGNAL(cellChanged(int,int)), this, SLOT(tableItemChanged(int,int)));
	connect(addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
	connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteEntry()));
	connect(clearButton, SIGNAL(clicked()), this, SLOT(clearEntries()));
	connect(copyButton, SIGNAL(clicked()), this, SLOT(copyEntry()));
}
Ejemplo n.º 27
0
int deleteFile (char *pattern) {
  struct dirEntryStruct *entry;
  entryIndex_t entryIndex = 0;
 int count =0;
  while ((entry = getEntry (entryIndex++))) {
		/* only process non-deleted files */
		if (entry->startBlock) {
		/* only delete files that match pattern */
			if (filenameMatch (entry->fileName, pattern)) {
				/* only delete non-locked files */
				if ((entry->fileType != DIR) && !(entry->readOnly)) {
					block_t tmpBufferBlock;
					bufferSize_t tmpBufferPtr;
					/* get inode of file to delete */
					ATTENTION_OFF();
					tmpBufferBlock = entry->startBlock;
					//ataGetBlock (tmpBufferBlock, tmpBuffer);
					tmpBufferPtr = 0;
					/* free all blocks belonging to file */
					while (entry->fileSize) {
						//  if at the end of inode, get next inode 
						if (tmpBufferPtr == (BLOCKSIZE / sizeof (block_t)) - 1) {
							freeBlock (tmpBufferBlock);
							tmpBufferBlock = ((block_t *)tmpBuffer)[tmpBufferPtr];
							//ataGetBlock (tmpBufferBlock, tmpBuffer);//get next block
							tmpBufferPtr = 0;
						}
						// free block 
						freeBlock (((block_t *)tmpBuffer)[tmpBufferPtr++]);
						entry->fileSize--;
					}
					/* free last inode block */
					freeBlock (tmpBufferBlock);
					/* remove entry from directory */
					deleteEntry (entry);
					flushDirBuffer();
					flushFreeBlockList();
					count ++;
					/* begin counting at 0 because direntries may have been moved */
					entryIndex = 0;
				}ATTENTION_ON();
			}
		}
		
	}
	return count; 
}
Ejemplo n.º 28
0
DocumentItemAttributes::DocumentItemAttributes(  QWidget* parent, Qt::WFlags fl  )
	: QWidget(parent, fl)
{
	setupUi(this);
	relationships << tr("None", "relationship") << tr("Relates To") << tr("Is Parent Of") << tr("Is Child Of");
	relationshipsData << "none" << "relation" << "parent" << "child";
	autoAddTo << tr("None", "auto add") << tr("Text Frames") << tr("Image Frames");
	autoAddToData << "none" << "textframes" << "imageframes";
	types << tr("None", "types") << tr("Boolean") << tr("Integer") << tr("Real Number") << tr("String");
	typesData << "none" << "boolean" << "integer" << "double" << "string";

	connect(attributesTable, SIGNAL(cellChanged(int,int)), this, SLOT(tableItemChanged(int,int)));
	connect(addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
	connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteEntry()));
	connect(clearButton, SIGNAL(clicked()), this, SLOT(clearEntries()));
	connect(copyButton, SIGNAL(clicked()), this, SLOT(copyEntry()));
}
Ejemplo n.º 29
0
void
LedgerDelta::mergeEntries(LedgerDelta& other)
{
    checkState();
    for (auto& d : other.mDelete)
    {
        deleteEntry(d);
    }
    for (auto& n : other.mNew)
    {
        addEntry(n.second);
    }
    for (auto& m : other.mMod)
    {
        modEntry(m.second);
    }
}
Ejemplo n.º 30
0
DialogDeleteEntry::DialogDeleteEntry(QWidget* parent)
                 : QDialog(parent)
{
    setWindowIcon(QIcon(":/images/remove_entry.png"));
    setWindowTitle("Remove entry");

    QVBoxLayout* mainLayout = new QVBoxLayout();

    modelEntry = new QSqlQueryModel();
    modelEntry->setQuery("SELECT group_name, real_name, id_entry, category.name, active_entries.entry_id FROM mod_entry_summary, category, active_entries WHERE category.category_id = mod_entry_summary.category_id AND id_entry = active_entries.entry_id");
    //summaryModelUnassigned->setHeaderData(0, Qt::Horizontal, tr("Order"));
    modelEntry->setHeaderData(0, Qt::Horizontal, tr("Group"));
    modelEntry->setHeaderData(1, Qt::Horizontal, tr("Real name 1"));
    modelEntry->setHeaderData(3, Qt::Horizontal, tr("Category"));

    viewEntry = new QTableView();
    //connect(summaryViewUnassigned,SIGNAL(clicked(const QModelIndex&)),this,SLOT(entrySelected(const QModelIndex&)));
    viewEntry->setModel(modelEntry);
    //summaryViewUnassigned->setColumnHidden(0,true);
    viewEntry->setColumnHidden(2,true);
    //summaryViewUnassigned->setColumnHidden(4,true);
    viewEntry->show();
    //summaryViewUnassigned->setMaximumWidth(400);
    mainLayout->addWidget(viewEntry);
    permaDelete = new QCheckBox("Delete permanently?");
    mainLayout->addWidget(permaDelete);
    QPushButton* delButton = new QPushButton(QIcon(":/images/graveyard2.png"),"Delete entry");
    delButton->setIconSize(QSize(48,48));
    delButton->setToolTip("Delete the entry.");
    connect(delButton,SIGNAL(clicked()),this,SLOT(deleteEntry()));
    QHBoxLayout* btnLayout = new QHBoxLayout();
    btnLayout->addWidget(delButton);
    btnLayout->addStretch();
    mainLayout->addLayout(btnLayout);

    QDialogButtonBox* buttonBox = new QDialogButtonBox();
    buttonBox->addButton(QDialogButtonBox::Close);
    connect(buttonBox,SIGNAL(accepted()),this,SLOT(accept()));
    connect(buttonBox,SIGNAL(rejected()),this,SLOT(reject()));
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);
    loadSettings();
}