/** Intializes the PartResizerWidget
	@param d the Device the Partition is on
	@param p the Partition to show and/or resize
	@param minFirst the minimum value for the first sector
	@param maxLast the maximum value for the last sector
*/
void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only, bool move_allowed)
{
    setDevice(d);
    setPartition(p);

    setMinimumFirstSector(minFirst);
    setMaximumLastSector(maxLast);

    setReadOnly(read_only);
    setMoveAllowed(move_allowed);

    setMinimumLength(qMax(partition().sectorsUsed(), partition().minimumSectors()));
    setMaximumLength(qMin(totalSectors(), partition().maximumSectors()));

    // set margins to accommodate to top/bottom button asymmetric layouts
    QStyleOptionButton bOpt;
    bOpt.initFrom(this);

    QRect buttonRect(style()->subElementRect(QStyle::SE_PushButtonContents, &bOpt));

    int asym = (rect().bottom() - buttonRect.bottom()) - (buttonRect.top() - rect().top());
    if (asym > 0)
        setContentsMargins(0, asym, 0, 0);
    else
        setContentsMargins(0, 0, 0, asym);

    if (!readOnly())
    {
        QPixmap pixmap(handleWidth(), handleHeight());
        pixmap.fill(Qt::transparent);
        QPainter p(&pixmap);
        QStyleOption opt;
        opt.state |= QStyle::State_Horizontal;
        opt.rect = pixmap.rect().adjusted(0, 2, 0, -2);
        style()->drawControl(QStyle::CE_Splitter, &opt, &p, this);

        leftHandle().setPixmap(pixmap);
        rightHandle().setPixmap(pixmap);

        leftHandle().setFixedSize(handleWidth(), handleHeight());
        rightHandle().setFixedSize(handleWidth(), handleHeight());
    }

    delete m_PartWidget;
    m_PartWidget = new PartWidget(this, &partition());

    if (!readOnly())
    {
        leftHandle().setCursor(Qt::SizeHorCursor);
        rightHandle().setCursor(Qt::SizeHorCursor);
    }

    if (moveAllowed())
        partWidget().setCursor(Qt::SizeAllCursor);

    partWidget().setToolTip(QString());

    updatePositions();
}
void CRichEditCtrlEx::PreSubclassWindow()
{
	CRichEditCtrl::PreSubclassWindow();
	SetBackgroundColor(FALSE, ::GetSysColor(COLOR_BTNFACE));
	disable();
	readOnly();
}
Esempio n. 3
0
void MSWidget::set(MSAttrValueList& avList_)
{
  MSIndexVector index;
  for (unsigned i=0;i<avList_.length();i++)
   {
     if (avList_[i].attribute()=="foreground")
      foreground(avList_[i].value()),index<<i;
     else if (avList_[i].attribute()=="background")
      background(avList_[i].value()),index<<i;
     else if (avList_[i].attribute()=="font")
      font(avList_[i].value()),index<<i;
     else if (avList_[i].attribute()=="acceptFocus")
      acceptFocus(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="dynamic")
      dynamic(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="sensitive")
      sensitive(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="readOnly")
      readOnly(avList_[i].value().asBoolean()),index<<i;
     else if (avList_[i].attribute()=="at")
      at(At(avList_[i].value())),index<<i;
     else if (avList_[i].attribute()=="resizeConstraints")
      resizeConstraints(avList_[i].value()),index<<i;
   } 
  avList_.remove(index);
}
Esempio n. 4
0
	bool Database::allowSweepThread(thread_db* tdbb)
	{
		if (readOnly())
			return false;

		Jrd::Attachment* const attachment = tdbb->getAttachment();
		if (attachment->att_flags & ATT_no_cleanup)
			return false;

		while (true)
		{
			AtomicCounter::counter_type old = dbb_flags;
			if ((old & (DBB_sweep_in_progress | DBB_sweep_starting)) || (dbb_ast_flags & DBB_shutdown))
				return false;

			if (dbb_flags.compareExchange(old, old | DBB_sweep_starting))
				break;
		}

		createSweepLock(tdbb);
		if (!LCK_lock(tdbb, dbb_sweep_lock, LCK_EX, LCK_NO_WAIT))
		{
			// clear lock error from status vector
			fb_utils::init_status(tdbb->tdbb_status_vector);

			dbb_flags &= ~DBB_sweep_starting;
			return false;
		}

		return true;
	}
