void EditorView::setPaper(int pid) { save(); p->signal_blocker = true; p->paperId = pid; Database *db = Kaqaz::database(); if( !p->paperId ) { p->title->setText(QString()); p->body->setText(QString()); p->body->setType(0); p->group->setGroup(0); p->date->setText(QString()); p->files->setPaper(0); p->signal_blocker = false; p->has_files = false; update(); return; } p->title->setText( db->paperTitle(pid) ); p->body->setText( db->paperText(pid) ); p->body->setType( db->paperType(pid) ); p->group->setGroup( db->paperGroup(pid) ); p->date->setText( "<font color=\"#888888\">" + Kaqaz::instance()->calendarConverter()->convertDateTimeToString(db->paperCreatedDate(pid)) + "</font>" ); p->files->setPaper(pid); p->synced = (db->revisionOf(db->paperUuid(pid))!=-1); p->attach_img = SImage(*paper_clip).colorize(db->groupColor(p->group->group()).rgba()); p->has_files = !db->paperFiles(pid).isEmpty(); p->signal_blocker = false; update(); }
ResourceId CResourceManager::createImage(const std::vector<unsigned char>& imageData, unsigned int width, unsigned int height, EColorFormat format) { // Create image ResourceId id = m_nextImageId; ++m_nextImageId; // TODO Sanity check if mesh id exists? // Add mesh m_images[id] = SImage(imageData, width, height, format); // Notify listener with create event notifyResourceListeners(EResourceType::Image, id, EListenerEvent::Create); return id; }
void EditorView::save() { if( p->title->text().isEmpty() && p->body->text().isEmpty() ) return; Database *db = Kaqaz::database(); if( p->paperId == 0 ) p->paperId = db->createPaper(); db->setSignalBlocker(true); db->setPaper( p->paperId, p->title->text(), p->body->text(), p->group->group() ); db->setSignalBlocker(false); p->attach_img = SImage(*paper_clip).colorize(db->groupColor(p->group->group()).rgba()); p->files->setPaper(p->paperId); emit saved(p->paperId); update(); }