Example #1
0
MythDialog* StorageGroupEditor::dialogWidget(MythMainWindow* parent,
                                          const char* widgetName)
{
    dialog = ConfigurationDialog::dialogWidget(parent, widgetName);
    connect(dialog, SIGNAL(menuButtonPressed()), this, SLOT(doDelete()));
    connect(dialog, SIGNAL(deleteButtonPressed()), this, SLOT(doDelete()));
    return dialog;
}
void IDBDatabaseBackendImpl::deleteObjectStoreInternal(ScriptExecutionContext*, PassRefPtr<IDBDatabaseBackendImpl> database, PassRefPtr<IDBObjectStoreBackendImpl> objectStore, PassRefPtr<IDBTransactionBackendInterface> transaction)
{
    doDelete(database->sqliteDatabase(), "DELETE FROM ObjectStores WHERE id = ?", objectStore->id());
    doDelete(database->sqliteDatabase(), "DELETE FROM ObjectStoreData WHERE objectStoreId = ?", objectStore->id());
    doDelete(database->sqliteDatabase(), "DELETE FROM IndexData WHERE indexId IN (SELECT id FROM Indexes WHERE objectStoreId = ?)", objectStore->id());
    doDelete(database->sqliteDatabase(), "DELETE FROM Indexes WHERE objectStoreId = ?", objectStore->id());

    transaction->didCompleteTaskEvents();
}
Example #3
0
void MLModel::actionSlot( QAction *action )
{
    QString name;
    QStringList mrls;
    QModelIndex index;
    playlist_item_t *p_item;

    actionsContainerType a = action->data().value<actionsContainerType>();
    switch ( a.action )
    {

    case actionsContainerType::ACTION_PLAY:
        play( a.indexes.first() );
        break;

    case actionsContainerType::ACTION_ADDTOPLAYLIST:
        break;

    case actionsContainerType::ACTION_REMOVE:
        doDelete( a.indexes );
        break;

    case actionsContainerType::ACTION_SORT:
        break;
    }
}
Example #4
0
void IndexReader::deleteDocument(int32_t docNum) {
    SyncLock syncLock(this);
    ensureOpen();
    acquireWriteLock();
    _hasChanges = true;
    doDelete(docNum);
}
Example #5
0
Picdok::Picdok(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::Picdok)     // Set up form.
{
    WaitPtr(true);
    ui->setupUi(this);
    showPic = 0;
    inParams = new QStringList(QApplication::arguments());
    curDir = "";
    curDirHdg = new QLabel;
    curDirLabel = new QLabel;
    curDirNum = new QLabel;
    img = new QImage;
    imgDisp = new QImage;
    pixmDisp = new QPixmap;
    matx = new QTransform;
    settings = new QSettings(QDir::homePath() + QDir::separator() + SETTINGS_FILE, QSettings::IniFormat, this);
    // Check command line parameter and use supplied directory if valid, else use saved settings,or current directory if none.
    readSettings(checkParams(inParams));
    noAutomove = false;
    setupStatusBar();
    // Connect the context menu signals from lblPic to the required slots here.
    connect(ui->lblPic, SIGNAL(pdlSigDesel()), this, SLOT(doDeselect()));
    connect(ui->lblPic, SIGNAL(pdlSigDel()), this, SLOT(doDelete()));
    connect(ui->lblPic, SIGNAL(pdlSigRen()), this, SLOT(doPicRename()));
    connect(ui->lblPic, SIGNAL(pdlSigMov()), this, SLOT(doPicMove()));
    desk = QApplication::desktop();
    setFocusOnCommentIfEmpty();
    WaitPtr(false);
}
Example #6
0
/* the test: insert some data, update it and finally delete it */
static sword doWork(char op, char *arg, OCISvcCtx *svcCtx, OCIStmt *stmthp, OCIError *errhp, test_req_t *resp) {
	sword status = OCI_SUCCESS;
	int empno;

	btlogger_debug( "TxLog doWork op=%c arg=%s", op, arg);
	empno = (*arg ? atoi(arg) : 8000);
	(resp->data)[0] = 0;

	if (op == '0') {
		status = doInsert(svcCtx, stmthp, errhp, empno);
	} else if (op == '1') {
		int rcnt = 0;	// no of matching records
		status = doSelect(svcCtx, stmthp, errhp, empno, &rcnt);
	   	btlogger_snprintf(resp->data, sizeof (resp->data), "%d", rcnt);
	} else if (op == '2') {
		status = doUpdate(svcCtx, stmthp, errhp, empno);
	} else if (op == '3') {
		status = doDelete(svcCtx, stmthp, errhp, empno);
	}

	if (status != OCI_SUCCESS)
		get_error(resp, errhp, status);

	return status;
}
void showMenu(){

   printf("     ___   ___      _____ ___ ___ ___       \n");
   printf("     /_\\ \\ / / |    |_   _| _ \\ __| __|  \n");
   printf("    / _ \\ - /| |__    | | |   / _|| _|     \n");
   printf("   /_/ \\_\\_/ |____|   |_| |_|_\\___|___|  \n");
   printf("                     By: Raven G. Duran     \n");
    printf("\n\n");
    printf("(1) Insert a Node\n");
    printf("(2) Delete a Node\n");
    printf("(3) Search a Node\n");
    printf("(4) Print In Order\n");
    printf("(5) Exit\n");

    int choice;
    printf("\n\nChoice: ");
    scanf("%d",&choice);

    switch(choice){
       case 1 : doInsert();   break;
       case 2 : doDelete();   break;
       case 3 : doSearch();   break;
       case 4 : doInOrder();   break;
       default  : exit(0);
    }
}
bool ImageValueEditor::onChar(wxKeyEvent& ev) {
	if (ev.AltDown() || ev.ShiftDown() || ev.ControlDown()) return false;
	switch (ev.GetKeyCode()) {
		case WXK_DELETE:
			doDelete();
			return true;
		default:
			return false;
	}
}
RefPtr<IDBRequest> IDBObjectStore::deleteFunction(ExecState& execState, JSValue key, ExceptionCodeWithMessage& ec)
{
    Ref<IDBKey> idbKey = scriptValueToIDBKey(execState, key);
    if (!idbKey->isValid()) {
        ec.code = IDBDatabaseException::DataError;
        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key.");
        return nullptr;
    }

    return doDelete(execState, &IDBKeyRange::create(WTFMove(idbKey)).get(), ec);
}
Example #10
0
	/** 销毁所有的着色器
	*/
	void ShaderManagerD3D9::releaseAllShader()
	{
		m_mutex.Lock();
		std::map<IShader*,ManagedItem*>::iterator e = items.end();
		for(std::map<IShader*,ManagedItem*>::iterator b = items.begin();b != e;++b)
		{
			doDelete((*b).first);
		}
		items.clear();
		names.clear();
		m_mutex.Unlock();
	}
