mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
All comments and formatting.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26876 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
50e5a3b796
commit
de01bc54ff
@ -285,7 +285,7 @@ void ModuleSelectionManager::updateAddPB()
|
|||||||
vector<string>::const_iterator selModStart = selModList.begin();
|
vector<string>::const_iterator selModStart = selModList.begin();
|
||||||
vector<string>::const_iterator selModEnd = selModList.end();
|
vector<string>::const_iterator selModEnd = selModList.end();
|
||||||
|
|
||||||
//Check whether some required module is available
|
// Check whether some required module is available
|
||||||
if (!reqs.empty()) {
|
if (!reqs.empty()) {
|
||||||
bool foundOne = false;
|
bool foundOne = false;
|
||||||
vector<string>::const_iterator it = reqs.begin();
|
vector<string>::const_iterator it = reqs.begin();
|
||||||
@ -302,7 +302,7 @@ void ModuleSelectionManager::updateAddPB()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check whether any excluded module is being used
|
// Check whether any excluded module is being used
|
||||||
if (!excl.empty()) {
|
if (!excl.empty()) {
|
||||||
vector<string>::const_iterator it = excl.begin();
|
vector<string>::const_iterator it = excl.begin();
|
||||||
vector<string>::const_iterator end = excl.end();
|
vector<string>::const_iterator end = excl.end();
|
||||||
@ -327,12 +327,12 @@ void ModuleSelectionManager::updateDownPB()
|
|||||||
}
|
}
|
||||||
QModelIndexList const selSels =
|
QModelIndexList const selSels =
|
||||||
selectedLV->selectionModel()->selectedIndexes();
|
selectedLV->selectionModel()->selectedIndexes();
|
||||||
//disable if empty or last item is selected
|
// disable if empty or last item is selected
|
||||||
if (selSels.empty() || selSels.first().row() == srows - 1) {
|
if (selSels.empty() || selSels.first().row() == srows - 1) {
|
||||||
downPB->setEnabled(false);
|
downPB->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//determine whether immediately succeding element requires this one
|
// determine whether immediately succeding element requires this one
|
||||||
QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
|
QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
|
||||||
int curRow = curIdx.row();
|
int curRow = curIdx.row();
|
||||||
if (curRow < 0 || curRow >= srows - 1) { //this shouldn't happen...
|
if (curRow < 0 || curRow >= srows - 1) { //this shouldn't happen...
|
||||||
@ -344,15 +344,15 @@ void ModuleSelectionManager::updateDownPB()
|
|||||||
|
|
||||||
vector<string> reqs = getRequiredList(nextModName);
|
vector<string> reqs = getRequiredList(nextModName);
|
||||||
|
|
||||||
//if it doesn't require anything....
|
// if it doesn't require anything....
|
||||||
if (reqs.empty()) {
|
if (reqs.empty()) {
|
||||||
downPB->setEnabled(true);
|
downPB->setEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME This should perhaps be more flexible and check whether, even
|
// Enable it if this module isn't required.
|
||||||
//if this one is required, there is also an earlier one that is required.
|
// FIXME This should perhaps be more flexible and check whether, even
|
||||||
//enable it if this module isn't required
|
// if this one is required, there is also an earlier one that is required.
|
||||||
downPB->setEnabled(
|
downPB->setEnabled(
|
||||||
find(reqs.begin(), reqs.end(), curModName) == reqs.end());
|
find(reqs.begin(), reqs.end(), curModName) == reqs.end());
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ void ModuleSelectionManager::updateUpPB()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//determine whether immediately preceding element is required by this one
|
// determine whether immediately preceding element is required by this one
|
||||||
QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
|
QModelIndex const & curIdx = selectedLV->selectionModel()->currentIndex();
|
||||||
int curRow = curIdx.row();
|
int curRow = curIdx.row();
|
||||||
if (curRow <= -1 || curRow > srows - 1) { //sanity check
|
if (curRow <= -1 || curRow > srows - 1) { //sanity check
|
||||||
@ -382,7 +382,7 @@ void ModuleSelectionManager::updateUpPB()
|
|||||||
string const curModName = getSelectedModel()->getIDString(curRow);
|
string const curModName = getSelectedModel()->getIDString(curRow);
|
||||||
vector<string> reqs = getRequiredList(curModName);
|
vector<string> reqs = getRequiredList(curModName);
|
||||||
|
|
||||||
//if this one doesn't require anything....
|
// if this one doesn't require anything....
|
||||||
if (reqs.empty()) {
|
if (reqs.empty()) {
|
||||||
upPB->setEnabled(true);
|
upPB->setEnabled(true);
|
||||||
return;
|
return;
|
||||||
@ -390,9 +390,9 @@ void ModuleSelectionManager::updateUpPB()
|
|||||||
|
|
||||||
string preModName = getSelectedModel()->getIDString(curRow - 1);
|
string preModName = getSelectedModel()->getIDString(curRow - 1);
|
||||||
|
|
||||||
//NOTE This is less flexible than it might be. You could check whether, even
|
// Enable it if the preceding module isn't required.
|
||||||
//if this one is required, there is also an earlier one that is required.
|
// NOTE This is less flexible than it might be. You could check whether, even
|
||||||
//enable it if the preceding module isn't required
|
// if this one is required, there is also an earlier one that is required.
|
||||||
upPB->setEnabled(find(reqs.begin(), reqs.end(), preModName) == reqs.end());
|
upPB->setEnabled(find(reqs.begin(), reqs.end(), preModName) == reqs.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,22 +410,22 @@ void ModuleSelectionManager::updateDelPB()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//determine whether some LATER module requires this one
|
// determine whether some LATER module requires this one
|
||||||
//NOTE Things are arranged so that this is the only way there
|
// NOTE Things are arranged so that this is the only way there
|
||||||
//can be a problem. At least, we hope so.
|
// can be a problem. At least, we hope so.
|
||||||
QModelIndex const & curIdx =
|
QModelIndex const & curIdx =
|
||||||
selectedLV->selectionModel()->currentIndex();
|
selectedLV->selectionModel()->currentIndex();
|
||||||
int const curRow = curIdx.row();
|
int const curRow = curIdx.row();
|
||||||
if (curRow < 0 || curRow >= srows) { //this shouldn't happen
|
if (curRow < 0 || curRow >= srows) { // this shouldn't happen
|
||||||
deletePB->setEnabled(false);
|
deletePB->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString const curModName = curIdx.data().toString();
|
QString const curModName = curIdx.data().toString();
|
||||||
|
|
||||||
//We're looking here for a reason NOT to enable the button. If we
|
// We're looking here for a reason NOT to enable the button. If we
|
||||||
//find one, we disable it and return. If we don't, we'll end up at
|
// find one, we disable it and return. If we don't, we'll end up at
|
||||||
//the end of the function, and then we enable it.
|
// the end of the function, and then we enable it.
|
||||||
for (int i = curRow + 1; i < srows; ++i) {
|
for (int i = curRow + 1; i < srows; ++i) {
|
||||||
string const thisMod = getSelectedModel()->getIDString(i);
|
string const thisMod = getSelectedModel()->getIDString(i);
|
||||||
vector<string> reqs = getRequiredList(thisMod);
|
vector<string> reqs = getRequiredList(thisMod);
|
||||||
@ -434,33 +434,33 @@ void ModuleSelectionManager::updateDelPB()
|
|||||||
//no...
|
//no...
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//OK, so this module requires us
|
// OK, so this module requires us
|
||||||
//is there an EARLIER module that also satisfies the require?
|
// is there an EARLIER module that also satisfies the require?
|
||||||
//NOTE We demand that it be earlier to keep the list of modules
|
// NOTE We demand that it be earlier to keep the list of modules
|
||||||
//consistent with the rule that a module must be proceeded by a
|
// consistent with the rule that a module must be proceeded by a
|
||||||
//required module. There would be more flexible ways to proceed,
|
// required module. There would be more flexible ways to proceed,
|
||||||
//but that would be a lot more complicated, and the logic here is
|
// but that would be a lot more complicated, and the logic here is
|
||||||
//already complicated. (That's why I've left the debugging code.)
|
// already complicated. (That's why I've left the debugging code.)
|
||||||
//lyxerr << "Testing " << thisMod << std::endl;
|
// lyxerr << "Testing " << thisMod << std::endl;
|
||||||
bool foundOne = false;
|
bool foundOne = false;
|
||||||
for (int j = 0; j < curRow; ++j) {
|
for (int j = 0; j < curRow; ++j) {
|
||||||
string const mod = getSelectedModel()->getIDString(j);
|
string const mod = getSelectedModel()->getIDString(j);
|
||||||
//lyxerr << "In loop: Testing " << mod << std::endl;
|
// lyxerr << "In loop: Testing " << mod << std::endl;
|
||||||
//do we satisfy the require?
|
// do we satisfy the require?
|
||||||
if (find(reqs.begin(), reqs.end(), mod) != reqs.end()) {
|
if (find(reqs.begin(), reqs.end(), mod) != reqs.end()) {
|
||||||
//lyxerr << mod << " does the trick." << std::endl;
|
// lyxerr << mod << " does the trick." << std::endl;
|
||||||
foundOne = true;
|
foundOne = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//did we find a module to satisfy the require?
|
// did we find a module to satisfy the require?
|
||||||
if (!foundOne) {
|
if (!foundOne) {
|
||||||
//lyxerr << "No matching module found." << std::endl;
|
// lyxerr << "No matching module found." << std::endl;
|
||||||
deletePB->setEnabled(false);
|
deletePB->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//lyxerr << "All's well that ends well." << std::endl;
|
// lyxerr << "All's well that ends well." << std::endl;
|
||||||
deletePB->setEnabled(true);
|
deletePB->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1332,14 +1332,21 @@ void GuiDocument::classChanged()
|
|||||||
return;
|
return;
|
||||||
string const classname = classes_model_.getIDString(idx);
|
string const classname = classes_model_.getIDString(idx);
|
||||||
|
|
||||||
// FIXME Note that by doing things this way, we load the TextClass
|
// We load the TextClass as soon as it is selected. This is
|
||||||
// as soon as it is selected. So, if you use the scroll wheel when
|
// necessary so that other options in the dialog can be updated
|
||||||
// sitting on the combo box, we'll load a lot of TextClass objects
|
// according to the new class. Note, however, that, if you use
|
||||||
// very quickly. This could be changed.
|
// the scroll wheel when sitting on the combo box, we'll load a
|
||||||
|
// lot of TextClass objects very quickly....
|
||||||
if (!bp_.setBaseClass(classname)) {
|
if (!bp_.setBaseClass(classname)) {
|
||||||
Alert::error(_("Error"), _("Unable to set document class."));
|
Alert::error(_("Error"), _("Unable to set document class."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME We should really check here whether the modules have been
|
||||||
|
// changed, I think, even if auto_reset_options is false. And, if so,
|
||||||
|
// pop the same dialog. So we would need to compare what is in
|
||||||
|
// modules_sel_model with what is in the OLD bp_.getModules() and
|
||||||
|
// so do that before we reset things.
|
||||||
if (lyxrc.auto_reset_options) {
|
if (lyxrc.auto_reset_options) {
|
||||||
if (applyPB->isEnabled()) {
|
if (applyPB->isEnabled()) {
|
||||||
int const ret = Alert::prompt(_("Unapplied changes"),
|
int const ret = Alert::prompt(_("Unapplied changes"),
|
||||||
@ -1352,16 +1359,13 @@ void GuiDocument::classChanged()
|
|||||||
bp_.useClassDefaults();
|
bp_.useClassDefaults();
|
||||||
}
|
}
|
||||||
// With the introduction of modules came a distinction between the base
|
// With the introduction of modules came a distinction between the base
|
||||||
// class and the document class. The former corresponds to the main layout
|
// class and the document class. The former corresponds to the main layout
|
||||||
// file; the latter is that plus the modules (or the document-specific layout,
|
// file; the latter is that plus the modules (or the document-specific layout,
|
||||||
// or whatever else there could be). Our parameters come from the document
|
// or whatever else there could be). Our parameters come from the document
|
||||||
// class. So when we set the base class, we also need to recreate the document
|
// class. So when we set the base class, we also need to recreate the document
|
||||||
// class. Otherwise, we still have the old one.
|
// class. Otherwise, we still have the old one.
|
||||||
bp_.makeDocumentClass();
|
bp_.makeDocumentClass();
|
||||||
// FIXME There's a little bug here connected with auto_reset, namely,
|
// the new class may require some default modules.
|
||||||
// that, if the preceding is skipped and the user has changed the
|
|
||||||
// modules before changing the class, those changes will be lost on
|
|
||||||
// update. But maybe that's what we want?
|
|
||||||
updateSelectedModules();
|
updateSelectedModules();
|
||||||
paramsToDialog(bp_);
|
paramsToDialog(bp_);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user