Esempio n. 5
0
void TSShapeAlloc::align32()
{
   readOnly();

   S32 aligned = mSize+3 & (~0x3);
   allocShape8(aligned-mSize);
}
Esempio n. 6
0
int ShellServer::writeFile(ServerContext& s, void *hdl, const char *buffer, size_t length, off_t offset)
{
	shell_hdl_t *h = static_cast<shell_hdl_t *>(hdl);

	if (readOnly(s))
	{
		return -EPERM;
	}

	if (!h)
	{
		return -EBADF;
	}

	size_t size = h->contents.size();
	if (offset == (off_t) size)
	{
		h->contents.append(buffer, length);
	}
	else if (offset > (off_t) size)
	{
		// sparse file case
		off_t gap = offset + size;
		h->contents.assign(gap, 0);
		h->contents.append(buffer, length);
		h->dirty = true;
	}
	else
	{
		// simple replacement
		h->contents.assign(buffer, length, offset);
	}
	return (int) length;
}
Esempio n. 7
0
void TSShapeAlloc::doAlloc()
{
   readOnly();

   mDest = new S8[mSize];
   mSize = 0;
}
Esempio n. 8
0
void Questionnaire::doFinish()
{
    if (!readOnly()) {
        // *** mark task as finished, or whatever
    }
    emit completed();
    emit finished();
}
Esempio n. 9
0
void Questionnaire::doCancel()
{
    if (!readOnly()) {
        // *** mark task as cancelled, or whatever
    }
    emit cancelled();
    emit finished();
}
Esempio n. 10
0
template<> bool
QConsoleWidget::_pf<bool, SelectKeyPressedReadOnly>(
        QConsoleWidget * thisp,
        QKeyEvent * e) {

    auto key_ = e->key();

    switch (key_)
    {
    case Qt::Key_Shift:
    case Qt::Key_Control:
    case Qt::Key_Meta:
    case Qt::Key_Alt:
    case Qt::Key_CapsLock:
    case Qt::Key_NumLock:
    case Qt::Key_ScrollLock:
    case Qt::Key_Up:
    case Qt::Key_Down:
    case Qt::Key_Left:
    case Qt::Key_Right:
    case Qt::Key_PageDown:
    case Qt::Key_PageUp:
    case Qt::Key_Home:
    case Qt::Key_End:return false;
    }

    if (e->modifiers() & Qt::ControlModifier) {
        switch (key_)
        {
        case Qt::Key_C:
        case Qt::Key_A:return false;
        }
    }

    /*设置为readonly模式*/
    class OnlyRead {
    public:
        QConsoleWidget * __this;
        OnlyRead(QConsoleWidget * s):__this(s) {
            __this->setReadOnly(true);
        }
        ~OnlyRead() {
            __this->setReadOnly(false);
        }
    };

    if (key_==Qt::Key_Backspace) {
        OnlyRead readOnly(thisp);
        _pf<void, MoveToEnd>(thisp);
        thisp->TP::keyPressEvent(e);
    }
    else {
        _pf<void, MoveToEnd>(thisp);
        thisp->TP::keyPressEvent(e);
    }

    return true;
}
Esempio n. 11
0
int ShellServer::wstat(ServerContext& s, const char *path, file_stat_t& in, uint32_t mask)
{
	string_list_t args;
	string_map_t env = s.getEnv();
	process_io_t io;
	char out[32];
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	if ((mask & FS_SIZE) == FS_SIZE)
	{
		sprintf(out, "%ld", (long) in.fs_size);
		env["_size"] = in.fs_size;
	}

	if ((mask & FS_MODE) == FS_MODE)
	{
		sprintf(out, "0%o", (in.fs_mode & 04777));
		env["_mode"] = out;
	}

	if ((mask & FS_UID) == FS_UID)
	{
		sprintf(out, "%d", in.fs_uid);
		env["_uid"] = out;
	}

	if ((mask & FS_GID) == FS_GID)
	{
		sprintf(out, "%d", in.fs_gid);
		env["_gid"] = out;
	}

	if ((mask & FS_ATIME) == FS_ATIME)
	{
		sprintf(out, "%ld", (long) in.fs_atime);
		env["_atime"] = out;
	}

	if ((mask & FS_MTIME) == FS_MTIME)
	{
		sprintf(out, "%ld", (long) in.fs_mtime);
		env["_mtime"] = out;
	}

	if ((mask & FS_RENAME) == FS_RENAME)
	{
		env["_rename"] = in.fs_rename;
	}

	return caller(s, "wstat", args, env, io);
}
Esempio n. 12
0
bool Score::saveCompressedFile(QFileInfo& info, bool onlySelection)
      {
      if (readOnly() && info == *masterScore()->fileInfo())
            return false;
      QFile fp(info.filePath());
      if (!fp.open(QIODevice::WriteOnly)) {
            MScore::lastError = tr("Open File\n%1\nfailed: %2").arg(info.filePath(), strerror(errno));
            return false;
            }
      return saveCompressedFile(&fp, info, onlySelection);
      }
