コード例 #1
0
// Init list image to count for item
void PictureHelper::initListImage() {
	listImg.clear();
	QString appFolder(QDir::homePath());
	appFolder.chop(4);
	QDir imgPath(appFolder + "shared/camera");
	QDirIterator it(imgPath.absolutePath());
	while (it.hasNext()) {
		it.next();
		if ((it.filePath().contains(".png")) || (it.filePath().contains(".jpg"))) {
			listImg << it.filePath();
		}
	}
	setImageCount(listImg.count());
}
コード例 #2
0
ファイル: CurlSocket.cpp プロジェクト: AsherBond/DimSim
CurlSocket::CurlSocket()
{
	// Initialise the curl subsystem
	curl_global_init(CURL_GLOBAL_ALL);

	// Initialize handler and clear out internal fields

	// Primary Initialization
	std::string appFolder(getenv("APPDATA"));
	appFolder.append("\\Dimdim\\dump.bin");
	osDump = new std::ofstream(appFolder.c_str(), std::ios::binary | std::ios::out);	// Handle to dump packets to local storage

	m_handler = NULL;							// Curl Handler

	m_uOperationType = 2;						//Enable only network by default
	m_blockSize = 32 * 1024;					// By default, choose 32KB blocks
	m_transactionWaitTime = 100;				// 100 ms by default. We allow a minimum of 20 ms

	// Auxiliary Initialization

	m_postCount = 0;
	m_totalDataSent = 0;						// In bytes
	m_totalDataCreated = 0;						// In bytes

	tg.reset();
	m_originalBlockSize = m_blockSize;			// A backup block size

	m_bSendFailed = false;
	m_eTimer = CreateEvent(NULL, true, false, "CurlTimer");

	// Set headers list

	m_headerList = NULL;
	m_headerList = curl_slist_append(m_headerList, "Expect:");
	m_headerList = curl_slist_append(m_headerList, "Content-Type: application/x-dimdim-dtp");
	m_headerList = curl_slist_append(m_headerList, "Connection: Keep-Alive");

	// Initialize proxy information to safe defaults

	m_proxyType.assign("DIRECT");
	m_proxyURL.assign("");

	m_bForceNode = false;
}
コード例 #3
0
Window::Window(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    if(!QSqlDatabase::isDriverAvailable("QSQLITE"))
    {
        QMessageBox::critical (nullptr,"Fatal error", "The driver for the database is not available. It is unlikely that you will solve this on your own. Rather you had better contact the developer.");
        return;
    }

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");

    QDir appFolder( QCoreApplication::applicationDirPath() );
    QString dbPath = appFolder.absoluteFilePath("dedic2.db");
    if( !appFolder.exists("dedic2.db") )
    {
        QMessageBox::critical (this,tr("Error Message"),tr("The database file does not exist. I was looking for: %1").arg(dbPath) );
        return;
    }

    db.setConnectOptions("QSQLITE_ENABLE_REGEXP");

    db.setDatabaseName( dbPath );
    if(!db.open())
    {
        QMessageBox::critical (this, tr("Error Message"), tr("There was a problem in opening the database. The database said: %1. It is unlikely that you will solve this on your own. Rather you had better contact the developer.").arg(db.lastError().databaseText()) );
        return;
    }

    db.exec("PRAGMA case_sensitive_like=ON;");

    mQueryModel = new QSqlQueryModel;

    connect(ui->comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(searchByChanged()));
    connect(ui->listView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(updateDefinition(const QModelIndex &)));
    connect(ui->searchEdit, SIGNAL(textEdited(const QString &)), this, SLOT(updateSuggestions()));
    connect(ui->versionButton, SIGNAL(clicked(bool)), this, SLOT(versionInformation()));
    connect(ui->searchMethodCombo, SIGNAL(currentTextChanged(QString)), this, SLOT(updateSuggestions()) );

    ui->searchEdit->setFocus();
}
コード例 #4
0
Handle<Value> TiDatabase::_install(void* userContext, TiObject* obj, const Arguments& args)
{
	if(args.Length() == 0) return Undefined();
	if(!args[0]->IsString()) return Undefined();
	QString realName = titanium::V8StringToQString(args[0]->ToString());
	QString givenName;
	if(args.Length() > 0 && args[1]->IsString())
	{
		givenName =  titanium::V8StringToQString(args[1]->ToString());
	}
	else
	{
		givenName =  titanium::V8StringToQString(args[0]->ToString());
	}

	QString dataFolder = "data";
	QString newFileName = dataFolder + "/" + givenName;
	QFile newFile(newFileName);

	if (!newFile.exists())
	{
		QString appFolder(QDir::homePath());
		appFolder.chop(4);

		QString originalFileName = appFolder + "app/native/assets/" + realName;
		QFile originalFile(originalFileName);

		if (originalFile.exists()) {
			originalFile.copy(newFileName);
		} else {
			return Undefined();
		}
	}

	return TiDatabase::_open(userContext, obj, args);
}