Example #11
0
void taskExplode::oneFrame()
{
    m_timer++;

    if(m_timer > 2)
    {
        m_timer = 0;
        m_anm++;

        if(m_anm >= 4)
            doDelete();
    }
}
Example #12
0
void CleanWorker::run() {
    while(true) {
        if(_queue.isEmpty()) {
            if (_can_over) {
                break;
            }
            usleep(_WORKER_WAIT_TIME);
            continue;
        }
        DelJob* deljob = _queue.pop();
        doDelete(deljob->getAllKey(), deljob->getSize());
        delete deljob;
    }
}
Example #13
0
RefPtr<IDBRequest> IDBObjectStore::modernDelete(ScriptExecutionContext& context, JSValue key, ExceptionCodeWithMessage& ec)
{
    auto exec = context.execState();
    if (!exec) {
        ec.code = IDBDatabaseException::UnknownError;
        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': Script execution context does not have an execution state.");
        return nullptr;
    }

    Ref<IDBKey> idbKey = scriptValueToIDBKey(*exec, key);
    if (!idbKey->isValid()) {
        ec.code = IDBDatabaseException::DataError;
        ec.message = ASCIILiteral("Failed to execute 'delete' on 'IDBObjectStore': The parameter is not a valid key.");
        return nullptr;
    }

    return doDelete(context, &IDBKeyRange::create(WTFMove(idbKey)).get(), ec);
}
Example #14
0
/**
	@brief Implement the class-specific methods.
	@param ctx Pointer to the method context.
	@return Zero if successful, or -1 if not.

	Branch on the method type: create, retrieve, update, delete, search, or id_list.

	The method parameters and the type of value returned to the client depend on the method
	type.
*/
int dispatchCRUDMethod( osrfMethodContext* ctx ) {

	// Get the method type, then can branch on it
	osrfHash* method_meta = (osrfHash*) ctx->method->userData;
	const char* methodtype = osrfHashGet( method_meta, "methodtype" );

	if( !strcmp( methodtype, "create" ))
		return doCreate( ctx );
	else if( !strcmp(methodtype, "retrieve" ))
		return doRetrieve( ctx );
	else if( !strcmp(methodtype, "update" ))
		return doUpdate( ctx );
	else if( !strcmp(methodtype, "delete" ))
		return doDelete( ctx );
	else if( !strcmp(methodtype, "search" ))
		return doSearch( ctx );
	else if( !strcmp(methodtype, "id_list" ))
		return doIdList( ctx );
	else {
		osrfAppRespondComplete( ctx, NULL );      // should be unreachable...
		return 0;
	}
}
Example #15
0
bool HttpServlet::doRun(session& session, socket_stream* stream /* = NULL */)
{
	socket_stream* in;
	socket_stream* out;
	bool cgi_mode;

	if (stream == NULL)
	{
		// 数据流为空,则当 CGI 模式处理,将标准输入输出
		// 作为数据流
		stream = NEW socket_stream();
		(void) stream->open(ACL_VSTREAM_IN);
		in = stream;

		stream = NEW socket_stream();
		(void) stream->open(ACL_VSTREAM_OUT);
		out = stream;
		cgi_mode = true;
	}
	else
	{
		in = out = stream;
		cgi_mode = false;
	}

	// req/res 采用栈变量,减少内存分配次数

	HttpServletResponse res(*out);
	HttpServletRequest req(res, session, *in, local_charset_,
		parse_body_enable_, parse_body_limit_);

	if (rw_timeout_ >= 0)
		req.setRwTimeout(rw_timeout_);

	res.setCgiMode(cgi_mode);

	bool  ret;

	http_method_t method = req.getMethod();

	switch (method)
	{
	case HTTP_METHOD_GET:
		ret = doGet(req, res);
		break;
	case HTTP_METHOD_POST:
		ret = doPost(req, res);
		break;
	case HTTP_METHOD_PUT:
		ret = doPut(req, res);
		break;
	case HTTP_METHOD_CONNECT:
		ret = doConnect(req, res);
		break;
	case HTTP_METHOD_PURGE:
		ret = doPurge(req, res);
		break;
	case HTTP_METHOD_DELETE:
		ret = doDelete(req, res);
		break;
	case  HTTP_METHOD_HEAD:
		ret = doHead(req, res);
		break;
	case HTTP_METHOD_OPTION:
		ret = doOption(req, res);
		break;
	default:
		ret = false; // 有可能是IO失败或未知方法
		if (req.getLastError() == HTTP_REQ_ERR_METHOD)
			doUnknown(req, res);
		else
			doError(req, res);
		break;
	}

	if (in != out)
	{
		// 如果是标准输入输出流,则需要先将数据流与标准输入输出解绑,
		// 然后才能释放数据流对象,数据流内部会自动判断流句柄合法性
		// 这样可以保证与客户端保持长连接
		in->unbind();
		out->unbind();
		delete in;
		delete out;
	}

	return ret;
}
Example #16
0
/**
    \brief Saves the object to the storage system.

    If the object is new then a new record will be inserted into the
    storage system. Existing objects will be updated if any of the storable
    properties were changed.

    \throw xeInvalidStorable If the object is not valid an
                             xeInvalidStorable will be thrown.
 */