Esempio n. 13
0
int
MemoryServer::removeDir(ServerContext& s, const char *path)
{
	ASSERT(path);
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	return removeDirInternal(s, path);
}
Esempio n. 14
0
void Questionnaire::finishClicked()
{
    if (currentPageNumOneBased() != nPages()) {
        // Not on the last page; can't finish here
        return;
    }
    QuPagePtr page = currentPagePtr();
    if (!readOnly() && page->missingInput()) {
        // Can't progress
        return;
    }
    doFinish();
}
Esempio n. 15
0
void Questionnaire::nextClicked()
{
    if (currentPageNumOneBased() >= nPages()) {
        // On the last page; use finish rather than next
        return;
    }
    QuPagePtr page = currentPagePtr();
    if (!readOnly() && page->missingInput()) {
        // Can't progress
        return;
    }
    goToPage(m_current_pagenum_zero_based + 1);
}
Esempio n. 16
0
void Questionnaire::resetButtons()
{
    QuPagePtr page = currentPagePtr();
    if (!page || !m_p_header) {
        return;
    }
    bool on_last_page = currentPageNumOneBased() == nPages();
    bool allow_progression = readOnly() || !page->missingInput();
    m_p_header->setButtons(
        m_current_pagenum_zero_based > 0,  // previous
        !on_last_page && allow_progression,  // next
        on_last_page && allow_progression  // finish
    );
}
Esempio n. 17
0
int
MemoryServer::createMlink(ServerContext& s, const char *path, const char *link)
{
	ASSERT(path);
	ASSERT(link);
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	return createMlinkInternal(s, path, link);
}
Esempio n. 18
0
int
MemoryServer::createDir(ServerContext& s, const char *path, uint32_t mode)
{
	//TRACE();
	ASSERT(path);
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	return createDirInternal(s, path, mode);
}
Esempio n. 19
0
bool Score::saveFile(QFileInfo& info)
      {
      if (readOnly() && info == *masterScore()->fileInfo())
            return false;
      if (info.suffix().isEmpty())
            info.setFile(info.filePath() + ".mscx");
      QFile fp(info.filePath());
      if (!fp.open(QIODevice::WriteOnly)) {
            MScore::lastError = tr("Open File\n%1\nfailed: %2").arg(info.filePath(), strerror(errno));
            return false;
            }
      saveFile(&fp, false, false);
      fp.close();
      return true;
      }
