void NotebookProperties::validateInput() { ok.setEnabled(true); if (name.text()=="") { ok.setEnabled(false); return; } NotebookTable t; QString notebook = name.text().trimmed(); if (t.findByName(notebook)>0 && name.text().trimmed() != originalName) { ok.setEnabled(false); return; } }
// Read in all of the data and build the menu. void NotebookMenuButton::loadData() { rootMenu.clear(); NotebookTable notebookTable; QList<qint32> lids; notebookTable.getAll(lids); if (notebookTable.findByName(currentNotebookName) <= 0) currentNotebookName = ""; for (qint32 i=0; i<lids.size(); i++) { Notebook book; if (notebookTable.get(book, lids[i])) { QAction *action = new QAction(this); actions.append(action); action->setText(QString::fromStdString(book.name)); action->setCheckable(true); connect(action, SIGNAL(triggered()), this, SLOT(notebookSelected())); QFont f = action->font(); f.setPixelSize(10); action->setFont(f); QMenu *currentMenu = findStack(book); addNotebookMenuItem(currentMenu, action); if (currentNotebookName == "" && book.__isset.defaultNotebook && book.defaultNotebook) { currentNotebookName = QString::fromStdString(book.name); setText(currentNotebookName); currentAction = actions.size()-1; } if (QString::fromStdString(book.name) == currentNotebookName) { action->setChecked(true); } } } }
void NotebookMenuButton::notebookSelected() { blockSignals(true); if (!actions[currentAction]->isChecked()) actions[currentAction]->setChecked(true); else { actions[currentAction]->setChecked(false); for (int i=0; i<actions.size(); i++) { if (actions[i]->isChecked()) { currentAction = i; i=actions.size(); } } } this->setText(actions[currentAction]->text()); blockSignals(false); NoteTable noteTable; NotebookTable notebookTable; QString name = text(); qint32 notebookLid = notebookTable.findByName(name); if (notebookLid > 0) { noteTable.updateNotebook(currentNoteLid, notebookLid, true); emit(notebookChanged()); } }
// Given a notebook's name as a std::string, we return the lid qint32 LinkedNotebookTable::findByName(string &name) { NotebookTable ntable; return ntable.findByName(name); }
//*********************************************************** //* Process a <notebook> node //*********************************************************** void ImportData::processNotebookNode() { Notebook notebook; bool notebookIsDirty = false; bool notebookIsLocal = false; bool notebookIsReadOnly = false; // notebookIcon = null; bool atEnd = false; // Loop through until we hit </notebook> while(!atEnd) { if (backup || importNotebooks) { if (reader->isStartElement()) { QString name = reader->name().toString().toLower(); if (name == "guid") { notebook.guid = textValue().toStdString(); notebook.__isset.guid = true; } if (name == "name") { notebook.name = textValue().toStdString(); notebook.__isset.name = true; } if (name == "updatesequencenumber") { notebook.updateSequenceNum = intValue(); notebook.__isset.updateSequenceNum = true; } if (name == "servicecreated") { notebook.serviceCreated = longValue(); notebook.__isset.serviceCreated = true; } if (name == "serviceupdated") { notebook.serviceUpdated = longValue(); notebook.__isset.serviceUpdated = true; } if (name == "defaultnotebook") { notebook.defaultNotebook = booleanValue(); notebook.__isset.defaultNotebook = true; } if (name == "dirty") { if (booleanValue()) notebookIsDirty = true; } if (name == "localnotebook") { if (booleanValue()) notebookIsLocal = true; } if (name == "readonly") { if (booleanValue()) notebookIsReadOnly = true; } if (name == "publishingpublicdescription") { notebook.publishing.publicDescription = textValue().toStdString(); notebook.publishing.__isset.publicDescription = true; } if (name == "publishinguri") { notebook.publishing.uri = textValue().toStdString(); notebook.publishing.__isset.uri = true; } if (name == "publishingorder") { //notebook->publishing.order = // NoteSortOrder.; QLOG_DEBUG() << "!!!!!!!!!!!! PublishingOrder not completed in import"; } if (name == "PublishingAscending") { if (booleanValue()) notebook.publishing.ascending = true; else notebook.publishing.ascending = false; notebook.publishing.__isset.ascending = true; } if (name == "icon") { //byte[] b = textValue().getBytes(); // data binary //QByteArray hexData = new QByteArray(b); //QByteArray binData = new QByteArray(QByteArray.fromHex(hexData)); //notebookIcon = new QIcon(QPixmap.fromImage(QImage.fromData(binData))); } if (name == "stack") { notebook.stack = textValue().toStdString(); notebook.__isset.stack = true; } } } reader->readNext(); QString endName = reader->name().toString().toLower(); if (endName == "notebook" && reader->isEndElement()) atEnd = true; } // We are at the end. We should have a valid notebook now NotebookTable notebookTable; // Check if there is a notebook by this name already. // If one exists, we treat this as an update qint32 lid = notebookTable.findByName(notebook.name); if (lid == 0) lid = notebookTable.getLid(notebook.guid); if (lid == 0) { notebookTable.add(lid,notebook,notebookIsDirty, notebookIsLocal); } else { notebookTable.sync(lid, notebook); notebookTable.setDirty(lid, notebookIsDirty); } return; }