bool FileManager::reloadBuffer(BufferID id) { Buffer* buf = getBufferByID(id); Document doc = buf->getDocument(); Utf8_16_Read UnicodeConvertor; buf->_canNotify = false; //disable notify during file load, we dont want dirty to be triggered int encoding = buf->getEncoding(); char data[blockSize + 8]; // +8 for incomplete multibyte char EolType bkformat; LangType lang = buf->getLangType(); buf->setLoadedDirty(false); // Since the buffer will be reloaded from the disk, and it will be clean (not dirty), we can set _isLoadedDirty false safetly. // Set _isLoadedDirty false before calling "_pscratchTilla->execute(SCI_CLEARALL);" in loadFileData() to avoid setDirty in SCN_SAVEPOINTREACHED / SCN_SAVEPOINTLEFT bool res = loadFileData(doc, buf->getFullPathName(), data, &UnicodeConvertor, lang, encoding, bkformat); buf->_canNotify = true; if (res) { if (encoding == -1) { buf->setUnicodeMode(UnicodeConvertor.getEncoding()); } else { buf->setEncoding(encoding); buf->setUnicodeMode(uniCookie); } } return res; }
bool FileManager::reloadBuffer(BufferID id) { Buffer * buf = getBufferByID(id); Document doc = buf->getDocument(); Utf8_16_Read UnicodeConvertor; buf->_canNotify = false; // Disable notify during file load, we don't want dirty to be triggered int encoding = buf->getEncoding(); formatType format; bool res = loadFileData(doc, buf->getFullPathName(), &UnicodeConvertor, buf->getLangType(), encoding, &format); buf->_canNotify = true; if (res) { if (encoding == -1) { if (UnicodeConvertor.getNewBuf()) { int format = getEOLFormatForm(UnicodeConvertor.getNewBuf()); buf->setFormat(format == -1?WIN_FORMAT:(formatType)format); } else { buf->setFormat(WIN_FORMAT); } buf->setUnicodeMode(UnicodeConvertor.getEncoding()); } else { buf->setEncoding(encoding); buf->setFormat(format); buf->setUnicodeMode(uniCookie); } } return res; }
void LabelPointsBySectionImageToolBoxAction::createMainCommandWidget() { QVBoxLayout *vb=new QVBoxLayout(); select = new QPushButton("Select Point"); select->setCheckable(true); connect(select,SIGNAL(toggled(bool)),this,SLOT(selectionPointButtonClick(bool))); vb->addWidget(select); QHBoxLayout *hb=new QHBoxLayout(); QPushButton *updatePB = new QPushButton("update"); connect(updatePB,SIGNAL(clicked()),this,SLOT(updateData())); QPushButton *reloadPB = new QPushButton("reload"); connect(reloadPB,SIGNAL(clicked()),this,SLOT(reloadData())); QPushButton *loadfilePB = new QPushButton("load file"); connect(loadfilePB,SIGNAL(clicked()),this,SLOT(loadFileData())); QPushButton *savefilePB = new QPushButton("save file"); connect(savefilePB,SIGNAL(clicked()),this,SLOT(saveFileData())); hb->addWidget(updatePB); hb->addWidget(reloadPB); hb->addWidget(loadfilePB); hb->addWidget(savefilePB); vb->addLayout(hb); QGroupBox *gb = new QGroupBox("Main Commands"); gb->setLayout(vb); this->addWidget(gb); }
QString SimpleMessageStyle::makeStyleTemplate() const { QString htmlFileName = FStylePath+"/Template.html"; if (!QFile::exists(htmlFileName)) htmlFileName =FSharedPath+"/Template.html"; return loadFileData(htmlFileName,QString::null);; }
BufferID FileManager::loadFile(const char * filename, Document doc) { if (doc == NULL) { doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); } char fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done bool res = loadFileData(doc, fullpath, &UnicodeConvertor, L_TXT); if (res) { Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath); BufferID id = (BufferID) newBuf; newBuf->_id = id; _buffers.push_back(newBuf); _nrBufs++; Buffer * buf = _buffers.at(_nrBufs - 1); // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT if (UnicodeConvertor.getNewBuf()) { buf->determinateFormat(UnicodeConvertor.getNewBuf()); } else { buf->determinateFormat(""); } buf->setUnicodeMode(UnicodeConvertor.getEncoding()); //determine buffer properties BufferID retval = _nextBufferID++; return id; } else { //failed loading, release document _pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document return BUFFER_INVALID; } }
void SimpleMessageStyle::loadTemplates() { FIn_ContentHTML = loadFileData(FStylePath+"/Incoming/Content.html",QString::null); FIn_NextContentHTML = loadFileData(FStylePath+"/Incoming/NextContent.html",FIn_ContentHTML); FOut_ContentHTML = loadFileData(FStylePath+"/Outgoing/Content.html",FIn_ContentHTML); FOut_NextContentHTML = loadFileData(FStylePath+"/Outgoing/NextContent.html",FOut_ContentHTML); FTopicHTML = loadFileData(FStylePath+"/Topic.html",QString::null); FStatusHTML = loadFileData(FStylePath+"/Status.html",FIn_ContentHTML); FMeCommandHTML = loadFileData(FStylePath+"/MeCommand.html",QString::null); }
bool FileManager::reloadBuffer(BufferID id) { Buffer * buf = getBufferByID(id); Document doc = buf->getDocument(); Utf8_16_Read UnicodeConvertor; buf->_canNotify = false; //disable notify during file load, we dont want dirty to be triggered bool res = loadFileData(doc, buf->getFilePath(), &UnicodeConvertor, buf->getLangType()); buf->_canNotify = true; if (res) { if (UnicodeConvertor.getNewBuf()) { buf->determinateFormat(UnicodeConvertor.getNewBuf()); } else { buf->determinateFormat(""); } buf->setUnicodeMode(UnicodeConvertor.getEncoding()); // buf->setNeedsLexing(true); } return res; }
bool FileManager::reloadBuffer(BufferID id) { Buffer* buf = getBufferByID(id); Document doc = buf->getDocument(); Utf8_16_Read UnicodeConvertor; buf->_canNotify = false; //disable notify during file load, we dont want dirty to be triggered int encoding = buf->getEncoding(); char data[blockSize + 8]; // +8 for incomplete multibyte char FormatType bkformat; LangType lang = buf->getLangType(); bool res = loadFileData(doc, buf->getFullPathName(), data, &UnicodeConvertor, lang, encoding, &bkformat); buf->_canNotify = true; if (res) { if (encoding == -1) { if (nullptr != UnicodeConvertor.getNewBuf()) { FormatType format = getEOLFormatForm(UnicodeConvertor.getNewBuf(), UnicodeConvertor.getNewSize()); buf->setFormat(format); } else buf->setFormat(FormatType::osdefault); buf->setUnicodeMode(UnicodeConvertor.getEncoding()); } else { buf->setEncoding(encoding); buf->setFormat(bkformat); buf->setUnicodeMode(uniCookie); } } return res; }
// backupFileName is sentinel of backup mode: if it's not NULL, then we use it (load it). Otherwise we use filename BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encoding, const TCHAR *backupFileName, time_t fileNameTimestamp) { bool ownDoc = false; if (doc == NULL) { doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); ownDoc = true; } TCHAR fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); bool isSnapshotMode = backupFileName != NULL && PathFileExists(backupFileName); if (isSnapshotMode && !PathFileExists(fullpath)) // if backup mode and fullpath doesn't exist, we guess is UNTITLED { lstrcpy(fullpath, filename); // we restore fullpath with filename, in our case is "new #" } Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done char data[blockSize + 8]; // +8 for incomplete multibyte char FormatType bkformat = FormatType::unknown; LangType detectedLang = L_TEXT; bool res = loadFileData(doc, backupFileName ? backupFileName : fullpath, data, &UnicodeConvertor, detectedLang, encoding, &bkformat); if (res) { Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath); BufferID id = (BufferID) newBuf; newBuf->_id = id; if (backupFileName != NULL) { newBuf->_backupFileName = backupFileName; if (!PathFileExists(fullpath)) newBuf->_currentStatus = DOC_UNNAMED; } if (fileNameTimestamp != 0) newBuf->_timeStamp = fileNameTimestamp; _buffers.push_back(newBuf); ++_nrBufs; Buffer* buf = _buffers.at(_nrBufs - 1); // restore the encoding (ANSI based) while opening the existing file NppParameters *pNppParamInst = NppParameters::getInstance(); const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); buf->setUnicodeMode(ndds._unicodeMode); buf->setEncoding(-1); // if a language has been detected, and the detected value is different from the file extension, // we use the detected value if (detectedLang != L_TEXT && detectedLang != buf->getLangType()) buf->setLangType(detectedLang); if (encoding == -1) { // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT if (nullptr != UnicodeConvertor.getNewBuf()) { FormatType format = getEOLFormatForm(UnicodeConvertor.getNewBuf(), UnicodeConvertor.getNewSize()); buf->setFormat(format); } else buf->setFormat(FormatType::osdefault); UniMode um = UnicodeConvertor.getEncoding(); if (um == uni7Bit) um = (ndds._openAnsiAsUtf8) ? uniCookie : uni8Bit; buf->setUnicodeMode(um); } else // encoding != -1 { // Test if encoding is set to UTF8 w/o BOM (usually for utf8 indicator of xml or html) buf->setEncoding((encoding == SC_CP_UTF8)?-1:encoding); buf->setUnicodeMode(uniCookie); buf->setFormat(bkformat); } //determine buffer properties ++_nextBufferID; return id; } else //failed loading, release document { if (ownDoc) _pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document return BUFFER_INVALID; } }
BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encoding) { bool ownDoc = false; if (doc == NULL) { doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); ownDoc = true; } TCHAR fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done formatType format; bool res = loadFileData(doc, fullpath, &UnicodeConvertor, L_TEXT, encoding, &format); if (res) { Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath); BufferID id = (BufferID) newBuf; newBuf->_id = id; _buffers.push_back(newBuf); ++_nrBufs; Buffer * buf = _buffers.at(_nrBufs - 1); // restore the encoding (ANSI based) while opening the existing file NppParameters *pNppParamInst = NppParameters::getInstance(); const NewDocDefaultSettings & ndds = (pNppParamInst->getNppGUI()).getNewDocDefaultSettings(); buf->setUnicodeMode(ndds._encoding); buf->setEncoding(-1); if (encoding == -1) { // 3 formats : WIN_FORMAT, UNIX_FORMAT and MAC_FORMAT if (UnicodeConvertor.getNewBuf()) { int format = getEOLFormatForm(UnicodeConvertor.getNewBuf()); buf->setFormat(format == -1?WIN_FORMAT:(formatType)format); } else { buf->setFormat(WIN_FORMAT); } UniMode um = UnicodeConvertor.getEncoding(); if (um == uni7Bit) { if (ndds._openAnsiAsUtf8) { um = uniCookie; } else { um = uni8Bit; } } buf->setUnicodeMode(um); } else // encoding != -1 { // Test if encoding is set to UTF8 without BOM (usually for UTF-8 indicator of XML or HTML) buf->setEncoding((encoding == SC_CP_UTF8)?-1:encoding); buf->setUnicodeMode(uniCookie); buf->setFormat(format); } //determine buffer properties ++_nextBufferID; return id; } else //failed loading, release document { if (ownDoc) _pscratchTilla->execute(SCI_RELEASEDOCUMENT, 0, doc); //Failure, so release document return BUFFER_INVALID; } }
void SimpleMessageStyle::setVariant(StyleViewer *AView, const QString &AVariant) { QString variant = QString("Variants/%1.css").arg(!FVariants.contains(AVariant) ? FInfo.value(MSIV_DEFAULT_VARIANT,"main").toString() : AVariant); AView->document()->setDefaultStyleSheet(loadFileData(FStylePath+"/"+variant,QString::null)); }
RDCartDialog::RDCartDialog(QString *filter,QString *group,QString *schedcode, QWidget *parent) : QDialog(parent,"",true) { // // Fix the Window Size // setMinimumWidth(sizeHint().width()); setMinimumHeight(sizeHint().height()); cart_cartnum=NULL; cart_type=RDCart::All; cart_group=group; cart_schedcode=schedcode; if(cart_schedcode->isNull()) { *cart_schedcode=tr("ALL"); } cart_temp_allowed=NULL; #ifdef WIN32 cart_filter_mode=RDStation::FilterSynchronous; #else cart_filter_mode=rda->station()->filterMode(); #endif // WIN32 if(filter==NULL) { cart_filter=new QString(); local_filter=true; } else { cart_filter=filter; local_filter=false; } cart_import_path=RDGetHomeDir(); cart_import_file_filter=RD_AUDIO_FILE_FILTER; setCaption(tr("Select Cart")); // // Create Fonts // QFont button_font=QFont("Helvetica",12,QFont::Bold); button_font.setPixelSize(12); QFont progress_font=QFont("Helvetica",16,QFont::Bold); progress_font.setPixelSize(16); // // Create Icons // cart_playout_map=new QPixmap(play_xpm); cart_macro_map=new QPixmap(rml5_xpm); // // Progress Dialog // cart_progress_dialog= new Q3ProgressDialog(tr("Please Wait..."),"Cancel",10,this, "cart_progress_dialog",false, Qt::WStyle_Customize|Qt::WStyle_NormalBorder); cart_progress_dialog->setCaption(" "); QLabel *label=new QLabel(tr("Please Wait..."),cart_progress_dialog); label->setAlignment(Qt::AlignCenter); label->setFont(progress_font); cart_progress_dialog->setLabel(label); cart_progress_dialog->setCancelButton(NULL); cart_progress_dialog->setMinimumDuration(2000); cart_busy_dialog=new RDBusyDialog(this); // // Filter Selector // cart_filter_edit=new QLineEdit(this); cart_filter_label=new QLabel(cart_filter_edit,tr("Cart Filter:"),this); cart_filter_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); cart_filter_label->setFont(button_font); connect(cart_filter_edit,SIGNAL(textChanged(const QString &)), this,SLOT(filterChangedData(const QString &))); // // Filter Search Button // cart_search_button=new QPushButton(this); cart_search_button->setText(tr("&Search")); cart_search_button->setFont(button_font); connect(cart_search_button,SIGNAL(clicked()),this,SLOT(filterSearchedData())); // // Filter Clear Button // cart_clear_button=new QPushButton(this); cart_clear_button->setText(tr("C&lear")); cart_clear_button->setFont(button_font); connect(cart_clear_button,SIGNAL(clicked()),this,SLOT(filterClearedData())); // // Group Code Selector // cart_group_box=new RDComboBox(this); cart_group_label=new QLabel(cart_group_box,tr("Group:"),this); cart_group_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); cart_group_label->setFont(button_font); connect(cart_group_box,SIGNAL(activated(const QString &)), this,SLOT(groupActivatedData(const QString &))); // // Scheduler Code Selector // cart_schedcode_box=new RDComboBox(this); cart_schedcode_label= new QLabel(cart_schedcode_box,tr("Scheduler Code:"),this); cart_schedcode_label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); cart_schedcode_label->setFont(button_font); connect(cart_schedcode_box,SIGNAL(activated(const QString &)), this,SLOT(schedcodeActivatedData(const QString &))); // // Search Limit Checkbox // cart_limit_box=new QCheckBox(this); cart_limit_box->setChecked(true); cart_limit_label= new QLabel(cart_limit_box,tr("Show Only First")+ QString().sprintf(" %d ", RD_LIMITED_CART_SEARCH_QUANTITY)+tr("Matches"),this); cart_limit_label->setAlignment(Qt::AlignLeft|Qt::AlignVCenter); cart_limit_label->setFont(button_font); connect(cart_limit_box,SIGNAL(stateChanged(int)), this,SLOT(limitChangedData(int))); // // Cart List // cart_cart_list=new RDListView(this); cart_cart_list->setSelectionMode(Q3ListView::Single); cart_cart_list->setAllColumnsShowFocus(true); cart_cart_list->setItemMargin(5); connect(cart_cart_list,SIGNAL(clicked(Q3ListViewItem *)), this,SLOT(clickedData(Q3ListViewItem *))); connect(cart_cart_list, SIGNAL(doubleClicked(Q3ListViewItem *,const QPoint &,int)), this, SLOT(doubleClickedData(Q3ListViewItem *,const QPoint &,int))); cart_cart_label=new QLabel(cart_cart_list,"Carts",this); cart_cart_label->setFont(button_font); cart_cart_list->addColumn(""); cart_cart_list->setColumnAlignment(0,Qt::AlignHCenter); cart_cart_list->addColumn(tr("NUMBER")); cart_cart_list->setColumnAlignment(1,Qt::AlignHCenter); cart_cart_list->addColumn(tr("LENGTH")); cart_cart_list->setColumnAlignment(2,Qt::AlignRight); cart_cart_list->setColumnSortType(2,RDListView::TimeSort); cart_cart_list->addColumn(tr("TITLE"),200); cart_cart_list->setColumnAlignment(3,Qt::AlignLeft); cart_cart_list->setColumnWidthMode(3,Q3ListView::Manual); cart_cart_list->addColumn(tr("ARTIST")); cart_cart_list->setColumnAlignment(4,Qt::AlignLeft); cart_cart_list->addColumn(tr("GROUP")); cart_cart_list->setColumnAlignment(5,Qt::AlignLeft); cart_cart_list->addColumn(tr("COMPOSER")); cart_cart_list->setColumnAlignment(6,Qt::AlignLeft); cart_cart_list->addColumn(tr("CONDUCTOR")); cart_cart_list->setColumnAlignment(7,Qt::AlignLeft); cart_cart_list->addColumn(tr("CLIENT")); cart_cart_list->setColumnAlignment(8,Qt::AlignLeft); cart_cart_list->addColumn(tr("AGENCY")); cart_cart_list->setColumnAlignment(9,Qt::AlignLeft); cart_cart_list->addColumn(tr("USER DEF")); cart_cart_list->setColumnAlignment(10,Qt::AlignLeft); cart_cart_list->addColumn(tr("START")); cart_cart_list->setColumnAlignment(11,Qt::AlignLeft); cart_cart_list->addColumn(tr("END")); cart_cart_list->setColumnAlignment(12,Qt::AlignLeft); // // Audition Player // #ifndef WIN32 if((rda->cae()==NULL)||(rda->station()->cueCard()<0)||(rda->station()->cuePort()<0)) { cart_player=NULL; } else { cart_player= new RDSimplePlayer(rda->station()->cueCard(),rda->station()->cuePort(), rda->station()->cueStartCart(),rda->station()->cueStopCart(),this); cart_player->playButton()->setDisabled(true); cart_player->stopButton()->setDisabled(true); cart_player->stopButton()->setOnColor(Qt::red); } #endif // WIN32 // // Send to Editor Button // cart_editor_button=new QPushButton(tr("Send to\n&Editor"),this); cart_editor_button->setFont(button_font); connect(cart_editor_button,SIGNAL(clicked()),this,SLOT(editorData())); if(rda->station()->editorPath().isEmpty()) { cart_editor_button->hide(); } // // Load From File Button // cart_file_button=new QPushButton(tr("Load From\n&File"),this); cart_file_button->setFont(button_font); connect(cart_file_button,SIGNAL(clicked()),this,SLOT(loadFileData())); if(rda->station()->editorPath().isEmpty()) { cart_file_button->hide(); } #ifdef WIN32 cart_file_button->hide(); #endif // WIN32 // // OK Button // cart_ok_button=new QPushButton(tr("&OK"),this); cart_ok_button->setFont(button_font); connect(cart_ok_button,SIGNAL(clicked()),this,SLOT(okData())); // // Cancel Button // cart_cancel_button=new QPushButton(tr("&Cancel"),this); cart_cancel_button->setFont(button_font); connect(cart_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData())); }