Esempio n. 20
0
int
MemoryServer::createHlink(ServerContext& s, const char *path, const char *link)
{
	ASSERT(path);
	ASSERT(link);
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	//return ::link(path, link) < 0 ? -errno : 0;
	return -ENOSYS;
}
Esempio n. 21
0
MSAttrValueList& MSWidget::get(MSAttrValueList& avList_)
{
  MSStringVector aStringVector("MSFalse\nMSTrue");
  
  avList_<<MSAttrValue("foreground",_server->colorName(foreground()),MSAttrValue::Color);
  avList_<<MSAttrValue("background",_server->colorName(background()),MSAttrValue::Color);  
  avList_<<MSAttrValue("font",_server->fontName(font()),MSAttrValue::Font); 
  avList_<<MSAttrValue("acceptFocus",aStringVector(acceptFocus()),aStringVector);
  avList_<<MSAttrValue("sensitive",aStringVector(sensitive()),aStringVector);
  avList_<<MSAttrValue("readOnly",aStringVector(readOnly()),aStringVector);
  avList_<<MSAttrValue("dynamic",aStringVector(dynamic()),aStringVector);
  At aAt=at();
  avList_<<MSAttrValue("resizeConstraints",aAt.parsedConstraints(),MSAttrValue::String);  
  avList_<<MSAttrValue("at",aAt.asString(),MSAttrValue::String);
  avList_<<MSAttrValue("destroy","",MSAttrValue::Callback);
  avList_<<MSAttrValue("takefocus","",MSAttrValue::Callback);  
  return avList_;
}
Esempio n. 22
0
int MemoryServer::writeFile(ServerContext& s, void *handle, const char *buffer, size_t length, off_t offset)
{
	// TODO ENPSPC
	if (readOnly(s))
	{
		return -EPERM;
	}

	memory_node_t* node = NULL;
	if (!(handle && (node = static_cast<memory_node_t *>(handle))))
	{
		return -EBADF;
	}
	memory_node_t& n = *node;
	if (!n.write_mode)
	{
		return -EPERM;
	}
	size_t size = n.contents.size();
	if (offset == (off_t) size)
	{
		n.contents.append(buffer, length);
	}
	else if (offset > (off_t) size)
	{
		// sparse file case
		off_t gap = offset + size;
		n.contents.assign(gap, 0);
		n.contents.append(buffer, length);
	}
	else
	{
		// simple replacement
		n.contents.assign(buffer, length, offset);
	}
	
	size_t newsize = n.contents.size();
	int newblocks = (int) (newsize / m_fs_stat.f_block_size) + ((newsize % m_fs_stat.f_block_size) ? 1 : 0);
	int oldblocks = (int) size / m_fs_stat.f_block_size + ((size % m_fs_stat.f_block_size) ? 1 : 0);
	m_fs_stat.f_used_blocks += (newblocks - oldblocks);
	node->stat.fs_size = newsize;
	node->stat.fs_blocks = newblocks;
	return (int) length;
}
Esempio n. 23
0
KParts::Part* PartController::createPart( const KUrl & url, const QString& preferredPart )
{
    kDebug() << "creating part with url" << url << "and pref part:" << preferredPart;
    QString mimeType;
    if ( url.isEmpty() )
        //create a part for empty text file
        mimeType = QString::fromLatin1("text/plain");
    else if ( !url.isValid() )
        return 0;
    else
        mimeType = KMimeType::findByUrl( url )->name();

    KParts::Part* part = createPart( mimeType, preferredPart );
    if( part )
    {
        readOnly( part ) ->openUrl( url );
        return part;
    }

    return 0;
}
Esempio n. 24
0
int
MemoryServer::removeFile(ServerContext& s, const char *path)
{
	ASSERT(path);
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	memory_node_t *node = MemoryNode::find(static_cast<memory_node_t *>(s.getData(name())), path, true);

	if (node)
	{
		const char *name = base_name(path);
		memory_files_t::iterator it = node->kids.find(name);
		if (it == node->kids.end())
		{
			return -ENOENT;
		}
		if ((it->second->stat.fs_mode & S_IFDIR) || it->second->kids.size() > 0)
		{
			return -EISDIR;
		}
		size_t size = it->second->contents.size();
		delete it->second;
		it->second = NULL;
		node->kids.erase(name);
		node->stat.fs_nlink--;
		m_fs_stat.f_used_blocks--;
		m_fs_stat.f_used_inodes--;

		int blocks = (int) size / m_fs_stat.f_block_size + ((size % m_fs_stat.f_block_size) ? 1 : 0);
		m_fs_stat.f_used_blocks -= blocks;
		return 0;
	}
	return -ENOTDIR;
}
Esempio n. 25
0
bool
Property::setValue(as_object& this_ptr, const as_value& value) const
{
    if (readOnly(*this)) {
        if (_destructive) {
            _destructive = false;
            _bound = value;
            return true;
        }
        return false;
    }

	switch (_bound.which()) {
        case TYPE_VALUE: 
            _bound = value;
            return true;
        case TYPE_GETTER_SETTER:
            // Destructive are always overwritten.
            if (_destructive) {
                _destructive = false;
                _bound = value;
            }
            else {
                GetterSetter& a = boost::get<GetterSetter>(_bound);

                const as_environment env(getVM(this_ptr));

                fn_call::Args args;
                args += value;

                fn_call fn(&this_ptr, env, args);

                a.set(fn);
                a.setCache(value);
            }
    }
    return true;
}
Esempio n. 26
0
KParts::ReadOnlyPart* PartController::activeReadOnly() const
{
    return readOnly( activePart() );
}
Esempio n. 27
0
void SVGTransformList::clear()
{
	readOnly();
}
Esempio n. 28
0
int
MemoryServer::openFile(ServerContext& s, const char *path, void **handle, const char *flags, int mode)
{
	int posix_flags = decode_flags(flags);
	bool is_create = (strchr(flags, 'c') != NULL) ? true : false;

	if (is_create && readOnly(s))
	{
		return -EPERM;
	}

	memory_node_t *node = MemoryNode::find(static_cast<memory_node_t *>(s.getData(name())), path, is_create);
	(void) posix_flags;
	(void) s;
	(void) mode;

	if (node == NULL)
	{
		return -ENOENT;

	}
	if ((node->stat.fs_mode & S_IFDIR) && !is_create)
	{
		return -EISDIR;
	}

	if (is_create)
	{
		memory_node_t *child = new memory_node_t;
		ASSERT(child);

		child->delete_mode = false;
		child->read_mode = is_create || (strchr(flags, 'r') != NULL) ? true : false;
		child->write_mode = is_create || (strchr(flags, 'w') != NULL) ? true : false;
		child->name = base_name(path);
		child->stat.fs_ino = ++m_inode;;
		child->stat.fs_size = 0;
		child->stat.fs_blocks = 1;
		child->stat.fs_atime = child->stat.fs_mtime = child->stat.fs_ctime = time(0);
		child->stat.fs_mode = S_IFREG | mode;
		child->stat.fs_nlink = 0;
		child->stat.fs_uid = 65534;
		child->stat.fs_gid = 65534;
		child->stat.fs_blksize = 4096;
		node->kids[child->name] = child;
		node->stat.fs_nlink++;
		child->parent = node;
		m_fs_stat.f_used_blocks++;
		m_fs_stat.f_used_inodes++;
		node = child;
	}
	else
	{
		node->delete_mode = false;
		node->read_mode = (strchr(flags, 'r') != NULL) ? true : false;
		node->write_mode = (strchr(flags, 'w') != NULL) ? true : false;
	}

	*handle = node;
	return 0;
}
Esempio n. 29
0
int
MemoryServer::wstat(ServerContext& s, const char *path, file_stat_t& in, uint32_t mask)
{
	//TRACE();
	int result = 0;
	(void) s;

	if (readOnly(s))
	{
		return -EPERM;
	}

	memory_node_t *node = MemoryNode::find(static_cast<memory_node_t *>(s.getData(name())), path);
	if (node == NULL)
	{
		return -ENOENT;
	}
	memory_node_t& n = *node;
	file_stat_t& fs = node->stat;

	if ((mask & FS_SIZE) == FS_SIZE)
	{
		size_t oldsize = n.contents.size();
		if (oldsize < in.fs_size)
		{
			extend(n, in.fs_size);
			return 0;
		}
		else if (oldsize < in.fs_size)
		{
			return -EPERM;
		}
		fs.fs_size = in.fs_size;
		n.contents.resize(in.fs_size);
		size_t newsize = in.fs_size;
		int newblocks = (int) (newsize / m_fs_stat.f_block_size) + ((newsize % m_fs_stat.f_block_size) ? 1 : 0);
		int oldblocks = (int) oldsize / m_fs_stat.f_block_size + ((oldsize % m_fs_stat.f_block_size) ? 1 : 0);
		m_fs_stat.f_used_blocks += (newblocks - oldblocks);
	}

	if ((mask & FS_MODE) == FS_MODE)
	{
		fs.fs_mode &= ~04777;
		fs.fs_mode |= (in.fs_mode & 04777);
	}

	if ((mask & FS_UID) == FS_UID && (mask & FS_GID) == FS_GID)
	{
		fs.fs_uid = in.fs_uid;
		fs.fs_gid = in.fs_gid;
	}

	if ((mask & FS_ATIME) == FS_ATIME && (mask & FS_MTIME) == FS_MTIME)
	{
		fs.fs_mtime = in.fs_mtime;
		fs.fs_atime = in.fs_atime;
	}

	if ((mask & FS_RENAME) == FS_RENAME)
	{
		string newpath = in.fs_rename;
		string oldpath = path;
		string newdir;
		string olddir;
		string newname = base_name(newpath.c_str());
		string oldname = base_name(oldpath.c_str());
		dir_name(newpath.c_str(), newdir);
		dir_name(oldpath.c_str(), olddir);
		n.name = newname;
		memory_node_t *newparent = MemoryNode::find(static_cast<memory_node_t *>(s.getData(name())), newpath.c_str(), true);
		memory_node_t *oldparent = MemoryNode::find(static_cast<memory_node_t *>(s.getData(name())), oldpath.c_str(), true);
		if (newparent == NULL || oldparent == NULL)
		{
			return -ENOENT;
		}
		memory_node_t& np = *newparent;
		memory_node_t& op = *oldparent;
		np.kids[newname] = node;
		op.kids.erase(oldname);
	}

	return result;
}
Esempio n. 30
0
SVGTransform* SVGTransformList::initialize(SVGTransform* newItem)
{
	readOnly();
	return NULL;
}