void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName, QgsMapLayer* layer, const QString& configFile, const QList<QString>& tempFiles ) { QgsMessageLog::logMessage( "Layer cache: insert Layer '" + layerName + "' configFile: " + configFile, QStringLiteral( "Server" ), QgsMessageLog::INFO ); if ( mEntries.size() > qMax( mDefaultMaxLayers, mProjectMaxLayers ) ) //force cache layer examination after 10 inserted layers { updateEntries(); } QPair<QString, QString> urlLayerPair = qMakePair( url, layerName ); QgsMSLayerCacheEntry newEntry; newEntry.layerPointer = layer; newEntry.url = url; newEntry.creationTime = time( nullptr ); newEntry.lastUsedTime = time( nullptr ); newEntry.temporaryFiles = tempFiles; newEntry.configFile = configFile; mEntries.insert( urlLayerPair, newEntry ); //update config file map if ( !configFile.isEmpty() ) { QHash< QString, int >::const_iterator configIt = mConfigFiles.constFind( configFile ); if ( configIt == mConfigFiles.constEnd() ) { mConfigFiles.insert( configFile, 1 ); mFileSystemWatcher.addPath( configFile ); } else { mConfigFiles[configFile] = configIt.value() + 1; //increment reference counter } } }
void LoadSaveWindow::onDirectoryChange(int i) { currentDirectoryIndex = i; for(int j = 0; j < (int) directoryButtons.size(); j++) { directoryButtons[j].setToggleState( (i==j) ); } updateEntries(); }
AccountListWidget::AccountListWidget( AccountModelFactoryProxy* model, QWidget* parent ) : QWidget( parent ) , m_model( model ) { QVBoxLayout* mainLayout = new QVBoxLayout( this ); TomahawkUtils::unmarginLayout( mainLayout ); m_layout = new QVBoxLayout; TomahawkUtils::unmarginLayout( m_layout ); mainLayout->addLayout( m_layout ); mainLayout->setSpacing( 8 ); connect( m_model, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( updateEntries( QModelIndex, QModelIndex ) ) ); connect( m_model, SIGNAL( rowsInserted ( QModelIndex, int, int ) ), this, SLOT( insertEntries( QModelIndex, int, int ) ) ); connect( m_model, SIGNAL( rowsRemoved( QModelIndex, int, int ) ), this, SLOT( removeEntries( QModelIndex, int, int ) ) ); connect( m_model, SIGNAL( modelReset() ), this, SLOT( loadAllEntries() ) ); connect( m_model, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SLOT( updateToggleOnlineStateButton() ) ); QWidget* separatorLine = new QWidget( this ); separatorLine->setFixedHeight( 1 ); separatorLine->setContentsMargins( 0, 0, 0, 0 ); separatorLine->setStyleSheet( "QWidget { border-top: 1px solid " + TomahawkStyle::BORDER_LINE.name() + "; }" ); //from ProxyStyle mainLayout->insertWidget( 0, separatorLine ); mainLayout->addSpacing( 6 ); QLabel *connectionsLabel = new QLabel( tr( "Connections" ).toUpper(), this ); QFont clFont = connectionsLabel->font(); clFont.setBold( true ); connectionsLabel->setStyleSheet( "color: " + TomahawkStyle::GROUP_HEADER.name() ); clFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 ); connectionsLabel->setFont( clFont ); connectionsLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_toggleOnlineButton = new QPushButton( tr( "Connect &All" ), this ); m_toggleOnlineButtonState = false; connect( m_toggleOnlineButton, SIGNAL( clicked() ), this, SLOT( toggleOnlineStateForAll() ) ); QHBoxLayout *headerLayout = new QHBoxLayout( this ); headerLayout->addWidget( connectionsLabel ); headerLayout->addSpacing( 30 ); headerLayout->addWidget( m_toggleOnlineButton ); mainLayout->insertLayout( 0, headerLayout ); updateToggleOnlineStateButton(); }
DirectoryListingReply* DirectoryListingService::list(DirectoryListingRequest* req) { updateEntries(); DirectoryListingReply* reply = new DirectoryListingReply(); map<string, struct stat>::iterator statIter = _knownEntries.begin(); Regex regex(req->pattern()); if (regex.hasError()) return reply; while(statIter != _knownEntries.end()) { DirectoryEntry* dOrig = statToEntry(statIter->first, statIter->second); if (regex.matches(statIter->first)) { DirectoryEntry* dEntry = reply->add_entries(); dEntry->CopyFrom(*dOrig); delete dOrig; } statIter++; } return reply; }
void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName, QgsMapLayer* layer, const QList<QString>& tempFiles ) { QgsDebugMsg( "inserting layer" ); if ( mEntries.size() > std::max( DEFAULT_MAX_N_LAYERS, mProjectMaxLayers ) ) //force cache layer examination after 10 inserted layers { updateEntries(); } QPair<QString, QString> urlLayerPair = qMakePair( url, layerName ); QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair ); if ( it != mEntries.end() ) { delete it->layerPointer; } QgsMSLayerCacheEntry newEntry; newEntry.layerPointer = layer; newEntry.url = url; newEntry.creationTime = time( NULL ); newEntry.lastUsedTime = time( NULL ); newEntry.temporaryFiles = tempFiles; mEntries.insert( qMakePair( url, layerName ), newEntry ); }
void DirectoryListingService::run() { while(isStarted()) { updateEntries(); Thread::sleepMs(500); } }
void SAP::update(GIMBLE_HANDLE o) { SAPObject *obj = mObjects[o]; updateEntries(obj); }
LoadSaveWindow::LoadSaveWindow(bool bSave, std::string caption, std::vector<std::string> directories, std::vector<std::string> directoryTitles, std::string extension, int preselectedDirectoryIndex, std::string preselectedFile, int color) : Window(0,0,0,0), bSaveWindow(bSave), directories(directories), directoryTitles(directoryTitles), extension(extension), currentDirectoryIndex(preselectedDirectoryIndex), preselectedFile(preselectedFile), color(color) { // set up window SDL_Surface *surf; surf = pGFXManager->getUIGraphic(UI_LoadSaveWindow); setBackground(surf,false); int xpos = std::max(0,(screen->w - surf->w)/2); int ypos = std::max(0,(screen->h - surf->h)/2); setCurrentPosition(xpos,ypos,surf->w,surf->h); setWindowWidget(&mainHBox); mainHBox.addWidget(HSpacer::create(16)); mainHBox.addWidget(&mainVBox); mainHBox.addWidget(HSpacer::create(16)); titleLabel.setTextColor(110, COLOR_TRANSPARENT); titleLabel.setAlignment((Alignment_Enum) (Alignment_HCenter | Alignment_VCenter)); titleLabel.setText(caption); mainVBox.addWidget(&titleLabel); mainVBox.addWidget(VSpacer::create(8)); if(directories.size() > 1) { directoryButtons.resize(directories.size()); for(size_t i=0;i<directories.size(); i++) { directoryButtons[i].setText(directoryTitles[i]); directoryButtons[i].setTextColor(color); directoryButtons[i].setToggleButton(true); directoryButtons[i].setOnClick(std::bind(&LoadSaveWindow::onDirectoryChange, this, i)); directoryHBox.addWidget(&directoryButtons[i]); } mainVBox.addWidget(&directoryHBox, 20); } mainVBox.addWidget(&fileListHBox, (bSave ? 120 : 150) - (directories.size() > 1 ? 20 : 0)); fileList.setColor(color); fileList.setOnSelectionChange(std::bind(&LoadSaveWindow::onSelectionChange, this, std::placeholders::_1)); fileList.setOnDoubleClick(std::bind(&LoadSaveWindow::onOK, this)); fileListHBox.addWidget(&fileList); mainVBox.addWidget(VSpacer::create(5)); if(bSave == true) { saveName.setTextColor(color); mainVBox.addWidget(&saveName); saveName.setMaximumTextLength(64); mainVBox.addWidget(VSpacer::create(5)); } mainVBox.addWidget(&buttonHBox); okButton.setText(_(bSave ? "Save" : "Load")); okButton.setTextColor(color); okButton.setOnClick(std::bind(&LoadSaveWindow::onOK, this)); buttonHBox.addWidget(&okButton); buttonHBox.addWidget(HSpacer::create(8)); cancelButton.setText(_("Cancel")); cancelButton.setTextColor(color); cancelButton.setOnClick(std::bind(&LoadSaveWindow::onCancel, this)); buttonHBox.addWidget(&cancelButton); mainVBox.addWidget(VSpacer::create(10)); if(directories.size() > 1) { onDirectoryChange(currentDirectoryIndex); } else { updateEntries(); } if(bSaveWindow && (fileList.getSelectedIndex() < 0)) { saveName.setText(preselectedFile); saveName.setActive(); } this->preselectedFile = ""; }
void DesktopAccessModel::setEntries(QVector<DesktopAccessEntry>& entries) { m_entries = entries; updateEntries(); }