void xtStorable::save()
{
  if(!isValid())
    throw xeInvalidStorable(*this);

  if(isLocked() && !isSelfLocked())
    throw std::runtime_error("cannot save this object as it has been locked by someone else.");

  if(isDeleted())
  {
    doDelete();
    return;
  }

  std::map<std::string, QVariant> changed;
  std::set<std::string> fieldnames = getPropertyNames(xtlib::FieldRole);
  for (std::set<std::string>::const_iterator it = fieldnames.begin();
       it != fieldnames.end();
       it++)
  {
    if(! xtAnyUtility::equal(getProperty(*it),
                             getProperty(*it, xtlib::PreviousValueRole)))
      changed.insert(std::pair<std::string, QVariant>(*it, getProperty(*it)));
  }

  if(changed.size())
  {
    _data->_enforceReadOnly = false;
    QString tuser = QString::fromStdString(xtSecurity::logicalUser());
    setProperty("modifier", tuser);
    changed.insert(std::pair<std::string, QVariant>("modifier", tuser));
    QDateTime newt = QDateTime::currentDateTime();
    setProperty("modified", newt);
    changed.insert(std::pair<std::string, QVariant>("modified", newt));
    _data->_enforceReadOnly = true;
    std::string sql;
    if(_data->_id)
    {
      sql = "UPDATE \"";
      sql += _data->_tableName;
      sql += "\" SET ";
      int colcnt = 0;
      for (std::map<std::string, QVariant>::iterator it = changed.begin();
           it != changed.end();
           it++, colcnt++)
      {
        QVariant pFieldData = getProperty((*it).first, xtlib::FieldRole);
        xtFieldData fd = pFieldData.value<xtFieldData>();
        std::string fieldName = _data->_prefix + fd.fieldName;
        if(colcnt)
          sql += ", ";
        sql += "\"" + fieldName;
        sql += "\"='" + xtAnyUtility::toString((*it).second) + "'";
      }
      sql += " WHERE (" + _data->_prefix + "id='";
      sql += QString::number(_data->_id).toStdString();
      sql += "');";
    }
    else
    {
      _data->_enforceReadOnly = false;
      setProperty("creator", tuser);
      changed.insert(std::pair<std::string, QVariant>("creator", tuser));
      setProperty("created", newt);
      changed.insert(std::pair<std::string, QVariant>("created", newt));
      _data->_enforceReadOnly = true;
      sql = "INSERT INTO \"";
      sql += _data->_tableName;
      sql += "\" (";

      int colcnt = 0;
      std::string values;

      for (std::map<std::string, QVariant>::iterator it = changed.begin();
           it != changed.end();
           it++, colcnt++)
      {
        QVariant pFieldData = getProperty((*it).first, xtlib::FieldRole);
        xtFieldData fd = pFieldData.value<xtFieldData>();
        std::string fieldName = _data->_prefix + fd.fieldName;
        if(colcnt)
        {
          sql    += ", ";
          values += ", ";
        }
        sql     += "\"" + fieldName  + "\"";
        values  += "'"  + xtAnyUtility::toString((*it).second) + "'";
      }
      sql += ") VALUES (";
      sql += values;
      sql += ") RETURNING " + _data->_prefix + "id;";
    }

    if(xtlib::debug)
      qDebug() << "executing: " << QString::fromStdString(sql);
    QSqlQuery query;
    query.exec(QString::fromStdString(sql));
    if(query.first())
      _data->_id = query.value(query.record().indexOf(QString::fromStdString(_data->_prefix) + "id")).toLongLong();

    load(_data->_id);
  }
}
void MLModel::popupDel()
{
    doDelete( current_selection );
}
Example #18
0
RefPtr<IDBRequest> IDBObjectStore::deleteFunction(ScriptExecutionContext& context, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
{
    return doDelete(context, keyRange, ec);
}
bool CHistoryManager::undo()
{
	if ( m_undoAction.size() == 0 )
		return false;	

	getIView()->getDocument()->clearSelect();		

	m_disable = true;

	HistoryAction lastAction = m_undoAction.back();
	SAction* action;

	bool isFailed = false;	
	
	int nAction = lastAction.size();
	for ( int iAction = nAction - 1; iAction >= 0; iAction-- )
	{
		action = &lastAction[iAction];

		if ( action->actionType == CHistoryManager::CreateObject )
		{
			if ( doCreate( action ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::DeleteObject )
		{
			if ( doDelete( action ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::ModifyObject )
		{
			if ( doModify( action ) == false )
			{
				isFailed = true;
				break;
			}
		}
	}

	if ( isFailed == true )
	{				
		m_redoAction.clear();
		m_undoAction.clear();
	}
	else
	{
		m_redoAction.push_back( lastAction );
		m_undoAction.pop_back();
	}
	
	getIView()->setObjectProperty( NULL );
	m_disable = false;

	return true;
}
Example #20
0
bool HttpServlet::doRun(dbuf_pool* dbuf)
{
	socket_stream* in;
	socket_stream* out;
	bool cgi_mode;

	bool first = first_;
	if (first_)
		first_ = false;

	if (stream_ == NULL)
	{
		// 数据流为空,则当 CGI 模式处理,将标准输入输出
		// 作为数据流
		in = NEW socket_stream();
		in->open(ACL_VSTREAM_IN);

		out = NEW socket_stream();
		out->open(ACL_VSTREAM_OUT);
		cgi_mode = true;
	}
	else
	{
		in = out = stream_;
		cgi_mode = false;
	}

	// req/res 采用栈变量,减少内存分配次数

	HttpServletResponse res(*out, dbuf);
	HttpServletRequest req(res, *session_, *in, local_charset_,
		parse_body_enable_, parse_body_limit_, dbuf);

	// 设置 HttpServletRequest 对象
	res.setHttpServletRequest(&req);

	if (rw_timeout_ >= 0)
		req.setRwTimeout(rw_timeout_);

	res.setCgiMode(cgi_mode);

	string method_s(32);
	http_method_t method = req.getMethod(&method_s);

	// 根据请求的值自动设定是否需要保持长连接
	if (!cgi_mode)
		res.setKeepAlive(req.isKeepAlive());

	bool  ret;

	switch (method)
	{
	case HTTP_METHOD_GET:
		ret = doGet(req, res);
		break;
	case HTTP_METHOD_POST:
		ret = doPost(req, res);
		break;
	case HTTP_METHOD_PUT:
		ret = doPut(req, res);
		break;
	case HTTP_METHOD_CONNECT:
		ret = doConnect(req, res);
		break;
	case HTTP_METHOD_PURGE:
		ret = doPurge(req, res);
		break;
	case HTTP_METHOD_DELETE:
		ret = doDelete(req, res);
		break;
	case  HTTP_METHOD_HEAD:
		ret = doHead(req, res);
		break;
	case HTTP_METHOD_OPTION:
		ret = doOptions(req, res);
		break;
	case HTTP_METHOD_PROPFIND:
		ret = doPropfind(req, res);
		break;
	case HTTP_METHOD_OTHER:
		ret = doOther(req, res, method_s.c_str());
		break;
	default:
		ret = false; // 有可能是IO失败或未知方法
		if (req.getLastError() == HTTP_REQ_ERR_METHOD)
			doUnknown(req, res);
		else if (first)
			doError(req, res);
		break;
	}

	if (in != out)
	{
		// 如果是标准输入输出流,则需要先将数据流与标准输入输出解绑,
		// 然后才能释放数据流对象,数据流内部会自动判断流句柄合法性
		// 这样可以保证与客户端保持长连接
		in->unbind();
		out->unbind();
		delete in;
		delete out;
	}

	// 返回给上层调用者:true 表示继续保持长连接,否则表示需断开连接
	return ret && req.isKeepAlive()
		&& res.getHttpHeader().get_keep_alive();
}
bool CHistoryManager::redo()
{
	if ( m_redoAction.size() == 0 )	
		return false;	

	getIView()->getDocument()->clearSelect();		

	m_disable = true;

	HistoryAction lastAction = m_redoAction.back();
	SAction* action;

	bool isFailed = false;

	HistoryAction::iterator i = lastAction.begin(), end = lastAction.end();
	while ( i != end )
	{
		action = &(*i);

		if ( action->actionType == CHistoryManager::CreateObject )
		{		
			if ( doCreate( action, true ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::DeleteObject )
		{
			if ( doDelete( action, true ) == false )
			{
				isFailed = true;
				break;
			}
		}
		
		if ( action->actionType == CHistoryManager::ModifyObject )
		{			
			if ( doModify( action, true ) == false )
			{
				isFailed = true;
				break;
			}
		}

		++i;
	}

	if ( isFailed == true )
	{
		m_redoAction.clear();
		m_undoAction.clear();
		return false;
	}
	else
	{
		m_undoAction.push_back( lastAction );
		m_redoAction.pop_back();		
	}


	// update box
	getIView()->setObjectProperty( NULL );
	m_disable = false;

	return true;
}
Example #22
0
bool MLModel::action( QAction *action, const QModelIndexList &indexes )
{
    actionsContainerType a = action->data().value<actionsContainerType>();
    input_item_t *p_input;

    switch ( a.action )
    {

    case ACTION_PLAY:
        if ( ! indexes.empty() && indexes.first().isValid() )
        {
            activateItem( indexes.first() );
            return true;
        }
        break;

    case ACTION_ADDTOPLAYLIST:
        foreach( const QModelIndex &index, indexes )
        {
            if( !index.isValid() ) return false;
            AddItemToPlaylist( itemId( index, MLMEDIA_ID ), false, p_ml, true );
        }
        return true;

    case ACTION_REMOVE:
        doDelete( indexes );
        return true;

    case ACTION_SORT:
        break;

    case ACTION_CLEAR:
        removeAll();
        return true;

    case ACTION_ENQUEUEFILE:
        foreach( const QString &uri, a.uris )
            playlist_Add( THEPL, uri.toAscii().constData(),
                          NULL, PLAYLIST_APPEND | PLAYLIST_PREPARSE,
                          PLAYLIST_END, false, pl_Unlocked );
        return true;

    case ACTION_ENQUEUEDIR:
        if( a.uris.isEmpty() ) return false;
        p_input = input_item_New( a.uris.first().toAscii().constData(), NULL );
        if( unlikely( p_input == NULL ) ) return false;

        /* FIXME: playlist_AddInput() can fail */
        playlist_AddInput( THEPL, p_input,
                           PLAYLIST_APPEND,
                           PLAYLIST_END, true, pl_Unlocked );
        vlc_gc_decref( p_input );
        return true;

    case ACTION_ENQUEUEGENERIC:
        foreach( const QString &uri, a.uris )
        {
            p_input = input_item_New( qtu( uri ), NULL );
            /* Insert options */
            foreach( const QString &option, a.options.split( " :" ) )
            {
                QString temp = colon_unescape( option );
                if( !temp.isEmpty() )
                    input_item_AddOption( p_input, qtu( temp ),
                                          VLC_INPUT_OPTION_TRUSTED );
            }

            /* FIXME: playlist_AddInput() can fail */
            playlist_AddInput( THEPL, p_input,
                    PLAYLIST_APPEND | PLAYLIST_PREPARSE,
                    PLAYLIST_END, false, pl_Unlocked );
            vlc_gc_decref( p_input );
        }
        return true;

    default:
        break;
    }
    return false;
}
Example #23
0
void CodeEditor::doCommand(uint32 cmd) {
	switch (cmd) {
		case CmdPrintFoo: {
			std::cerr << "Foo\n";
		} break;

		case CmdSave: {
			save();
		} break;

		case CmdReloadOpenDocument: {
			reload();
		} break;

		case CmdLoadTest: {
			loadTest();
		} break;

		case CmdMoveUpToBlank: {
			moveCursorUpToBlank();
		} break;

		case CmdMoveDownToBlank: {
			moveCursorDownToBlank();
		} break;

		case CmdMoveToDocumentBegin: {
			moveCursorToDocumentBegin();
		} break;

		case CmdMoveToDocumentEnd: {
			moveCursorToDocumentEnd();
		} break;

		case CmdMoveToLineBegin: {
			moveCursorToLineBegin();
		} break;

		case CmdMoveToLineEnd: {
			moveCursorToLineEnd();
		} break;

		case CmdSetMark: {
			setMark();
		} break;

		case CmdSwapCursorAndMark: {
			swapCursorAndMark();
		} break;

		case CmdMoveCursorToMark: {
			moveCursorToMark();
		} break;

		case CmdToggleMarkVisibility: {
			toggleMarkVisibility();
		} break;

		case CmdBackspace: {
			doBackspace();
		} break;

		case CmdDelete: {
			doDelete();
		} break;

		case CmdClearLine: {
			clearLine(mCurrentLine);
		} break;

		case CmdClearDocument: {
			clear();
		} break;

		case CmdTab: {
			doTab();
		} break;

		case CmdNewline: {
			addLine();
		} break;

		case CmdOpenConfig: {
			loadConfig();
		} break;

		case CmdOpenTheme: {
			loadCurrentTheme();
		} break;

		case CmdLoadHelp: {
			loadReadMe();
		} break;
	}
}
Example #24
0
FileHandling::FileHandling(QWidget *parent, bool v, QString cf) : MyWidget(parent) {

	this->setVisibleArea(QSize(600,400));

	// Some variables
	currentfile = cf;
	verbose = v;

	QString fileTreeCSS = "QTreeView {";
	fileTreeCSS += "color:white;";
	fileTreeCSS += "background: rgba(0,0,0,0);";
	fileTreeCSS += "show-decoration-selected: 1;";
	fileTreeCSS += "}";

	fileTreeCSS += "QTreeView::item:hover{";
	fileTreeCSS += "background: rgba(255,255,255,128);";
	fileTreeCSS += "color: black";
	fileTreeCSS += "}";

	fileTreeCSS += "QTreeView::item:selected{";
	fileTreeCSS += "background: white;";
	fileTreeCSS += "color: black;";
	fileTreeCSS += "}";

	fileTreeCSS += "QTreeView::item:selected:active{";
	fileTreeCSS += "background: white;";
	fileTreeCSS += "color: black";
	fileTreeCSS += "}";

	fileTreeCSS += "QTreeView::item:selected:!active{";
	fileTreeCSS += "background: white;";
	fileTreeCSS += "color: black";
	fileTreeCSS += "}";


	/**********************************
	/////////// RENAME ////////////////
	**********************************/

	renameWidget = new QWidget(this);

	renameLay = new QVBoxLayout;
	renameTitle = new CustomLabel("<center>" + tr("Rename File") + "</center>");
	renameTitle->setFontSize(25);
	renameTitle->setBold(true);
	renameOldName = new CustomLabel;
	renameOldName->setFontSize(15);
	renameOldName->setItalic(true);
	renameOldName->setFontColor("grey","grey");
	renameOldName->setPadding(10);
	QHBoxLayout *renameNewLay = new QHBoxLayout;
	renameNewName = new CustomLineEdit;
	renameNewName->setFixedWidth(300);
	renameNewName->setFontSize(15);
	renameOldEnding = new CustomLabel;
	renameOldEnding->setFontSize(15);
	renameNewLay->addStretch();
	renameNewLay->addWidget(renameNewName);
	renameNewLay->addWidget(renameOldEnding);
	renameNewLay->addStretch();

	renameNewNameExists = new CustomLabel(" ");
	renameNewNameExists->setFontColor("red","red");
	renameNewNameExists->setBold(true);

	renameSave = new CustomPushButton(tr("Save"));
	renameSave->setPadding(10);
	renameSave->setFontSize("13pt");
	renameSave->setBold(true);

	renameCancel = new CustomPushButton(tr("Cancel"));
	renameCancel->setPadding(10);
	renameCancel->setFontSize("13pt");
	renameCancel->setBold(true);

	renameLay->addStretch();
	renameLay->addWidget(renameTitle);
	renameLay->addWidget(renameOldName);
	renameLay->addSpacing(5);
	renameLay->addLayout(renameNewLay);
	renameLay->addWidget(renameNewNameExists);
	QHBoxLayout *renameButLay = new QHBoxLayout;
	renameButLay->addStretch();
	renameButLay->addWidget(renameSave);
	renameButLay->addWidget(renameCancel);
	renameButLay->addStretch();
	renameLay->addLayout(renameButLay);
	renameLay->addStretch();

	connect(renameNewName, SIGNAL(textEdited(QString)), this, SLOT(validateRenameFilename()));
	connect(renameSave, SIGNAL(clicked()), this, SLOT(doRename()));
	connect(renameCancel, SIGNAL(clicked()), this, SLOT(animate()));

	renameWidget->setLayout(renameLay);



	/**********************************
	/////////// DELETE ////////////////
	**********************************/

	// On Linux (X11) a "move to trash" is the default (according to freedesktop.org standard). On all other systems, this option is not (yet) available.

	deleteWidget = new QWidget(this);

	deleteLay = new QVBoxLayout;
	deleteTitle = new CustomLabel("<center>" + tr("Delete File") + "</center>");
	deleteTitle->setFontSize(15);
	deleteTitle->setBold(true);
	deleteFilename = new CustomLabel(" ");
	deleteFilename->setFontSize(15);
	deleteFilename->setItalic(true);
	deleteFilename->setFontColor("grey","grey");
	deleteFilename->setPadding(10);
	deleteQuestion = new CustomLabel("<center>" + tr("Do you really want to delete this file?") +"</center>");
	deleteQuestion->setFontSize(15);
	deleteQuestion->setPadding(10);



	deleteYesHard = new CustomPushButton(tr("Delete permanently"));
	deleteYesHard->setPadding(6);
#ifdef Q_OS_LINUX
	deleteYesHard->setFontSize("10pt");
#else
	deleteYesHard->setFontSize("13pt");
	deleteYesHard->setBold(true);
#endif

#ifdef Q_OS_LINUX
	deleteYes = new CustomPushButton(tr("Move to Trash"));
	deleteYes->setPadding(6);
	deleteYes->setFontSize("13pt");
	deleteYes->setBold(true);
#else
	deleteYes = new CustomPushButton;
	deleteYes->hide();
#endif

	deleteNo = new CustomPushButton(tr("Cancel"));
	deleteNo->setPadding(6);
	deleteNo->setFontSize("13pt");
	deleteNo->setBold(true);

	QHBoxLayout *deleteButLay = new QHBoxLayout;
	deleteButLay->addStretch();

#ifdef Q_OS_LINUX
	deleteButLay->addWidget(deleteYes);
#else
	deleteButLay->addWidget(deleteYesHard);
#endif

	deleteButLay->addWidget(deleteNo);
	deleteButLay->addStretch();

#ifdef Q_OS_LINUX
	QHBoxLayout *deleteHardButLay = new QHBoxLayout;
	deleteHardButLay->addStretch();
	deleteHardButLay->addWidget(deleteYesHard);
	deleteHardButLay->addStretch();
#endif

	deleteLay->addStretch();
	deleteLay->addWidget(deleteTitle);
	deleteLay->addWidget(deleteFilename);
	deleteLay->addWidget(deleteQuestion);
	deleteLay->addLayout(deleteButLay);
#ifdef Q_OS_LINUX
	deleteLay->addLayout(deleteHardButLay);
#endif
	deleteLay->addStretch();

	connect(deleteYes, SIGNAL(clicked()), this, SLOT(doDelete()));
	connect(deleteNo, SIGNAL(clicked()), this, SLOT(animate()));

	QSignalMapper *mapper = new QSignalMapper;
	mapper->setMapping(deleteYesHard,1);
	connect(deleteYesHard, SIGNAL(clicked()), mapper, SLOT(map()));
	connect(mapper, SIGNAL(mapped(int)), this, SLOT(doDelete(int)));



	deleteWidget->setLayout(deleteLay);



	/********************************
	/////////// MOVE ////////////////
	********************************/

	moveWidget = new QWidget(this);

	moveLay = new QVBoxLayout;
	moveTitle = new CustomLabel("<center>" + tr("Moving File") + "</center>");
	moveTitle->setFontSize(25);
	moveTitle->setBold(true);

	moveTree = new QTreeView;
	moveTree->setStyleSheet(fileTreeCSS);
	moveTree->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	moveTree->setHeaderHidden(true);
	moveScrollbar = new CustomScrollbar;
	moveScrollbar->keepAlwaysVisible(true);
	moveTree->setVerticalScrollBar(moveScrollbar);
	moveTreeModel = new QFileSystemModel;
	moveTreeModel->setRootPath(QDir::rootPath());
	moveTreeModel->setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
	moveTree->setCurrentIndex(moveTreeModel->index(QDir::homePath()));
	moveTree->setModel(moveTreeModel);
	for(int i = 1; i < moveTreeModel->columnCount(); ++i)
		moveTree->setColumnHidden(i,true);

	moveNewNameExists = new CustomLabel(" ");
	moveNewNameExists->setFontColor("red","red");
	moveNewNameExists->setBold(true);

	moveNewNameLabel = new CustomLabel(tr("Filename") + ":");
	moveNewNameLabel->setFontSize(12);
	moveNewNameLabel->setBold(true);
	moveNewName = new CustomLineEdit;
	moveNewName->setFixedWidth(300);
	moveNewName->setFontSize(12);
	moveNewNameEnding = new CustomLabel(".xyz");
	moveNewNameEnding->setFontSize(12);
	moveNewNameEnding->setBold(true);

	QHBoxLayout *moveNewNameLay = new QHBoxLayout;
	moveNewNameLay->addStretch();
	moveNewNameLay->addWidget(moveNewNameLabel);
	moveNewNameLay->addWidget(moveNewName);
	moveNewNameLay->addWidget(moveNewNameEnding);
	moveNewNameLay->addStretch();

	moveSave = new CustomPushButton(tr("Move"));
	moveSave->setPadding(10);
	moveSave->setFontSize("11pt");
	moveSave->setBold(true);
	moveCancel = new CustomPushButton(tr("Cancel"));
	moveCancel->setPadding(10);
	moveCancel->setFontSize("11pt");
	moveCancel->setBold(true);

	QHBoxLayout *moveButLay = new QHBoxLayout;
	moveButLay->addStretch();
	moveButLay->addWidget(moveSave);
	moveButLay->addWidget(moveCancel);
	moveButLay->addStretch();

	moveLay->addSpacing(20);
	moveLay->addWidget(moveTitle);
	moveLay->addWidget(moveTree);
	moveLay->addWidget(moveNewNameExists);
	moveLay->addLayout(moveNewNameLay);
	moveLay->addLayout(moveButLay);
	moveLay->addSpacing(20);

	connect(moveCancel, SIGNAL(clicked()), this, SLOT(animate()));
	connect(moveSave, SIGNAL(clicked()), this, SLOT(doMove()));
	connect(moveNewName, SIGNAL(textEdited(QString)), this, SLOT(validateMoveAndCopyFilename()));
	connect(moveTree, SIGNAL(clicked(QModelIndex)), this, SLOT(validateMoveAndCopyFilename()));

	moveWidget->setLayout(moveLay);



	/********************************
	/////////// COPY ////////////////
	********************************/

	copyWidget = new QWidget(this);

	copyLay = new QVBoxLayout;
	copyTitle = new CustomLabel("<center>" + tr("Copying File") + "</center>");
	copyTitle->setFontSize(25);
	copyTitle->setBold(true);

	copyTree = new QTreeView;
	copyTree->setStyleSheet(fileTreeCSS);
	copyTree->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	copyTree->setHeaderHidden(true);
	copyScrollbar = new CustomScrollbar;
	copyScrollbar->keepAlwaysVisible(true);
	copyTree->setVerticalScrollBar(copyScrollbar);
	copyTreeModel = new QFileSystemModel;
	copyTreeModel->setRootPath(QDir::rootPath());
	copyTreeModel->setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
	copyTree->setCurrentIndex(copyTreeModel->index(QDir::homePath()));
	copyTree->setModel(copyTreeModel);
	for(int i = 1; i < copyTreeModel->columnCount(); ++i)
		copyTree->setColumnHidden(i,true);

	copyNewNameExists = new CustomLabel(" ");
	copyNewNameExists->setFontColor("red", "red");
	copyNewNameExists->setBold(true);

	copyNewNameLabel = new CustomLabel(tr("Filename") + ":");
	copyNewNameLabel->setFontSize(12);
	copyNewNameLabel->setBold(true);
	copyNewName = new CustomLineEdit;
	copyNewName->setFixedWidth(300);
	copyNewName->setFontSize(12);
	copyNewNameEnding = new CustomLabel(".xyz");
	copyNewNameEnding->setFontSize(12);
	copyNewNameEnding->setBold(true);

	QHBoxLayout *copyNewNameLay = new QHBoxLayout;
	copyNewNameLay->addStretch();
	copyNewNameLay->addWidget(copyNewNameLabel);
	copyNewNameLay->addWidget(copyNewName);
	copyNewNameLay->addWidget(copyNewNameEnding);
	copyNewNameLay->addStretch();

	copySave = new CustomPushButton(tr("Copy"));
	copySave->setFontSize("11pt");
	copySave->setPadding(10);
	copySave->setBold(true);
	copyCancel = new CustomPushButton(tr("Cancel"));
	copyCancel->setFontSize("11pt");
	copyCancel->setPadding(10);
	copyCancel->setBold(true);

	QHBoxLayout *copyButLay = new QHBoxLayout;
	copyButLay->addStretch();
	copyButLay->addWidget(copySave);
	copyButLay->addWidget(copyCancel);
	copyButLay->addStretch();

	copyLay->addSpacing(20);
	copyLay->addWidget(copyTitle);
	copyLay->addWidget(copyTree);
	copyLay->addWidget(copyNewNameExists);
	copyLay->addLayout(copyNewNameLay);
	copyLay->addLayout(copyButLay);
	copyLay->addSpacing(20);

	connect(copyCancel, SIGNAL(clicked()), this, SLOT(animate()));
	connect(copySave, SIGNAL(clicked()), this, SLOT(doCopy()));
	connect(copyNewName, SIGNAL(textEdited(QString)), this, SLOT(validateMoveAndCopyFilename()));
	connect(copyTree, SIGNAL(clicked(QModelIndex)), this, SLOT(validateMoveAndCopyFilename()));

	copyWidget->setLayout(copyLay);




	// Widget layout - only one at a time will be visible
	allWidgets = new QHBoxLayout;
	allWidgets->addWidget(renameWidget);
	allWidgets->addWidget(copyWidget);
	allWidgets->addWidget(deleteWidget);
	allWidgets->addWidget(moveWidget);
	this->setWidgetLayout(allWidgets);

	// catch finished animation event:
	connect(this, SIGNAL(notifyOfAniFinished()), this, SLOT(aniFinished()));

}
void NBFolderView::createAndSetupActions() {

	connect( IconView, SIGNAL( peek( QModelIndex ) ), this, SLOT( doPeek( QModelIndex ) ) );

	connect( IconView, SIGNAL( open( QModelIndex ) ), this, SLOT( doOpen( QModelIndex ) ) );
	connect( IconView, SIGNAL( open( QString ) ), this, SLOT( doOpen( QString ) ) );

	connect( IconView, SIGNAL( contextMenuRequested( QPoint ) ), this, SLOT( showContextMenu( QPoint ) ) );
	connect( IconView, SIGNAL( actionsMenuRequested( QPoint ) ), this, SLOT( showActionsMenu( QPoint ) ) );

	connect(
		IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
		this, SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) )
	);

	connect( IconView->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), this, SLOT( updateActions() ) );

	connect( IconView, SIGNAL( link( QStringList, QString ) ), this, SLOT( link( QStringList, QString ) ) );

	// DragDrop copy
	connect( IconView, SIGNAL( copy( QStringList, QString ) ), this, SLOT( copy( QStringList, QString ) ) );

	// DragDrop move
	connect( IconView, SIGNAL( move( QStringList, QString ) ), this, SLOT( move( QStringList, QString ) ) );

	// Update actions once the directory is loaded
	connect( fsModel, SIGNAL( directoryLoaded( QString ) ), this, SLOT( updateActions() ) );

	// Peek
	peekAct = new QAction( QIcon( ":/icons/peek.png" ), "Pee&k", this );
	peekAct->setShortcuts( Settings->shortcuts( "Peek" ) );

	connect( peekAct, SIGNAL( triggered() ), this, SLOT( doPeek() ) );
	addAction( peekAct );

	// Home Dir
	actHomeDir = new QAction( QIcon( ":/icons/home.png" ), "&Home", this );
	actHomeDir->setShortcuts( Settings->shortcuts( "GoHome" ) );

	connect( actHomeDir, SIGNAL( triggered() ), this, SLOT( loadHomeDir() ) );
	addAction( actHomeDir );

	// Home
	actGoHome = new QAction( QIcon( ":/icons/home.png" ), "&Home", this );
	actGoHome->setShortcut( tr( "Alt+Shift+Home" ) );

	connect( actGoHome, SIGNAL( triggered() ), this, SLOT( doOpenHome() ) );
	addAction( actGoHome );

	// Up
	actParDir = new QAction( QIcon( ":/icons/up.png" ), "&Up", this );
	actParDir->setShortcuts( Settings->shortcuts( "GoUp" ) );

	connect( actParDir, SIGNAL( triggered() ), fsModel, SLOT( goUp() ) );
	addAction( actParDir );

	// Back
	actPrevDir = new QAction( QIcon( ":/icons/prev.png" ), "&Back", this );
	actPrevDir->setShortcuts( Settings->shortcuts( "GoLeft" ) );

	connect( actPrevDir, SIGNAL( triggered() ), fsModel, SLOT( goBack() ) );
	addAction( actPrevDir );

	// Forward
	actNextDir = new QAction( QIcon( ":/icons/next.png" ), "&Forward", this );
	actNextDir->setShortcuts( Settings->shortcuts( "GoRight" ) );

	connect( actNextDir, SIGNAL( triggered() ), fsModel, SLOT( goForward() ) );
	addAction( actNextDir );

	// New Folder
	actNewDir = new QAction( QIcon::fromTheme( "folder-new" ), "New folder", this );
	actNewDir->setShortcuts( Settings->shortcuts( "NewFolder" ) );

	connect( actNewDir, SIGNAL( triggered() ), this, SLOT( newFolder() ) );
	addAction( actNewDir );

	// New file
	actNewFile = new QAction( QIcon::fromTheme( "document-new" ), "New File", this );
	actNewFile->setShortcuts( Settings->shortcuts( "NewFile" ) );

	connect( actNewFile, SIGNAL( triggered() ), this, SLOT( newFile() ) );
	addAction( actNewFile );

	// New file
	actNewEncFS = new QAction( QIcon::fromTheme( "document-new" ), "New Encrypted Directory", this );
	actNewEncFS->setShortcuts( Settings->shortcuts( "NewEncFS" ) );

	connect( actNewEncFS, SIGNAL( triggered() ), this, SLOT( createEncFS() ) );
	addAction( actNewEncFS );

	// Copy
	copyAct = new QAction( QIcon( ":/icons/copy.png" ), "&Copy", this );
	copyAct->setShortcuts( Settings->shortcuts( "Copy" ) );

	connect( copyAct, SIGNAL( triggered() ), this, SLOT( prepareCopy() ) );
	addAction( copyAct );

	// Move
	moveAct = new QAction( QIcon( ":/icons/cut.png" ), "Cu&t", this );
	moveAct->setShortcuts( Settings->shortcuts( "Cut" ) );

	connect( moveAct, SIGNAL( triggered() ), this, SLOT( prepareMove() ) );
	addAction( moveAct );

	// Paste
	pasteAct = new QAction( QIcon( ":/icons/paste.png" ), "&Paste", this );
	pasteAct->setShortcuts( Settings->shortcuts( "Paste" ) );

	connect( pasteAct, SIGNAL( triggered() ), this, SLOT( prepareIO() ) );
	addAction( pasteAct );

	// Rename
	renameAct = new QAction( QIcon( ":/icons/rename.png" ), "&Rename", this );
	renameAct->setShortcuts( Settings->shortcuts( "Rename" ) );

	connect( renameAct, SIGNAL( triggered() ), this, SLOT( doRename() ) );
	addAction( renameAct );

	// Reload
	reloadAct = new QAction( QIcon( ":/icons/reload.png" ), "Re&fresh", this );
	reloadAct->setShortcuts( Settings->shortcuts( "Reload" ) );

	connect( reloadAct, SIGNAL( triggered() ), this, SLOT( doReload() ) );
	addAction( reloadAct );

	// showDotFiles
	showHideDotFiles = new QAction( QIcon( ":/icons/showDotFiles.png" ), "Show &Hidden", this );
	showHideDotFiles->setShortcuts( Settings->shortcuts( "ToggleHidden" ) );

	connect( showHideDotFiles, SIGNAL( triggered() ), this, SLOT( doToggleHidden() ) );
	addAction( showHideDotFiles );

	// Trash
	trashAct = new QAction( QIcon( ":/icons/trash.png" ), "Move to trash", this );
	trashAct->setShortcuts( Settings->shortcuts( "Trash" ) );

	connect( trashAct, SIGNAL( triggered() ), this, SLOT( doSendToTrash() ) );
	addAction( trashAct );

	// Delete
	delAct = new QAction( QIcon( ":/icons/delete.png" ), "Delete", this );
	delAct->setShortcuts( Settings->shortcuts( "Delete" ) );

	connect( delAct, SIGNAL( triggered() ), this, SLOT( doDelete() ) );
	addAction( delAct );

	// Properties
	propertiesAct = new QAction( QIcon( ":/icons/props.png" ), "&Properties", this );
	propertiesAct->setShortcuts( Settings->shortcuts( "Properties" ) );

	connect( propertiesAct, SIGNAL( triggered() ), this, SIGNAL( showProperties() ) );
	addAction( propertiesAct );

	// Permissions
	permissionsAct = new QAction( QIcon::fromTheme( "system-users" ), "P&ermissions", this );
	permissionsAct->setShortcuts( Settings->shortcuts( "Permissions" ) );

	connect( permissionsAct, SIGNAL( triggered() ), this, SIGNAL( showPermissions() ) );
	addAction( permissionsAct );

	// Open a virtual terminal emulator
	openVTE = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE", this );
	openVTE->setShortcuts( Settings->shortcuts( "Terminal" ) );

	connect( openVTE, SIGNAL( triggered() ), this, SLOT( openTerminal() ) );
	addAction( openVTE );

	// Open a virtual terminal emulator
	openVTEin = new QAction( QIcon::fromTheme( "utilities-terminal" ), "Open &VTE Here", this );
	// openVTEin->setShortcuts( Settings->shortcuts( "Terminal" ) );
	connect( openVTEin, SIGNAL( triggered() ), this, SLOT( openTerminalIn() ) );

	// Select All
	QAction *selectAllAct = new QAction( "&Select All", this );
	selectAllAct->setShortcuts( Settings->shortcuts( "SelectAll" ) );

	connect( selectAllAct, SIGNAL( triggered() ), this, SLOT( selectAll() ) );
	addAction( selectAllAct );

	// Sorting
	sortByNameAct = new QAction( QIcon::fromTheme( "format-text-underline" ), "&Name", this );
	sortByNameAct->setCheckable( true );
	connect( sortByNameAct, SIGNAL( triggered() ), this, SLOT( sortByName() ) );

	sortByTypeAct = new QAction( QIcon::fromTheme( "preferences-other" ), "&Type", this );
	sortByTypeAct->setCheckable( true );
	connect( sortByTypeAct, SIGNAL( triggered() ), this, SLOT( sortByType() ) );

	sortBySizeAct = new QAction( QIcon( ":/icons/size.png" ), "&Size", this );
	sortBySizeAct->setCheckable( true );
	connect( sortBySizeAct, SIGNAL( triggered() ), this, SLOT( sortBySize() ) );

	sortByDateAct = new QAction( QIcon::fromTheme( "office-calendar" ), "&Date", this );
	sortByDateAct->setCheckable( true );
	connect( sortByDateAct, SIGNAL( triggered() ), this, SLOT( sortByDate() ) );

	QActionGroup *sortGroup = new QActionGroup( this );
	sortGroup->addAction( sortByNameAct );
	sortGroup->addAction( sortByTypeAct );
	sortGroup->addAction( sortBySizeAct );
	sortGroup->addAction( sortByDateAct );

	switch( ( int )Settings->value( "SortColumn" ) ) {
		case 0: {
			sortByNameAct->setChecked( true );
			break;
		}
		case 1: {
			sortBySizeAct->setChecked( true );
			break;
		}
		case 2: {
			sortByTypeAct->setChecked( true );
			break;
		}
		case 4: {
			sortByDateAct->setChecked( true );
			break;
		}
	}

	groupsAct = new QAction( QIcon::fromTheme( "view-group", QIcon( ":/icons/groups.png" ) ), "Show in &Groups", this );
	groupsAct->setCheckable( true );
	groupsAct->setChecked( Settings->value( "Grouping" ) );
	connect( groupsAct, SIGNAL( triggered() ), this, SIGNAL( toggleGroups() ) );

	// Add bookmark
	addBookMarkAct = new QAction( QIcon( ":/icons/bookmark.png" ), "Add &Bookmark", this );
	addBookMarkAct->setShortcuts( Settings->shortcuts( "AddBookmark" ) );

	connect( addBookMarkAct, SIGNAL( triggered() ), this, SLOT( addBookMark() ) );
	addAction( addBookMarkAct );

	/* Add to SuperStart */
	addToSuperStartAct = new QAction( QIcon( ":/icons/superstart.png" ), "Add to S&uperStart", this );
	addToSuperStartAct->setShortcut( tr( "Ctrl+U" ) );

	connect( addToSuperStartAct, SIGNAL( triggered() ), this, SLOT( addToSuperStart() ) );
	addAction( addToSuperStartAct );

	updateActions();
};
Example #26
0
bool HttpServlet::start()
{
	socket_stream* in;
	socket_stream* out;
	bool cgi_mode;

	bool first = first_;
	if (first_)
		first_ = false;

	if (stream_ == NULL)
	{
		// 数据流为空,则当 CGI 模式处理,将标准输入输出
		// 作为数据流
		in = NEW socket_stream();
		in->open(ACL_VSTREAM_IN);

		out = NEW socket_stream();
		out->open(ACL_VSTREAM_OUT);
		cgi_mode = true;
	}
	else
	{
		in = out = stream_;
		cgi_mode = false;
	}

	// 在 HTTP 长连接重复请求情况下,以防万一,需要首先删除请求/响应对象
	delete req_;
	delete res_;

	res_ = NEW HttpServletResponse(*out);
	req_ = NEW HttpServletRequest(*res_, *session_, *in, local_charset_,
			 parse_body_enable_, parse_body_limit_);

	// 设置 HttpServletRequest 对象
	res_->setHttpServletRequest(req_);

	if (rw_timeout_ >= 0)
		req_->setRwTimeout(rw_timeout_);

	res_->setCgiMode(cgi_mode);

	string method_s(32);
	http_method_t method = req_->getMethod(&method_s);

	// 根据请求的值自动设定是否需要保持长连接
	if (!cgi_mode)
		res_->setKeepAlive(req_->isKeepAlive());

	bool  ret;

	switch (method)
	{
	case HTTP_METHOD_GET:
		if (upgradeWebsocket(*req_, *res_))
		{
			if (res_->sendHeader() == false)
			{
				logger_error("sendHeader error!");
				return false;
			}
			ret = doWebsocket(*req_, *res_);
		} else
			ret = doGet(*req_, *res_);
		break;
	case HTTP_METHOD_POST:
		ret = doPost(*req_, *res_);
		break;
	case HTTP_METHOD_PUT:
		ret = doPut(*req_, *res_);
		break;
	case HTTP_METHOD_CONNECT:
		ret = doConnect(*req_, *res_);
		break;
	case HTTP_METHOD_PURGE:
		ret = doPurge(*req_, *res_);
		break;
	case HTTP_METHOD_DELETE:
		ret = doDelete(*req_, *res_);
		break;
	case  HTTP_METHOD_HEAD:
		ret = doHead(*req_, *res_);
		break;
	case HTTP_METHOD_OPTION:
		ret = doOptions(*req_, *res_);
		break;
	case HTTP_METHOD_PROPFIND:
		ret = doPropfind(*req_, *res_);
		break;
	case HTTP_METHOD_OTHER:
		ret = doOther(*req_, *res_, method_s.c_str());
		break;
	default:
		ret = false; // 有可能是IO失败或未知方法
		if (req_->getLastError() == HTTP_REQ_ERR_METHOD)
			doUnknown(*req_, *res_);
		else if (first)
			doError(*req_, *res_);
		break;
	}

	if (in != out)
	{
		// 如果是标准输入输出流,则需要先将数据流与标准输入输出解绑,
		// 然后才能释放数据流对象,数据流内部会自动判断流句柄合法性
		// 这样可以保证与客户端保持长连接
		in->unbind();
		out->unbind();
		delete in;
		delete out;
	}

	return ret;
}
Example #27
0
 bool alsoDelete()
 {
     doDelete();
     return true;
 }
Example #28
0
    bool WriteBatchExecutor::doWrite( const string& ns,
                                      const BatchItemRef& itemRef,
                                      CurOp* currentOp,
                                      WriteStats* stats,
                                      BSONObj* upsertedID,
                                      BatchedErrorDetail* error ) {

        const BatchedCommandRequest& request = *itemRef.getRequest();
        int index = itemRef.getItemIndex();

        //
        // Check our shard version if we need to (must be in the write lock)
        //

        if ( shardingState.enabled() && request.isShardVersionSet()
             && !ChunkVersion::isIgnoredVersion( request.getShardVersion() ) ) {

            Lock::assertWriteLocked( ns );
            CollectionMetadataPtr metadata = shardingState.getCollectionMetadata( ns );
            ChunkVersion shardVersion =
                metadata ? metadata->getShardVersion() : ChunkVersion::UNSHARDED();

            if ( !request.getShardVersion() //
                .isWriteCompatibleWith( shardVersion ) ) {

                // Write stale error to results
                error->setErrCode( ErrorCodes::StaleShardVersion );

                BSONObjBuilder infoB;
                shardVersion.addToBSON( infoB, "vWanted" );
                error->setErrInfo( infoB.obj() );

                string errMsg = mongoutils::str::stream()
                    << "stale shard version detected before write, received "
                    << request.getShardVersion().toString() << " but local version is "
                    << shardVersion.toString();
                error->setErrMessage( errMsg );

                return false;
            }
        }

        //
        // Not stale, do the actual write
        //

        if ( request.getBatchType() == BatchedCommandRequest::BatchType_Insert ) {

            // Insert
            return doInsert( ns,
                             request.getInsertRequest()->getDocumentsAt( index ),
                             currentOp,
                             stats,
                             error );
        }
        else if ( request.getBatchType() == BatchedCommandRequest::BatchType_Update ) {

            // Update
            return doUpdate( ns,
                             *request.getUpdateRequest()->getUpdatesAt( index ),
                             currentOp,
                             stats,
                             upsertedID,
                             error );
        }
        else {
            dassert( request.getBatchType() ==
                BatchedCommandRequest::BatchType_Delete );

            // Delete
            return doDelete( ns,
                             *request.getDeleteRequest()->getDeletesAt( index ),
                             currentOp,
                             stats,
                             error );
        }
    }
RefPtr<IDBRequest> IDBObjectStore::deleteFunction(ExecState& execState, IDBKeyRange* keyRange, ExceptionCodeWithMessage& ec)
{
    return doDelete(execState, keyRange, ec);
}